Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature : added some smooth framer animation #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
psychlone77 merged 14 commits into quicksnip-dev:main from mayur1377:feature-framer
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions package-lock.json
View file Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"preview": "vite preview"
},
"dependencies": {
"framer-motion": "^11.15.0",
"prismjs": "^1.29.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
51 changes: 37 additions & 14 deletions src/components/SnippetList.tsx
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from "react";
import { motion, AnimatePresence } from "framer-motion";
import { SnippetType } from "../types";
import { useAppContext } from "../contexts/AppContext";
import { useSnippets } from "../hooks/useSnippets";
Expand Down Expand Up @@ -30,31 +31,53 @@ const SnippetList = () => {

return (
<>
<ul role="list" className="snippets">
<motion.ul
role="list"
className="snippets"
initial="hidden"
animate="visible"
variants={{
visible: {
transition: {
staggerChildren: 0.1
}
}
}}
>
{fetchedSnippets.map((snippet, idx) => (
<li key={idx}>
<button
<motion.li
key={idx}
variants={{
hidden: { opacity: 0, y: 20 },
visible: { opacity: 1, y: 0 }
}}
>
<motion.button
className="snippet | flow"
data-flow-space="sm"
onClick={() => handleOpenModal(snippet)}
whileHover={{ scale: 1.01 }}
whileTap={{ scale: 0.98 }}
>
<div className="snippet__preview">
<img src={language.icon} alt={language.lang} />
</div>

<h3 className="snippet__title">{snippet.title}</h3>
</button>
</li>
</motion.button>
</motion.li>
))}
</ul>

{isModalOpen && snippet && (
<SnippetModal
snippet={snippet}
handleCloseModal={handleCloseModal}
language={language.lang}
/>
)}
</motion.ul>

<AnimatePresence mode="wait">
{isModalOpen && snippet && (
<SnippetModal
snippet={snippet}
handleCloseModal={handleCloseModal}
language={language.lang}
/>
)}
</AnimatePresence>
</>
);
};
Expand Down
22 changes: 18 additions & 4 deletions src/components/SnippetModal.tsx
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import ReactDOM from "react-dom";
import { motion } from "framer-motion";
import Button from "./Button";
import { CloseIcon } from "./Icons";
import CodePreview from "./CodePreview";
Expand All @@ -23,15 +24,28 @@ const SnippetModal: React.FC<Props> = ({
useEscapeKey(handleCloseModal);

return ReactDOM.createPortal(
<div
<motion.div
key="modal-overlay"
className="modal-overlay"
onClick={(e) => {
if (e.target === e.currentTarget) {
handleCloseModal();
}
}}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.2 }}
>
<div className="modal | flow" data-flow-space="lg">
<motion.div
key="modal-content"
className="modal | flow"
data-flow-space="lg"
initial={{ scale: 0.8, opacity: 0, y: 20 }}
animate={{ scale: 1, opacity: 1, y: 0 }}
exit={{ scale: 0.8, opacity: 0, y: 20 }}
transition={{ type: "spring", duration: 0.5 }}
>
<div className="modal__header">
<h2 className="section-title">{snippet.title}</h2>
<Button isIcon={true} onClick={handleCloseModal}>
Expand Down Expand Up @@ -61,8 +75,8 @@ const SnippetModal: React.FC<Props> = ({
</li>
))}
</ul>
</div>
</div>,
</motion.div>
</motion.div>,
modalRoot
);
};
Expand Down
1 change: 1 addition & 0 deletions tsconfig.app.tsbuildinfo
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/components/button.tsx","./src/components/categorylist.tsx","./src/components/codepreview.tsx","./src/components/copytoclipboard.tsx","./src/components/icons.tsx","./src/components/languageselector.tsx","./src/components/linkbutton.tsx","./src/components/logo.tsx","./src/components/searchinput.tsx","./src/components/snippetlist.tsx","./src/components/snippetmodal.tsx","./src/components/themetoggle.tsx","./src/contexts/appcontext.tsx","./src/hooks/usecategories.ts","./src/hooks/useescapekey.ts","./src/hooks/usefetch.ts","./src/hooks/usekeyboardnavigation.ts","./src/hooks/uselanguages.ts","./src/hooks/usesnippets.ts","./src/layouts/banner.tsx","./src/layouts/footer.tsx","./src/layouts/header.tsx","./src/layouts/sidebar.tsx","./src/types/index.ts","./src/utils/slugify.ts"],"version":"5.6.3"}
1 change: 1 addition & 0 deletions tsconfig.node.tsbuildinfo
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./vite.config.ts"],"version":"5.6.3"}

AltStyle によって変換されたページ (->オリジナル) /