feat(docs): add dark/light mode icon support for variants #4671
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.
Add dark/light mode icon support for variants
This PR implements runtime support for dark/light mode icons in the documentation platform, enabling icons to automatically adapt to the user's theme preference.
What was the motivation & context behind this PR?
User requested the ability to specify different icons for dark and light modes in docs.yml. Previously, the
iconfield only supported a single string value that would display the same in both themes. Now it supports both:icon: "icon-name"(uses same icon for both themes)icon: { dark: "icon-dark", light: "icon-light" }(different icons per theme)This is a runtime-only implementation without schema changes. The FDR API schema still defines
iconasoptional<string>, but the frontend now accepts objects at runtime.Changes Made
Updated both
processIconimplementations (inpackages/fern-docs/bundle/andpackages/fern-docs/components/):ThemedIconinterface andisThemedIcon()type guardprocessIconString()helper functiondark:hidden/hidden dark:inline-blockclassesHow has this PR been tested?
Local verification completed:
pnpm formatandpnpm checkImportant Review Items
High Priority:
stringin FDR SDK but now accepts objects at runtime. Should we update the schema or document this as unsupported/experimental?dark:hiddenandhidden dark:inline-blockwork correctly in all contexts where icons are rendered?isThemedIcon()type guard comprehensive enough to prevent invalid inputs?Medium Priority:
4. Edge cases: What should happen when both dark/light are empty strings or both undefined?
5. Testing strategy: How should we test this before merging? Local docs.yml? E2E tests?
6. Documentation: Should we document this feature for users, or keep it undocumented until schema is updated?
Devin Session: https://app.devin.ai/sessions/cf2b0ed912fe454cbdc13b764952c786
Requested by: Kapil Gowru (@kgowru)