-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathalert.js
164 lines (153 loc) · 5.16 KB
/
alert.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import React from 'react'
import { ThemeProvider, Alert, Link, Text, Stack } from 'react-ui'
import {
Page,
Props,
Example,
Section,
Table,
Para,
Badge
} from '../../components'
const Documentation = () => {
return (
<Page
title="Alert"
tagline="Show a message intended to draw the user's attention"
badges={[<Badge key={0}>accessible</Badge>]}
>
<Example>
<Example.Preview>
<Alert variant="warning">This is an important message!</Alert>
</Example.Preview>
<Example.Code>
{`
<Alert variant="warning">This is an important message!</Alert>
`}
</Example.Code>
</Example>
<Section title="Props">
<Props
props={[
{
name: 'variant',
type: 'default | warning | success | destructive | info',
description: 'Picked from the variants defined in theme',
default: 'primary'
},
{
name: 'type',
type: 'polite | asertive',
description:
'Controls whether the assistive technology should read immediately ("assertive") or wait until the user is idle ("polite").',
default: 'polite'
}
]}
/>
</Section>
<Section title="Examples">
<Example title="Variants">
<Example.Preview direction="vertical" gap={4}>
<Alert variant="default">Just a regular message</Alert>
<Alert variant="warning">Oh oh, you should pay attention</Alert>
<Alert variant="success">Kudos! You did the thing!</Alert>
<Alert variant="destructive">We have bad news</Alert>
<Alert variant="info">You should probably know this</Alert>
</Example.Preview>
<Example.Code>{`
<Alert variant="default">Just a regular message</Alert>
<Alert variant="warning">You should pay attention</Alert>
<Alert variant="success">You did the thing!</Alert>
<Alert variant="destructive">We have bad news</Alert>
<Alert variant="info">You should probably know this</Alert>
`}</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>Alert 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}>Alert</Table.Column>
</Table.Row>
<Table.Row>
<Table.Column span={4}>variant</Table.Column>
<Table.Column span={8}>components.Alert.variants</Table.Column>
</Table.Row>
</Table>
<Example>
<Example.Code lang="js">{`
import { tokens, components } from 'react-ui/themes/base'
components.Alert = {
fontSize: 3,
borderRadius: 1,
padding: 4,
border: '1px solid',
variants: {
warning: {
backgroundColor: 'gold',
color: 'black',
borderColor: 'black'
},
success: {
backgroundColor: 'palegreen',
color: 'darkgreen',
borderColor: 'darkgreen'
}
}
}
`}</Example.Code>
<Example.Code lang="jsx">{`
<ThemeProvider tokens={tokens} components={components}>
<Alert variant="warning">You should pay attention</Alert>
<Alert variant="success">You did the thing!</Alert>
</ThemeProvider>
`}</Example.Code>
<Example.Preview direction="vertical">
<ThemeProvider
components={{
Alert: {
fontSize: 3,
borderRadius: 1,
padding: 4,
border: '1px solid',
variants: {
warning: {
backgroundColor: 'gold',
color: 'black',
borderColor: 'black'
},
success: {
backgroundColor: 'palegreen',
color: 'darkgreen',
borderColor: 'darkgreen'
}
}
}
}}
>
<Stack direction="vertical" gap={4}>
<Alert variant="warning">You should pay attention</Alert>
<Alert variant="success">You did the thing!</Alert>
</Stack>
</ThemeProvider>
</Example.Preview>
</Example>
</Section>
</Page>
)
}
export default Documentation