@splunk/react-ui 5.7.1 → 5.8.0
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/Accordion.js +6 -6
- package/Box.js +83 -34
- package/CHANGELOG.md +29 -0
- package/CollapsiblePanel.js +11 -11
- package/ComboBox.js +31 -27
- package/ControlGroup.js +92 -91
- package/DefinitionList.js +9 -9
- package/Drawer.d.ts +2 -0
- package/Drawer.js +679 -0
- package/DualListbox.js +1 -1
- package/JSONTree.js +73 -72
- package/Link.js +2 -2
- package/MIGRATION.md +10 -0
- package/Menu.js +338 -240
- package/Modal.js +127 -109
- package/Multiselect.js +437 -351
- package/Paginator.js +14 -12
- package/Popover.js +4 -1
- package/README.md +11 -0
- package/RadioBar.js +1 -1
- package/Search.js +103 -88
- package/Select.js +42 -40
- package/SelectBase.js +374 -328
- package/SidePanel.js +346 -167
- package/SlidingPanels.js +11 -11
- package/StepBar.js +7 -7
- package/Switch.js +5 -5
- package/Text.js +24 -24
- package/TextArea.js +7 -7
- package/TransitionOpen.js +188 -169
- package/docs-llm/Accordion.md +267 -0
- package/docs-llm/Anchor Menu.md +115 -0
- package/docs-llm/Anchor.md +54 -0
- package/docs-llm/AnimationToggle.md +254 -0
- package/docs-llm/Avatar.md +298 -0
- package/docs-llm/Badge.md +212 -0
- package/docs-llm/Breadcrumbs.md +306 -0
- package/docs-llm/Button Group.md +53 -0
- package/docs-llm/Button.md +361 -0
- package/docs-llm/Card Layout.md +286 -0
- package/docs-llm/Card.md +619 -0
- package/docs-llm/Checkbox.md +218 -0
- package/docs-llm/Chip.md +291 -0
- package/docs-llm/Clickable.md +160 -0
- package/docs-llm/Code.md +292 -0
- package/docs-llm/Collapsible Panel.md +744 -0
- package/docs-llm/Color.md +253 -0
- package/docs-llm/Column Layout.md +391 -0
- package/docs-llm/Combo Box.md +540 -0
- package/docs-llm/Control Group.md +594 -0
- package/docs-llm/Date.md +270 -0
- package/docs-llm/Definition List.md +278 -0
- package/docs-llm/Divider.md +216 -0
- package/docs-llm/Drawer.md +414 -0
- package/docs-llm/Dropdown.md +472 -0
- package/docs-llm/Dual Listbox.md +325 -0
- package/docs-llm/File.md +653 -0
- package/docs-llm/Form Rows.md +374 -0
- package/docs-llm/Heading.md +179 -0
- package/docs-llm/Image.md +109 -0
- package/docs-llm/JSON Tree.md +260 -0
- package/docs-llm/Layer.md +74 -0
- package/docs-llm/Layout.md +50 -0
- package/docs-llm/Link.md +318 -0
- package/docs-llm/List.md +189 -0
- package/docs-llm/Markdown.md +179 -0
- package/docs-llm/Menu.md +735 -0
- package/docs-llm/Message Bar.md +236 -0
- package/docs-llm/Message.md +248 -0
- package/docs-llm/Modal.md +443 -0
- package/docs-llm/Monogram.md +159 -0
- package/docs-llm/Multiselect.md +937 -0
- package/docs-llm/Number.md +298 -0
- package/docs-llm/Paginator.md +395 -0
- package/docs-llm/Paragraph.md +148 -0
- package/docs-llm/Phone Number.md +254 -0
- package/docs-llm/Popover.md +166 -0
- package/docs-llm/Progress.md +141 -0
- package/docs-llm/Radio Bar.md +303 -0
- package/docs-llm/Radio List.md +350 -0
- package/docs-llm/Resize.md +362 -0
- package/docs-llm/Screen Reader Content.md +73 -0
- package/docs-llm/Scroll Container Context.md +155 -0
- package/docs-llm/Scroll.md +152 -0
- package/docs-llm/Search.md +381 -0
- package/docs-llm/Select.md +985 -0
- package/docs-llm/Side Panel.md +777 -0
- package/docs-llm/Slider.md +339 -0
- package/docs-llm/Sliding Panels.md +340 -0
- package/docs-llm/Split Button.md +295 -0
- package/docs-llm/Static Content.md +90 -0
- package/docs-llm/Step Bar.md +292 -0
- package/docs-llm/Switch.md +268 -0
- package/docs-llm/Tab Bar.md +439 -0
- package/docs-llm/Tab Layout.md +398 -0
- package/docs-llm/Table.md +2642 -0
- package/docs-llm/Text Area.md +253 -0
- package/docs-llm/Text.md +339 -0
- package/docs-llm/Tooltip.md +325 -0
- package/docs-llm/Transition Open.md +406 -0
- package/docs-llm/Tree.md +586 -0
- package/docs-llm/Typography.md +125 -0
- package/docs-llm/Wait Spinner.md +121 -0
- package/docs-llm/llms.txt +97 -0
- package/package.json +6 -5
- package/types/src/Box/Box.d.ts +2 -10
- package/types/src/Drawer/Body.d.ts +17 -0
- package/types/src/Drawer/Drawer.d.ts +114 -0
- package/types/src/Drawer/DrawerContext.d.ts +11 -0
- package/types/src/Drawer/Footer.d.ts +25 -0
- package/types/src/Drawer/Header.d.ts +41 -0
- package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
- package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
- package/types/src/Drawer/index.d.ts +2 -0
- package/types/src/JSONTree/JSONTree.d.ts +12 -5
- package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
- package/types/src/Menu/Item.d.ts +2 -1
- package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
- package/types/src/Modal/Modal.d.ts +1 -2
- package/types/src/Select/Option.d.ts +6 -3
- package/types/src/Select/Select.d.ts +8 -5
- package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
- package/types/src/SelectBase/OptionBase.d.ts +6 -3
- package/types/src/SelectBase/SelectBase.d.ts +8 -3
- package/types/src/SidePanel/SidePanel.d.ts +43 -2
- package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
- package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
- package/types/src/useKeyPress/index.d.ts +9 -2
- package/types/src/useOnClickOutside/index.d.ts +2 -0
- package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
- package/useKeyPress.js +23 -18
- package/useOnClickOutside.d.ts +2 -0
- package/useOnClickOutside.js +79 -0
- package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Color
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of a Color component.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
- You need to allow users to select a specific color, such as customizing the look and feel of a dashboard, data visualization or other customizeable element.
|
|
11
|
+
|
|
12
|
+
## When to use another component
|
|
13
|
+
- If you have a list of predefined options consider using a Radio list or Select.
|
|
14
|
+
- If you only need to capture a hex value for data-entry purposes use Text.
|
|
15
|
+
|
|
16
|
+
```mermaid
|
|
17
|
+
graph TD
|
|
18
|
+
accDescr: Decision tree that guides on when to use the Color component or something else
|
|
19
|
+
A(Does the user need to select or input a custom color?) -- Yes --- B(Color picker)
|
|
20
|
+
A -- No --- C(Radio List, Text, or Select)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Check out
|
|
24
|
+
- [Radio List][1]
|
|
25
|
+
- [Select][2]
|
|
26
|
+
- [Text][3]
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Number of options
|
|
31
|
+
#### Limit choices
|
|
32
|
+
Avoid overwhelming users with too many options, this can increase cognitive load.
|
|
33
|
+
|
|
34
|
+
> Image: Example laying emphasis on number of color swatch options provided to the user. The first example with the heart eyes emoji displays The color component to have 20 color swatch options, whereas the second example with the grimacing emoji displays the Color component to have too many color swatch options available. This could increase cognitive load for the user (according to Miller
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#### Too few options
|
|
38
|
+
Avoid limiting users with too few color options, this can make them feel restricted and unable to fully express their preferences or align with their brand identity.
|
|
39
|
+
|
|
40
|
+
> Image: Example laying emphasis on number of color swatch options provided to the user. The first example with the heart eyes emoji displays the Color component to have 20 color swatch options, whereas the second example with the grimacing emoji displays the Color component to have too few color swatch options available. This could make users feel restricted.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Color preview
|
|
44
|
+
Showcase a live color preview of the chosen color. This provides real-time visual feedback ensuring the user is confident in their selection.
|
|
45
|
+
|
|
46
|
+
> Image: Example showcasing the significance of visually displaying the selected color to the user. The first example with the heart eyes emoji displays the Color component to showcase the selected color visually, whereas the second example with the grimacing emoji displays the Color component to only display the hex value of the selected color.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Text preview
|
|
50
|
+
When possible, set the hideInput property to false to display the input field, ensuring inclusive design with text and color affordances.
|
|
51
|
+
|
|
52
|
+
> Image: Example showcasing the significance of displaying the text input field to the user. The first example with the heart eyes emoji displays the Color component to showcase the selected color with both a color swatch and a text input, whereas the second example with the grimacing emoji displays the Color component to only display the color swatch of the selected color.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
[1]: ./RadioList
|
|
56
|
+
[2]: ./Select
|
|
57
|
+
[3]: ./Text
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Uncontrolled
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import React from 'react';
|
|
66
|
+
|
|
67
|
+
import Color from '@splunk/react-ui/Color';
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
function Uncontrolled() {
|
|
71
|
+
return <Color defaultValue="#F29BAC" />;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default Uncontrolled;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Controlled
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import React, { useState } from 'react';
|
|
83
|
+
|
|
84
|
+
import Color, { ColorChangeHandler } from '@splunk/react-ui/Color';
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
function Controlled() {
|
|
88
|
+
const [colorValue, setColorValue] = useState<string | null | undefined>('#000000');
|
|
89
|
+
|
|
90
|
+
const handleChange: ColorChangeHandler = ({ value }) => {
|
|
91
|
+
setColorValue(value);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return <Color value={colorValue} onChange={handleChange} />;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default Controlled;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### Theme Variables
|
|
103
|
+
|
|
104
|
+
Variables from @splunk/themes can be used to set Color values, such as defaultValue.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import React from 'react';
|
|
108
|
+
|
|
109
|
+
import Color, { defaultPalette } from '@splunk/react-ui/Color';
|
|
110
|
+
import useSplunkTheme from '@splunk/themes/useSplunkTheme';
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
export default function ThemeVariables() {
|
|
114
|
+
const { syntaxTeal } = useSplunkTheme();
|
|
115
|
+
|
|
116
|
+
const palette = [...defaultPalette, syntaxTeal];
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div style={{ width: 170 }}>
|
|
120
|
+
<Color defaultValue={syntaxTeal} palette={palette} />
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Transparent
|
|
129
|
+
|
|
130
|
+
Including transparent in the palette is supported. Put this option at the start or end of the palette.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import React from 'react';
|
|
134
|
+
|
|
135
|
+
import Color, { defaultPalette } from '@splunk/react-ui/Color';
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
function Transparent() {
|
|
139
|
+
return <Color defaultValue="transparent" palette={['transparent', ...defaultPalette]} />;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default Transparent;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
### N/A
|
|
148
|
+
|
|
149
|
+
Including N/A in the palette is supported. Put this option at the start or end of the palette. Selecting N/A will return null.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import React, { useState } from 'react';
|
|
153
|
+
|
|
154
|
+
import Color, { ColorChangeHandler } from '@splunk/react-ui/Color';
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
function Null() {
|
|
158
|
+
const [colorValue, setColorValue] = useState<string | null | undefined>(null);
|
|
159
|
+
|
|
160
|
+
const handleChange: ColorChangeHandler = ({ value }) => {
|
|
161
|
+
setColorValue(value);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
return <Color value={colorValue} onChange={handleChange} />;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export default Null;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
### Customized Palette
|
|
173
|
+
|
|
174
|
+
Color has defaultPalette exported which can be modified.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import React from 'react';
|
|
178
|
+
|
|
179
|
+
import Color, { defaultPalette } from '@splunk/react-ui/Color';
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
export default function CustomizedPalette() {
|
|
183
|
+
const customSwatches = [
|
|
184
|
+
'#53a051',
|
|
185
|
+
'#62b3b2',
|
|
186
|
+
'#4fa484',
|
|
187
|
+
'#f8be44',
|
|
188
|
+
'#5a4575',
|
|
189
|
+
'#708794',
|
|
190
|
+
'#294e70',
|
|
191
|
+
'#b6c75a',
|
|
192
|
+
];
|
|
193
|
+
const myPalette = [...customSwatches, ...defaultPalette];
|
|
194
|
+
|
|
195
|
+
return <Color defaultValue="#4fa484" palette={myPalette} />;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
### Hide Input
|
|
202
|
+
|
|
203
|
+
Color without hex value text input. The input will still appear inside the dropdown when opened.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import React from 'react';
|
|
207
|
+
|
|
208
|
+
import Color from '@splunk/react-ui/Color';
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
function HideInput() {
|
|
212
|
+
return <Color hideInput defaultValue="#912344" />;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export default HideInput;
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
## API
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
### Color API
|
|
225
|
+
|
|
226
|
+
#### Props
|
|
227
|
+
|
|
228
|
+
| Name | Type | Required | Default | Description |
|
|
229
|
+
|------|------|------|------|------|
|
|
230
|
+
| append | boolean | no | | Append removes border from the right side. |
|
|
231
|
+
| defaultValue | string \| null | no | | Set this property instead of value to make value uncontrolled. |
|
|
232
|
+
| describedBy | string | no | | The id of the description. When placed in a ControlGroup, this is automatically set to the ControlGroup's help component. |
|
|
233
|
+
| disabled | boolean | no | | Add a disabled attribute and prevent clicking. |
|
|
234
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
235
|
+
| error | boolean | no | | Add an error attribute. |
|
|
236
|
+
| hideInput | boolean | no | | Set this property to hide the hex value text input in the initial appearance. The input will still appear inside the dropdown when opened. |
|
|
237
|
+
| labelledBy | string | no | | The id of the label. When placed in a ControlGroup, this is automatically set to the ControlGroup's label. |
|
|
238
|
+
| name | string | no | | The name is returned with onChange events, which can be used to identify the control when multiple controls share an onChange callback. |
|
|
239
|
+
| onChange | ColorChangeHandler | no | | A callback that receives the value of a newly selected color. |
|
|
240
|
+
| palette | (string \| null)[] | no | defaultPalette | An array of optional color swatch values (hexadecimal or 'transparent'). The 'transparent' option should only be put at the start or end of the palette. |
|
|
241
|
+
| prepend | boolean | no | | This has no effect on the appearance at this time but is recommended to be used when a control is joined to the left. Styles may change in the future. |
|
|
242
|
+
| value | string \| null | no | | The value of the color (hexadecimal or 'transparent'). Setting this value makes the property controlled. An `onChange` callback is required. |
|
|
243
|
+
|
|
244
|
+
#### Types
|
|
245
|
+
|
|
246
|
+
| Name | Type | Description |
|
|
247
|
+
|------|------|------|
|
|
248
|
+
| ColorChangeHandler | (data: { name?: string; value?: string \| null }) => void | |
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
# Column Layout
|
|
2
|
+
|
|
3
|
+
## Examples
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Columns and Spans
|
|
7
|
+
|
|
8
|
+
The span property can be set to vary the width of the Columns. The spans must add up to 12. The Columns are colored for this example.
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import React from 'react';
|
|
12
|
+
|
|
13
|
+
import ColumnLayout from '@splunk/react-ui/ColumnLayout';
|
|
14
|
+
import { useSplunkTheme } from '@splunk/themes';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
function Basic() {
|
|
18
|
+
const { syntaxBlue } = useSplunkTheme();
|
|
19
|
+
const colStyle: React.CSSProperties = {
|
|
20
|
+
border: `1px solid ${syntaxBlue}`,
|
|
21
|
+
padding: 10,
|
|
22
|
+
minHeight: 80,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ColumnLayout>
|
|
27
|
+
<ColumnLayout.Row>
|
|
28
|
+
<ColumnLayout.Column style={colStyle}>1</ColumnLayout.Column>
|
|
29
|
+
<ColumnLayout.Column style={colStyle}>2</ColumnLayout.Column>
|
|
30
|
+
<ColumnLayout.Column style={colStyle}>3</ColumnLayout.Column>
|
|
31
|
+
<ColumnLayout.Column style={colStyle}>4</ColumnLayout.Column>
|
|
32
|
+
<ColumnLayout.Column style={colStyle}>5</ColumnLayout.Column>
|
|
33
|
+
<ColumnLayout.Column style={colStyle}>6</ColumnLayout.Column>
|
|
34
|
+
<ColumnLayout.Column style={colStyle}>7</ColumnLayout.Column>
|
|
35
|
+
<ColumnLayout.Column style={colStyle}>8</ColumnLayout.Column>
|
|
36
|
+
<ColumnLayout.Column style={colStyle}>9</ColumnLayout.Column>
|
|
37
|
+
<ColumnLayout.Column style={colStyle}>10</ColumnLayout.Column>
|
|
38
|
+
<ColumnLayout.Column style={colStyle}>11</ColumnLayout.Column>
|
|
39
|
+
<ColumnLayout.Column style={colStyle}>12</ColumnLayout.Column>
|
|
40
|
+
</ColumnLayout.Row>
|
|
41
|
+
<ColumnLayout.Row>
|
|
42
|
+
<ColumnLayout.Column style={colStyle} span={4}>
|
|
43
|
+
Span 4
|
|
44
|
+
</ColumnLayout.Column>
|
|
45
|
+
<ColumnLayout.Column style={colStyle} span={8}>
|
|
46
|
+
Span 8
|
|
47
|
+
</ColumnLayout.Column>
|
|
48
|
+
</ColumnLayout.Row>
|
|
49
|
+
<ColumnLayout.Row>
|
|
50
|
+
<ColumnLayout.Column style={colStyle} span={2}>
|
|
51
|
+
Span 2
|
|
52
|
+
</ColumnLayout.Column>
|
|
53
|
+
<ColumnLayout.Column style={colStyle} span={5}>
|
|
54
|
+
Span 5
|
|
55
|
+
</ColumnLayout.Column>
|
|
56
|
+
<ColumnLayout.Column style={colStyle} span={5}>
|
|
57
|
+
Span 5
|
|
58
|
+
</ColumnLayout.Column>
|
|
59
|
+
</ColumnLayout.Row>
|
|
60
|
+
<ColumnLayout.Row>
|
|
61
|
+
<ColumnLayout.Column style={colStyle} span={6}>
|
|
62
|
+
Span 6
|
|
63
|
+
</ColumnLayout.Column>
|
|
64
|
+
<ColumnLayout.Column style={colStyle} span={3}>
|
|
65
|
+
Span 3
|
|
66
|
+
</ColumnLayout.Column>
|
|
67
|
+
<ColumnLayout.Column style={colStyle} span={3}>
|
|
68
|
+
Span 3
|
|
69
|
+
</ColumnLayout.Column>
|
|
70
|
+
</ColumnLayout.Row>
|
|
71
|
+
</ColumnLayout>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default Basic;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
### Gutters
|
|
81
|
+
|
|
82
|
+
Column Layout spaces Rows and Columns with gutters, but these can be removed or changed.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import React from 'react';
|
|
86
|
+
|
|
87
|
+
import ColumnLayout from '@splunk/react-ui/ColumnLayout';
|
|
88
|
+
import Heading from '@splunk/react-ui/Heading';
|
|
89
|
+
import { useSplunkTheme } from '@splunk/themes';
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
function Gutters() {
|
|
93
|
+
const { syntaxBlue } = useSplunkTheme();
|
|
94
|
+
const colStyle: React.CSSProperties = {
|
|
95
|
+
border: `1px solid ${syntaxBlue}`,
|
|
96
|
+
padding: 10,
|
|
97
|
+
minHeight: 80,
|
|
98
|
+
};
|
|
99
|
+
const headingStyle: React.CSSProperties = {
|
|
100
|
+
margin: '1.414em 0 0.4em',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div>
|
|
105
|
+
<Heading level={4} style={headingStyle}>
|
|
106
|
+
8px gutter
|
|
107
|
+
</Heading>
|
|
108
|
+
<ColumnLayout gutter={8}>
|
|
109
|
+
<ColumnLayout.Row>
|
|
110
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
111
|
+
1 of 2
|
|
112
|
+
</ColumnLayout.Column>
|
|
113
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
114
|
+
2 of 2
|
|
115
|
+
</ColumnLayout.Column>
|
|
116
|
+
</ColumnLayout.Row>
|
|
117
|
+
<ColumnLayout.Row>
|
|
118
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
119
|
+
1 of 3
|
|
120
|
+
</ColumnLayout.Column>
|
|
121
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
122
|
+
2 of 3
|
|
123
|
+
</ColumnLayout.Column>
|
|
124
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
125
|
+
2 of 3
|
|
126
|
+
</ColumnLayout.Column>
|
|
127
|
+
</ColumnLayout.Row>
|
|
128
|
+
</ColumnLayout>
|
|
129
|
+
<Heading level={4} style={headingStyle}>
|
|
130
|
+
0px gutter
|
|
131
|
+
</Heading>
|
|
132
|
+
<ColumnLayout gutter={0}>
|
|
133
|
+
<ColumnLayout.Row>
|
|
134
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
135
|
+
1 of 2
|
|
136
|
+
</ColumnLayout.Column>
|
|
137
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
138
|
+
2 of 2
|
|
139
|
+
</ColumnLayout.Column>
|
|
140
|
+
</ColumnLayout.Row>
|
|
141
|
+
<ColumnLayout.Row>
|
|
142
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
143
|
+
1 of 3
|
|
144
|
+
</ColumnLayout.Column>
|
|
145
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
146
|
+
2 of 3
|
|
147
|
+
</ColumnLayout.Column>
|
|
148
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
149
|
+
2 of 3
|
|
150
|
+
</ColumnLayout.Column>
|
|
151
|
+
</ColumnLayout.Row>
|
|
152
|
+
</ColumnLayout>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default Gutters;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Dividers
|
|
163
|
+
|
|
164
|
+
Column Layout can show different types of dividers.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import React from 'react';
|
|
168
|
+
|
|
169
|
+
import ColumnLayout from '@splunk/react-ui/ColumnLayout';
|
|
170
|
+
import Heading from '@splunk/react-ui/Heading';
|
|
171
|
+
import { useSplunkTheme } from '@splunk/themes';
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
function Dividers() {
|
|
175
|
+
const { syntaxBlue } = useSplunkTheme();
|
|
176
|
+
const colStyle: React.CSSProperties = {
|
|
177
|
+
border: `1px solid ${syntaxBlue}`,
|
|
178
|
+
padding: 10,
|
|
179
|
+
minHeight: 80,
|
|
180
|
+
};
|
|
181
|
+
const headingStyle: React.CSSProperties = {
|
|
182
|
+
margin: '1.414em 0 0.4em',
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div>
|
|
187
|
+
<Heading level={4} style={headingStyle}>
|
|
188
|
+
Vertical dividers
|
|
189
|
+
</Heading>
|
|
190
|
+
<ColumnLayout divider="vertical">
|
|
191
|
+
<ColumnLayout.Row>
|
|
192
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
193
|
+
1 of 2
|
|
194
|
+
</ColumnLayout.Column>
|
|
195
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
196
|
+
2 of 2
|
|
197
|
+
</ColumnLayout.Column>
|
|
198
|
+
</ColumnLayout.Row>
|
|
199
|
+
<ColumnLayout.Row>
|
|
200
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
201
|
+
1 of 3
|
|
202
|
+
</ColumnLayout.Column>
|
|
203
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
204
|
+
2 of 3
|
|
205
|
+
</ColumnLayout.Column>
|
|
206
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
207
|
+
2 of 3
|
|
208
|
+
</ColumnLayout.Column>
|
|
209
|
+
</ColumnLayout.Row>
|
|
210
|
+
</ColumnLayout>
|
|
211
|
+
<Heading level={4} style={headingStyle}>
|
|
212
|
+
Horizontal dividers
|
|
213
|
+
</Heading>
|
|
214
|
+
<ColumnLayout divider="horizontal">
|
|
215
|
+
<ColumnLayout.Row>
|
|
216
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
217
|
+
1 of 2
|
|
218
|
+
</ColumnLayout.Column>
|
|
219
|
+
<ColumnLayout.Column span={6} style={colStyle}>
|
|
220
|
+
2 of 2
|
|
221
|
+
</ColumnLayout.Column>
|
|
222
|
+
</ColumnLayout.Row>
|
|
223
|
+
<ColumnLayout.Row>
|
|
224
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
225
|
+
1 of 3
|
|
226
|
+
</ColumnLayout.Column>
|
|
227
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
228
|
+
2 of 3
|
|
229
|
+
</ColumnLayout.Column>
|
|
230
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
231
|
+
2 of 3
|
|
232
|
+
</ColumnLayout.Column>
|
|
233
|
+
</ColumnLayout.Row>
|
|
234
|
+
</ColumnLayout>
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export default Dividers;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
### Align Items
|
|
245
|
+
|
|
246
|
+
By default, the Columns grow vertically to fill the available space. The values for this property are the same as flexbox's align-items property.
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
import React from 'react';
|
|
250
|
+
|
|
251
|
+
import ColumnLayout from '@splunk/react-ui/ColumnLayout';
|
|
252
|
+
import { useSplunkTheme } from '@splunk/themes';
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
function AlignItems() {
|
|
256
|
+
const { syntaxBlue } = useSplunkTheme();
|
|
257
|
+
const colStyle: React.CSSProperties = { border: `1px solid ${syntaxBlue}`, padding: 10 };
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<ColumnLayout>
|
|
261
|
+
<ColumnLayout.Row alignItems="stretch">
|
|
262
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
263
|
+
A short column can stretch to fill the space.
|
|
264
|
+
</ColumnLayout.Column>
|
|
265
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
266
|
+
A tall
|
|
267
|
+
<br />
|
|
268
|
+
column defines
|
|
269
|
+
<br />
|
|
270
|
+
the height
|
|
271
|
+
<br />
|
|
272
|
+
of the row.
|
|
273
|
+
</ColumnLayout.Column>
|
|
274
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
275
|
+
Another
|
|
276
|
+
<br />
|
|
277
|
+
column.
|
|
278
|
+
</ColumnLayout.Column>
|
|
279
|
+
</ColumnLayout.Row>
|
|
280
|
+
<ColumnLayout.Row alignItems="start">
|
|
281
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
282
|
+
A short column can align to the start (top) of the row.
|
|
283
|
+
</ColumnLayout.Column>
|
|
284
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
285
|
+
A tall
|
|
286
|
+
<br />
|
|
287
|
+
column defines
|
|
288
|
+
<br />
|
|
289
|
+
the height
|
|
290
|
+
<br />
|
|
291
|
+
of the row.
|
|
292
|
+
</ColumnLayout.Column>
|
|
293
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
294
|
+
Another
|
|
295
|
+
<br />
|
|
296
|
+
column.
|
|
297
|
+
</ColumnLayout.Column>
|
|
298
|
+
</ColumnLayout.Row>
|
|
299
|
+
<ColumnLayout.Row alignItems="end">
|
|
300
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
301
|
+
A short column can align to the end (bottom) of the row.
|
|
302
|
+
</ColumnLayout.Column>
|
|
303
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
304
|
+
A tall
|
|
305
|
+
<br />
|
|
306
|
+
column defines
|
|
307
|
+
<br />
|
|
308
|
+
the height
|
|
309
|
+
<br />
|
|
310
|
+
of the row.
|
|
311
|
+
</ColumnLayout.Column>
|
|
312
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
313
|
+
Another
|
|
314
|
+
<br />
|
|
315
|
+
column.
|
|
316
|
+
</ColumnLayout.Column>
|
|
317
|
+
</ColumnLayout.Row>
|
|
318
|
+
<ColumnLayout.Row alignItems="center">
|
|
319
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
320
|
+
A short column can align to the center (middle) of the row.
|
|
321
|
+
</ColumnLayout.Column>
|
|
322
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
323
|
+
A tall
|
|
324
|
+
<br />
|
|
325
|
+
column defines
|
|
326
|
+
<br />
|
|
327
|
+
the height
|
|
328
|
+
<br />
|
|
329
|
+
of the row.
|
|
330
|
+
</ColumnLayout.Column>
|
|
331
|
+
<ColumnLayout.Column span={4} style={colStyle}>
|
|
332
|
+
Another
|
|
333
|
+
<br />
|
|
334
|
+
column.
|
|
335
|
+
</ColumnLayout.Column>
|
|
336
|
+
</ColumnLayout.Row>
|
|
337
|
+
</ColumnLayout>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export default AlignItems;
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
## API
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
### ColumnLayout API
|
|
351
|
+
|
|
352
|
+
`ColumnLayout` provides simple API for laying out content into columns. It is based on flexbox
|
|
353
|
+
and has 12 columns.
|
|
354
|
+
|
|
355
|
+
#### Props
|
|
356
|
+
|
|
357
|
+
| Name | Type | Required | Default | Description |
|
|
358
|
+
|------|------|------|------|------|
|
|
359
|
+
| children | React.ReactNode | no | | `children` must be `ColumnLayout.Row` elements. |
|
|
360
|
+
| divider | 'none' \| 'vertical' \| 'horizontal' | no | 'none' | Show dividers between columns. |
|
|
361
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
362
|
+
| gutter | number | no | | Set gutter width in pixels. This is propagated down to its `children`. |
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
### ColumnLayout.Row API
|
|
367
|
+
|
|
368
|
+
#### Props
|
|
369
|
+
|
|
370
|
+
| Name | Type | Required | Default | Description |
|
|
371
|
+
|------|------|------|------|------|
|
|
372
|
+
| alignItems | 'start' \| 'end' \| 'center' \| 'stretch' | no | 'stretch' | Set vertical alignment of columns in a row |
|
|
373
|
+
| children | React.ReactNode | no | | `children` must be `ColumnLayout.Column` elements |
|
|
374
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
### ColumnLayout.Column API
|
|
379
|
+
|
|
380
|
+
#### Props
|
|
381
|
+
|
|
382
|
+
| Name | Type | Required | Default | Description |
|
|
383
|
+
|------|------|------|------|------|
|
|
384
|
+
| children | React.ReactNode | no | | |
|
|
385
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
386
|
+
| span | number | no | 1 | The number of columns the element spans. |
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|