Skip to content

Commit e0de60f

Browse files
committed
✨ Add Button component
1 parent a1862ed commit e0de60f

File tree

4 files changed

+97
-1
lines changed

4 files changed

+97
-1
lines changed

.internal/theme.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const Link = css`
88
}
99
`
1010

11+
const Button = css`
12+
border-radius: 5px;
13+
padding: 10px 20px;
14+
`
15+
1116
const theme = {
1217
media: {
1318
sm: '(max-width: 600px)',
@@ -67,7 +72,14 @@ const theme = {
6772
fontWeight: 'bold'
6873
}
6974
},
70-
Link
75+
Link,
76+
Button,
77+
buttonVariant: {
78+
default: {
79+
background: 'royalblue',
80+
color: 'white'
81+
}
82+
}
7183
}
7284

7385
const themeWithRems = {

docs/button.mdx

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Button
3+
route: /button
4+
menu: Primitives
5+
---
6+
7+
import { Playground } from 'docz'
8+
import { ThemeProvider } from 'emotion-theming'
9+
import { PropsTable } from '../.internal/props-table'
10+
import { theme } from '../.internal/theme'
11+
import { Button, Link } from '../src'
12+
13+
# Button
14+
15+
## Description
16+
17+
Based on [Box](/box). Renders `<button>` element.
18+
19+
20+
## Usage
21+
22+
```js
23+
import { Button } from 'pss-components'
24+
```
25+
26+
<Playground>
27+
<Button>Button</Button>
28+
<Button variant='auto'>Button</Button>
29+
<Button bg='red' ml={1}>Button</Button>
30+
</Playground>
31+
32+
## Examples
33+
34+
### Change element
35+
36+
<Playground>
37+
<Button variant='auto' use='a' href='http://example.com' target='_blank'>
38+
Button
39+
</Button>
40+
</Playground>
41+
42+
43+
## Props
44+
45+
<PropsTable of={Button} />

src/button.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import styled from '@emotion/styled'
2+
import { themePath, variant } from 'pss'
3+
import { Box } from './box'
4+
5+
const buttonVariant = variant({
6+
themeKey: 'buttonVariant'
7+
})
8+
9+
const Button = styled(Box)(
10+
{
11+
appearance: 'none',
12+
textAlign: 'center',
13+
textDecoration: 'none',
14+
cursor: 'pointer',
15+
'&[disabled]': {
16+
cursor: 'auto',
17+
pointerEvents: 'none'
18+
}
19+
},
20+
themePath('Button'),
21+
buttonVariant
22+
)
23+
24+
Button.displayName = 'Button'
25+
26+
Button.propTypes = {
27+
...buttonVariant.propTypes,
28+
...Box.propTypes
29+
}
30+
31+
Button.defaultProps = {
32+
element: 'button',
33+
display: 'inline-block'
34+
}
35+
36+
export {
37+
Button
38+
}

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export { Box } from './box'
2+
export { Button } from './button'
23
export { Feed } from './feed'
34
export { Flex } from './flex'
45
export { FlexGrid } from './flex-grid'

0 commit comments

Comments
 (0)