-
Notifications
You must be signed in to change notification settings - Fork 896
carousel #74
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
carousel #74
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { type MotionValue, motion, useTransform } from "framer-motion"; | ||
|
|
||
| interface AnimatedBackgroundProps { | ||
| progress: MotionValue<number>; | ||
| modeCount: number; | ||
| } | ||
|
|
||
| export function AnimatedBackground({ | ||
| progress, | ||
| modeCount, | ||
| }: AnimatedBackgroundProps) { | ||
| // Calculate the width of each button (36px = h-9 w-9) + gap (4px = gap-1) | ||
| const buttonWidth = 36; | ||
| const gap = 4; | ||
| const totalButtonWidth = buttonWidth + gap; | ||
|
|
||
| // Transform progress (0-1) to translateX position | ||
| // For 2 modes: 0 -> 0px, 1 -> 40px (buttonWidth + gap) | ||
| const translateX = useTransform( | ||
| progress, | ||
| [0, modeCount - 1], | ||
| [0, (modeCount - 1) * totalButtonWidth] | ||
| ); | ||
|
|
||
| return ( | ||
| <motion.div | ||
| className="absolute h-9 rounded-lg bg-neutral-800/60" | ||
| style={{ | ||
| width: buttonWidth, | ||
| x: translateX, | ||
| }} | ||
| initial={false} | ||
| transition={{ | ||
| type: "spring", | ||
| stiffness: 300, | ||
| damping: 30, | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { AnimatedBackground } from "./AnimatedBackground"; | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import type { ReactNode } from "react"; | ||
| import { ModeHeader } from "../ModeHeader"; | ||
| import type { SidebarMode } from "../../types"; | ||
|
|
||
| interface ModeContentProps { | ||
| mode: SidebarMode; | ||
| isActive: boolean; | ||
| children: ReactNode; | ||
| } | ||
|
Comment on lines
+5
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused The Consider either:
If 🤖 Prompt for AI Agents |
||
|
|
||
| export function ModeContent({ mode, children }: ModeContentProps) { | ||
| return ( | ||
| <div | ||
| className="overflow-y-auto h-full" | ||
| style={{ | ||
| scrollSnapAlign: "start", | ||
| scrollSnapStop: "always", | ||
| }} | ||
| > | ||
| <ModeHeader mode={mode} /> | ||
| <div className="px-3">{children}</div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { ModeContent } from "./ModeContent"; | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { modeLabels } from "../../constants"; | ||
| import type { SidebarMode } from "../../types"; | ||
|
|
||
| interface ModeHeaderProps { | ||
| mode: SidebarMode; | ||
| } | ||
|
|
||
| export function ModeHeader({ mode }: ModeHeaderProps) { | ||
| return ( | ||
| <div className="px-3 py-2"> | ||
| <span className="text-xs font-medium text-neutral-300"> | ||
| {modeLabels[mode]} | ||
| </span> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { ModeHeader } from "./ModeHeader"; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify the progress input range in the comment.
The comment states "Transform progress (0-1)" but the actual input range is
[0, modeCount - 1](e.g., 0-1 for 2 modes, 0-2 for 3 modes), not a normalized 0-1 range.Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents