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

enhancement: Smoothed modal animation + reduced motion #174

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 9 commits into quicksnip-dev:main from Yugveer06:motion
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
removed idx from the snippet type and swtiched to title and descripti...
...on for unique key
  • Loading branch information
Yugveer06 committed Jan 4, 2025
commit cd6c616c3785d0a7d1fa11077f99641f15b4441d
17 changes: 6 additions & 11 deletions src/components/SnippetList.tsx
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ const SnippetList = () => {
<>
<motion.ul role="list" className="snippets">
<AnimatePresence mode="popLayout">
{fetchedSnippets.map((currentSnippet, idx) => {
{fetchedSnippets.map((snippet, idx) => {
const uniqueId = `${snippet.title}-${snippet.description}`;
return (
<motion.li
key={currentSnippet.title + idx}
layoutId={currentSnippet.title + (idx + 1).toString()} // unique id for layout animation
key={uniqueId}
layoutId={uniqueId}
initial={{ opacity: 0, y: 20 }}
animate={{
opacity: 1,
Expand All @@ -66,20 +67,14 @@ const SnippetList = () => {
<motion.button
className="snippet | flow"
data-flow-space="sm"
onClick={() =>
handleOpenModal({
...currentSnippet,
// added idx for the layout animation to work correctly
idx: idx + 1,
})
}
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">{currentSnippet.title}</h3>
<h3 className="snippet__title">{snippet.title}</h3>
</motion.button>
</motion.li>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/SnippetModal.tsx
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const SnippetModal: React.FC<Props> = ({
key="modal-content"
className="modal | flow"
data-flow-space="lg"
layoutId={snippet.title + snippet.idx?.toString()} // unique id for layout animation
layoutId={`${snippet.title}-${snippet.description}`}
transition={{ type: "spring", duration: shouldReduceMotion ? 0 : 0.5 }}
>
<div className="modal__header">
Expand Down
1 change: 0 additions & 1 deletion src/types/index.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export type SnippetType = {
code: string;
tags: string[];
author: string;
idx?: number;
};

export type AppState = {
Expand Down
Loading

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /