This repository was archived by the owner on Jun 20, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 14 files changed +177
-10
lines changed
Expand file tree Collapse file tree 14 files changed +177
-10
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 11node_modules /
22build /
33styleguide /
4+ package.json
5+ CHANGELOG.json
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 },
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff line change 11### Variants
22
3- Set sizes using ` variant ` prop.
3+ Set variants using ` variant ` prop.
44
55``` js
66< div>
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments