Skip to content

Commit bab5787

Browse files
committed
✨ Add Input
1 parent 0cceaee commit bab5787

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

.internal/theme.js

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const Button = css`
1313
padding: 10px 20px;
1414
`
1515

16+
const Input = css`
17+
border: 1px solid rgba(255, 255, 255, 0.3);
18+
padding: 10px 20px;
19+
`
20+
1621
const theme = {
1722
media: {
1823
sm: '(max-width: 600px)',
@@ -79,6 +84,12 @@ const theme = {
7984
background: 'royalblue',
8085
color: 'white'
8186
}
87+
},
88+
Input,
89+
inputStyle: {
90+
default: {
91+
background: '#2e3440',
92+
}
8293
}
8394
}
8495

docs/input.mdx

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Input
3+
route: /input
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 { Input, Link } from '../src'
12+
13+
# Input
14+
15+
## Description
16+
17+
Based on [Box](/box). Renders `<input>` or `<textarea>` element.
18+
19+
20+
## Usage
21+
22+
```js
23+
import { Input } from 'pss-components'
24+
```
25+
26+
<Playground>
27+
<Input defaultValue='Input' />
28+
<Input defaultValue='Input' variant='auto' mt={1} />
29+
<Input defaultValue='Input' bg='red' mt={1} />
30+
</Playground>
31+
32+
## Examples
33+
34+
### Change element
35+
36+
<Playground>
37+
<Input as='textarea' defaultValue='TextArea' variant='auto' rows={3} />
38+
</Playground>
39+
40+
41+
## Props
42+
43+
<PropsTable of={Input} />

src/button.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { themePath, variant } from 'pss'
33
import { getPropTypes } from 'pss/prop-type'
44
import { Box } from './box'
55

6-
const buttonVariant = variant({
6+
const buttonStyle = variant({
77
themeKey: 'buttonStyle'
88
})
99

@@ -19,13 +19,13 @@ const Button = styled(Box)(
1919
}
2020
},
2121
themePath('Button'),
22-
buttonVariant
22+
buttonStyle
2323
)
2424

2525
Button.displayName = 'Button'
2626

2727
Button.propTypes = {
28-
...getPropTypes(buttonVariant),
28+
...getPropTypes(buttonStyle),
2929
...Box.propTypes
3030
}
3131

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export { Feed } from './feed'
44
export { Flex } from './flex'
55
export { FlexGrid } from './flex-grid'
66
export { Grid } from './grid'
7+
export { Input } from './input'
78
export { Image } from './image'
89
export { Layout } from './layout'
910
export { Link } from './link'

src/input.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import styled from '@emotion/styled'
2+
import { themePath, variant } from 'pss'
3+
import { getPropTypes } from 'pss/prop-type'
4+
import { Box } from './box'
5+
6+
const inputStyle = variant({
7+
themeKey: 'inputStyle'
8+
})
9+
10+
const Input = styled(Box)(
11+
{
12+
appearance: 'none',
13+
'&[disabled]': {
14+
'-webkit-text-fill-color': 'currentColor',
15+
'-webkit-opacity': 1
16+
}
17+
},
18+
themePath('Input'),
19+
inputStyle
20+
)
21+
22+
Input.displayName = 'Input'
23+
24+
Input.propTypes = {
25+
...getPropTypes(inputStyle),
26+
...Box.propTypes
27+
}
28+
29+
Input.defaultProps = {
30+
as: 'input',
31+
width: '100%',
32+
borderRadius: 0
33+
}
34+
35+
export {
36+
Input
37+
}

0 commit comments

Comments
 (0)