@instructure/ui-view 11.6.0 → 11.6.1-snapshot-129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -307
- package/es/ContextView/{index.js → v1/index.js} +2 -2
- package/es/ContextView/v2/index.js +125 -0
- package/es/ContextView/v2/props.js +26 -0
- package/es/ContextView/v2/styles.js +256 -0
- package/es/View/{index.js → v1/index.js} +1 -1
- package/es/View/v2/index.js +167 -0
- package/es/View/v2/props.js +29 -0
- package/es/View/v2/styles.js +420 -0
- package/es/{index.js → exports/a.js} +2 -2
- package/{src/index.ts → es/exports/b.js} +2 -6
- package/lib/ContextView/{index.js → v1/index.js} +4 -4
- package/lib/ContextView/v2/index.js +130 -0
- package/lib/ContextView/v2/props.js +31 -0
- package/lib/ContextView/v2/styles.js +262 -0
- package/lib/View/{index.js → v1/index.js} +1 -1
- package/lib/View/v2/index.js +175 -0
- package/lib/View/v2/props.js +34 -0
- package/lib/View/v2/styles.js +426 -0
- package/lib/{index.js → exports/a.js} +4 -4
- package/lib/exports/b.js +19 -0
- package/package.json +41 -19
- package/src/ContextView/{index.tsx → v1/index.tsx} +2 -2
- package/src/ContextView/v2/README.md +53 -0
- package/src/ContextView/v2/index.tsx +144 -0
- package/src/ContextView/v2/props.ts +98 -0
- package/src/ContextView/v2/styles.ts +332 -0
- package/src/View/{index.tsx → v1/index.tsx} +1 -1
- package/src/View/v2/README.md +803 -0
- package/src/View/v2/index.tsx +240 -0
- package/src/View/v2/props.ts +278 -0
- package/src/View/v2/styles.ts +503 -0
- package/src/exports/a.ts +29 -0
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ContextView/v1/index.d.ts.map +1 -0
- package/types/ContextView/v1/props.d.ts.map +1 -0
- package/types/ContextView/v1/styles.d.ts.map +1 -0
- package/types/ContextView/v1/theme.d.ts.map +1 -0
- package/types/ContextView/v2/index.d.ts +50 -0
- package/types/ContextView/v2/index.d.ts.map +1 -0
- package/types/ContextView/v2/props.d.ts +36 -0
- package/types/ContextView/v2/props.d.ts.map +1 -0
- package/types/ContextView/v2/styles.d.ts +14 -0
- package/types/ContextView/v2/styles.d.ts.map +1 -0
- package/types/View/v1/index.d.ts.map +1 -0
- package/types/View/v1/props.d.ts.map +1 -0
- package/types/View/v1/styles.d.ts.map +1 -0
- package/types/View/v1/theme.d.ts.map +1 -0
- package/types/View/v2/index.d.ts +36 -0
- package/types/View/v2/index.d.ts.map +1 -0
- package/types/View/v2/props.d.ts +157 -0
- package/types/View/v2/props.d.ts.map +1 -0
- package/types/View/v2/styles.d.ts +11 -0
- package/types/View/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +5 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/ContextView/index.d.ts.map +0 -1
- package/types/ContextView/props.d.ts.map +0 -1
- package/types/ContextView/styles.d.ts.map +0 -1
- package/types/ContextView/theme.d.ts.map +0 -1
- package/types/View/index.d.ts.map +0 -1
- package/types/View/props.d.ts.map +0 -1
- package/types/View/styles.d.ts.map +0 -1
- package/types/View/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/ContextView/{props.js → v1/props.js} +0 -0
- /package/es/ContextView/{styles.js → v1/styles.js} +0 -0
- /package/es/ContextView/{theme.js → v1/theme.js} +0 -0
- /package/es/View/{props.js → v1/props.js} +0 -0
- /package/es/View/{styles.js → v1/styles.js} +0 -0
- /package/es/View/{theme.js → v1/theme.js} +0 -0
- /package/lib/ContextView/{props.js → v1/props.js} +0 -0
- /package/lib/ContextView/{styles.js → v1/styles.js} +0 -0
- /package/lib/ContextView/{theme.js → v1/theme.js} +0 -0
- /package/lib/View/{props.js → v1/props.js} +0 -0
- /package/lib/View/{styles.js → v1/styles.js} +0 -0
- /package/lib/View/{theme.js → v1/theme.js} +0 -0
- /package/src/ContextView/{README.md → v1/README.md} +0 -0
- /package/src/ContextView/{props.ts → v1/props.ts} +0 -0
- /package/src/ContextView/{styles.ts → v1/styles.ts} +0 -0
- /package/src/ContextView/{theme.ts → v1/theme.ts} +0 -0
- /package/src/View/{README.md → v1/README.md} +0 -0
- /package/src/View/{props.ts → v1/props.ts} +0 -0
- /package/src/View/{styles.ts → v1/styles.ts} +0 -0
- /package/src/View/{theme.ts → v1/theme.ts} +0 -0
- /package/types/ContextView/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/ContextView/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/ContextView/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/ContextView/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/View/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/View/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/View/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/View/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
---
|
|
2
|
+
describes: View
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
### View: the visual basis of Instructure UI
|
|
6
|
+
|
|
7
|
+
View provides the base appearance for most of the components
|
|
8
|
+
in Instructure UI.
|
|
9
|
+
|
|
10
|
+
> **Because View provides access to so many visual styles, it
|
|
11
|
+
> can be easy to abuse.** Before you use View, ensure that the component
|
|
12
|
+
> you're trying to style doesn't already have access to the same props.
|
|
13
|
+
> For example, don't wrap a `<Button>` in a `<View>` just to add
|
|
14
|
+
> `margin` around the button: Instead, use the `margin` prop on the
|
|
15
|
+
> button itself.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
---
|
|
19
|
+
type: example
|
|
20
|
+
---
|
|
21
|
+
<View
|
|
22
|
+
as="div"
|
|
23
|
+
margin="small"
|
|
24
|
+
padding="large"
|
|
25
|
+
textAlign="center"
|
|
26
|
+
background="primary"
|
|
27
|
+
>
|
|
28
|
+
{lorem.sentence()}
|
|
29
|
+
</View>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### `background`
|
|
33
|
+
|
|
34
|
+
Change the background color using the `background` prop.
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
---
|
|
38
|
+
type: example
|
|
39
|
+
---
|
|
40
|
+
<div>
|
|
41
|
+
<View
|
|
42
|
+
as="div"
|
|
43
|
+
display="inline-block"
|
|
44
|
+
maxWidth="10rem"
|
|
45
|
+
margin="small"
|
|
46
|
+
padding="small"
|
|
47
|
+
background="transparent"
|
|
48
|
+
>
|
|
49
|
+
{lorem.sentence()}
|
|
50
|
+
</View>
|
|
51
|
+
<View
|
|
52
|
+
as="div"
|
|
53
|
+
display="inline-block"
|
|
54
|
+
maxWidth="10rem"
|
|
55
|
+
margin="small"
|
|
56
|
+
padding="small"
|
|
57
|
+
background="primary"
|
|
58
|
+
>
|
|
59
|
+
{lorem.sentence()}
|
|
60
|
+
</View>
|
|
61
|
+
<View
|
|
62
|
+
as="div"
|
|
63
|
+
display="inline-block"
|
|
64
|
+
maxWidth="10rem"
|
|
65
|
+
margin="small"
|
|
66
|
+
padding="small"
|
|
67
|
+
background="secondary"
|
|
68
|
+
>
|
|
69
|
+
{lorem.sentence()}
|
|
70
|
+
</View>
|
|
71
|
+
<View
|
|
72
|
+
as="div"
|
|
73
|
+
display="inline-block"
|
|
74
|
+
maxWidth="10rem"
|
|
75
|
+
margin="small"
|
|
76
|
+
padding="small"
|
|
77
|
+
background="primary-inverse"
|
|
78
|
+
>
|
|
79
|
+
{lorem.sentence()}
|
|
80
|
+
</View>
|
|
81
|
+
<View
|
|
82
|
+
as="div"
|
|
83
|
+
display="inline-block"
|
|
84
|
+
maxWidth="10rem"
|
|
85
|
+
margin="small"
|
|
86
|
+
padding="small"
|
|
87
|
+
background="brand"
|
|
88
|
+
>
|
|
89
|
+
{lorem.sentence()}
|
|
90
|
+
</View>
|
|
91
|
+
<View
|
|
92
|
+
as="div"
|
|
93
|
+
display="inline-block"
|
|
94
|
+
maxWidth="10rem"
|
|
95
|
+
margin="small"
|
|
96
|
+
padding="small"
|
|
97
|
+
background="alert"
|
|
98
|
+
>
|
|
99
|
+
{lorem.sentence()}
|
|
100
|
+
</View>
|
|
101
|
+
<View
|
|
102
|
+
as="div"
|
|
103
|
+
display="inline-block"
|
|
104
|
+
maxWidth="10rem"
|
|
105
|
+
margin="small"
|
|
106
|
+
padding="small"
|
|
107
|
+
background="success"
|
|
108
|
+
>
|
|
109
|
+
{lorem.sentence()}
|
|
110
|
+
</View>
|
|
111
|
+
<View
|
|
112
|
+
as="div"
|
|
113
|
+
display="inline-block"
|
|
114
|
+
maxWidth="10rem"
|
|
115
|
+
margin="small"
|
|
116
|
+
padding="small"
|
|
117
|
+
background="danger"
|
|
118
|
+
>
|
|
119
|
+
{lorem.sentence()}
|
|
120
|
+
</View>
|
|
121
|
+
<View
|
|
122
|
+
as="div"
|
|
123
|
+
display="inline-block"
|
|
124
|
+
maxWidth="10rem"
|
|
125
|
+
margin="small"
|
|
126
|
+
padding="small"
|
|
127
|
+
background="warning"
|
|
128
|
+
>
|
|
129
|
+
{lorem.sentence()}
|
|
130
|
+
</View>
|
|
131
|
+
</div>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### `shadow`
|
|
135
|
+
|
|
136
|
+
Add a CSS box-shadow to the View using the `shadow` prop.
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
---
|
|
140
|
+
type: example
|
|
141
|
+
---
|
|
142
|
+
<div>
|
|
143
|
+
<View
|
|
144
|
+
as="span"
|
|
145
|
+
display="inline-block"
|
|
146
|
+
maxWidth="10rem"
|
|
147
|
+
margin="small"
|
|
148
|
+
padding="large"
|
|
149
|
+
background="primary"
|
|
150
|
+
shadow="resting"
|
|
151
|
+
>
|
|
152
|
+
{lorem.sentence()}
|
|
153
|
+
</View>
|
|
154
|
+
<View
|
|
155
|
+
as="span"
|
|
156
|
+
display="inline-block"
|
|
157
|
+
maxWidth="10rem"
|
|
158
|
+
margin="small"
|
|
159
|
+
padding="large"
|
|
160
|
+
background="primary"
|
|
161
|
+
shadow="above"
|
|
162
|
+
>
|
|
163
|
+
{lorem.sentence()}
|
|
164
|
+
</View>
|
|
165
|
+
<View
|
|
166
|
+
as="span"
|
|
167
|
+
display="inline-block"
|
|
168
|
+
maxWidth="10rem"
|
|
169
|
+
margin="small"
|
|
170
|
+
padding="large"
|
|
171
|
+
background="primary"
|
|
172
|
+
shadow="topmost"
|
|
173
|
+
>
|
|
174
|
+
{lorem.sentence()}
|
|
175
|
+
</View>
|
|
176
|
+
</div>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `borderWidth`
|
|
180
|
+
|
|
181
|
+
Apply a border with the `borderWidth` prop. Utilize
|
|
182
|
+
[CSS shorthand style](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties)
|
|
183
|
+
to apply different border styles to individual edges.
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
---
|
|
187
|
+
type: example
|
|
188
|
+
---
|
|
189
|
+
<div>
|
|
190
|
+
<View
|
|
191
|
+
as="span"
|
|
192
|
+
display="inline-block"
|
|
193
|
+
maxWidth="10rem"
|
|
194
|
+
margin="small"
|
|
195
|
+
padding="small"
|
|
196
|
+
background="primary"
|
|
197
|
+
borderWidth="small"
|
|
198
|
+
>
|
|
199
|
+
{lorem.sentence()}
|
|
200
|
+
</View>
|
|
201
|
+
<View
|
|
202
|
+
as="span"
|
|
203
|
+
display="inline-block"
|
|
204
|
+
maxWidth="10rem"
|
|
205
|
+
margin="small"
|
|
206
|
+
padding="small"
|
|
207
|
+
background="primary"
|
|
208
|
+
borderWidth="medium"
|
|
209
|
+
>
|
|
210
|
+
{lorem.sentence()}
|
|
211
|
+
</View>
|
|
212
|
+
<View
|
|
213
|
+
as="span"
|
|
214
|
+
display="inline-block"
|
|
215
|
+
maxWidth="10rem"
|
|
216
|
+
margin="small"
|
|
217
|
+
padding="small"
|
|
218
|
+
background="primary"
|
|
219
|
+
borderWidth="large none"
|
|
220
|
+
>
|
|
221
|
+
{lorem.sentence()}
|
|
222
|
+
</View>
|
|
223
|
+
<View
|
|
224
|
+
as="div"
|
|
225
|
+
margin="small"
|
|
226
|
+
padding="small"
|
|
227
|
+
background="primary"
|
|
228
|
+
borderWidth="none none small none"
|
|
229
|
+
>
|
|
230
|
+
{lorem.sentence()}
|
|
231
|
+
</View>
|
|
232
|
+
</div>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### `borderColor`
|
|
236
|
+
|
|
237
|
+
Change the color of View's border for different contexts via the `borderColor` prop.
|
|
238
|
+
|
|
239
|
+
```js
|
|
240
|
+
---
|
|
241
|
+
type: example
|
|
242
|
+
---
|
|
243
|
+
<div>
|
|
244
|
+
<View
|
|
245
|
+
as="span"
|
|
246
|
+
display="inline-block"
|
|
247
|
+
margin="small"
|
|
248
|
+
padding="small"
|
|
249
|
+
background="primary"
|
|
250
|
+
borderWidth="large"
|
|
251
|
+
>
|
|
252
|
+
primary
|
|
253
|
+
</View>
|
|
254
|
+
<View
|
|
255
|
+
as="span"
|
|
256
|
+
display="inline-block"
|
|
257
|
+
margin="small"
|
|
258
|
+
padding="small"
|
|
259
|
+
background="primary"
|
|
260
|
+
borderWidth="large"
|
|
261
|
+
borderColor="info"
|
|
262
|
+
>
|
|
263
|
+
info
|
|
264
|
+
</View>
|
|
265
|
+
<View
|
|
266
|
+
as="span"
|
|
267
|
+
display="inline-block"
|
|
268
|
+
margin="small"
|
|
269
|
+
padding="small"
|
|
270
|
+
background="primary"
|
|
271
|
+
borderWidth="large"
|
|
272
|
+
borderColor="warning"
|
|
273
|
+
>
|
|
274
|
+
warning
|
|
275
|
+
</View>
|
|
276
|
+
<View
|
|
277
|
+
as="span"
|
|
278
|
+
display="inline-block"
|
|
279
|
+
margin="small"
|
|
280
|
+
padding="small"
|
|
281
|
+
background="primary"
|
|
282
|
+
borderWidth="large"
|
|
283
|
+
borderColor="danger"
|
|
284
|
+
>
|
|
285
|
+
danger
|
|
286
|
+
</View>
|
|
287
|
+
<View
|
|
288
|
+
as="span"
|
|
289
|
+
display="inline-block"
|
|
290
|
+
margin="small"
|
|
291
|
+
padding="small"
|
|
292
|
+
background="primary"
|
|
293
|
+
borderWidth="large"
|
|
294
|
+
borderColor="alert"
|
|
295
|
+
>
|
|
296
|
+
alert
|
|
297
|
+
</View>
|
|
298
|
+
<View
|
|
299
|
+
as="span"
|
|
300
|
+
display="inline-block"
|
|
301
|
+
margin="small"
|
|
302
|
+
padding="small"
|
|
303
|
+
background="primary"
|
|
304
|
+
borderWidth="large"
|
|
305
|
+
borderColor="success"
|
|
306
|
+
>
|
|
307
|
+
success
|
|
308
|
+
</View>
|
|
309
|
+
<View
|
|
310
|
+
as="span"
|
|
311
|
+
display="inline-block"
|
|
312
|
+
margin="small"
|
|
313
|
+
padding="small"
|
|
314
|
+
background="primary"
|
|
315
|
+
borderWidth="large"
|
|
316
|
+
borderColor="brand"
|
|
317
|
+
>
|
|
318
|
+
brand
|
|
319
|
+
</View>
|
|
320
|
+
</div>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### `borderRadius`
|
|
324
|
+
|
|
325
|
+
Adjust the border radius using the `borderRadius` prop. Utilize
|
|
326
|
+
[CSS shorthand style](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties)
|
|
327
|
+
to apply different border radii to individual corners.
|
|
328
|
+
|
|
329
|
+
```js
|
|
330
|
+
---
|
|
331
|
+
type: example
|
|
332
|
+
---
|
|
333
|
+
<div>
|
|
334
|
+
<View
|
|
335
|
+
as="span"
|
|
336
|
+
display="inline-block"
|
|
337
|
+
maxWidth="10rem"
|
|
338
|
+
margin="small"
|
|
339
|
+
padding="medium"
|
|
340
|
+
background="primary-inverse"
|
|
341
|
+
borderRadius="medium"
|
|
342
|
+
textAlign="center"
|
|
343
|
+
>
|
|
344
|
+
medium
|
|
345
|
+
</View>
|
|
346
|
+
<View
|
|
347
|
+
as="span"
|
|
348
|
+
display="inline-block"
|
|
349
|
+
maxWidth="10rem"
|
|
350
|
+
margin="small"
|
|
351
|
+
padding="medium"
|
|
352
|
+
background="primary-inverse"
|
|
353
|
+
borderRadius="large large none none"
|
|
354
|
+
textAlign="center"
|
|
355
|
+
>
|
|
356
|
+
large large none none
|
|
357
|
+
</View>
|
|
358
|
+
<View
|
|
359
|
+
as="span"
|
|
360
|
+
display="inline-block"
|
|
361
|
+
maxWidth="10rem"
|
|
362
|
+
margin="small"
|
|
363
|
+
padding="medium"
|
|
364
|
+
background="primary-inverse"
|
|
365
|
+
borderRadius="none none large large"
|
|
366
|
+
textAlign="center"
|
|
367
|
+
>
|
|
368
|
+
none none large large
|
|
369
|
+
</View>
|
|
370
|
+
<View
|
|
371
|
+
display="inline-block"
|
|
372
|
+
width="6rem"
|
|
373
|
+
height="6rem"
|
|
374
|
+
margin="small"
|
|
375
|
+
padding="medium"
|
|
376
|
+
background="primary-inverse"
|
|
377
|
+
borderRadius="circle"
|
|
378
|
+
textAlign="center"
|
|
379
|
+
>
|
|
380
|
+
circle
|
|
381
|
+
</View>
|
|
382
|
+
<View
|
|
383
|
+
display="inline-block"
|
|
384
|
+
width="10rem"
|
|
385
|
+
margin="small"
|
|
386
|
+
padding="medium"
|
|
387
|
+
background="primary-inverse"
|
|
388
|
+
borderRadius="pill"
|
|
389
|
+
textAlign="center"
|
|
390
|
+
>
|
|
391
|
+
pill
|
|
392
|
+
</View>
|
|
393
|
+
</div>
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### `position`
|
|
397
|
+
|
|
398
|
+
`position` sets the CSS position rule for the component: `static`, `absolute`, `relative`,
|
|
399
|
+
`sticky`, or `fixed`.
|
|
400
|
+
|
|
401
|
+
```js
|
|
402
|
+
---
|
|
403
|
+
type: example
|
|
404
|
+
---
|
|
405
|
+
<View
|
|
406
|
+
position="relative"
|
|
407
|
+
as="div"
|
|
408
|
+
height="200px"
|
|
409
|
+
borderWidth="small"
|
|
410
|
+
>
|
|
411
|
+
<View
|
|
412
|
+
as="div"
|
|
413
|
+
position="absolute"
|
|
414
|
+
insetInlineEnd="100px"
|
|
415
|
+
insetBlockStart="10px"
|
|
416
|
+
insetBlockEnd="0"
|
|
417
|
+
background="primary-inverse"
|
|
418
|
+
>
|
|
419
|
+
Positioned View inside a View with relative positioning.
|
|
420
|
+
</View>
|
|
421
|
+
</View>
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Indicating that a View is focused
|
|
425
|
+
|
|
426
|
+
By default, if a `View` is rendered as a focusable element, a focus outline will display when it is focused for accessibility.
|
|
427
|
+
|
|
428
|
+
```javascript
|
|
429
|
+
---
|
|
430
|
+
type: example
|
|
431
|
+
---
|
|
432
|
+
<Flex gap="medium" direction="column">
|
|
433
|
+
<View tabIndex="0" role="button" cursor="pointer">
|
|
434
|
+
Tab here to see the focus outline
|
|
435
|
+
</View>
|
|
436
|
+
<View focusWithin>
|
|
437
|
+
if the <code>focusWithin</code> prop is <code>true</code>, the View will display the focus ring if any of its descendants receives focus
|
|
438
|
+
<div tabIndex="0" role="button" style={{outline: 'none'}}>Tab here to see the focus outline</div>
|
|
439
|
+
</View>
|
|
440
|
+
</Flex>
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
In some situations, you may want to manually control when the focus outline is displayed instead of leaving it up to the browser.
|
|
444
|
+
This can be done using the `withFocusOutline` prop. Set it to `true` to make View's focus outline display or `false` to hide it.
|
|
445
|
+
Be careful when overriding the display of the focus outline as it is essential for accessibility.
|
|
446
|
+
|
|
447
|
+
The focus outline adjusts to account for the shape of the View. For example, the following values can be set for `borderRadius`:
|
|
448
|
+
`circle`, `pill`, `small`, `medium`, and `large`. In each case, the border radius of the focus outline will automatically adjust
|
|
449
|
+
to match the border radius of the corresponding View. The color of the focus outline can be changed for different contexts via the `focusColor` property.
|
|
450
|
+
|
|
451
|
+
```js
|
|
452
|
+
---
|
|
453
|
+
type: example
|
|
454
|
+
---
|
|
455
|
+
const FocusedExample = () => {
|
|
456
|
+
const [isFocused, setIsFocused] = useState(true)
|
|
457
|
+
const [inset, setInset] = useState(false)
|
|
458
|
+
const [focusColor, setfocusColor] = useState(undefined)
|
|
459
|
+
|
|
460
|
+
const updateFocused = (event) => setIsFocused(event.target.checked)
|
|
461
|
+
const updateInset = (event) => setInset(event.target.checked)
|
|
462
|
+
const updateFocusRingColor = (event) => setfocusColor(event.target.value)
|
|
463
|
+
|
|
464
|
+
return (
|
|
465
|
+
<View as="div">
|
|
466
|
+
<View
|
|
467
|
+
as="div"
|
|
468
|
+
background="primary"
|
|
469
|
+
padding="small"
|
|
470
|
+
margin="0 0 small"
|
|
471
|
+
borderWidth="small"
|
|
472
|
+
>
|
|
473
|
+
<FormFieldGroup
|
|
474
|
+
rowSpacing="small"
|
|
475
|
+
description={
|
|
476
|
+
<ScreenReaderContent>
|
|
477
|
+
View focus outline examples
|
|
478
|
+
</ScreenReaderContent>
|
|
479
|
+
}
|
|
480
|
+
>
|
|
481
|
+
<Flex gap="small" direction="row">
|
|
482
|
+
<Flex gap="small" direction="column" width="15rem">
|
|
483
|
+
<Checkbox
|
|
484
|
+
label="withFocusOutline"
|
|
485
|
+
checked={isFocused}
|
|
486
|
+
onChange={updateFocused}
|
|
487
|
+
/>
|
|
488
|
+
<Checkbox
|
|
489
|
+
label="focusPosition = inset"
|
|
490
|
+
checked={inset}
|
|
491
|
+
onChange={updateInset}
|
|
492
|
+
/>
|
|
493
|
+
</Flex>
|
|
494
|
+
<RadioInputGroup
|
|
495
|
+
onChange={updateFocusRingColor}
|
|
496
|
+
name="focusColor_2"
|
|
497
|
+
defaultValue="info"
|
|
498
|
+
variant="toggle"
|
|
499
|
+
description="Focus ring color"
|
|
500
|
+
>
|
|
501
|
+
<RadioInput label="info" value="info" />
|
|
502
|
+
<RadioInput label="inverse" value="inverse" />
|
|
503
|
+
<RadioInput label="success" value="success" />
|
|
504
|
+
<RadioInput label="danger" value="danger" />
|
|
505
|
+
</RadioInputGroup>
|
|
506
|
+
</Flex>
|
|
507
|
+
</FormFieldGroup>
|
|
508
|
+
</View>
|
|
509
|
+
<View as="div">
|
|
510
|
+
<code>borderRadius =</code>
|
|
511
|
+
<View
|
|
512
|
+
display="inline-block"
|
|
513
|
+
margin="small"
|
|
514
|
+
padding="small"
|
|
515
|
+
background="primary"
|
|
516
|
+
borderRadius="small"
|
|
517
|
+
borderWidth="small"
|
|
518
|
+
position="relative"
|
|
519
|
+
focusColor={focusColor}
|
|
520
|
+
withFocusOutline={isFocused}
|
|
521
|
+
focusPosition={inset ? 'inset' : 'offset'}
|
|
522
|
+
>
|
|
523
|
+
small
|
|
524
|
+
</View>
|
|
525
|
+
<View
|
|
526
|
+
display="inline-block"
|
|
527
|
+
margin="small"
|
|
528
|
+
padding="small"
|
|
529
|
+
background="primary"
|
|
530
|
+
borderRadius="medium"
|
|
531
|
+
borderWidth="small"
|
|
532
|
+
position="relative"
|
|
533
|
+
withFocusOutline={isFocused}
|
|
534
|
+
focusColor={focusColor}
|
|
535
|
+
focusPosition={inset ? 'inset' : 'offset'}
|
|
536
|
+
>
|
|
537
|
+
medium
|
|
538
|
+
</View>
|
|
539
|
+
<View
|
|
540
|
+
display="inline-block"
|
|
541
|
+
margin="small"
|
|
542
|
+
padding="small"
|
|
543
|
+
background="primary"
|
|
544
|
+
borderRadius="large"
|
|
545
|
+
borderWidth="small"
|
|
546
|
+
position="relative"
|
|
547
|
+
withFocusOutline={isFocused}
|
|
548
|
+
focusColor={focusColor}
|
|
549
|
+
focusPosition={inset ? 'inset' : 'offset'}
|
|
550
|
+
>
|
|
551
|
+
large
|
|
552
|
+
</View>
|
|
553
|
+
<View
|
|
554
|
+
display="inline-block"
|
|
555
|
+
height="100px"
|
|
556
|
+
width="100px"
|
|
557
|
+
margin="small"
|
|
558
|
+
background="primary"
|
|
559
|
+
borderRadius="circle"
|
|
560
|
+
borderWidth="small"
|
|
561
|
+
position="relative"
|
|
562
|
+
withFocusOutline={isFocused}
|
|
563
|
+
focusColor={focusColor}
|
|
564
|
+
focusPosition={inset ? 'inset' : 'offset'}
|
|
565
|
+
>
|
|
566
|
+
<Flex
|
|
567
|
+
width="100%"
|
|
568
|
+
height="100%"
|
|
569
|
+
alignItems="center"
|
|
570
|
+
justifyItems="center"
|
|
571
|
+
>
|
|
572
|
+
<Flex.Item>circle</Flex.Item>
|
|
573
|
+
</Flex>
|
|
574
|
+
</View>
|
|
575
|
+
<View
|
|
576
|
+
background="primary-inverse"
|
|
577
|
+
display="inline-block"
|
|
578
|
+
padding="small"
|
|
579
|
+
>
|
|
580
|
+
<View
|
|
581
|
+
display="block"
|
|
582
|
+
margin="small"
|
|
583
|
+
padding="small"
|
|
584
|
+
background="primary-inverse"
|
|
585
|
+
borderRadius="large"
|
|
586
|
+
borderWidth="small"
|
|
587
|
+
position="relative"
|
|
588
|
+
withFocusOutline={isFocused}
|
|
589
|
+
focusColor={focusColor}
|
|
590
|
+
focusColor="inverse"
|
|
591
|
+
focusPosition={inset ? 'inset' : 'offset'}
|
|
592
|
+
>
|
|
593
|
+
medium
|
|
594
|
+
</View>
|
|
595
|
+
</View>
|
|
596
|
+
<View
|
|
597
|
+
display="inline-block"
|
|
598
|
+
margin="small"
|
|
599
|
+
padding="small"
|
|
600
|
+
background="primary"
|
|
601
|
+
borderRadius="pill"
|
|
602
|
+
borderWidth="small"
|
|
603
|
+
position="relative"
|
|
604
|
+
focusColor="success"
|
|
605
|
+
width="100px"
|
|
606
|
+
textAlign="center"
|
|
607
|
+
focusColor={focusColor}
|
|
608
|
+
withFocusOutline={isFocused}
|
|
609
|
+
focusPosition={inset ? 'inset' : 'offset'}
|
|
610
|
+
>
|
|
611
|
+
pill
|
|
612
|
+
</View>
|
|
613
|
+
<View
|
|
614
|
+
display="inline-block"
|
|
615
|
+
margin="small"
|
|
616
|
+
padding="small"
|
|
617
|
+
background="primary"
|
|
618
|
+
borderWidth="small"
|
|
619
|
+
borderRadius="none large"
|
|
620
|
+
focusColor="danger"
|
|
621
|
+
position="relative"
|
|
622
|
+
focusColor={focusColor}
|
|
623
|
+
withFocusOutline={isFocused}
|
|
624
|
+
focusPosition={inset ? 'inset' : 'offset'}
|
|
625
|
+
>
|
|
626
|
+
none large
|
|
627
|
+
</View>
|
|
628
|
+
</View>
|
|
629
|
+
</View>
|
|
630
|
+
)
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
render(<FocusedExample />)
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
Handle vertical and horizontal content overflow with the `overflowX` and `overflowY`
|
|
637
|
+
props.
|
|
638
|
+
|
|
639
|
+
> **Important CSS note:** Setting one axis to `visible` and setting the other to a different value results in `visible` behaving as `auto`.
|
|
640
|
+
|
|
641
|
+
```js
|
|
642
|
+
---
|
|
643
|
+
type: example
|
|
644
|
+
---
|
|
645
|
+
const OverflowExample = () => {
|
|
646
|
+
const [overflowY, setOverflowY] = useState('visible')
|
|
647
|
+
const [overflowX, setOverflowX] = useState('visible')
|
|
648
|
+
|
|
649
|
+
const updateOverflowY = (event, value) => {
|
|
650
|
+
setOverflowY(value)
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
const updateOverflowX = (event, value) => {
|
|
654
|
+
setOverflowX(value)
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
return (
|
|
658
|
+
<View as="div">
|
|
659
|
+
<FormFieldGroup
|
|
660
|
+
description={
|
|
661
|
+
<ScreenReaderContent>Overflow example</ScreenReaderContent>
|
|
662
|
+
}
|
|
663
|
+
rowSpacing="small"
|
|
664
|
+
vAlign="top"
|
|
665
|
+
layout="columns"
|
|
666
|
+
>
|
|
667
|
+
<RadioInputGroup
|
|
668
|
+
onChange={updateOverflowY}
|
|
669
|
+
name="overflowY"
|
|
670
|
+
defaultValue="visible"
|
|
671
|
+
variant="toggle"
|
|
672
|
+
description="overflowY ="
|
|
673
|
+
>
|
|
674
|
+
<RadioInput label="visible" value="visible" />
|
|
675
|
+
<RadioInput label="auto" value="auto" />
|
|
676
|
+
<RadioInput label="hidden" value="hidden" />
|
|
677
|
+
</RadioInputGroup>
|
|
678
|
+
<RadioInputGroup
|
|
679
|
+
onChange={updateOverflowX}
|
|
680
|
+
name="overflowX"
|
|
681
|
+
defaultValue="visible"
|
|
682
|
+
variant="toggle"
|
|
683
|
+
description="overflowX ="
|
|
684
|
+
>
|
|
685
|
+
<RadioInput label="visible" value="visible" />
|
|
686
|
+
<RadioInput label="auto" value="auto" />
|
|
687
|
+
<RadioInput label="hidden" value="hidden" />
|
|
688
|
+
</RadioInputGroup>
|
|
689
|
+
</FormFieldGroup>
|
|
690
|
+
<View
|
|
691
|
+
as="div"
|
|
692
|
+
height="7rem"
|
|
693
|
+
width="20rem"
|
|
694
|
+
margin="medium none x-large"
|
|
695
|
+
overflowY={overflowY}
|
|
696
|
+
overflowX={overflowX}
|
|
697
|
+
withVisualDebug
|
|
698
|
+
>
|
|
699
|
+
<div style={{ width: '30rem', height: '10rem' }}>
|
|
700
|
+
<Img src={avatarSquare} constrain="cover" />
|
|
701
|
+
</div>
|
|
702
|
+
</View>
|
|
703
|
+
</View>
|
|
704
|
+
)
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
render(<OverflowExample />)
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
### Debugging
|
|
711
|
+
|
|
712
|
+
Set the `withVisualDebug` prop to see the View's boundaries. Use this only for debugging.
|
|
713
|
+
|
|
714
|
+
> This effect uses a CSS box-shadow, so the `shadow` prop will be overridden
|
|
715
|
+
|
|
716
|
+
```js
|
|
717
|
+
---
|
|
718
|
+
type: example
|
|
719
|
+
---
|
|
720
|
+
<div>
|
|
721
|
+
<View
|
|
722
|
+
as="div"
|
|
723
|
+
padding="large"
|
|
724
|
+
withVisualDebug
|
|
725
|
+
>
|
|
726
|
+
{lorem.sentence()}
|
|
727
|
+
</View>
|
|
728
|
+
<View
|
|
729
|
+
as="div"
|
|
730
|
+
display="flex"
|
|
731
|
+
withVisualDebug
|
|
732
|
+
>
|
|
733
|
+
<View
|
|
734
|
+
as="div"
|
|
735
|
+
margin="small"
|
|
736
|
+
padding="small"
|
|
737
|
+
withVisualDebug
|
|
738
|
+
>
|
|
739
|
+
{lorem.sentence()}
|
|
740
|
+
</View>
|
|
741
|
+
<View
|
|
742
|
+
as="div"
|
|
743
|
+
margin="small"
|
|
744
|
+
padding="small"
|
|
745
|
+
withVisualDebug
|
|
746
|
+
>
|
|
747
|
+
{lorem.sentence()}
|
|
748
|
+
</View>
|
|
749
|
+
</View>
|
|
750
|
+
</div>
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
### The `as` prop
|
|
754
|
+
|
|
755
|
+
Change the `as` prop to set what element the View should render as.
|
|
756
|
+
In the example below a `<section>` wraps a `<header>` and a paragraph of content.
|
|
757
|
+
The outermost `<section>` View provides padding for all the content, while
|
|
758
|
+
the header and paragraph are separated by bottom margin from the `<header>` View.
|
|
759
|
+
|
|
760
|
+
```js
|
|
761
|
+
---
|
|
762
|
+
type: example
|
|
763
|
+
---
|
|
764
|
+
<View
|
|
765
|
+
as="section"
|
|
766
|
+
padding="small"
|
|
767
|
+
withVisualDebug
|
|
768
|
+
>
|
|
769
|
+
<View
|
|
770
|
+
as="header"
|
|
771
|
+
margin="0 0 medium"
|
|
772
|
+
withVisualDebug
|
|
773
|
+
>
|
|
774
|
+
Some header content
|
|
775
|
+
</View>
|
|
776
|
+
<Text as="p">{lorem.paragraph()}</Text>
|
|
777
|
+
</View>
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
### Inline Views
|
|
781
|
+
|
|
782
|
+
By default, View will render as a span which displays inline. When using the `as`
|
|
783
|
+
prop to render a block level element, setting `display` to `inline-block`, styles
|
|
784
|
+
the View to display inline-block with other inline elements.
|
|
785
|
+
|
|
786
|
+
```js
|
|
787
|
+
---
|
|
788
|
+
type: example
|
|
789
|
+
---
|
|
790
|
+
<View as="div" textAlign="center" padding="x-small" withVisualDebug>
|
|
791
|
+
<View
|
|
792
|
+
as="div"
|
|
793
|
+
display="inline-block"
|
|
794
|
+
withVisualDebug
|
|
795
|
+
textAlign="end"
|
|
796
|
+
margin="large auto"
|
|
797
|
+
padding="0 small 0 0"
|
|
798
|
+
>
|
|
799
|
+
{lorem.sentence()}
|
|
800
|
+
</View>
|
|
801
|
+
<Button color="success">Some Action</Button>
|
|
802
|
+
</View>
|
|
803
|
+
```
|