From 13e449f4b04a1321950685a5c0966e8aca067531 Mon Sep 17 00:00:00 2001 From: Simeon Simeonoff Date: Tue, 23 Nov 2021 17:20:49 +0200 Subject: [PATCH 01/27] feat(themes): add dark theme presets --- .storybook/preview.js | 50 ++++- src/components/card/card.bootstrap.scss | 2 +- src/styles/themes/dark/bootstrap.scss | 200 +++++++++++++++++++ src/styles/themes/{ => dark}/fluent.scss | 20 +- src/styles/themes/{ => dark}/indigo.scss | 26 +-- src/styles/themes/{ => dark}/material.scss | 2 +- src/styles/themes/{ => light}/bootstrap.scss | 24 +-- src/styles/themes/light/fluent.scss | 166 +++++++++++++++ src/styles/themes/light/indigo.scss | 195 ++++++++++++++++++ src/styles/themes/light/material.scss | 29 +++ stories/story.ts | 3 +- 11 files changed, 669 insertions(+), 48 deletions(-) create mode 100644 src/styles/themes/dark/bootstrap.scss rename src/styles/themes/{ => dark}/fluent.scss (85%) rename src/styles/themes/{ => dark}/indigo.scss (83%) rename src/styles/themes/{ => dark}/material.scss (95%) rename src/styles/themes/{ => light}/bootstrap.scss (86%) create mode 100644 src/styles/themes/light/fluent.scss create mode 100644 src/styles/themes/light/indigo.scss create mode 100644 src/styles/themes/light/material.scss diff --git a/.storybook/preview.js b/.storybook/preview.js index c312f977c..aa8fd8b6c 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -1,11 +1,15 @@ import { html } from 'lit-html'; const Themes = { - material: await import('../src/styles/themes/material.scss'), - bootstrap: await import('../src/styles/themes/bootstrap.scss'), - fluent: await import('../src/styles/themes/fluent.scss'), - indigo: await import('../src/styles/themes/indigo.scss') -} + material_light: await import('../src/styles/themes/light/material.scss'), + bootstrap_light: await import('../src/styles/themes/light/bootstrap.scss'), + fluent_light: await import('../src/styles/themes/light/fluent.scss'), + indigo_light: await import('../src/styles/themes/light/indigo.scss'), + material_dark: await import('../src/styles/themes/dark/material.scss'), + bootstrap_dark: await import('../src/styles/themes/dark/bootstrap.scss'), + fluent_dark: await import('../src/styles/themes/dark/fluent.scss'), + indigo_dark: await import('../src/styles/themes/dark/indigo.scss'), +}; export const globalTypes = { theme: { @@ -18,6 +22,16 @@ export const globalTypes = { showName: 'True', }, }, + variant: { + name: 'Variant', + description: 'Theme variant', + defaultValue: 'light', + toolbar: { + icon: 'mirror', + items: ['light', 'dark'], + showName: 'True', + }, + }, direction: { name: 'Direction', description: 'Component direction', @@ -26,16 +40,32 @@ export const globalTypes = { icon: 'accessibility', items: ['ltr', 'rtl'], showName: 'True', - } - } + }, + }, +}; + +export const parameters = { + backgrounds: { + default: 'light', + values: [ + { + name: 'light', + value: '#fff', + }, + { + name: 'dark', + value: '#333', + }, + ], + }, }; -const getTheme = (themeName) => { - return Themes[themeName]; +const getTheme = (themeName, variant) => { + return Themes[`${themeName}_${variant}`]; }; const themeProvider = (Story, context) => { - const theme = getTheme(context.globals.theme); + const theme = getTheme(context.globals.theme, context.globals.variant); return html`