feat: Make alert icons customizable via setAlertIcons function#441
feat: Make alert icons customizable via setAlertIcons function#441ainsleyclark merged 3 commits intomainfrom
Conversation
Introduces setAlertIcons() to allow consumers to override the default Lucide icons with their own SVG components globally, without needing to pass a custom icon prop on every instance. https://claude.ai/code/session_01Am2tu2GzwFut2SBD25he1E
This comment has been minimized.
This comment has been minimized.
Replaces Lucide-specific typeof IconType with Svelte's Component type to match IconDetail, resolving the type mismatch when consumers pass custom SVG components via the icon prop. https://claude.ai/code/session_01Am2tu2GzwFut2SBD25he1E
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed563755d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * Writable store holding the active icon map for all Alert and Notice components. | ||
| * Consumers can override individual or all entries via setAlertIcons(). | ||
| */ | ||
| export const alertIconStore = writable<Record<NotificationType, IconDetail>>(defaultAlertIcons); |
There was a problem hiding this comment.
Avoid request-shared icon state in the module store
If a SvelteKit app follows the new docstring and calls setAlertIcons() from +layout.svelte, this writable(...) lives in module scope and is therefore shared by every SSR request handled by the same server process. Any request-specific branding or tenant override will leak into later responses until another request mutates the store again, so one user's alerts can render with another user's icons/colours. This configuration needs to be scoped per render tree (for example via props/context) rather than stored in a process-wide singleton.
Useful? React with 👍 / 👎.
Review summary
Clean, idiomatic Svelte implementation with good JSDoc coverage. The main concern is that a module-level singleton store in an SSR context is a footgun that the documentation actively points users towards — the rest are minor. Critical issues 🔴None Warnings 🟡1. SSR singleton risk
This is safe only when the icons are truly global constants (same for every user/request). As soon as someone uses it for per-tenant white-labelling or any request-scoped logic it becomes a data contamination bug. The documentation should at minimum carry a warning. 2. Missing
3. No tests for The new public API function has no test coverage. A minimal vitest test verifying that Suggestions 🟢1. Add an SSR caveat to the JSDoc Consider adding a 2. Confirm
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #441 +/- ##
==========================================
+ Coverage 64.59% 70.26% +5.67%
==========================================
Files 154 187 +33
Lines 6064 7439 +1375
==========================================
+ Hits 3917 5227 +1310
+ Misses 2064 2012 -52
- Partials 83 200 +117 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
This PR refactors the alert icon system to support global customization, allowing consumers to override default Lucide icons with their own SVG components.
Key Changes
alertIconsto a writable store (alertIconStore) to enable runtime customization of notification iconssetAlertIcons()function that allows consumers to globally override icon configurations for Alert and Notice componentsNotificationTypeandIconDetailpublicly available for type safetytypeof IconTypetoComponentfor better flexibility with custom SVG componentsalertIconStoreinstead of directly referencing the static objectImplementation Details
setAlertIcons()store.update()to merge overrides with existing configuration, allowing partial updateshttps://claude.ai/code/session_01Am2tu2GzwFut2SBD25he1E