-
Notifications
You must be signed in to change notification settings - Fork 326
Change from setContext/getContext to createContext #1868
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. |
WalkthroughCentralizes context handling by adding Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45–75 minutes Focus areas:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 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:
🔇 Additional comments (2)
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/routes/docs-examples/extend/button-toggle/ButtonColor.svelte (1)
19-24: Use separate state variables and handlers for independent button toggle groups.Both
ButtonToggleGroupinstances currently share the samesingleValuestate andhandleSingleSelecthandler, causing selections in one group to deselect toggles in the other. According to Flowbite-Svelte documentation, multiple toggle groups should use independent state variables and handlers. Apply the suggested diff to give each group its own state (singleValueandsingleValue2) and handler (handleSingleSelectandhandleSingleSelect2).
♻️ Duplicate comments (1)
LIST_CONTEXT_MIGRATION.md (1)
1-168: Same documentation placement consideration applies.See earlier comment on
TOOLBAR_CONTEXT_MIGRATION.mdregarding whether these migration guides should be retained, moved, or removed post-migration.
🧹 Nitpick comments (13)
src/routes/docs-examples/components/buttons/Outline.svelte (1)
5-10: Button outline variants look correct; double‑check docs layout after wrapper removalThe Button API usage (outline + color variants) is consistent and looks good. The only potential side effect is from dropping the previous flex wrapper (centering/gap), which may change how these buttons appear in the docs. Please verify the example still matches the intended layout and spacing; if not, consider reinstating an appropriate layout container higher up in the docs example.
src/lib/types.ts (1)
361-374: ButtonToggle context re‑export and roundedSize literals look consistent with the new context modelExporting
ButtonToggleContextTypefrom$lib/contextand wiringButtonToggleGroupProps.roundedSizeto an explicit"sm" | "md" | "lg" | "xl" | "full"union aligns with the centralized context/types cleanup and the theme-supported values. This also prevents"none"leaking into the public group API.If you expect consumers to rely on
"none"for the group prop, consider calling that out as a breaking (or tightening) change in release notes; otherwise this looks correct.src/lib/dropdown/DropdownItem.svelte (1)
2-21: Dropdown context migration looks correct; consider simplifying isActive expressionUsing
getDropdownContext()with optional chaining keepsDropdownItemsafe outside of aDropdownand matches the new context pattern. TheisActivelogic is sound.For readability you could simplify it to an explicit boolean:
const ctx = getDropdownContext(); let isActive = $derived(!!href && ctx?.activeUrl === href);Functionally equivalent but a bit easier to scan.
src/routes/docs-examples/components/buttons/IconButton.svelte (1)
6-13: Structural simplification is fine; consider adding aria‑labels to icon‑only buttonsDropping the extra wrapper and relying on the example container for layout is fine and keeps the snippet minimal.
Since these are icon‑only buttons and the docs emphasize accessibility, it would be a good time to add
aria-label(or similar) to eachButtonso the example also demonstrates best practice for assistive technologies.src/lib/carousel/CarouselIndicators.svelte (1)
2-7: Indicators now degrade gracefully when carousel context is missingUsing
getCarouselContext()with the{#if _state}wrapper ensures indicators only render when state is available, avoiding previous hard failures. The optional chaining ingoToIndexis a minor redundancy given theif _stateguard, but it doesn’t hurt readability or behavior.Also applies to: 13-18, 21-34
src/lib/carousel/Controls.svelte (1)
2-3: Controls context usage is safer; consider whether silent no‑ops are desiredFetching state via
getCarouselContext()and bailing out inchangeSlidewhen_stateis absent avoids runtime errors and keeps the API surface clean. If you’d rather not expose non-functional controls when used outside a carousel, you could additionally gate the rendered markup on_state, but that’s an API choice rather than a requirement.Also applies to: 6-7, 12-17
src/lib/accordion/AccordionItem.svelte (1)
67-69: Consider simplifying the complex class derivation.The expression on line 69 is quite dense with multiple fallback chains. While functionally correct, this could benefit from being broken into smaller, more readable pieces.
- let buttonClass = $derived(clsx(open && !ctx?.flush && (styling.active || ctx?.activeClass || active()), !open && !ctx?.flush && (styling.inactive || ctx?.inactiveClass || inactive()))); + let buttonClass = $derived.by(() => { + if (ctx?.flush) return ""; + const activeStyles = styling.active || ctx?.activeClass || active(); + const inactiveStyles = styling.inactive || ctx?.inactiveClass || inactive(); + return clsx(open && activeStyles, !open && inactiveStyles); + });src/lib/pagination/Pagination.svelte (1)
13-24: MissingactiveClassesgetter compared to PaginationNav.
PaginationNav.svelteprovides anactiveClassesgetter in its context (line 50-52), but this component does not. This inconsistency may cause issues if consumers expectactiveClassesto be available from either pagination provider.Consider adding the getter for consistency:
const ctx: PaginationContextType = { get group() { return true; }, get table() { return table; }, get size() { return size; + }, + get activeClasses() { + return undefined; // or expose via props if needed } };TOOLBAR_CONTEXT_MIGRATION.md (1)
1-224: Consider documentation placement.This migration guide provides valuable context but may become stale once the migration is complete. Consider whether this should be:
- Moved to a
docs/orCONTRIBUTING.mdsection if it's meant to guide future contributors- Removed after the migration is verified, keeping only inline code comments
- Kept as an ADR (Architecture Decision Record) in a dedicated location
src/lib/forms/button-toggle/ButtonToggle.svelte (1)
36-39: Consider documenting the size mapping rationale.The size transformations (
xs→sm,none→md) are important business logic. A brief comment explaining why these mappings exist would help future maintainers.// Filter size to only valid buttonToggle sizes (no 'xs') + // buttonToggle theme doesn't support 'xs', map to 'sm' as closest alternative const actualSize = (size === "xs" ? "sm" : size) as VariantProps<typeof buttonToggle>["size"]; // Filter roundedSize to only valid buttonToggle roundedSize values (remove 'none') + // 'none' is not a valid rounded variant, default to 'md' for consistent appearance const actualRoundedSize = (roundedSize === "none" ? "md" : roundedSize) as VariantProps<typeof buttonToggle>["roundedSize"];src/lib/context.ts (2)
45-48: Inconsistent type definition locations.Some context types are defined inline here (
DrawerContextType,DropdownContextType,PaginationContextType,ButtonToggleContextType,ListContextType,ToolbarContextType), while others are imported from./types(AccordionCtxType,BottomNavContextType,CarouselState).For maintainability, consider consolidating all context type definitions either:
- All in
./types.tswith imports here, or- All defined here and re-exported
The relevant code snippets show
src/lib/types.tsre-exports these types, which suggests option 1 may be preferred for consistency.Also applies to: 62-65, 79-85, 99-109, 123-126, 140-143
9-14: Consider extracting the try/catch wrapper into a helper.The same try/catch pattern is repeated 10 times. A generic helper would reduce duplication:
function safeGetContext<T>(getter: () => T): T | undefined { try { return getter(); } catch { return undefined; } } // Usage: const getAccordionContext = () => safeGetContext(getAccordionContextRaw);This reduces boilerplate and ensures consistent error handling across all contexts.
TYPE_ERRORS_FIXED.md (1)
192-210: Testing recommendations are thorough but lack automation details.The testing recommendations cover the key scenarios affected by the fixes (size mapping, roundedSize mapping, and PaginationNav activeClasses). However, the recommendations are manual. Consider whether:
- Automated tests should verify the type-mapping behavior.
- The
pnpm checkrecommendation should be expanded to include test execution.Expand the testing section to include automated test recommendations:
## Testing Recommendations ### Automated Testing - Add unit tests to verify size 'xs' → 'sm' mapping in ButtonToggle - Add unit tests to verify roundedSize 'none' → 'md' mapping in ButtonToggle - Add snapshot or integration tests for PaginationNav with ClassValue activeClasses - Run: `pnpm test` to verify all changes ### Manual Testing 1. **Verify ButtonToggle with different sizes**: - Test with `size="xs"` (should map to 'sm') - ...
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (49)
LIST_CONTEXT_MIGRATION.md(1 hunks)THEME_CONTEXT_MIGRATION.md(1 hunks)TOOLBAR_CONTEXT_MIGRATION.md(1 hunks)TYPE_ERRORS_FIXED.md(1 hunks)package.json(2 hunks)src/lib/accordion/Accordion.svelte(1 hunks)src/lib/accordion/AccordionItem.svelte(3 hunks)src/lib/bottom-navigation/BottomNav.svelte(2 hunks)src/lib/bottom-navigation/BottomNavItem.svelte(3 hunks)src/lib/carousel/Carousel.svelte(2 hunks)src/lib/carousel/CarouselIndicators.svelte(1 hunks)src/lib/carousel/Controls.svelte(1 hunks)src/lib/carousel/Slide.svelte(1 hunks)src/lib/context.ts(1 hunks)src/lib/drawer/Drawer.svelte(2 hunks)src/lib/drawer/DrawerHandle.svelte(1 hunks)src/lib/dropdown/Dropdown.svelte(1 hunks)src/lib/dropdown/DropdownItem.svelte(2 hunks)src/lib/forms/button-toggle/ButtonToggle.svelte(3 hunks)src/lib/forms/button-toggle/ButtonToggleGroup.svelte(2 hunks)src/lib/pagination/Pagination.svelte(1 hunks)src/lib/pagination/PaginationButton.svelte(1 hunks)src/lib/pagination/PaginationItem.svelte(1 hunks)src/lib/pagination/PaginationNav.svelte(2 hunks)src/lib/theme/ThemeProvider.svelte(2 hunks)src/lib/theme/themeUtils.ts(1 hunks)src/lib/toolbar/Toolbar.svelte(1 hunks)src/lib/toolbar/ToolbarButton.svelte(1 hunks)src/lib/toolbar/ToolbarGroup.svelte(2 hunks)src/lib/types.ts(4 hunks)src/lib/typography/list/Li.svelte(1 hunks)src/lib/typography/list/List.svelte(1 hunks)src/routes/docs-examples/components/button-group/Disabled.svelte(1 hunks)src/routes/docs-examples/components/buttons/IconButton.svelte(1 hunks)src/routes/docs-examples/components/buttons/Outline.svelte(1 hunks)src/routes/docs-examples/components/datepicker/ElementRef.svelte(1 hunks)src/routes/docs-examples/components/gallery/Featured.svelte(1 hunks)src/routes/docs-examples/components/gallery/Filters.svelte(1 hunks)src/routes/docs-examples/components/pagination/Default.svelte(1 hunks)src/routes/docs-examples/components/pagination/Default2.svelte(2 hunks)src/routes/docs-examples/components/pagination/PreviousNext.svelte(2 hunks)src/routes/docs-examples/components/pagination/PreviousNextIcons.svelte(2 hunks)src/routes/docs-examples/extend/button-toggle/ButtonColor.svelte(1 hunks)src/routes/docs/components/buttons.md(2 hunks)src/routes/docs/components/indicators.md(1 hunks)src/routes/docs/components/kbd.md(2 hunks)src/routes/docs/components/list-group.md(1 hunks)src/routes/docs/components/popover.md(2 hunks)src/routes/theme-context-test/+page.svelte(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/lib/dropdown/DropdownItem.sveltesrc/routes/docs-examples/components/gallery/Filters.sveltesrc/routes/theme-context-test/+page.sveltesrc/routes/docs-examples/components/pagination/Default.sveltesrc/lib/dropdown/Dropdown.sveltesrc/lib/accordion/AccordionItem.sveltesrc/routes/docs-examples/components/gallery/Featured.sveltesrc/lib/pagination/PaginationButton.sveltesrc/lib/toolbar/ToolbarGroup.sveltesrc/lib/accordion/Accordion.sveltesrc/routes/docs-examples/components/pagination/PreviousNextIcons.sveltesrc/lib/carousel/CarouselIndicators.sveltesrc/lib/theme/ThemeProvider.sveltesrc/lib/typography/list/List.sveltesrc/lib/toolbar/ToolbarButton.sveltesrc/lib/toolbar/Toolbar.sveltesrc/routes/docs-examples/components/datepicker/ElementRef.sveltesrc/routes/docs-examples/components/buttons/Outline.sveltesrc/lib/types.tssrc/lib/drawer/Drawer.sveltesrc/lib/carousel/Carousel.sveltesrc/lib/carousel/Controls.sveltesrc/lib/theme/themeUtils.tssrc/lib/carousel/Slide.sveltesrc/lib/pagination/PaginationItem.sveltesrc/lib/pagination/Pagination.sveltesrc/lib/drawer/DrawerHandle.sveltesrc/lib/forms/button-toggle/ButtonToggleGroup.sveltesrc/routes/docs-examples/extend/button-toggle/ButtonColor.sveltesrc/routes/docs-examples/components/pagination/PreviousNext.sveltesrc/lib/bottom-navigation/BottomNavItem.sveltesrc/routes/docs-examples/components/pagination/Default2.sveltesrc/routes/docs-examples/components/buttons/IconButton.sveltesrc/lib/forms/button-toggle/ButtonToggle.sveltesrc/routes/docs-examples/components/button-group/Disabled.sveltesrc/lib/typography/list/Li.sveltesrc/lib/bottom-navigation/BottomNav.sveltesrc/lib/context.tssrc/lib/pagination/PaginationNav.svelte
🧠 Learnings (9)
📚 Learning: 2024-10-18T09:38:03.879Z
Learnt from: Chizaruu
Repo: themesberg/flowbite-svelte PR: 1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In `Timepicker.svelte`, the `Dropdown` opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Applied to files:
src/lib/dropdown/DropdownItem.sveltesrc/lib/dropdown/Dropdown.sveltesrc/routes/docs-examples/components/datepicker/ElementRef.sveltesrc/lib/types.ts
📚 Learning: 2024-11-22T08:37:27.996Z
Learnt from: mrh1997
Repo: themesberg/flowbite-svelte PR: 1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In `src/lib/utils/Popper.svelte`, inconsistencies in event handling (e.g., using both `mouseenter`/`mouseleave` and `pointerenter`/`pointerleave`) may be intentional to minimize modifications and reduce the risk of new problems.
Applied to files:
src/lib/dropdown/DropdownItem.sveltesrc/routes/docs-examples/components/datepicker/ElementRef.sveltesrc/routes/docs/components/popover.mdsrc/lib/forms/button-toggle/ButtonToggle.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} : Use the Flowbite-Svelte MCP server to discover components by name or category before implementing UI components
Applied to files:
src/routes/docs-examples/components/gallery/Filters.sveltepackage.jsonsrc/routes/docs-examples/components/pagination/Default.sveltesrc/routes/docs-examples/components/buttons/Outline.sveltesrc/routes/docs-examples/components/button-group/Disabled.svelte
📚 Learning: 2025-11-25T07:26:39.377Z
Learnt from: CR
Repo: themesberg/flowbite-svelte PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T07:26:39.377Z
Learning: Use getComponentList tool to discover available Flowbite-Svelte components with their categories or to help users explore component options
Applied to files:
src/routes/docs-examples/components/gallery/Filters.sveltesrc/routes/docs-examples/components/buttons/Outline.sveltesrc/routes/docs-examples/components/button-group/Disabled.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: Use getComponentList tool to discover available Flowbite-Svelte components or help users explore component options
Applied to files:
src/routes/docs/components/kbd.mdsrc/routes/docs-examples/components/buttons/Outline.sveltesrc/routes/docs-examples/components/button-group/Disabled.svelte
📚 Learning: 2024-11-12T10:36:34.807Z
Learnt from: LahTeuto
Repo: themesberg/flowbite-svelte PR: 1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting `role="presentation"` on elements that should retain the `link` role, as it can diminish ARIA role coverage and negatively affect accessibility.
Applied to files:
src/routes/docs/components/buttons.md
📚 Learning: 2024-10-15T22:41:47.429Z
Learnt from: Chizaruu
Repo: themesberg/flowbite-svelte PR: 1464
File: src/routes/component-data/Datepicker.json:0-0
Timestamp: 2024-10-15T22:41:47.429Z
Learning: The component should be named 'Datepicker' (with lowercase 'p') throughout the codebase to maintain consistency.
Applied to files:
src/routes/docs-examples/components/datepicker/ElementRef.svelte
📚 Learning: 2025-03-20T12:47:33.307Z
Learnt from: superstes
Repo: themesberg/flowbite-svelte PR: 0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles with focus-within, create a dedicated focusWithinClasses object with appropriate colors for each state (base, primary, green, red). Using just 'focus-within:ring-1' without color specification won't correctly apply color-specific styling when the input receives focus directly.
Applied to files:
src/routes/docs-examples/components/buttons/Outline.svelte
📚 Learning: 2025-08-31T12:56:05.074Z
Learnt from: jjagielka
Repo: themesberg/flowbite-svelte PR: 1745
File: src/lib/types.ts:677-686
Timestamp: 2025-08-31T12:56:05.074Z
Learning: HTMLInputAttributes includes a `group` property that can be used for grouping form controls like checkboxes and radio buttons, so interfaces extending HTMLInputAttributes don't need to explicitly declare `group` unless they want to override its type.
Applied to files:
src/lib/types.ts
🧬 Code graph analysis (2)
src/lib/theme/themeUtils.ts (2)
src/lib/theme/index.ts (1)
ThemeConfig(6-8)src/lib/context.ts (1)
getThemeContext(168-168)
src/lib/context.ts (1)
src/lib/types.ts (8)
AccordionCtxType(199-204)BottomNavContextType(278-282)CarouselState(405-412)DrawerContextType(620-620)DropdownContextType(639-639)PaginationContextType(1190-1190)ButtonToggleContextType(361-361)ThemeConfig(1837-1837)
🔇 Additional comments (48)
src/routes/docs-examples/components/gallery/Filters.svelte (3)
19-21: Clean reactive state implementation with Svelte 5 runes.Good use of
$stateand$derivedfor the filtering logic. The derived computation correctly handles both the "All" case and category-specific filtering.
24-30: Well-implemented filter buttons with correct active state handling.The
outlineprop logic correctly shows solid buttons when selected and outlined buttons when not. The inlineonclickhandlers are appropriate for this simple state update pattern.
32-32: LGTM!The Gallery correctly receives the derived
filteredImagesand will reactively update when the selected category changes.src/routes/docs-examples/components/pagination/PreviousNext.svelte (1)
2-2: LGTM!The addition of the pagination status display (
"Showing {currentPage} of {totalPages} Entries") improves user experience by providing clear feedback about the current pagination state. The import and usage of thePcomponent are correct.Also applies to: 13-13
src/routes/docs/components/kbd.md (1)
31-31: LGTM!The addition of
class="flex flex-wrap gap-2"to the code fence attributes provides consistent, responsive layout styling for the KBD component examples in the documentation.Also applies to: 63-63, 71-71, 79-79
src/routes/docs-examples/components/pagination/PreviousNextIcons.svelte (1)
2-2: LGTM!Consistent with the pagination status display added to other pagination examples. This improves user experience by showing clear pagination state feedback.
Also applies to: 14-14
src/routes/docs-examples/components/datepicker/ElementRef.svelte (1)
10-16: LGTM!The addition of the blur button complements the existing focus and select buttons well, providing a complete set of element reference interactions. The layout update to use flexbox with wrapping improves responsiveness.
THEME_CONTEXT_MIGRATION.md (1)
1-141: LGTM!Excellent documentation for the Theme context migration. The document clearly explains the rationale, benefits, and implementation details of migrating from
setContext/getContexttocreateContext. The inclusion of before/after examples, testing recommendations, and a reusable migration pattern for other contexts makes this a valuable reference for the team.src/routes/docs-examples/components/gallery/Featured.svelte (1)
3-3: LGTM!The interactive thumbnail gallery is well-implemented with proper typing using
ImgTypeand Svelte 5's$staterune. The click handler correctly updates the main image when thumbnails are clicked, providing a clean and type-safe user experience.Also applies to: 18-35
package.json (1)
105-105: Svelte 5.40.0 is available and compatible with the createContext API migration.Svelte 5.40.0 exists and was released in November 2025. The version bump from ^5.29.0 to ^5.40.0 is safe—there are no breaking changes between these versions. The key improvement in 5.40.0 is that
createContextnow preserves and passes types with the stored context, eliminating the need to re-typegetContextreturn values. This enhancement actually benefits the migration to thecreateContextAPI.src/lib/types.ts (1)
619-621: Re‑exporting Drawer/Dropdown/Pagination context types is a good consolidation stepThe new
export type { DrawerContextType },DropdownContextType, andPaginationContextTypefrom$lib/contextgive consumers a single, consistent import surface for context typings and keep the definitions centralized. No functional risks here; this matches the broader context refactor.Also applies to: 639-640, 1190-1191
src/routes/docs/components/indicators.md (1)
39-41: Legend example styling update improves readability and dark‑mode supportAdding
text-sm font-medium text-gray-900 dark:text-white flex flex-wrap gap-2makes the legend text more consistent with design tokens and prevents overflow when items wrap. Looks good.src/routes/docs/components/list-group.md (1)
84-86: More responsive layout for horizontal list with tooltipSwitching to
gap-4 flex flex-wrap justify-center items-centerremoves the hardcoded height and enables wrapping, which should behave better on smaller viewports while keeping alignment. Looks good.src/lib/theme/ThemeProvider.svelte (1)
3-17: ThemeProvider now correctly uses the centralized theme context helperImporting
setThemeContextfrom$lib/contextand calling it when athemeis provided aligns ThemeProvider with the new context system and keeps the public props unchanged. This is a straightforward, behavior‑preserving migration.src/routes/docs/components/buttons.md (2)
224-226: Icon buttons example container now handles wrapping and vertical centeringUpdating to
flex flex-wrap items-center gap-2should keep icon buttons aligned while allowing them to wrap cleanly on smaller screens. Looks good.
238-240: Loader example container made more responsiveSwitching to
flex flex-wrap justify-center gap-2lets loader buttons wrap while remaining centered, which is friendlier on narrow viewports. No issues here.src/lib/typography/list/Li.svelte (1)
4-11: Li now correctly consumes the centralized List context with safe fallbackUsing
getListContext()andctx?.ctxClassto buildliClsintegratesLiwith the new List context while still behaving sensibly when no provider is present. Theclsxcomposition with theiconflag remains clear and maintainable.src/lib/theme/themeUtils.ts (1)
3-3: LGTM! Clean migration to centralized context API.The replacement of Svelte's
getContextwithgetThemeContextcorrectly follows the PR's migration pattern, and the existing optional chaining safely handles undefined contexts.Also applies to: 7-8
src/lib/drawer/DrawerHandle.svelte (1)
6-6: LGTM! Context migration correctly implemented.The replacement of
getContext("drawer")withgetDrawerContext()aligns with the centralized context pattern, and optional chaining ensures safe access when context is undefined.Also applies to: 10-10
src/routes/docs-examples/components/pagination/Default.svelte (1)
15-23: Verify SSR safety of window access.The
checkMobilefunction accesseswindow.innerWidth, which is only available in the browser. WhileonMountensures this runs client-side, ensure the initialisMobile = falsestate provides acceptable SSR behavior (showing all pagination examples server-side, then hiding on mobile after hydration).If SSR/hydration flash is a concern, consider adding a guard:
function checkMobile() { + if (typeof window === 'undefined') return; isMobile = window.innerWidth <= 640; }src/lib/toolbar/Toolbar.svelte (1)
14-25: LGTM! Clean getter/setter context pattern.The migration to
setToolbarContextwith a getter/setter wrapper maintains reactivity while centralizing context management. The pattern correctly exposesseparatorsthrough accessors backed by the reactivecontext.separatorsstate.src/routes/docs/components/popover.md (1)
54-54: LGTM! Documentation layout improvements.The class updates improve responsive behavior (
h-[550px] md:h-96) and example presentation, with no impact on component functionality.Also applies to: 112-112
src/lib/dropdown/Dropdown.svelte (1)
16-23: LGTM! Simplified context with read-only getter.The migration replaces the stateful store pattern with a cleaner getter-based approach. The
activeUrlgetter correctly defaults to an empty string whenactiveUrlprop is undefined, and consumers (likeDropdownItem) appropriately access this as read-only context.src/lib/toolbar/ToolbarButton.svelte (1)
15-15: Verify that hardcodingbackground: falseis intentional.The dynamic background behavior based on context has been removed, and
backgroundis now alwaysfalse. Ensure this change doesn't break existing use cases where the background was dynamically set based on toolbar context.src/lib/toolbar/ToolbarGroup.svelte (1)
5-5: Toolbar group context migration is safe and idiomaticUsing
getToolbarContext()with a null-check before mutatingctx.separatorskeeps the previous behavior while avoiding errors when no toolbar context is present. No further changes needed here.Also applies to: 14-16
src/lib/carousel/Carousel.svelte (1)
6-7: Centralized carousel context setup looks correctProviding
_stateviasetCarouselContext(_state)right after it’s created cleanly replaces directsetContextusage without changing behavior. The state object remains the single source of truth for slides and is available to all carousel children.Also applies to: 56-59
src/routes/docs-examples/components/pagination/Default2.svelte (1)
4-7: Responsive pagination toggle is implemented safelyThe
isMobilestate pluscheckMobileand the mounted resize listener provide a clean, leak-free way to hide the large pagination on small viewports. BecausecheckMobileis only called inside the mount callback, this remains SSR-safe while preserving initial markup.Also applies to: 39-47, 51-53
src/routes/theme-context-test/+page.svelte (1)
1-41: Theme context test page is well-scoped and representativeThe page exercises default theming, a single provider, and multiple children in one provider using a minimal
customTheme, which is exactly what you want for validating the theme context migration. No issues spotted.src/lib/carousel/Slide.svelte (1)
2-3: Slide transitions now handle missing carousel context robustlyUsing
getCarouselContext()with optional chaining in the transition configs preserves existing behavior when state is present and falls back to sane defaults (duration ?? 1000, fixed directions) when it is not. This makes the slide component more resilient without changing its public API.Also applies to: 5-6, 9-9, 15-21, 23-29
src/lib/bottom-navigation/BottomNavItem.svelte (1)
2-3: Bottom nav item context access is correctly guardedSwitching to
getBottomNavContext()with optional access (context?.activeUrl,context?.navType,context?.activeClass) maintains the existing active-state and styling behavior when used within a BottomNav, while making standalone usage safe (no context, no active state). The class composition for active items remains consistent with the previous behavior.Also applies to: 5-5, 17-21, 36-41
src/lib/typography/list/List.svelte (1)
14-22: LGTM! Clean context migration pattern.The getter-based context object correctly exposes reactive state, and
setListContextis appropriately called during component initialization. The$effecton lines 24-26 ensurescontextClassstays synchronized with thectxClassprop.src/lib/pagination/PaginationItem.svelte (1)
12-23: LGTM! Proper optional chaining for context access.The context retrieval correctly handles the case where the component is used outside a
Paginationparent. The nullish coalescing operators provide sensible fallbacks to component props or default values.src/lib/accordion/AccordionItem.svelte (1)
44-49: LGTM! Context migration with proper fallback handling.The context is correctly retrieved with optional chaining. The transition type logic appropriately prioritizes the component's
transitionTypeprop over the context value, ensuring local overrides work as expected.src/lib/pagination/PaginationButton.svelte (1)
12-36: LGTM! Proper context handling with conditional styling.The derived class computation correctly handles both the presence and absence of context. The
ctx.activeClassesaccess on line 23 is safe due to the guard on line 16. The fallback pattern is consistent with other pagination components.src/lib/forms/button-toggle/ButtonToggleGroup.svelte (2)
54-68: LGTM! Toggle selection logic with onSelect callback.The
toggleSelectedfunction correctly manages both single and multi-select modes, and properly invokes theonSelectcallback after each state change. The state management withselectedValuesis reactive and will work correctly through the context getter.
79-108: Destructured props in context getters may lose reactivity if props change dynamically.The getters for
multiSelect,color,size,roundedSize,ctxIconClass, andctxBtnClassreference destructured props that may not update reactively if the parent component changes these values after mount in Svelte 5.Verify whether these props are intended to be static or dynamic. If dynamic updates are expected, consider using
$props()or alternative approaches to maintain reactivity.src/lib/bottom-navigation/BottomNav.svelte (1)
19-32: Destructured props in context getters may not reflect updates in Svelte 5.Destructuring props breaks reactivity in Svelte 5. When context getters reference destructured prop values, they capture the initial values and won't update when parent props change.
Consider maintaining prop reactivity by accessing them without destructuring:
+ const props = $props<BottomNavProps>(); + const context: BottomNavContextType = { get activeClass() { return activeCls; }, get activeUrl() { - return activeUrl; + return props.activeUrl ?? ""; }, get navType() { - return navType; + return props.navType ?? "default"; } };Alternatively, use
$derived($props())to keep destructured values reactive.src/lib/accordion/Accordion.svelte (1)
13-30: LGTM! Clean migration to getter-based context.The context object correctly exposes reactive getters that reference the component's props directly. This pattern ensures consumers always receive current values without needing a store wrapper.
src/lib/pagination/PaginationNav.svelte (1)
39-56: LGTM! Complete context implementation.The context object correctly provides all
PaginationContextTypefields with reactive getters. TheactiveClassesgetter properly handles the optionalclassesprop with optional chaining.src/lib/drawer/Drawer.svelte (1)
29-36: LGTM! Clean context implementation.The drawer context correctly exposes the
placementprop through a getter, allowing child components likeDrawerHandle.svelteto reactively access the current placement.src/lib/forms/button-toggle/ButtonToggle.svelte (1)
18-30: LGTM! Robust context consumption with proper fallbacks.The destructuring pattern with fallback values handles the case when the component is used outside of
ButtonToggleGroup. The no-op function fortoggleSelectedand false forisSelectedensure the component remains functional standalone.src/lib/context.ts (1)
1-4: VerifycreateContextimport compatibility with Svelte version.The import
createContextfrom"svelte"is a Svelte 5 API available since v5.40.0. Ensure thepackage.jsonpeer dependency reflects this requirement.TYPE_ERRORS_FIXED.md (6)
1-26: Clarify the intended purpose and permanence of this documentation.This file appears to be added as a permanent repository artifact to document type errors fixed during the migration. However, it's unclear whether this is appropriate as a committed file or if this information should live in PR documentation, a CHANGELOG, or a migration guide instead.
Key concerns:
- Line numbers (e.g.,
PaginationNav.svelte:44,ButtonToggle.svelte:40) will become stale as code evolves.- The file references a specific migration event, which typically belongs in release notes or changelogs rather than permanent documentation.
- No guidance on whether this is a temporary reference or long-term documentation.
Please confirm:
- Is this file meant to be a permanent migration guide in the repository?
- If yes, should it be placed in a
docs/directory or similar?- Should the content be consolidated into
CHANGELOG.md, a migration guide, or release notes instead?- Will this file be maintained as code evolves, or is it a snapshot of this specific PR?
172-190: Acknowledge the explanation of why stricter type checking revealed these errors.The explanation that
createContextprovides stricter type checking thangetContextis sound and helps contextualize why these issues surfaced. This is a good catch by the migration, as it improves type safety.
124-142: Verify that all context type consolidation was completed consistently across the codebase.The documentation claims that
PaginationContextType,DrawerContextType,DropdownContextType, andButtonToggleContextTypewere all consolidated to/src/lib/context.tsand re-exported from/src/lib/types.ts. However, this requires verification against the actual codebase to ensure no lingering duplicates or inconsistent imports exist. Check that:
- All four context types are defined in
src/lib/context.ts- All four are properly re-exported from
src/lib/types.ts- No duplicate type definitions remain in
types.ts- All imports throughout the codebase reference the consolidated types correctly
7-49: Verify that the PaginationContextType consolidation is correctly implemented across all files.The documentation states that
PaginationContextTypewas defined in two places (types.ts and context.ts) and the fix was to remove the duplicate and re-export from context.ts. However, the actual implementation could not be verified due to repository access limitations. The same verification applies toDrawerContextTypeandDropdownContextTypementioned for consistency.To confirm this consolidation is complete, verify:
PaginationContextTypeis defined only once in/src/lib/context.ts/src/lib/types.tsre-exports it withexport type { PaginationContextType } from "$lib/context"- No duplicate definition exists in
/src/lib/types.ts- The same pattern applies to
DrawerContextTypeandDropdownContextType
101-122: Manual verification required for type assertions and import handling in ButtonToggle.svelte.The three points requested for verification cannot be automatically confirmed:
- Whether
VariantPropsimport fromtailwind-variantsis correctly used in the type assertion- Whether the context type for color is appropriately narrowed or remains a temporary workaround
- Whether the unused import warning for
ButtonToggleVariantswas actually resolvedPlease manually confirm these implementation details by examining:
- The import statements at the top of
ButtonToggle.svelte(line 4 and surrounding imports)- The
actualColorvariable assignment around line 49- The
ButtonToggleContextTypedefinition incontext.tsto verify thecolorproperty type
51-98: Verify ButtonToggle size and roundedSize filtering implementationThe documentation describes type filtering logic that maps
'xs'to'sm'for size and'none'to'md'for roundedSize. These mappings require verification to ensure:
- The filtering actually prevents type errors in ButtonToggle.svelte
- The mapped values are semantically correct (e.g., 'xs' → 'sm' makes visual sense)
- All components using ButtonToggle context are aware of these mappings
- Type definitions in context.ts (ButtonToggleContextType) and types.ts (ButtonToggleGroupProps) match the documented values
src/routes/docs-examples/components/button-group/Disabled.svelte
Outdated
Show resolved
Hide resolved
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: 0
🧹 Nitpick comments (6)
src/lib/navbar/NavUl.svelte (1)
11-12: Consider optional chaining for consistency with Table components.The non-null assertions (
!) will throw runtime errors ifNavUlis used outside aNavbarcontext. While this fail-fast approach is valid, it's inconsistent with the defensive optional chaining pattern used inTableBodyRow.svelteandTableHead.svelte(lines 14-17 in those files).If you prefer consistency and more graceful degradation, consider:
- let navState = getNavbarStateContext()!; - let navBreakpoint = getNavbarBreakpointContext()!; + let navState = getNavbarStateContext(); + let navBreakpoint = getNavbarBreakpointContext();Then update line 55 to handle potentially undefined context:
- let hidden: boolean = $derived(navState.hidden ?? true); + let hidden: boolean = $derived(navState?.hidden ?? true);And line 57:
- let { base, ul, active, nonActive } = $derived(navbarUl({ hidden, breakpoint: navBreakpoint })); + let { base, ul, active, nonActive } = $derived(navbarUl({ hidden, breakpoint: navBreakpoint ?? "md" }));However, if the intent is to enforce that
NavUlmust always be used within aNavbar, the current fail-fast approach is acceptable.src/lib/navbar/NavHamburger.svelte (1)
17-18: Consider optional chaining for consistency with Table components.Similar to
NavUl.svelte, the non-null assertions here will cause runtime errors ifNavHamburgeris used outside aNavbarcontext. This is inconsistent with the defensive optional chaining pattern in the Table components.If graceful degradation is preferred:
- const navState = getNavbarStateContext()!; - const navBreakpoint = getNavbarBreakpointContext()!; + const navState = getNavbarStateContext(); + const navBreakpoint = getNavbarBreakpointContext();Then guard access on line 22:
const toggle: MouseEventHandler<HTMLButtonElement> = () => { - navState.hidden = !navState.hidden; + if (navState) navState.hidden = !navState.hidden; };And line 19:
- const { base, menu } = navbarHamburger({ breakpoint: navBreakpoint }); + const { base, menu } = navbarHamburger({ breakpoint: navBreakpoint ?? "md" });Alternatively, if strict enforcement that
NavHamburgermust be withinNavbaris intended, the current approach is valid.src/lib/navbar/NavLi.svelte (1)
3-9: Navbar context migration is consistent; consider avoiding non‑null assertionsUsing
getNavbarStateContext()/getNavbarBreakpointContext()aligns with the new centralized context API, but the!assertions mean you’ll still hard‑fail at runtime if the navbar context is missing. If the intent ofcreateSafeContextis to allow safer/optional consumption, consider handling theundefinedcase explicitly (e.g., guard or fallback) or throwing a clearer error when context is absent.src/lib/sidebar/SidebarItem.svelte (1)
2-15: Simplify active state expression;??fallback is never usedThe migration to
getSidebarContext/getActiveUrlContextlooks good, and the optional chaining onactiveUrlis safe. However:
activeItemis always a boolean:let activeItem = $derived( active !== undefined ? active : activeUrl?.value ? href === activeUrl?.value : false );- Consequently,
(activeItem ?? activeUrl?.value === href)in bothaClsandaria-currentcan never evaluate the right-hand side, becausefalseis not nullish.You can simplify and make intent clearer:
- let activeItem = $derived(active !== undefined ? active : activeUrl?.value ? href === activeUrl?.value : false); - - let aCls = $derived((activeItem ?? activeUrl?.value === href) ? (activeClass ?? context.activeClass) : (nonActiveClass ?? context.nonActiveClass)); + let activeItem = $derived( + active !== undefined + ? active + : activeUrl?.value + ? href === activeUrl.value + : false + ); + + let aCls = $derived( + activeItem + ? activeClass ?? context.activeClass + : nonActiveClass ?? context.nonActiveClass + );And similarly for
aria-current:- aria-current={(activeItem ?? activeUrl?.value === href) ? "page" : undefined} + aria-current={activeItem ? "page" : undefined}This keeps the behavior the same while removing dead code and improving readability.
Also applies to: 18-18
src/lib/table/TableSearch.svelte (1)
2-4: Table context wiring looks correct; avoid duplicating color mappingThe switch to
setTableContextwith aTableCtxTypepayload looks consistent with the new context module, and the “custom” color handling is sound. You currently duplicate the"custom" → "default"mapping:const themeColor = color === "custom" ? "default" : (color as /* union */); const tableSearchCtx: TableCtxType = { striped, hoverable, color: color === "custom" ? "default" : (color as TableVariants["color"]) };To keep things DRY and ensure the context and visual styling stay in sync, you can reuse
themeColor:- const themeColor = color === "custom" ? "default" : (color as TableVariants["color"]); + const themeColor = color === "custom" ? "default" : (color as TableVariants["color"]); ... - const tableSearchCtx: TableCtxType = { - striped, - hoverable, - color: color === "custom" ? "default" : (color as TableVariants["color"]) - }; + const tableSearchCtx: TableCtxType = { + striped, + hoverable, + color: themeColor + };This removes redundant logic and keeps any future changes to the color mapping centralized.
Also applies to: 50-64, 66-67
src/lib/context.ts (1)
22-38: Safe context helpers look good; clarify / wire up TableSearch contextThe
createSafeContextwrapper around Svelte’screateContextis a clean way to exposegetXContext(): T | undefined/setXContext()pairs and avoid hard throws when a provider is missing. The various contexts (Accordion, BottomNav, Carousel, Drawer, Dropdown, Pagination, ButtonToggle, List, Toolbar, Theme, ListGroup, ButtonGroup, Navbar, Sidebar, Table) all follow this pattern consistently.At the bottom:
// Table const [getTableContext, setTableContext] = createSafeContext<TableCtxType>(); // TableSearch (also uses tableCtx key for compatibility) const [getTableSearchContext, setTableSearchContext] = createSafeContext<TableSearchType>();Two points to verify:
In this PR,
TableSearch.svelteusessetTableContext(...)but does not appear to callsetTableSearchContext(...), and other table components usegetTableContext(...). That makesgetTableSearchContext/setTableSearchContexteffectively unused right now; consider either wiring them up where needed or dropping them to avoid dead API surface.The comment “also uses tableCtx key for compatibility” reflects the old string‑keyed context pattern; with
createContexteach call creates its own key, so this comment is now misleading unless you intentionally share the same[get,set]pair between Table and TableSearch.Tidying this up (by either using or removing the TableSearch context and updating the comment) will reduce confusion for future maintainers.
Also applies to: 88-108
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
src/lib/context.ts(1 hunks)src/lib/navbar/NavHamburger.svelte(1 hunks)src/lib/navbar/NavLi.svelte(1 hunks)src/lib/navbar/NavUl.svelte(1 hunks)src/lib/navbar/Navbar.svelte(1 hunks)src/lib/sidebar/Sidebar.svelte(3 hunks)src/lib/sidebar/SidebarDropdownWrapper.svelte(2 hunks)src/lib/sidebar/SidebarItem.svelte(1 hunks)src/lib/table/Table.svelte(2 hunks)src/lib/table/TableBodyRow.svelte(1 hunks)src/lib/table/TableHead.svelte(1 hunks)src/lib/table/TableSearch.svelte(2 hunks)src/lib/types.ts(1 hunks)src/routes/admin-dashboard/(no-sidebar)/Footer.svelte(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/routes/admin-dashboard/(no-sidebar)/Footer.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/navbar/Navbar.sveltesrc/lib/navbar/NavUl.sveltesrc/lib/table/TableBodyRow.sveltesrc/lib/sidebar/SidebarItem.sveltesrc/lib/table/Table.sveltesrc/lib/sidebar/SidebarDropdownWrapper.sveltesrc/lib/navbar/NavLi.sveltesrc/lib/context.tssrc/lib/sidebar/Sidebar.sveltesrc/lib/table/TableSearch.sveltesrc/lib/types.tssrc/lib/table/TableHead.sveltesrc/lib/navbar/NavHamburger.svelte
🧠 Learnings (2)
📚 Learning: 2024-11-22T08:37:27.996Z
Learnt from: mrh1997
Repo: themesberg/flowbite-svelte PR: 1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In `src/lib/utils/Popper.svelte`, inconsistencies in event handling (e.g., using both `mouseenter`/`mouseleave` and `pointerenter`/`pointerleave`) may be intentional to minimize modifications and reduce the risk of new problems.
Applied to files:
src/lib/navbar/NavUl.sveltesrc/lib/sidebar/Sidebar.sveltesrc/lib/navbar/NavHamburger.svelte
📚 Learning: 2024-10-18T09:38:03.879Z
Learnt from: Chizaruu
Repo: themesberg/flowbite-svelte PR: 1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In `Timepicker.svelte`, the `Dropdown` opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Applied to files:
src/lib/sidebar/SidebarDropdownWrapper.svelte
🧬 Code graph analysis (2)
src/lib/context.ts (1)
src/lib/types.ts (16)
AccordionCtxType(351-356)BottomNavContextType(359-363)CarouselState(366-373)DrawerContextType(376-378)DropdownContextType(381-383)PaginationContextType(386-391)ButtonToggleContextType(394-403)ListContextType(406-408)ToolbarContextType(411-413)ListGroupContextType(416-419)ButtonGroupContextType(422-425)NavbarState(1181-1186)NavbarBreakpoint(1188-1188)SidebarCtxType(1445-1452)TableCtxType(1756-1761)TableSearchType(1827-1831)
src/lib/types.ts (2)
src/lib/bottom-navigation/theme.ts (1)
BottomNavVariants(5-5)src/lib/forms/button-toggle/theme.ts (1)
ButtonToggleVariants(17-17)
🔇 Additional comments (7)
src/lib/navbar/Navbar.svelte (1)
7-15: LGTM! Clean migration to centralized context API.The explicit
NavbarStatetype parameter on line 13 improves type safety, and the new context setters from$lib/contextprovide a cleaner, more maintainable API surface.src/lib/sidebar/SidebarDropdownWrapper.svelte (1)
5-6: LGTM! Safe fallback pattern implemented correctly.The fallback object
{ isSingle: false }on line 43 prevents runtime errors when the sidebar context is unavailable. The non-null assertion on line 60 is safe because it's guarded by thectx.isSinglecheck, and theselectedstore is guaranteed to be initialized whenisSingleis true (lines 47-49).Also applies to: 43-60
src/lib/sidebar/Sidebar.svelte (1)
6-6: LGTM! Clean context setter migration.The migration to
setSidebarContextandsetActiveUrlContextis straightforward and maintains the existing behavior.Also applies to: 60-60, 84-84
src/lib/table/Table.svelte (1)
2-2: LGTM! Straightforward context setter migration.Also applies to: 37-37
src/lib/table/TableBodyRow.svelte (1)
2-2: LGTM! Excellent defensive programming with optional chaining.The optional chaining (
?.) on lines 14-17 gracefully handles cases where the table context might be unavailable, with sensible fallback defaults.Also applies to: 12-17
src/lib/table/TableHead.svelte (1)
2-2: LGTM! Consistent defensive pattern with optional chaining.The implementation matches
TableBodyRow.svelte's approach, providing graceful degradation when context is unavailable.Also applies to: 13-17
src/lib/types.ts (1)
347-403: VerifyroundedSizeunion consistency between ButtonToggleContextType and ButtonToggleGroupPropsThe new "Context Types" section is well-structured and aligns with
src/lib/context.tsimports.However, a potential inconsistency exists with button-toggle rounding:
ButtonToggleContextType.roundedSize:"sm" | "md" | "lg" | "none" | "xl" | "full"ButtonToggleGroupProps.roundedSize:"sm" | "md" | "lg" | "xl" | "full"(missing"none")If
ButtonToggleVariants["roundedSize"]supports"none", the public prop type is stricter than the context type, which may break existing code. Ensure both unions align with the actual theme support, and confirm whether"none"should be included or excluded from both.
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: 3
🧹 Nitpick comments (1)
src/lib/types.ts (1)
393-403: AlignroundedSizeunions between ButtonToggle context and props
ButtonToggleContextType.roundedSizeincludes"none"butButtonToggleGroupProps.roundedSizenow omits it. This asymmetry can be confusing and allows"none"in the context even though the public prop type no longer accepts it.Consider either:
- Removing
"none"fromButtonToggleContextType.roundedSizeif it’s no longer a supported variant, or- Re‑adding
"none"toButtonToggleGroupProps.roundedSizeif you still want to support it externally.Also applies to: 429-436
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
src/lib/context.ts(1 hunks)src/lib/navbar/NavHamburger.svelte(1 hunks)src/lib/navbar/NavLi.svelte(1 hunks)src/lib/navbar/NavUl.svelte(2 hunks)src/lib/sidebar/SidebarItem.svelte(1 hunks)src/lib/split-pane/Pane.svelte(1 hunks)src/lib/split-pane/SplitPane.svelte(1 hunks)src/lib/table/TableSearch.svelte(2 hunks)src/lib/tabs/TabItem.svelte(2 hunks)src/lib/tabs/Tabs.svelte(2 hunks)src/lib/types.ts(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/navbar/NavHamburger.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/table/TableSearch.sveltesrc/lib/tabs/TabItem.sveltesrc/lib/navbar/NavUl.sveltesrc/lib/context.tssrc/lib/tabs/Tabs.sveltesrc/lib/split-pane/Pane.sveltesrc/lib/navbar/NavLi.sveltesrc/lib/types.tssrc/lib/split-pane/SplitPane.sveltesrc/lib/sidebar/SidebarItem.svelte
🧠 Learnings (1)
📚 Learning: 2024-11-22T08:37:27.996Z
Learnt from: mrh1997
Repo: themesberg/flowbite-svelte PR: 1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In `src/lib/utils/Popper.svelte`, inconsistencies in event handling (e.g., using both `mouseenter`/`mouseleave` and `pointerenter`/`pointerleave`) may be intentional to minimize modifications and reduce the risk of new problems.
Applied to files:
src/lib/navbar/NavUl.sveltesrc/lib/navbar/NavLi.svelte
🧬 Code graph analysis (2)
src/lib/context.ts (1)
src/lib/types.ts (17)
AccordionCtxType(351-356)BottomNavContextType(359-363)CarouselState(366-373)DrawerContextType(376-378)DropdownContextType(381-383)PaginationContextType(386-391)ButtonToggleContextType(394-403)ListContextType(406-408)ToolbarContextType(411-413)ThemeConfig(1895-1895)ListGroupContextType(416-419)ButtonGroupContextType(422-425)NavbarState(1181-1186)NavbarBreakpoint(1188-1188)SidebarCtxType(1445-1452)SplitPaneContext(2268-2278)TabsContextType(1883-1888)
src/lib/types.ts (2)
src/lib/bottom-navigation/theme.ts (1)
BottomNavVariants(5-5)src/lib/forms/button-toggle/theme.ts (1)
ButtonToggleVariants(17-17)
🔇 Additional comments (8)
src/lib/split-pane/Pane.svelte (1)
13-27: LGTM! Excellent defensive coding.The context retrieval and usage properly handles the case where context might be undefined through consistent use of optional chaining and conditional checks.
src/lib/navbar/NavUl.svelte (1)
11-12: LGTM! Proper defensive context handling.The code correctly handles potentially undefined context values through:
- Optional chaining (
navState?.hidden)- Fallback values (
?? true,?? "md")- Guard clause (line 60) before property mutations
Also applies to: 55-64
src/lib/navbar/NavLi.svelte (1)
8-9: LGTM! Excellent defensive context handling.The migration to centralized context accessors is implemented safely with:
- Consistent optional chaining for context property access (
navState?.activeUrl,navState?.hidden,navState?.activeClass)- Appropriate fallback values (
navBreakpoint ?? "md",navState?.hidden ?? true)- Guard clause before state mutation (line 26)
Also applies to: 15-22, 24-28
src/lib/types.ts (3)
347-373: Context interfaces are cohesive and match their component responsibilitiesThe new context types (accordion, bottom nav, carousel, drawer, dropdown, pagination, button toggle, list, toolbar, list group, button group) are well-scoped, use existing variant types appropriately, and provide clear contracts for the centralized context module.
Also applies to: 375-425
1883-1888: TabsContextType cleanly models tab registration and shared stateThe
TabsContextTypeinterface (activeClasses, sharedTabCtxType, register/unregister callbacks) is straightforward and provides a solid contract for tabs consumers.
2268-2278: SplitPaneContext matches SplitPane/Divider contracts wellThe
SplitPaneContextinterface mirrors the props onSplitPaneandDivider(direction, dragging state, size/style getters, mouse/touch/keyboard handlers), which should make context usage type‑safe and predictable.src/lib/context.ts (2)
23-39: Safe context wrapper is simple and preserves types
createSafeContext<T>()cleanly wraps Svelte’s context API, exposing a getter that safely returnsundefinedwhen no provider is present while keeping a strongly‑typed setter. The tupleas constkeeps inference tight for consumers.
41-113: Centralized getXContext/setXContext exports improve consistency across componentsDefining all contexts through
createSafeContext(for accordion, navigation, carousel, drawer, dropdown, pagination, button toggle, list, toolbar, theme, list group, button group, navbar, sidebar, active URL, table, split pane, and tabs) gives a single, type‑safe source of truth and should simplify future refactors.
…ntext/getContext with createContext
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
🧹 Nitpick comments (2)
src/lib/forms/select/MultiSelect.svelte (1)
41-42: Simplify context assignment by inlininggetButtonGroupContext
groupCtxis an unnecessary intermediate; you can inline for brevity without changing behavior:- const groupCtx = getButtonGroupContext(); - const group = groupCtx; + const group = getButtonGroupContext();Since
groupis only used ingrouped: !!group, this keeps the intent clear and types should still flow from the helper.src/lib/forms/select/Select.svelte (1)
37-38: InlinegetButtonGroupContextfor clarity and to match MultiSelectYou can remove the extra
groupCtxvariable and mirror a simpler pattern:- const groupCtx = getButtonGroupContext(); - const group = groupCtx; + const group = getButtonGroupContext();Keeps the code shorter and consistent with other components using the same helper.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
MIGRATION_BUTTONGROUP_CONTEXT.md(1 hunks)src/lib/button-group/ButtonGroup.svelte(1 hunks)src/lib/buttons/Button.svelte(1 hunks)src/lib/buttons/GradientButton.svelte(1 hunks)src/lib/forms/input-addon/InputAddon.svelte(2 hunks)src/lib/forms/input-field/Input.svelte(2 hunks)src/lib/forms/select/MultiSelect.svelte(2 hunks)src/lib/forms/select/Select.svelte(2 hunks)src/routes/docs-examples/forms/number-input/Control.svelte(1 hunks)src/routes/docs-examples/forms/number-input/ControlIcon.svelte(1 hunks)src/routes/docs-examples/forms/number-input/Counter.svelte(1 hunks)src/routes/docs-examples/forms/phone-input/Select.svelte(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/lib/button-group/ButtonGroup.sveltesrc/lib/forms/input-field/Input.sveltesrc/lib/buttons/Button.sveltesrc/routes/docs-examples/forms/number-input/Control.sveltesrc/lib/forms/input-addon/InputAddon.sveltesrc/lib/buttons/GradientButton.sveltesrc/routes/docs-examples/forms/phone-input/Select.sveltesrc/routes/docs-examples/forms/number-input/Counter.sveltesrc/routes/docs-examples/forms/number-input/ControlIcon.sveltesrc/lib/forms/select/Select.sveltesrc/lib/forms/select/MultiSelect.svelte
🧠 Learnings (3)
📚 Learning: 2025-08-31T12:56:05.074Z
Learnt from: jjagielka
Repo: themesberg/flowbite-svelte PR: 1745
File: src/lib/types.ts:677-686
Timestamp: 2025-08-31T12:56:05.074Z
Learning: HTMLInputAttributes includes a `group` property that can be used for grouping form controls like checkboxes and radio buttons, so interfaces extending HTMLInputAttributes don't need to explicitly declare `group` unless they want to override its type.
Applied to files:
src/lib/button-group/ButtonGroup.sveltesrc/lib/forms/input-field/Input.sveltesrc/lib/forms/input-addon/InputAddon.svelte
📚 Learning: 2025-03-20T12:47:33.307Z
Learnt from: superstes
Repo: themesberg/flowbite-svelte PR: 0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles with focus-within, create a dedicated focusWithinClasses object with appropriate colors for each state (base, primary, green, red). Using just 'focus-within:ring-1' without color specification won't correctly apply color-specific styling when the input receives focus directly.
Applied to files:
src/lib/forms/input-field/Input.svelte
📚 Learning: 2024-10-18T09:38:03.879Z
Learnt from: Chizaruu
Repo: themesberg/flowbite-svelte PR: 1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In `Timepicker.svelte`, the `Dropdown` opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Applied to files:
src/lib/forms/select/Select.sveltesrc/lib/forms/select/MultiSelect.svelte
🪛 LanguageTool
MIGRATION_BUTTONGROUP_CONTEXT.md
[style] ~137-~137: This phrase is redundant. Consider using “outside”.
Context: ...nsure proper styling 3. Test components outside of ButtonGroup to ensure they work indepen...
(OUTSIDE_OF)
🔇 Additional comments (11)
src/routes/docs-examples/forms/number-input/ControlIcon.svelte (1)
17-17: Verify Tailwind version and confirm scope of styling change.The class attribute now uses
!w-40for the important modifier. Tailwind v3 uses the prefix syntax (!w-40), while Tailwind v4 requires suffix syntax (w-40!). Flowbite-Svelte supports both versions. Please confirm which version this project uses, and if v4, update tow-40!.Additionally, this styling change (width increase from w-28 to w-40) appears unrelated to the PR's stated objective of migrating from setContext/getContext to createContext. Clarify whether this is an intentional styling update or scope creep.
src/routes/docs-examples/forms/number-input/Control.svelte (1)
9-15: Confirm Tailwind important modifier syntax for!w-32The layout change looks fine, but
!w-32uses the old leading-!important syntax. If the project is on Tailwind v4, the recommended form isw-32!instead. Please confirm this matches the Tailwind version you’re targeting and adjust if needed.src/routes/docs-examples/forms/phone-input/Select.svelte (1)
18-20: Select styling within ButtonGroup looks goodUsing
classes={{ select: "border-r-0" }}keeps the visual merge with the Clipboard button while simplifying the class list. No behavioral issues spotted.src/lib/buttons/Button.svelte (1)
4-11: ButtonGroup context migration is consistent and safeUsing
getButtonGroupContext()and derivinggroup/ctxDisabledfrom it cleanly replaces the previous raw context access, with correct undefined-safe handling when no provider is present. The rest of the sizing/disabled logic continues to behave as before.src/lib/forms/input-field/Input.svelte (1)
4-5: Input’s ButtonGroup context wiring and size fallback look correctThe switch to
getButtonGroupContext()and the_sizeresolution (size→ clampedgroup.size→"md") preserves existing behavior while handling the absence of a ButtonGroup provider safely. No issues spotted with grouped styling or combobox behavior.Also applies to: 74-78
src/lib/buttons/GradientButton.svelte (1)
4-10: GradientButton group context migration aligns with new APIObtaining the group information via
getButtonGroupContext()and passinggroup: !!groupinto the theme keeps grouped styling behavior intact while avoiding directgetContextusage.src/lib/button-group/ButtonGroup.svelte (1)
6-13: Centralized ButtonGroup context setup looks correctReplacing the separate
setContext("group")/setContext("disabled")calls withsetButtonGroupContext({ size, disabled })cleanly matches the new context API and keeps the initial size/disabled propagation semantics unchanged.src/lib/forms/input-addon/InputAddon.svelte (1)
6-12: InputAddon group context and size computation are consistentUsing
getButtonGroupContext()and deriving_sizefrom explicit size → clampedgroup.size→"md"is consistent with the other consumers and keeps grouped border behavior (group && "not-first:-ms-px") intact.Also applies to: 33-34
MIGRATION_BUTTONGROUP_CONTEXT.md (1)
1-142: Migration doc accurately reflects the implemented ButtonGroup context changesThe before/after snippets and the described benefits match the updated implementations in ButtonGroup, Button, GradientButton, InputAddon, and Input, and the testing recommendations cover the key usage scenarios. Nothing blocking here.
src/lib/forms/select/MultiSelect.svelte (1)
3-10: Imports now correctly match actual usageRemoving
SizeTypefrom the type import, droppinggetContext, and keepingonMountplus addinggetButtonGroupContextall align with the current code usage and the new centralized context API. No functional issues here.src/lib/forms/select/Select.svelte (1)
4-8: Type and context imports are consistent with the new APIUsing only
SelectPropsfrom$liband importinggetButtonGroupContext(while no longer relying on Svelte’sgetContext) is consistent with the refactor to centralized context helpers. No issues from a typing or runtime perspective.
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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/routes/blocks/utils/Newsletter.svelte (1)
37-46: Tailwind important modifier syntax looks incorrect (sm:w-96!)
sm:w-96!is not valid Tailwind syntax; the important modifier should prefix the utility (e.g.,sm:!w-96). As written, Tailwind will likely ignore this class and the small‑breakpoint width won't apply as intended.Consider fixing the class:
- class="formkit-input focus:ring-primary-600 focus:border-primary-600 pl-12 text-gray-900 sm:w-96!" + class="formkit-input focus:ring-primary-600 focus:border-primary-600 pl-12 text-gray-900 sm:!w-96"(or just
sm:w-96if you don't actually need!).
🧹 Nitpick comments (2)
src/routes/docs-examples/forms/number-input/ControlIcon.svelte (1)
17-17: Consider removing the!importantmodifier if possible.The
w-40!class uses Tailwind's important modifier, which typically indicates a specificity conflict with other styles. While this works, it may be better to resolve the underlying specificity issue rather than forcing the style with!important.If the important modifier is needed to override Flowbite's Input component styles, consider whether:
- The component can be styled more specifically without
!important- This is documented as an intentional override
Note: This styling change appears unrelated to the PR's main objective of migrating to
createContext.src/lib/buttons/Button.svelte (1)
4-5: getButtonGroupContext integration looks correct; consider a small cleanupThe migration to
ButtonPropsplusgetButtonGroupContext()for group size/disabled is consistent with the new context API, and the derivedactualSize,actualColor, andisDisabledcalculations still behave as before.For a tiny readability and micro-optimization improvement, you could call the context helper once and clarify naming, e.g.:
-import { getButtonGroupContext } from "$lib/context"; - -const group = getButtonGroupContext()?.size; -const ctxDisabled = getButtonGroupContext()?.disabled; +import { getButtonGroupContext } from "$lib/context"; + +const groupContext = getButtonGroupContext(); +const group = groupContext?.size; +const ctxDisabled = groupContext?.disabled;This makes it clear that
groupis the group size value and avoids calling the getter twice.Also applies to: 7-10
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
src/lib/buttons/Button.svelte(1 hunks)src/lib/buttons/GradientButton.svelte(1 hunks)src/lib/drawer/theme.ts(1 hunks)src/lib/forms/input-addon/InputAddon.svelte(2 hunks)src/lib/forms/input-field/Input.svelte(2 hunks)src/lib/forms/select/MultiSelect.svelte(2 hunks)src/lib/forms/select/Select.svelte(2 hunks)src/lib/tour/theme.ts(1 hunks)src/routes/blocks/utils/Newsletter.svelte(1 hunks)src/routes/docs-examples/forms/number-input/Control.svelte(1 hunks)src/routes/docs-examples/forms/number-input/ControlIcon.svelte(1 hunks)src/routes/docs-examples/forms/number-input/Counter.svelte(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- src/lib/buttons/GradientButton.svelte
- src/lib/forms/select/MultiSelect.svelte
- src/lib/forms/select/Select.svelte
- src/routes/docs-examples/forms/number-input/Counter.svelte
- src/routes/docs-examples/forms/number-input/Control.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/forms/input-field/Input.sveltesrc/routes/blocks/utils/Newsletter.sveltesrc/lib/buttons/Button.sveltesrc/lib/forms/input-addon/InputAddon.sveltesrc/routes/docs-examples/forms/number-input/ControlIcon.sveltesrc/lib/drawer/theme.tssrc/lib/tour/theme.ts
🧠 Learnings (2)
📚 Learning: 2025-08-31T12:56:05.074Z
Learnt from: jjagielka
Repo: themesberg/flowbite-svelte PR: 1745
File: src/lib/types.ts:677-686
Timestamp: 2025-08-31T12:56:05.074Z
Learning: HTMLInputAttributes includes a `group` property that can be used for grouping form controls like checkboxes and radio buttons, so interfaces extending HTMLInputAttributes don't need to explicitly declare `group` unless they want to override its type.
Applied to files:
src/lib/forms/input-field/Input.sveltesrc/lib/forms/input-addon/InputAddon.svelte
📚 Learning: 2025-03-20T12:47:33.307Z
Learnt from: superstes
Repo: themesberg/flowbite-svelte PR: 0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles with focus-within, create a dedicated focusWithinClasses object with appropriate colors for each state (base, primary, green, red). Using just 'focus-within:ring-1' without color specification won't correctly apply color-specific styling when the input receives focus directly.
Applied to files:
src/lib/forms/input-field/Input.svelte
🔇 Additional comments (2)
src/lib/drawer/theme.ts (1)
16-17: Verify Tailwind CSS version and consistency of important modifier syntax.The review comment recommends modernizing Tailwind CSS syntax from prefix notation (
!w-full) to suffix notation (w-full!), which is supported in Tailwind v3.1+. However, verification is needed to confirm:
- The project's Tailwind CSS version supports suffix important modifiers (v3.1+)
- This syntax pattern is applied consistently across theme files to maintain code uniformity
Without confirming version compatibility and codebase consistency, the approval cannot be finalized.
src/lib/forms/input-field/Input.svelte (1)
4-5: Button group context migration and size derivation look consistentUsing
getButtonGroupContext()forgroupand computing_sizeassize || (group?.size ? clampSize(group.size) : undefined) || "md"keeps the previous precedence (explicit size > group size >"md"), avoids relying onclampSizefor undefined values, and aligns this input with the new centralized button-group context helpers. I don't see any functional or type-safety issues here.Also applies to: 74-77
| progressContainer: "flex gap-2 justify-center", | ||
| progressDot: ["w-2 h-2 rounded-full bg-gray-300", "hover:bg-gray-400 transition-all duration-200 hover:scale-110"], | ||
| progressDotActive: "!bg-blue-500 !w-6 rounded", | ||
| progressDotActive: "!bg-blue-500 w-6! 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
# First, let's see the full context of the file
echo "=== Full file content ==="
cat -n src/lib/tour/theme.ts
echo ""
echo "=== Searching for w-[0-9]+ with trailing ! ==="
rg -n "w-[0-9]+!" src/lib
echo ""
echo "=== Searching for !w-[0-9]+ with leading ! ==="
rg -n "!w-[0-9]+" src/libRepository: themesberg/flowbite-svelte
Length of output: 196
🌐 Web query:
Tailwind CSS ! important modifier syntax trailing vs leading
💡 Result:
Short answer: Tailwind uses a leading exclamation mark as a prefix (e.g. !bg-red-500). A trailing exclamation (bg-red-500!) is not the Tailwind syntax.
Details/examples:
- Add ! immediately before the utility name (after any variant prefixes): sm:hover:!bg-red-500. [1]
- The ! makes the generated declaration use !important; it’s distinct from the config-level important option. [1][2]
Sources:
[1] Tailwind CSS docs — Important modifier.
[2] Tailkits article — Using !important in Tailwind.
Change w-6! to !w-6 to use correct Tailwind priority modifier syntax
Tailwind requires the ! prefix to come immediately before the utility name, not after it. The current w-6! is invalid syntax; it should be !w-6 to match the already-correct !bg-blue-500 on the same line. This inconsistency will likely cause the width priority modifier to not apply as intended.
🤖 Prompt for AI Agents
In src/lib/tour/theme.ts around line 18, the Tailwind priority modifier is
placed after the utility (w-6!) which is invalid; change that token to the
correct prefix form (!w-6) so the priority applies properly and matches the
existing !bg-blue-500 on the same line.
🔗 Related issue (optional)
Closes #
📑 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
Bug Fixes
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.