-
Notifications
You must be signed in to change notification settings - Fork 42
[Appdir] Adds theme-switcher with Select
in code-examples
#3787
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
|
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.
Pull Request Overview
This PR introduces a theme-switcher feature for code examples, enabling users to toggle between legacy and darkside light/dark themes by dynamically loading the corresponding CSS. Key changes include the addition of a theme provider component, updates to configuration to expose the design system version, and a query parameter update to ensure the darkside theme is applied in iframes.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
aksel.nav.no/website/pages/_app.tsx | Wraps app content in the new ExampleTheming provider |
aksel.nav.no/website/package.json | Adds the "semver" dependency |
aksel.nav.no/website/next.config.ts | Imports package.json to expose ds-react version and updates CSP |
aksel.nav.no/website/components/website-modules/examples/withDsExample.tsx | Updates example theming and breakpoint display with theme support |
aksel.nav.no/website/components/website-modules/examples/withDsExample.theme.tsx | Implements the theme provider and switcher components |
aksel.nav.no/website/components/styles/index.css | Adopts new CSS layer syntax for style separation |
aksel.nav.no/website/app/_ui/kode-eksempler/KodeEksempler.iframe.tsx | Appends a darkside query parameter to the iframe URL |
Comments suppressed due to low confidence (2)
aksel.nav.no/website/next.config.ts:60
- There is a possible error if '@navikt/ds-react' is not defined in package.json; consider checking for its existence before calling .replace to prevent runtime failures.
const akselVersion = packageJson.dependencies["@navikt/ds-react"].replace("^","");
aksel.nav.no/website/components/website-modules/examples/withDsExample.tsx:92
- [nitpick] Consider using React.ElementType for Wrapper's type to improve type safety and clarity of the intended component behavior.
let Wrapper: string | ((props: any) => JSX.Element) = "div";
aksel.nav.no/website/components/website-modules/examples/withDsExample.theme.tsx
Outdated
Show resolved
Hide resolved
…sExample.theme.tsx
aksel.nav.no/website/components/website-modules/examples/withDsExample.theme.tsx
Outdated
Show resolved
Hide resolved
…sExample.theme.tsx
Description
Adds theme-switcher to change between legacy and darkside light/dark. The CSS is loaded dynamically, so legacy/darkside wont overlap. As of now the "default" legacy-css is loaded by in _app by default, so there might be some broken CSS until we remove if from loading by default when we launch the new sites. Note that this can only happen /dev since the switcher is hidden in prod.
Screen.Recording.2025-05-13.at.19.08.52.mov
Component Checklist 📝
@navikt/core/css/config/_mappings.js
)@navikt/core/css/tokens.json
)@navikt/aksel-stylelint/src/deprecations.ts
)@navikt/core/react/src/index.ts
and@navikt/core/react/package.json
)@navikt/core/css/index.css
)<Component>: <gitmoji?> <Text>.
E.g. "Button: ✨ Add feature xyz.")