Skip to content
This repository was archived by the owner on Jan 4, 2024. It is now read-only.

Commit ecff369

Browse files
Disabled button styles (#121)
* Update Button component * Update README.md * Update CHANGELOG.md * Bump to v1.2.2 Co-Authored-By: Daniel Brierton <[email protected]>
1 parent 22538c9 commit ecff369

File tree

9 files changed

+63
-27
lines changed

9 files changed

+63
-27
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
_The format of this document is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)._
22

3+
## [v1.2.2](https://github.com/RaspberryPiFoundation/Bits/compare/v1.2.1...v1.2.2) - 2019-10-14
4+
5+
### Changed
6+
7+
- Added `disabled` styles for buttons as per Sketch doc
8+
39
## [v1.2.1](https://github.com/RaspberryPiFoundation/Bits/compare/v1.2.0...v1.2.1) - 2019-10-09
410

511
### Changed

README.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,17 @@ Deploys to: https://static.raspberrypi.org/styles/Bits/<version> via:
2020

2121
(where <version> is taken from package.json & ENV vars are in .env which needs to be created from .env.example)
2222

23-
eg: https://static.raspberrypi.org/styles/Bits/1.0.0/Bits.min.css
23+
e.g. https://static.raspberrypi.org/styles/Bits/<version>/Bits.min.css
2424

2525
## Local Development
2626

27-
You can use gulp to watch the scss files & rebuild as necessary:
28-
```
29-
npm run gulp:watch
30-
```
27+
To bring up everything you need for development, run the `start` command:
3128

32-
When writing documentation, use:
3329
```
34-
npm run docs
30+
npm run start
3531
```
3632

37-
Before creating a PR, make sure you run:
38-
```
39-
npm run build
40-
```
41-
to build all the css & javascript files.
33+
This will automatically compile JavaScript and Sass during development.
4234

4335
## Local Development in another app
4436

lib/index.es.js

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"type": "git",
1111
"url": "https://github.com/RaspberryPiFoundation/Bits.git"
1212
},
13-
"version": "1.2.1",
13+
"version": "1.2.2",
1414
"main": "lib/index.js",
1515
"files": [
1616
"lib",
@@ -28,7 +28,7 @@
2828
"prepublishOnly": "npm run build",
2929
"rollup": "rollup -c",
3030
"rollup:watch": "rollup -c -w",
31-
"start": "npm-run-all rollup:watch gulp:watch",
31+
"start": "npm-run-all rollup:watch gulp:watch docs:serve",
3232
"test": "jest --env=jsdom --notify --watch",
3333
"test-coverage": "jest --env=jsdom --coverage",
3434
"docs": "styleguidist server",

src/components/Button/Button.scss

+13-1
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,23 @@ $button-lod-hover-color: $color-ui-grey-dark !default;
8080
width: 100%;
8181
}
8282

83+
.c-button--disabled,
84+
.c-button--disabled:visited,
85+
.c-button[disabled=''],
86+
.c-button[disabled='']:visited,
87+
.c-button[disabled='disabled'],
88+
.c-button[disabled='disabled']:visited {
89+
background-color: $color-ui-grey-lightest;
90+
border-color: $color-ui-grey-lightest;
91+
color: $color-ui-grey-medium;
92+
pointer-events: none;
93+
}
94+
8395
@each $color-name, $color-value in $colors {
8496
.#{'c-button--' + $color-name},
8597
.#{'c-button--' + $color-name + ':visited'} {
8698
background-color: #{$color-value};
8799
border-color: #{$color-value};
88-
color: set-color($color-value);
100+
color: set-color($color-value);
89101
}
90102
}

src/components/Button/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<Button secondary>Button Secondary</Button>
99
```
1010

11+
### Button Disabled
12+
```jsx
13+
<Button disabled>Button Disabled</Button>
14+
```
15+
1116
### Button as Link
1217
```jsx
1318
<Button to="https://www.raspberrypi.org/">Raspberry Pi Homepage</Button>

src/components/Button/index.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
import './Button.scss'
2+
13
import { Base } from 'react-iotacss'
2-
import classnames from 'classnames'
4+
import Link from '../Link'
35
import PropTypes from 'prop-types'
46
import React from 'react'
5-
6-
import './Button.scss'
7-
import Link from '../Link'
7+
import classnames from 'classnames'
88

99
/**
1010
* A styled button that can also be used as a link
1111
*/
1212
const Button = ({
1313
children,
1414
className,
15+
disabled,
1516
lightOnDark,
1617
secondary,
1718
to,
@@ -20,6 +21,7 @@ const Button = ({
2021
const classNames = classnames('c-button', className, {
2122
'c-button--light-on-dark': lightOnDark,
2223
'c-button--secondary': secondary,
24+
'c-button--disabled': disabled,
2325
})
2426
const isLink = () => typeof to === 'string'
2527

@@ -32,7 +34,12 @@ const Button = ({
3234
}
3335

3436
return (
35-
<Base {...props} className={classNames} tagName="button">
37+
<Base
38+
{...props}
39+
className={classNames}
40+
disabled={disabled}
41+
tagName="button"
42+
>
3643
{children}
3744
</Base>
3845
)
@@ -43,6 +50,8 @@ Button.propTypes = {
4350
className: PropTypes.string,
4451
/** The contents of the button */
4552
children: PropTypes.node.isRequired,
53+
/** Determines if button should render in a disabled state */
54+
disabled: PropTypes.bool,
4655
/** Changes the hover styles to better suit dark backgrounds */
4756
lightOnDark: PropTypes.bool,
4857
/** Applies secondary button styling */

0 commit comments

Comments
 (0)