Skip to content
Snippets Groups Projects
Commit fe811c23 authored by Alf Eaton's avatar Alf Eaton
Browse files

Use global CSS variables for the primary colour

parent eb4e88fb
No related branches found
No related tags found
No related merge requests found
import React from 'react' import React from 'react'
import classnames from 'classnames'
import classes from './Button.local.scss' import classes from './Button.local.scss'
const Button = ({ children, type = 'button', disabled, onClick}) => ( const Button = ({ children, type = 'button', disabled, primary, onClick}) => (
<button <button
className={classes.root} className={classnames(classes.root, {
[classes.disabled]: disabled,
[classes.primary]: primary
})}
type={type} type={type}
disabled={disabled} disabled={disabled}
onClick={onClick}>{children}</button> onClick={onClick}>{children}</button>
......
.root { .root {
composes: primary from '../lib/colors.local.scss';
text-transform: uppercase; text-transform: uppercase;
border: none; border: none;
font-size: inherit; font-size: inherit;
padding: 10px 20px; padding: 10px 20px;
cursor: pointer;
}
.primary {
background-color: var(--primary-color);
color: white;
}
.disabled {
background-color: gray;
color: white;
} }
A button. A button.
```js ```js
<Button>Save</Button> <Button>Save</Button>
``` ```
...@@ -9,3 +10,9 @@ A button can be disabled. ...@@ -9,3 +10,9 @@ A button can be disabled.
```js ```js
<Button disabled>Save</Button> <Button disabled>Save</Button>
``` ```
A button can be marked as the "primary" action.
```js
<Button primary>Save</Button>
```
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment