diff --git a/.storybook/main.js b/.storybook/main.js index e9e799c8..a6c1ec40 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -7,7 +7,7 @@ module.exports = { '../src/components/*.stories.mdx', '../src/components/**/**/*.stories.@(tsx|mdx)', ], - addons: ['@storybook/addon-docs', '@storybook/addon-links', '@storybook/addon-controls'], + addons: ['@storybook/addon-docs', '@storybook/addon-links', '@storybook/addon-controls', 'storybook-addon-themes'], presets: [ '@storybook/preset-create-react-app', { diff --git a/.storybook/preview.js b/.storybook/preview.js index e5034a5c..424e3652 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -20,4 +20,16 @@ export const parameters = { actions: { argTypesRegex: '^on[A-Z].*' }, layout: 'centered', controls: { expanded: true }, + themes: { + default: 'Blue', + list: [ + { name: 'Blue', class: '', color: '#3bc0f9' }, + { name: 'Dark', class: 'theme--dark', color: '#222222' }, + { name: 'Grey', class: 'theme--grey', color: '#888888' }, + { name: 'Green', class: 'theme--green', color: '#2ac952' }, + { name: 'Yellow', class: 'theme--yellow', color: '#ffd83d' }, + { name: 'Red', class: 'theme--red', color: '#ff3a30' }, + { name: 'Violet', class: 'theme--violet', color: '#9b1dd9' }, + ], + }, }; diff --git a/package.json b/package.json index ed90bf12..0238ca29 100644 --- a/package.json +++ b/package.json @@ -113,6 +113,7 @@ "rollup-plugin-scss": "^2.6.1", "rollup-plugin-typescript2": "^0.17.0", "rollup-plugin-url": "^1.4.0", + "storybook-addon-themes": "^6.1.0", "typescript": "^3.9.7" }, "files": [ diff --git a/src/components/atoms/Avatar/Avatar.scss b/src/components/atoms/Avatar/Avatar.scss index fdeb3bf8..73a78a9f 100644 --- a/src/components/atoms/Avatar/Avatar.scss +++ b/src/components/atoms/Avatar/Avatar.scss @@ -10,17 +10,17 @@ } &--regular { - color: $primary-color; + color: var(--primary-color); background-color: $grey-100; .ebs-icon { - color: $primary-color; + color: var(--primary-color); } } &--primary { color: $white; - background-color: $primary-color; + background-color: var(--primary-color); .ebs-icon { color: $white; @@ -100,7 +100,7 @@ } &--regular { - background-color: $primary-color; + background-color: var(--primary-color); } &--inactive { diff --git a/src/components/atoms/Button/Button.scss b/src/components/atoms/Button/Button.scss index e26a57ff..3b313e8d 100644 --- a/src/components/atoms/Button/Button.scss +++ b/src/components/atoms/Button/Button.scss @@ -34,19 +34,19 @@ // button type (Color) &--primary { - border-color: $primary-color; - background-color: $primary-color; + border-color: var(--primary-color); + background-color: var(--primary-color); color: $white; &:hover { - border-color: $primary-600; - background-color: $primary-600; + border-color: var(--primary-600); + background-color: var(--primary-600); } &:active, &.active { - border-color: $primary-700; - background-color: $primary-700; + border-color: var(--primary-700); + background-color: var(--primary-700); } .ebs-icon { @@ -68,8 +68,8 @@ color: $white; @include hover-state { - border-color: $primary-600; - background-color: $primary-600; + border-color: var(--primary-600); + background-color: var(--primary-600); } .ebs-button, @@ -92,13 +92,13 @@ } &--fill { - border-color: $primary-100; - background-color: $primary-100; - color: $primary-color; + border-color: var(--primary-100); + background-color: var(--primary-100); + color: var(--primary-color); &:hover { - border-color: $primary-color; - background-color: $primary-color; + border-color: var(--primary-color); + background-color: var(--primary-color); color: $white; .ebs-button, @@ -109,8 +109,8 @@ &:active, &.active { - border-color: $primary-600; - background-color: $primary-600; + border-color: var(--primary-600); + background-color: var(--primary-600); color: $white; .ebs-button, @@ -120,12 +120,12 @@ } .ebs-icon { - color: $primary-color; + color: var(--primary-color); } } &--fill & { - color: $primary-color; + color: var(--primary-color); } &--ghost.ebs-button__wrapper { @@ -167,14 +167,14 @@ &--text { background-color: transparent; - color: $primary-color; + color: var(--primary-color); &:hover { background-color: transparent; .ebs-button, .ebs-icon { - color: $primary-600; + color: var(--primary-600); } } @@ -184,17 +184,17 @@ .ebs-button, .ebs-icon { - color: $primary-700; + color: var(--primary-700); } } .ebs-icon { - color: $primary-color; + color: var(--primary-color); } } &--text & { - color: $primary-color; + color: var(--primary-color); } &--disabled { diff --git a/src/components/atoms/Chips/Chips.scss b/src/components/atoms/Chips/Chips.scss index f21b11c6..ba337e17 100644 --- a/src/components/atoms/Chips/Chips.scss +++ b/src/components/atoms/Chips/Chips.scss @@ -9,13 +9,13 @@ transition: all $transition-time; &--checked { - background-color: $primary-000; - border-color: $primary-color; - color: $primary-color; + background-color: var(--primary-000); + border-color: var(--primary-color); + color: var(--primary-color); &:hover { - background-color: $primary-color; - border-color: $primary-color; + background-color: var(--primary-color); + border-color: var(--primary-color); color: $white; .ebs-icon { @@ -31,8 +31,8 @@ &:hover { background-color: transparent; - border-color: $primary-400; - color: $primary-400; + border-color: var(--primary-400); + color: var(--primary-400); } } diff --git a/src/components/atoms/Input/Input.scss b/src/components/atoms/Input/Input.scss index 538f74ab..ca628fca 100644 --- a/src/components/atoms/Input/Input.scss +++ b/src/components/atoms/Input/Input.scss @@ -15,7 +15,7 @@ &--active, &.focus { - border-color: $primary-color; + border-color: var(--primary-color); background-color: $white; .ebs-input { diff --git a/src/components/atoms/Label/Label.scss b/src/components/atoms/Label/Label.scss index cdfc0947..ed9da39c 100644 --- a/src/components/atoms/Label/Label.scss +++ b/src/components/atoms/Label/Label.scss @@ -84,9 +84,9 @@ } &--primary { - background-color: $primary-000; - color: $primary-color; - border-color: $primary-color; + background-color: var(--primary-000); + color: var(--primary-color); + border-color: var(--primary-color); } &--fill { diff --git a/src/components/atoms/Radio/Radio.scss b/src/components/atoms/Radio/Radio.scss index 8b6fedfb..a7e8417d 100644 --- a/src/components/atoms/Radio/Radio.scss +++ b/src/components/atoms/Radio/Radio.scss @@ -82,27 +82,27 @@ cursor: pointer; &:hover ~ .ebs-radio { - background-color: $primary-100; + background-color: var(--primary-100); &__dot { - border-color: $primary-color; - background-color: $primary-100; + border-color: var(--primary-color); + background-color: var(--primary-100); } } &:checked:hover ~ .ebs-radio { - background-color: $primary-100; + background-color: var(--primary-100); &__dot { - border-color: $primary-color; - background-color: $primary-color; - box-shadow: 0px 0px 0px 3px $primary-100 inset; + border-color: var(--primary-color); + background-color: var(--primary-color); + box-shadow: 0px 0px 0px 3px var(--primary-100 inset); } } &:checked ~ .ebs-radio .ebs-radio__dot { - border-color: $primary-color; - background-color: $primary-color; + border-color: var(--primary-color); + background-color: var(--primary-color); box-shadow: 0px 0px 0px 3px $white inset; } } diff --git a/src/components/atoms/Switch/Switch.scss b/src/components/atoms/Switch/Switch.scss index 551db4c7..ca1f7098 100644 --- a/src/components/atoms/Switch/Switch.scss +++ b/src/components/atoms/Switch/Switch.scss @@ -15,8 +15,8 @@ } &:hover .ebs-switch__dot { - border-color: $primary-200; - box-shadow: 0px 0px 0px 2px $primary-color inset; + border-color: var(--primary-200); + box-shadow: 0px 0px 0px 2px var(--primary-color inset); } } @@ -32,29 +32,29 @@ } &--checked { - background-color: $primary-200; + background-color: var(--primary-200); .ebs-switch__dot { transform: translate(16px, -50%); - background-color: $primary-400; - border-color: $primary-200; + background-color: var(--primary-400); + border-color: var(--primary-200); } &:hover .ebs-switch__dot { - border-color: $primary-300; - box-shadow: 0px 0px 0px 2px $primary-color inset; + border-color: var(--primary-300); + box-shadow: 0px 0px 0px 2px var(--primary-color inset); } } &--checked.disabled { cursor: not-allowed; - background-color: $primary-100; + background-color: var(--primary-100); .ebs-switch__dot, .ebs-switch__dot:hover { - box-shadow: 0px 0px 0px 2px $primary-400 inset; - background-color: $primary-300; - border-color: $primary-100; + box-shadow: 0px 0px 0px 2px var(--primary-400 inset); + background-color: var(--primary-300); + border-color: var(--primary-100); } } @@ -66,7 +66,7 @@ width: rem(16px); height: rem(16px); border: 2px solid transparent; - box-shadow: 0px 0px 0px 2px $primary-color inset; + box-shadow: 0px 0px 0px 2px var(--primary-color inset); border-radius: 50%; overflow: hidden; transition: all $transition-time; diff --git a/src/components/molecules/Checkbox/Checkbox.scss b/src/components/molecules/Checkbox/Checkbox.scss index 19e57b10..16df2fdc 100644 --- a/src/components/molecules/Checkbox/Checkbox.scss +++ b/src/components/molecules/Checkbox/Checkbox.scss @@ -14,8 +14,8 @@ } .ebs-checkbox { - border-color: $primary-color; - background-color: $primary-color; + border-color: var(--primary-color); + background-color: var(--primary-color); .ebs-checkbox__check { font-size: 0; @@ -91,8 +91,8 @@ &:checked { ~ .ebs-checkbox { - border-color: $primary-color; - background-color: $primary-color; + border-color: var(--primary-color); + background-color: var(--primary-color); } ~ .ebs-checkbox .ebs-checkbox__check { @@ -101,20 +101,20 @@ } &:hover ~ .ebs-checkbox { - border-color: $primary-color; - background-color: $primary-color; + border-color: var(--primary-color); + background-color: var(--primary-color); &:before { - background-color: $primary-100; + background-color: var(--primary-100); } } } &:hover ~ .ebs-checkbox { - border-color: $primary-color; + border-color: var(--primary-color); &:before { - background-color: $primary-100; + background-color: var(--primary-100); } } } diff --git a/src/components/molecules/Checkbox/CheckboxMixins.scss b/src/components/molecules/Checkbox/CheckboxMixins.scss index 493a6d2c..9c380d82 100644 --- a/src/components/molecules/Checkbox/CheckboxMixins.scss +++ b/src/components/molecules/Checkbox/CheckboxMixins.scss @@ -1,18 +1,18 @@ // TODO use these in Checkbox.scss @mixin checkbox-hover() { - border-color: $primary-color; + border-color: var(--primary-color); &:before { - background-color: $primary-100; + background-color: var(--primary-100); } } @mixin checkbox-checked-hover() { - border-color: $primary-color; - background-color: $primary-color; + border-color: var(--primary-color); + background-color: var(--primary-color); &:before { - background-color: $primary-100; + background-color: var(--primary-100); } } diff --git a/src/components/molecules/DatePicker/DatePicker.scss b/src/components/molecules/DatePicker/DatePicker.scss index 4d50456d..7dfa0b92 100644 --- a/src/components/molecules/DatePicker/DatePicker.scss +++ b/src/components/molecules/DatePicker/DatePicker.scss @@ -76,7 +76,7 @@ } @include hover-state { - border-color: $primary-color; + border-color: var(--primary-color); background-color: $white; } @@ -117,11 +117,11 @@ &.is-opened { .ebs-datepicker { - border-color: $primary-color; + border-color: var(--primary-color); } .react-datepicker-wrapper:first-child { .ebs-datepicker { - border-right-color: $primary-color; + border-right-color: var(--primary-color); } } } @@ -129,11 +129,11 @@ &:not(.disabled) { @include hover-state { .ebs-datepicker { - border-color: $primary-color; + border-color: var(--primary-color); } .react-datepicker-wrapper:first-child { .ebs-datepicker { - border-right-color: $primary-color; + border-right-color: var(--primary-color); } } } @@ -184,7 +184,7 @@ } &__time-list-item:hover { - background-color: $primary-100; + background-color: var(--primary-100); color: $text-color; } @@ -194,7 +194,7 @@ &__time-list-item--selected, &__time-list-item--selected:hover { - background-color: $primary-color; + background-color: var(--primary-color); color: $white; } @@ -318,15 +318,15 @@ } &__day:hover { - background-color: $primary-100; + background-color: var(--primary-100); } &__day--in-range { - background-color: $primary-100; + background-color: var(--primary-100); } &__day--in-selecting-range { - background-color: $primary-000; + background-color: var(--primary-000); } &__day--selected, @@ -336,7 +336,7 @@ &__day--range-start, &__day--range-end { border-radius: rem($border-radius); - background-color: $primary-color; + background-color: var(--primary-color); color: $white; } } @@ -357,7 +357,7 @@ color: $text-color; @include hover-state { - background-color: $primary-100; + background-color: var(--primary-100); } } @@ -367,7 +367,7 @@ ul.react-datepicker__time-list li.react-datepicker__time-list-item { @include hover-state { - background-color: $primary-100; + background-color: var(--primary-100); } } @@ -376,7 +376,7 @@ .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item--selected { - background-color: $primary-color; + background-color: var(--primary-color); } } diff --git a/src/components/molecules/InputPhone/InputPhone.scss b/src/components/molecules/InputPhone/InputPhone.scss index e1d28b44..1138d607 100644 --- a/src/components/molecules/InputPhone/InputPhone.scss +++ b/src/components/molecules/InputPhone/InputPhone.scss @@ -5,7 +5,7 @@ &.active .form-control, &.active .flag-dropdown { - border-color: $primary-color; + border-color: var(--primary-color); background-color: $white; color: $heading-color; } @@ -44,15 +44,15 @@ .country.highlight, .country:hover, .country[aria-selected='true'] { - background-color: $primary-000; + background-color: var(--primary-000); border-radius: rem($border-radius); } .country[aria-selected='true'] { - color: $primary-color; + color: var(--primary-color); .dial-code { - color: $primary-400; + color: var(--primary-400); } } diff --git a/src/components/molecules/Loader/Loader.scss b/src/components/molecules/Loader/Loader.scss index 43e9082d..919d0597 100644 --- a/src/components/molecules/Loader/Loader.scss +++ b/src/components/molecules/Loader/Loader.scss @@ -56,7 +56,7 @@ &--small { border: 2px solid $grey-500; - border-top: 2px solid $primary-color; + border-top: 2px solid var(--primary-color); width: rem(#{$base-size / 2}); height: rem(#{$base-size / 2}); top: calc(50% - #{$base-size / 4}); @@ -64,7 +64,7 @@ &--middle { border: 2px solid $grey-500; - border-top: 2px solid $primary-color; + border-top: 2px solid var(--primary-color); width: rem(#{$base-size - $gutter-size}); height: rem(#{$base-size - $gutter-size}); top: calc(50% - #{($base-size - $gutter-size) / 2}); @@ -73,7 +73,7 @@ &--regular { border: 6px solid $grey-500; - border-top: 6px solid $primary-color; + border-top: 6px solid var(--primary-color); width: rem(#{$base-size * 2}); height: rem(#{$base-size * 2}); top: calc(50% - #{$base-size}); diff --git a/src/components/molecules/Notify/Notify.scss b/src/components/molecules/Notify/Notify.scss index ec177d31..8755c436 100644 --- a/src/components/molecules/Notify/Notify.scss +++ b/src/components/molecules/Notify/Notify.scss @@ -92,12 +92,12 @@ color: $text-color; .ebs-icon { - color: $primary-color; + color: var(--primary-color); } } &--primary { - background-color: $primary-color; + background-color: var(--primary-color); } &--success { diff --git a/src/components/molecules/Select/Select.scss b/src/components/molecules/Select/Select.scss index 76207411..77fcd69a 100644 --- a/src/components/molecules/Select/Select.scss +++ b/src/components/molecules/Select/Select.scss @@ -145,7 +145,7 @@ .ebs-select__clear { font-weight: 100; - color: $primary-color; + color: var(--primary-color); } } @@ -178,11 +178,11 @@ &.active { .ebs-select__prefix { - border-color: $primary-color; + border-color: var(--primary-color); } .ebs-select-dropdown__wrapper .ebs-select { - border-color: $primary-color; + border-color: var(--primary-color); background-color: $white; .ebs-select-value { @@ -192,7 +192,7 @@ .ebs-select__suffix { .ebs-button__wrapper { - border-color: $primary-color; + border-color: var(--primary-color); } } } diff --git a/src/components/molecules/Select/Select.stories.tsx b/src/components/molecules/Select/Select.stories.tsx index 0eb44096..5f8f884b 100644 --- a/src/components/molecules/Select/Select.stories.tsx +++ b/src/components/molecules/Select/Select.stories.tsx @@ -24,6 +24,7 @@ const limit = 20; export const Regular: React.FC & { args: SelectProps } = ({ children, ...props }) => { const [search, setSearch] = React.useState(''); const [list, setList] = React.useState([]); + const [value, setValue] = React.useState(); const [page, setPage] = React.useState(1); const [total, setTotal] = React.useState(0); const [loading, setLoaded] = React.useState(true); @@ -56,7 +57,7 @@ export const Regular: React.FC & { args: SelectProps } = ({ childre return (