Skip to content

Commit

Permalink
feat(Button)!: add selected state for all views (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
amje committed Jul 14, 2023
1 parent 49418ab commit 8658b39
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
43 changes: 36 additions & 7 deletions src/components/Button/Button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ $iconWidth: 16px;
--yc-button-background-color-hover: var(--yc-color-base-generic-hover);

@include button-text-color(var(--yc-color-text-primary));

&#{$block}_selected {
--yc-button-background-color: var(--yc-color-base-selection);
--yc-button-background-color-hover: var(--yc-color-base-selection-hover);

@include button-text-color(var(--yc-color-text-special));
}
}

&_action {
Expand Down Expand Up @@ -307,6 +300,42 @@ $iconWidth: 16px;
}
}

&_view {
&_normal,
&_action,
&_outlined,
&_outlined-info,
&_raised,
&_flat,
&_flat-secondary,
&_flat-info {
&#{$block}_selected {
--yc-button-background-color: var(--yc-color-base-selection);
--yc-button-background-color-hover: var(--yc-color-base-selection-hover);

@include button-text-color(var(--yc-my-color-brand-text));

&::before {
border: none;
}
}
}

&_outlined-danger,
&_flat-danger {
&#{$block}_selected {
--yc-button-background-color: var(--yc-color-base-danger);
--yc-button-background-color-hover: var(--yc-color-base-danger-hover);

@include button-text-color(var(--yc-color-text-danger));

&::before {
border: none;
}
}
}
}

@include mixins.pin($block, ('::before', '::after'), var(--yc-button-border-radius));

&__text {
Expand Down
11 changes: 2 additions & 9 deletions src/components/Button/__stories__/ButtonShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,15 @@ function renderViewGrid() {
props.children = 'Button';
}

let content: React.ReactElement | null = <Button {...props} />;

if (props.selected && props.view !== 'normal') {
content = null;
}

items.push(
<div
key={key}
style={{
backgroundColor:
view.endsWith('contrast') && content ? contrastColor : '',
backgroundColor: view.endsWith('contrast') ? contrastColor : '',
}}
className={b('grid-cell')}
>
{content}
<Button {...props} />
</div>,
);
}
Expand Down

0 comments on commit 8658b39

Please sign in to comment.