-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathtextarea.js
150 lines (140 loc) · 4.46 KB
/
textarea.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import React from 'react'
import { ThemeProvider, Textarea, Link, Text } from 'react-ui'
import { Page, Props, Example, Section, Table, Para } from '../../components'
const Documentation = () => {
return (
<Page
title="Textarea"
tagline="Use Textarea to request a lot of information from user."
>
<Para>
<Text>
Extends <Link href="/components/Input">Input</Link>.
</Text>
</Para>
<Example>
<Example.Preview>
<Textarea placeholder="Please enter your address" />
</Example.Preview>
<Example.Code>
{`
<Textarea placeholder="Please enter your address" />
`}
</Example.Code>
</Example>
<Section title="Props">
<Props
props={[
{
name: 'rows',
type: 'number',
description: 'Number of rows in textarea (html attribute)'
},
{
name: '+',
type: 'props of Input',
description: ''
}
]}
/>
</Section>
<Section title="Examples">
<Para>
<Text>
Texarea can be used with{' '}
<Link href="/components/Form">Form.Field</Link> which adds
accessible labels and error states.
</Text>
</Para>
<Example>
<Example.Preview direction="vertical" gap={2}>
<Textarea placeholder="Please enter your address" />
<Textarea disabled placeholder="Please enter your address" />
<Textarea invalid placeholder="Please enter your address" />
</Example.Preview>
<Example.Code>{`
<Textarea placeholder="Please enter your address" />
<Textarea disabled placeholder="Please enter your address" />
<Textarea invalid placeholder="Please enter your address" />
`}</Example.Code>
</Example>
</Section>
<Section title="Customisation">
<Para>
<Text variant="subtle" css={{ fontStyle: 'italic' }}>
Please read the docs on{' '}
<Link href="/core-concepts/customising-components">
customising components
</Link>{' '}
first.
</Text>
</Para>
<Para>
Textarea extends Input and uses the following theme properties:
</Para>
<Table>
<Table.Header>
<Table.Column span={4}>Property</Table.Column>
<Table.Column span={8}>Theme key</Table.Column>
</Table.Header>
<Table.Row>
<Table.Column span={4}>component name</Table.Column>
<Table.Column span={8}>Textarea</Table.Column>
</Table.Row>
<Table.Row>
<Table.Column span={4}>height</Table.Column>
<Table.Column span={8}>Textarea.sizes</Table.Column>
</Table.Row>
</Table>
<Example>
<Example.Code lang="js">{`
import { tokens, components } from 'react-ui/themes/base'
// overwrite Textarea styles
components.Textarea = {
sizes: { medium: 10 }, // medium is default size
fontSize: 4,
paddingX: 2,
border: '2px solid',
borderColor: 'green',
'::placeholder': {
color: 'green'
}
':focus': {
outline: 'none',
borderColor: 'lightgreen'
}
}
`}</Example.Code>
<Example.Code lang="jsx">{`
<ThemeProvider components={components}>
<Textarea placeholder="Please enter your address" />
</ThemeProvider>
`}</Example.Code>
<Example.Preview>
<ThemeProvider
components={{
Textarea: {
sizes: { medium: 10 },
fontSize: 4,
paddingX: 2,
border: '2px solid',
borderColor: 'green',
'::placeholder': {
color: 'green'
},
':focus': {
outline: 'none',
borderColor: 'lightgreen'
}
}
}}
>
<Textarea placeholder="Please enter your address" />
</ThemeProvider>
</Example.Preview>
</Example>
</Section>
</Page>
)
}
export default Documentation