dotkom / design-system

Component library, maybe
https://design.online.ntnu.no
MIT License
4 stars 4 forks source link

Add support for theming #153

Open oleast opened 4 years ago

oleast commented 4 years ago

Is your feature request related to a problem? Please describe. Some apps may use their own theme or use specific colors for things or sections of a page. Examples of this would be:

Describe the solution you'd like There are two good solutions to this problem that both have their drawbacks. But there may be a way to do them both at the same time?

1. --cssVariables: We could define all our colors as CSS variables in a root element. This solution works really well with how browsers work and will let us handle styling from back-ends and server-side rendering seamlessly. It also has the benefit of working with media queries, like prefers-color-scheme to set colors.

Selecting a theme is done by selecting a specific global style-sheet. When changing something in the middle of a page you add an override to an element that will cascade to all children.

2. Styled Component Theme: Styled components has a built-in theming system, where a theme is accessible as a prop in all styled components.

Selecting a theme is done by adding a by giving a different theme object to the top-level theme provider for the app. Changing the theme in the middle of a page will require a new ThemeProvider with a config to override the top-level one.