From c27f6af09088d2b7118f388b089ef8179c737ccb Mon Sep 17 00:00:00 2001 From: Angelina Gadzhieva Date: Tue, 21 Nov 2023 19:23:53 +0300 Subject: [PATCH] feat(Progress)!: add customization, remove default theme value --- src/components/Progress/Progress.scss | 47 +++++++++++-------- src/components/Progress/Progress.tsx | 4 +- .../Progress/__stories__/Progress.stories.tsx | 16 +++++++ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/components/Progress/Progress.scss b/src/components/Progress/Progress.scss index 639a940013..4f5908515e 100644 --- a/src/components/Progress/Progress.scss +++ b/src/components/Progress/Progress.scss @@ -11,19 +11,22 @@ $progress-xs-height: 4px; font-size: var(--g-text-body-short-font-size); font-weight: var(--g-text-body-font-weight); font-family: var(--g-text-body-font-family); - color: var(--g-color-text-primary); padding: 0 10px; box-sizing: border-box; } #{$block} { + --g-progress-empty-background-color: var(--g-color-base-generic); + --g-progress-empty-text-color: var(--g-color-text-primary); + --g-progress-filled-text-color: var(--g-color-text-primary); + position: relative; margin: 0 auto; overflow: hidden; border-radius: 3px; - background-color: var(--g-color-base-generic); + background-color: var(--g-progress-empty-background-color); text-align: center; @@ -31,6 +34,7 @@ $progress-xs-height: 4px; @include progress-text; position: relative; + color: var(--g-progress-empty-text-color); } &__text-inner { @@ -40,6 +44,7 @@ $progress-xs-height: 4px; width: 100%; height: 100%; + color: var(--g-progress-filled-text-color); transition: transform 0.6s ease; } @@ -55,28 +60,32 @@ $progress-xs-height: 4px; transition: transform 0.6s ease, width 0.6s ease, background-color 0.6s ease; - &_theme_default { - background-color: var(--g-color-base-neutral-medium); - } + background-color: var(--g-progress-filled-background-color); - &_theme_success { - background-color: var(--g-color-base-positive-medium); - } + &_theme { + &_default { + --g-progress-filled-background-color: var(--g-color-base-neutral-medium); + } - &_theme_warning { - background-color: var(--g-color-base-warning-medium); - } + &_success { + --g-progress-filled-background-color: var(--g-color-base-positive-medium); + } - &_theme_danger { - background-color: var(--g-color-base-danger-medium); - } + &_warning { + --g-progress-filled-background-color: var(--g-color-base-warning-medium); + } - &_theme_info { - background-color: var(--g-color-base-info-medium); - } + &_danger { + --g-progress-filled-background-color: var(--g-color-base-danger-medium); + } + + &_info { + --g-progress-filled-background-color: var(--g-color-base-info-medium); + } - &_theme_misc { - background-color: var(--g-color-base-misc-medium); + &_misc { + --g-progress-filled-background-color: var(--g-color-base-misc-medium); + } } &_loading { diff --git a/src/components/Progress/Progress.tsx b/src/components/Progress/Progress.tsx index dab93b8543..784ba3d49a 100644 --- a/src/components/Progress/Progress.tsx +++ b/src/components/Progress/Progress.tsx @@ -30,13 +30,14 @@ export interface ProgressColorStops { interface ProgressGeneralProps { /** ClassName of element */ className?: string; + theme: ProgressTheme; } interface ProgressDefaultProps { /** Text inside progress bar */ text: string; /** Theme */ - theme: ProgressTheme; + // theme: ProgressTheme; /** Size. Text of progress bar is displayed in `m` size only. */ size: ProgressSize; /** Loading. Аdds loading animation */ @@ -65,7 +66,6 @@ export type ProgressProps = ProgressWithStack | ProgressWithValue; export class Progress extends React.Component { static defaultProps: ProgressDefaultProps = { text: '', - theme: 'default', size: 'm', loading: false, }; diff --git a/src/components/Progress/__stories__/Progress.stories.tsx b/src/components/Progress/__stories__/Progress.stories.tsx index f0fbea88e5..f681419343 100644 --- a/src/components/Progress/__stories__/Progress.stories.tsx +++ b/src/components/Progress/__stories__/Progress.stories.tsx @@ -34,6 +34,22 @@ const ThemeTemplate: StoryFn = (args) => { export const Theme = ThemeTemplate.bind({}); +export const Custom: StoryFn = (args) => { + return ( + + + + + ); +}; + const StackTemplate: StoryFn = (args) => { return (