Skip to content
This repository was archived by the owner on Jun 20, 2022. It is now read-only.

Commit 28d6950

Browse files
authored
Merge pull request #3 from smooth-code/alerts
Alerts
2 parents 54b4fb6 + 6c369fc commit 28d6950

File tree

14 files changed

+177
-10
lines changed

14 files changed

+177
-10
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ module.exports = {
1414
'import/prefer-default-export': 'off',
1515

1616
'no-return-assign': 'off',
17+
'no-param-reassign': 'off',
18+
'no-shadow': 'off',
1719
},
1820
}

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules/
22
build/
33
styleguide/
4+
package.json
5+
CHANGELOG.json

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: node_js
2+
3+
node_js:
4+
- 8
5+
6+
script:
7+
- yarn ci
8+
9+
notifications:
10+
email: false
11+
12+
cache:
13+
yarn: true
14+
directories:
15+
- "node_modules"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</h1>
44
<p align="center" style="font-size: 1.2rem;">React Components library based on Styled Components.</p>
55

6-
<!-- [![Build Status][build-badge]][build] -->
6+
[![Build Status][build-badge]][build]
77

88
<!-- [![Code Coverage][coverage-badge]][coverage] -->
99

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
"build:lib": "cross-env BABEL_ENV=lib babel --out-dir build src",
1414
"build:rollup": "cross-env BABEL_ENV=rollup rollup -c",
1515
"build:watch": "yarn build:lib --watch",
16+
"ci": "yarn lint",
1617
"deploy:docs": "firebase deploy",
1718
"dev": "styleguidist server",
19+
"lint": "eslint .",
1820
"prebuild": "shx rm -rf dist/*",
1921
"release": "standard-version && conventional-github-releaser -p angular && yarn build && yarn deploy:docs"
2022
},

src/Alert.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
4+
import styled, { css } from 'styled-components'
5+
import handleRef from './internal/handleRef'
6+
import setWithComponent from './internal/setWithComponent'
7+
import * as defaultTheme from './style/defaultTheme'
8+
import { th, mixin } from './utils'
9+
10+
const variants = [
11+
'primary',
12+
'secondary',
13+
'success',
14+
'danger',
15+
'warning',
16+
'info',
17+
'light',
18+
'dark',
19+
]
20+
21+
const AlertComponent = ({
22+
className,
23+
component: Component = 'div',
24+
theme,
25+
variant,
26+
...props
27+
}) => (
28+
<Component
29+
{...props}
30+
className={classNames(
31+
'sui-alert',
32+
{
33+
[`sui-alert-${variant}`]: variant,
34+
},
35+
className,
36+
)}
37+
/>
38+
)
39+
40+
const Alert = styled(handleRef(AlertComponent))`
41+
position: relative;
42+
padding: ${th('alertPaddingY')} ${th('alertPaddingX')};
43+
margin-bottom: ${th('alertMarginBottom')};
44+
border: 1px solid transparent;
45+
border-radius: ${th('borderRadius')};
46+
47+
${variants.map(
48+
variant => css`
49+
&.sui-alert-${variant} {
50+
${mixin('alertVariant', variant)};
51+
}
52+
`,
53+
)};
54+
`
55+
56+
Alert.propTypes = {
57+
variant: PropTypes.oneOf(variants),
58+
theme: PropTypes.object,
59+
}
60+
61+
Alert.defaultProps = {
62+
variant: 'primary',
63+
theme: defaultTheme,
64+
}
65+
66+
setWithComponent(Alert, AlertComponent)
67+
68+
/** @component */
69+
export default Alert

src/Alert.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### Variants
2+
3+
Set variants using `variant` prop.
4+
5+
```js
6+
<div>
7+
<span style={{ margin: '5px' }}>
8+
<Alert variant="primary">This is a primary alert—check it out!</Alert>
9+
</span>
10+
<span style={{ margin: '5px' }}>
11+
<Alert variant="secondary">This is a secondary alert—check it out!</Alert>
12+
</span>
13+
<span style={{ margin: '5px' }}>
14+
<Alert variant="success">This is a success alert—check it out!</Alert>
15+
</span>
16+
<span style={{ margin: '5px' }}>
17+
<Alert variant="danger">This is a danger alert—check it out!</Alert>
18+
</span>
19+
<span style={{ margin: '5px' }}>
20+
<Alert variant="warning">This is a warning alert—check it out!</Alert>
21+
</span>
22+
<span style={{ margin: '5px' }}>
23+
<Alert variant="info">This is a info alert—check it out!</Alert>
24+
</span>
25+
<span style={{ margin: '5px' }}>
26+
<Alert variant="light">This is a light alert—check it out!</Alert>
27+
</span>
28+
<span style={{ margin: '5px' }}>
29+
<Alert variant="dark">This is a dark alert—check it out!</Alert>
30+
</span>
31+
</div>
32+
```

src/Button.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Variants
22

3-
Set sizes using `variant` prop.
3+
Set variants using `variant` prop.
44

55
```js
66
<div>
File renamed without changes.

0 commit comments

Comments
 (0)