Skip to content
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

docs: update docs about gatsby-plugin-eufemia-theme-handler #2740

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dnb-design-system-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"gatsby-plugin-babel-react-live": "1.4.2",
"gatsby-plugin-catch-links": "5.12.0",
"gatsby-plugin-emotion": "8.12.0",
"gatsby-plugin-eufemia-theme-handler": "1.5.1",
"gatsby-plugin-eufemia-theme-handler": "1.6.4",
"gatsby-plugin-gatsby-cloud": "5.12.0",
"gatsby-plugin-manifest": "5.12.0",
"gatsby-plugin-mdx": "5.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ render(
</Theme>,
)
```

## Runtime theme swap

How ever, the above solution will not work for changing the theme in runtime.
tujoworker marked this conversation as resolved.
Show resolved Hide resolved

Changing a theme in runtime, without pre-loading all CSS styles and fonts together, requires a more sufisitcated solution.
tujoworker marked this conversation as resolved.
Show resolved Hide resolved

When using Gatsby, you can use this plugin [gatsby-plugin-eufemia-theme-handler](https://github.com/dnbexperience/gatsby-plugin-eufemia-theme-handler).
tujoworker marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ To include the packages `dnb-ui-core`, `ui-theme-basis` and `ui-theme-components
import '@dnb/eufemia/style'
```

## Gatsby Plugin

The [gatsby-plugin-eufemia-theme-handler](https://github.com/dnbexperience/gatsby-plugin-eufemia-theme-handler) plugin makes it easy to add the needed styles and provides also a runtime style switch mechanism.

## Importing styles from within CSS

```css
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Read more about [how to import styles](/uilib/usage/customisation/styling/consum

How ever, giving the user the ability to switch a theme during runtime, is a very much different challenge.

The Eufemia Portal (documentation) uses [gatsby-plugin-eufemia-theme-handler-2](https://github.com/dnbexperience/gatsby-plugin-eufemia-theme-handler) to handle it both in development and production mode.
The Eufemia Portal (documentation) uses [gatsby-plugin-eufemia-theme-handler](https://github.com/dnbexperience/gatsby-plugin-eufemia-theme-handler) to handle it both in development and production mode.

## WIP: Ready to use themes

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12606,7 +12606,7 @@ __metadata:
gatsby-plugin-babel-react-live: 1.4.2
gatsby-plugin-catch-links: 5.12.0
gatsby-plugin-emotion: 8.12.0
gatsby-plugin-eufemia-theme-handler: 1.5.1
gatsby-plugin-eufemia-theme-handler: 1.6.4
gatsby-plugin-gatsby-cloud: 5.12.0
gatsby-plugin-manifest: 5.12.0
gatsby-plugin-mdx: 5.12.0
Expand Down Expand Up @@ -15765,9 +15765,9 @@ __metadata:
languageName: node
linkType: hard

"gatsby-plugin-eufemia-theme-handler@npm:1.5.1":
version: 1.5.1
resolution: "gatsby-plugin-eufemia-theme-handler@npm:1.5.1"
"gatsby-plugin-eufemia-theme-handler@npm:1.6.4":
version: 1.6.4
resolution: "gatsby-plugin-eufemia-theme-handler@npm:1.6.4"
dependencies:
gatsby-core-utils: 4.12.0
globby: 11.0.4
Expand All @@ -15778,7 +15778,7 @@ __metadata:
"@dnb/eufemia": ">=10"
gatsby: ">=4"
react: ">=17"
checksum: 6b72b1ed191ef565cd0e100055445346225ff457f52fc5f60a409719ad311219cf5b27a3e105d09d06695a22841ca5af211583dec1c6b54b037d40d051ff7fb5
checksum: 2f5f9739e1456737a0c2ca2fff6527df233a1f39fa1ea70f3a288a70b0a9db81000d5b6e7b1e91fd38833a58f1b092de3746ea17859dc236fb04c1fa93daad95
languageName: node
linkType: hard

Expand Down
Loading