feat(icon): make the chrome icon library configurable via DocsKit.configuration.icon_library - #6
Merged
Merged
Conversation
…figuration.icon_library
Summary
-------
DocsUI::Icon rendered the docs chrome's lucide icons (menu, search, file-code,
...) against RailsIcons.configuration.default_library. On a host app whose
default_library is non-lucide (phosphor, heroicons), those lucide names don't
exist, raising Icons::IconNotFound in development — and an app couldn't flip its
global default just for the docs chrome.
This adds a DocsKit.configuration.icon_library knob (default "lucide", matching
the icon names docs-kit ships). DocsUI::Icon#rails_icons_library now reads it and
falls back to the host's RailsIcons default_library:
DocsKit.configuration.icon_library || ::RailsIcons.configuration.default_library
Zero-config behavior is unchanged for lucide-default apps; any app can now pin
the chrome to lucide without touching its global default. Setting icon_library
to nil restores the old defer-to-host behavior.
Test Coverage
-------------
- spec/docs_kit/configuration_spec.rb — #icon_library defaults to "lucide" and
is overridable via DocsKit.configure.
- spec/docs_ui/icon_spec.rb — #rails_icons_library returns the configured
icon_library (the `||` short-circuits, so it never touches RailsIcons), falls
back to RailsIcons.configuration.default_library when icon_library is nil (with
RailsIcons stubbed in), and degrades to nil when RailsIcons is absent.
Verification
------------
- [x] bundle exec rspec — 55 examples, 0 failures
- [x] bundle exec rubocop (lib app spec) — 32 files, no offenses
- [x] Backwards compatible: default "lucide" keeps existing lucide apps working
16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DocsUI::Iconrenders the docs chrome's lucide icon names (menu,search,file-code,list,info,palette,lightbulb,triangle-alert,file-text, ...) but resolved them againstRailsIcons.configuration.default_library.On a host app whose
default_libraryis not lucide (e.g. phosphor or heroicons), those lucide names don't exist in the configured library, so every chrome icon raisesIcons::IconNotFoundin development. The host app couldn't fix this without flipping its global RailsIcons default — which it shouldn't have to do just to render docs-kit's chrome.Fix
Add a
DocsKit.configuration.icon_libraryconfig option (default"lucide", matching the lucide icon names docs-kit ships).DocsUI::Icon#rails_icons_librarynow reads it, falling back to the host app'sRailsIcons.configuration.default_library:"lucide", and the icon names docs-kit ships are lucide names, so existing lucide-default apps are unaffected.icon_libraryat"lucide"and the chrome keeps rendering, without changing its owndefault_library.icon_librarytonilto restore the old defer-to-host behavior.This follows the project invariant that site-specific values live on
DocsKit.configurationwith a sensible default.Test plan
New specs (written first, RED → GREEN):
spec/docs_kit/configuration_spec.rb—#icon_librarydefaults to"lucide"; overridable viaDocsKit.configure { |c| c.icon_library = "phosphor" }.spec/docs_ui/icon_spec.rb—#rails_icons_library:icon_librarywhen set (the||short-circuits, so it never touches RailsIcons — the representative path for a non-lucide host);RailsIcons.configuration.default_librarywhenicon_libraryisnil(RailsIcons stubbed in — it's a Railtie gem, absent from the isolated suite);nilwhen RailsIcons isn't loaded.Verification (local — this repo has no PR CI, only a release-triggered deploy workflow):
bundle exec rspec→ 55 examples, 0 failuresbundle exec rubocop lib app spec→ 32 files, no offensesCloses #3