-
Notifications
You must be signed in to change notification settings - Fork 324
fix: TimelineItem for default order #1884
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
Conversation
|
@shinokada is attempting to deploy a commit to the Themesberg Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis PR updates the Timeline component hierarchy by introducing a new visual element ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{svelte,ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-12-16T13:21:19.575ZApplied to files:
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 6
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
package.json(4 hunks)src/lib/timeline/Timeline.svelte(2 hunks)src/lib/timeline/TimelineItem.svelte(4 hunks)src/lib/timeline/theme.ts(2 hunks)src/lib/types.ts(1 hunks)src/routes/docs-examples/components/timeline/Activity.svelte(1 hunks)src/routes/docs-examples/components/timeline/Grouped.svelte(2 hunks)src/routes/docs-examples/components/timeline/[slug]/+page.svelte(1 hunks)src/routes/docs-examples/components/timeline/[slug]/+page.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{svelte,ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{svelte,ts,tsx,js,jsx}: Use the Flowbite-Svelte MCP server to discover components by name or category before implementing UI components
Always use findComponent tool FIRST to locate the correct Flowbite-Svelte component before fetching documentation
After calling findComponent, use getComponentDoc tool to fetch complete documentation including usage examples, props, and best practices for Flowbite-Svelte components
Files:
src/routes/docs-examples/components/timeline/Grouped.sveltesrc/routes/docs-examples/components/timeline/[slug]/+page.tssrc/routes/docs-examples/components/timeline/[slug]/+page.sveltesrc/lib/timeline/theme.tssrc/lib/timeline/Timeline.sveltesrc/lib/timeline/TimelineItem.sveltesrc/routes/docs-examples/components/timeline/Activity.sveltesrc/lib/types.ts
🧠 Learnings (3)
📚 Learning: 2025-12-16T13:21:19.575Z
Learnt from: shinokada
Repo: themesberg/flowbite-svelte PR: 1882
File: src/lib/bottom-navigation/BottomNavHeaderItem.svelte:9-9
Timestamp: 2025-12-16T13:21:19.575Z
Learning: When using ThemeProvider with reactive themes in Flowbite-Svelte, ensure that getTheme("componentName") calls are placed inside a $derived() expression (not at module scope) so components react to dynamic theme changes. This applies broadly to Svelte components in this repo that rely on theme-derived values. For example:
// bad: at module scope
const theme = getTheme("button");
// good: inside a derived store
import { derived } from 'svelte/store';
const themeDerived = derived(themeProviderStore, ($themeProvider) => getTheme("button"));
// use $themeDerived in template/component
Applied to files:
src/routes/docs-examples/components/timeline/Grouped.sveltesrc/routes/docs-examples/components/timeline/[slug]/+page.sveltesrc/lib/timeline/Timeline.sveltesrc/lib/timeline/TimelineItem.sveltesrc/routes/docs-examples/components/timeline/Activity.svelte
📚 Learning: 2025-11-25T07:26:46.504Z
Learnt from: CR
Repo: themesberg/flowbite-svelte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T07:26:46.504Z
Learning: Applies to **/*.{svelte,ts,tsx,js,jsx} : After calling findComponent, use getComponentDoc tool to fetch complete documentation including usage examples, props, and best practices for Flowbite-Svelte components
Applied to files:
package.json
📚 Learning: 2025-11-25T07:26:46.504Z
Learnt from: CR
Repo: themesberg/flowbite-svelte PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T07:26:46.504Z
Learning: Applies to **/*.{svelte,ts,tsx,js,jsx} : Use the Flowbite-Svelte MCP server to discover components by name or category before implementing UI components
Applied to files:
package.json
🔇 Additional comments (6)
package.json (1)
43-43: LGTM! Routine dependency maintenance.The development dependency version bumps are minor/patch updates and should not introduce breaking changes.
Also applies to: 54-54, 59-60, 63-63, 80-80, 89-89, 95-95, 98-99, 101-101
src/lib/types.ts (1)
1967-1967: LGTM! Clean type addition.The optional
defaultDivClassproperty extends the TimelineItem public API in a non-breaking way and aligns with the component implementation changes.src/routes/docs-examples/components/timeline/Activity.svelte (1)
5-5: LGTM! Example data enhancement.Adding unique
idfields to activity objects improves item identification in examples.Also applies to: 13-13, 21-21
src/routes/docs-examples/components/timeline/[slug]/+page.svelte (1)
1-8: LGTM! Clean dynamic content loader.The page component correctly uses SvelteKit's load data pattern with reactive derivation to render dynamic content.
src/routes/docs-examples/components/timeline/Grouped.svelte (1)
5-6: LGTM! Example data enhancement.Adding
idandnamefields enriches the grouped timeline example data structure.Also applies to: 16-17
src/lib/timeline/TimelineItem.svelte (1)
19-19: LGTM! Clean defaultDivClass implementation.The new
defaultDivClassprop and its integration with the theme system is well-implemented:
- Optional prop allows custom styling override
- Falls back to theme-derived
defaultDiv()when not provided- Conditionally renders for
order === "default"with date presentThe reactive theme derivation on Line 52 correctly uses
$derived(getTheme("timelineItem"))following the established pattern.Also applies to: 55-57, 109-109
src/lib/timeline/theme.ts
Outdated
| div: "text-gray-600 dark:text-gray-400", | ||
| title: "text-base font-normal", | ||
| span: "inline-flex items-center text-xs font-normal text-gray-500 dark:text-gray-400", | ||
| span: "inline-flex items-center bg-neutral-primary-medium border border-default-medium text-heading text-xs font-medium px-1.5 py-0.5 rounded", |
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.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for the theme.ts file and examine its contents
echo "=== Finding timeline theme file ==="
find . -name "theme.ts" -path "*/timeline/*" 2>/dev/null
# Search for Tailwind/CSS config files
echo -e "\n=== Searching for Tailwind config files ==="
find . -name "tailwind.config.*" -o -name "app.css" -o -name "global.css" 2>/dev/null | head -20
# Search for custom token definitions with neutral-primary or similar patterns
echo -e "\n=== Searching for neutral-primary-medium token definition ==="
rg -n "neutral-primary-medium|neutral-primary|default-medium|text-heading" --type=ts --type=css --type=js -C 2 2>/dev/null | head -50
echo -e "\n=== Searching in theme definitions ==="
rg -n "@theme|--neutral-primary|--default-medium" --type=ts --type=css -C 2 2>/dev/null | head -50Repository: themesberg/flowbite-svelte
Length of output: 807
🏁 Script executed:
#!/bin/bash
# Read the app.css file to see the @theme definitions
echo "=== Reading src/app.css @theme section ==="
cat src/app.cssRepository: themesberg/flowbite-svelte
Length of output: 20494
🏁 Script executed:
#!/bin/bash
# Search for any definition of these semantic tokens
echo "=== Searching for neutral-primary-medium definition ==="
rg -r "neutral-primary-medium|neutral-primary|default-medium|text-heading" --type=ts --type=css --type=js 2>/dev/null | grep -E "(:|=|:)" | head -30
# Check if these are maybe in Flowbite or other plugin sources
echo -e "\n=== Checking for plugin or external token definitions ==="
find . -name "*.json" -o -name "*.config.*" | xargs grep -l "neutral-primary\|default-medium" 2>/dev/null
# Verify if the classes would actually be generated by checking Flowbite plugin
echo -e "\n=== Looking for token generation patterns ==="
rg -n "neutral|primary|medium|default" src/app.cssRepository: themesberg/flowbite-svelte
Length of output: 744
Add missing semantic token definitions to @theme directive.
The span styling at line 43 uses custom Tailwind classes (bg-neutral-primary-medium, border-default-medium, text-heading) that are not currently defined in your src/app.css @theme block. These classes will not generate any utility styles until the corresponding CSS variables are added. Define these tokens in your @theme directive:
@theme {
/* existing tokens... */
--color-neutral-primary-medium: /* your color value */;
--border-color-default-medium: /* your color value */;
/* Add text-heading mapping if needed */
}🤖 Prompt for AI Agents
In src/lib/timeline/theme.ts around line 43 the span class uses custom semantic
tokens (bg-neutral-primary-medium, border-default-medium, text-heading) that are
not defined in the @theme directive; add corresponding CSS variable definitions
to your src/app.css @theme block — e.g. define --color-neutral-primary-medium
and --border-color-default-medium and map text-heading appropriately (or add a
semantic token alias) so Tailwind will generate the utility classes; ensure
names match exactly and provide concrete color values consistent with your
design tokens.
| // svelte-ignore state_referenced_locally | ||
| setContext<TimelineVariants["order"]>("order", order); |
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.
Restore reactive context for dynamic order updates.
The direct setContext call with the svelte-ignore comment removes reactivity. If the order prop changes after mount, child TimelineItem components won't receive the updated value.
Restore the reactive effect pattern to ensure context updates propagate:
- // svelte-ignore state_referenced_locally
- setContext<TimelineVariants["order"]>("order", order);
+ $effect(() => {
+ setContext<TimelineVariants["order"]>("order", order);
+ });This ensures that when order changes, all child components receive the updated context value.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // svelte-ignore state_referenced_locally | |
| setContext<TimelineVariants["order"]>("order", order); | |
| $effect(() => { | |
| setContext<TimelineVariants["order"]>("order", order); | |
| }); |
🤖 Prompt for AI Agents
In src/lib/timeline/Timeline.svelte around lines 11–12, the current direct
setContext call (with a svelte-ignore) breaks reactivity so updates to the order
prop won't propagate to children; replace the direct call with a reactive
statement (use Svelte's $: setContext("order", order)) so setContext runs
whenever order changes, remove the svelte-ignore, and keep the typed/context key
consistent with TimelineVariants["order"] so child TimelineItem components
receive updated values.
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.
This doesn't work. It breaks to render unnecessary code.
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.
@shinokada, you're absolutely right, and I apologize for the incorrect suggestion. Using $effect to repeatedly call setContext can indeed cause rendering issues.
In Svelte 5, setContext should typically be called once at the component's initialization, not inside effects. The current implementation with the direct call is correct for this pattern.
Could you clarify: Is the order prop expected to change dynamically after the Timeline component mounts, or is it set once during initialization and remains constant? This will help me understand the intended behavior and avoid similar incorrect suggestions in the future.
🧠 Learnings used
Learnt from: shinokada
Repo: themesberg/flowbite-svelte PR: 1882
File: src/lib/bottom-navigation/BottomNavHeaderItem.svelte:9-9
Timestamp: 2025-12-16T13:21:28.743Z
Learning: In flowbite-svelte, when using ThemeProvider with reactive themes, `getTheme("componentName")` calls must be placed inside `$derived()` expressions (not at module scope) to ensure components react to dynamic theme changes. This pattern is intentional for reactive theming support.
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.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/lib/timeline/theme.ts (1)
112-112: Remove duplicate bg-gray-200 class (previously flagged).As noted in a previous review, line 112 contains duplicate
bg-gray-200classes. Only the last one will apply in Tailwind CSS. Additionally, verify thatborder-bufferis defined in your Tailwind configuration.Apply this diff to remove the duplicate:
- defaultDiv: "absolute w-2 h-2 bg-gray-200 rounded-full mt-1.5 -start-5 border border-buffer bg-gray-200", + defaultDiv: "absolute w-2 h-2 bg-gray-200 rounded-full mt-1.5 -start-5 border border-buffer",To verify the
border-buffertoken, run:#!/bin/bash # Description: Verify border-buffer token is defined in Tailwind config # Check Tailwind config files for border-buffer definition echo "=== Checking Tailwind config for border-buffer ===" fd -e js -e ts -e cjs "tailwind.config" --exec cat {} # Search for border-buffer or similar custom border tokens echo -e "\n=== Searching for border token definitions ===" rg -n "border-buffer|--border|borderColor" tailwind.config.* src/app.css -C 3
🧹 Nitpick comments (1)
src/lib/timeline/TimelineItem.svelte (1)
108-114: Add aria-hidden to decorative empty div.The empty div at line 109 serves as a purely decorative visual marker (dot/circle). For accessibility, decorative elements should be marked with
aria-hidden="true"to prevent screen readers from announcing empty content.Apply this diff:
- <div class={defaultDivCls}></div> + <div class={defaultDivCls} aria-hidden="true"></div>
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/lib/timeline/Timeline.svelte(2 hunks)src/lib/timeline/TimelineItem.svelte(4 hunks)src/lib/timeline/theme.ts(2 hunks)src/routes/docs-examples/components/timeline/Grouped.svelte(2 hunks)src/routes/docs-examples/components/timeline/[slug]/+page.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/routes/docs-examples/components/timeline/[slug]/+page.ts
- src/lib/timeline/Timeline.svelte
- src/routes/docs-examples/components/timeline/Grouped.svelte
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{svelte,ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{svelte,ts,tsx,js,jsx}: Use the Flowbite-Svelte MCP server to discover components by name or category before implementing UI components
Always use findComponent tool FIRST to locate the correct Flowbite-Svelte component before fetching documentation
After calling findComponent, use getComponentDoc tool to fetch complete documentation including usage examples, props, and best practices for Flowbite-Svelte components
Files:
src/lib/timeline/TimelineItem.sveltesrc/lib/timeline/theme.ts
🧠 Learnings (1)
📚 Learning: 2025-12-16T13:21:19.575Z
Learnt from: shinokada
Repo: themesberg/flowbite-svelte PR: 1882
File: src/lib/bottom-navigation/BottomNavHeaderItem.svelte:9-9
Timestamp: 2025-12-16T13:21:19.575Z
Learning: When using ThemeProvider with reactive themes in Flowbite-Svelte, ensure that getTheme("componentName") calls are placed inside a $derived() expression (not at module scope) so components react to dynamic theme changes. This applies broadly to Svelte components in this repo that rely on theme-derived values. For example:
// bad: at module scope
const theme = getTheme("button");
// good: inside a derived store
import { derived } from 'svelte/store';
const themeDerived = derived(themeProviderStore, ($themeProvider) => getTheme("button"));
// use $themeDerived in template/component
Applied to files:
src/lib/timeline/TimelineItem.svelte
🔇 Additional comments (2)
src/lib/timeline/TimelineItem.svelte (2)
19-19: LGTM! Prop follows existing customization pattern.The new
defaultDivClassprop allows customization of the default order marker, consistent with other*Classprops in the component.
52-57: LGTM! Correct reactive theme pattern.The
getThemecall is properly placed inside$derived()to react to dynamic theme changes, as per the learned pattern. The fallback logic fordefaultDivClsis clear and appropriate.Based on learnings, this follows the correct pattern for reactive theme integration in Flowbite-Svelte.
| div: "text-gray-600 dark:text-gray-400", | ||
| title: "text-base font-normal", | ||
| span: "inline-flex items-center text-xs font-normal text-gray-500 dark:text-gray-400", | ||
| span: "inline-flex items-center bg-gray-100 border border-gray-200 text-xs font-medium px-1.5 py-0.5 rounded", |
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.
Verify if groupItem span styling change is intentional.
This line changes the groupItem span from plain text styling to a badge-like appearance (adds background, border, padding, and rounded corners). This is a significant visual change that affects the GroupItem component, but appears unrelated to the Timeline default order icon fix described in issue #1881.
Confirm whether this styling change is:
- Intentional and part of a broader design update, or
- Accidentally included from another branch/change
Run the following script to check if this change is referenced in any related issues or documentation:
#!/bin/bash
# Description: Check for references to groupItem or badge styling changes
# Search for groupItem usage and styling references
echo "=== Searching for groupItem component usage ==="
rg -n "groupItem|GroupItem" --type=svelte --type=ts -C 2
# Search for any TODO or comments about badge styling
echo -e "\n=== Checking for badge-related comments ==="
rg -n "badge|pill" src/lib/timeline/ -C 2
🔗 Related issue (optional)
Closes #1881
📑 Description
🔍 PR Type
🚦 PR Status
✅ Checklist
pnpm lint && pnpm check && pnpm test:e2eand all tests passmainbranch (not the published npm version)🧪 Screenshots / Demos (optional)
ℹ️ Additional Information
Summary by CodeRabbit
New Features
Style
✏️ Tip: You can customize this high-level summary in your review settings.