mirror of https://github.com/grafana/grafana
Storybook: Add color theme and theme switcher (#22005)
* Add color theme and serve static files for storybook * Add color theme and serve static files for storybook * Export dark and light theme * Add storybook-dark-mode package * Add theme toggle functionality * Toggle story theme too * Remove unused import * webpack config changes not neededpull/21387/head
parent
d9414b4693
commit
029a6c64b4
@ -1,4 +1,9 @@ |
||||
module.exports = { |
||||
stories: ['../src/**/*.story.{js,jsx,ts,tsx,mdx}'], |
||||
addons: ['@storybook/addon-knobs', '@storybook/addon-actions', '@storybook/addon-docs'], |
||||
addons: [ |
||||
'@storybook/addon-knobs', |
||||
'@storybook/addon-actions', |
||||
'@storybook/addon-docs', |
||||
'storybook-dark-mode/register', |
||||
], |
||||
}; |
||||
|
@ -0,0 +1 @@ |
||||
<link rel="icon" href="/fav32.png" /> |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 5.6 KiB |
@ -0,0 +1,49 @@ |
||||
//@ts-ignore
|
||||
import { create } from '@storybook/theming/create'; |
||||
import lightTheme from '../src/themes/light'; |
||||
import darkTheme from '../src/themes/dark'; |
||||
import ThemeCommons from '../src/themes/default'; |
||||
import { GrafanaTheme } from '@grafana/data'; |
||||
|
||||
const createTheme = (theme: GrafanaTheme) => { |
||||
return create({ |
||||
base: theme.name.includes('Light') ? 'light' : 'dark', |
||||
|
||||
colorPrimary: theme.colors.brandPrimary, |
||||
colorSecondary: theme.colors.brandPrimary, |
||||
|
||||
// UI
|
||||
appBg: theme.colors.bodyBg, |
||||
appContentBg: theme.colors.bodyBg, |
||||
appBorderColor: theme.colors.pageHeaderBorder, |
||||
appBorderRadius: 4, |
||||
|
||||
// Typography
|
||||
fontBase: ThemeCommons.typography.fontFamily.sansSerif, |
||||
fontCode: ThemeCommons.typography.fontFamily.monospace, |
||||
|
||||
// Text colors
|
||||
textColor: theme.colors.text, |
||||
textInverseColor: 'rgba(255,255,255,0.9)', |
||||
|
||||
// Toolbar default and active colors
|
||||
barTextColor: theme.colors.formInputBorderActive, |
||||
barSelectedColor: theme.colors.brandPrimary, |
||||
barBg: theme.colors.bodyBg, |
||||
|
||||
// Form colors
|
||||
inputBg: theme.colors.formInputBg, |
||||
inputBorder: theme.colors.formInputBorder, |
||||
inputTextColor: theme.colors.formInputText, |
||||
inputBorderRadius: 4, |
||||
|
||||
brandTitle: 'Grafana UI', |
||||
brandUrl: '/', |
||||
brandImage: '/grafana_icon.svg', |
||||
}); |
||||
}; |
||||
|
||||
const GrafanaLight = createTheme(lightTheme); |
||||
const GrafanaDark = createTheme(darkTheme); |
||||
|
||||
export { GrafanaLight, GrafanaDark }; |
Loading…
Reference in new issue