Skip to content

Commit

Permalink
feat: active state for button component
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Sep 19, 2021
1 parent 26c7061 commit 09283e0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/button/bem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import clsx from 'clsx';

export const defaultArgs = {
active: false,
busy: false,
disabled: false,
focus: false,
Expand All @@ -16,14 +17,16 @@ export const defaultArgs = {
};

export const Button = ({
textContent = '',
active = false,
busy = false,
disabled = false,
focus = false,
hover = false,
disabled = false,
textContent = '',
type = 'button',
}) =>
`<button class="${clsx('utrecht-button', {
'utrecht-button--active': active,
'utrecht-button--busy': busy,
'utrecht-button--hover': hover,
'utrecht-button--focus': focus,
Expand Down
6 changes: 6 additions & 0 deletions components/button/bem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
cursor: var(--utrecht-action-disabled-cursor);
}

.utrecht-button:active,
.utrecht-button--active {
background-color: var(--utrecht-button-active-background-color, var(--utrecht-button-background-color));
color: var(--utrecht-button-active-color, var(--utrecht-button-color));
}

.utrecht-button--focus,
.utrecht-button:not(.utrecht-button--disabled):focus {
@include utrecht-focus;
Expand Down
16 changes: 16 additions & 0 deletions components/button/bem.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ Styling via the `.utrecht-button` class name:

## States

### Active

Styling via the `.utrecht-button--active` class name:

<Canvas>
<Story
name="Button active"
args={{
active: true,
textContent: "Read more...",
}}
>
{Button.bind({})}
</Story>
</Canvas>

### Hover

Styling via the `.utrecht-button--hover` class name:
Expand Down
14 changes: 14 additions & 0 deletions components/button/modifier.tokens.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
{
"utrecht": {
"button": {
"active": {
"background-color": {
"css": {
"syntax": "<color>",
"inherits": true
}
},
"color": {
"css": {
"syntax": "<color>",
"inherits": true
}
}
},
"disabled": {
"color": {
"css": {
Expand Down

0 comments on commit 09283e0

Please sign in to comment.