@neo4j-ndl/react 4.16.8 → 4.16.9
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/package.json +5 -2
- package/skills/ndl-react/SKILL.md +152 -0
- package/skills/ndl-react/components/accordion.md +386 -0
- package/skills/ndl-react/components/ai/code-preview.md +128 -0
- package/skills/ndl-react/components/ai/file-tag.md +90 -0
- package/skills/ndl-react/components/ai/image-tag.md +91 -0
- package/skills/ndl-react/components/ai/more-files.md +73 -0
- package/skills/ndl-react/components/ai/presence.md +54 -0
- package/skills/ndl-react/components/ai/preview.md +498 -0
- package/skills/ndl-react/components/ai/prompt.md +362 -0
- package/skills/ndl-react/components/ai/reasoning.md +95 -0
- package/skills/ndl-react/components/ai/response.md +1109 -0
- package/skills/ndl-react/components/ai/suggestion.md +84 -0
- package/skills/ndl-react/components/ai/thinking.md +43 -0
- package/skills/ndl-react/components/ai/tool-call.md +43 -0
- package/skills/ndl-react/components/ai/user-bubble.md +187 -0
- package/skills/ndl-react/components/avatar.md +169 -0
- package/skills/ndl-react/components/banner.md +225 -0
- package/skills/ndl-react/components/box.md +39 -0
- package/skills/ndl-react/components/breadcrumbs.md +245 -0
- package/skills/ndl-react/components/checkbox.md +269 -0
- package/skills/ndl-react/components/clean-icon-button.md +294 -0
- package/skills/ndl-react/components/clipboard-button.md +154 -0
- package/skills/ndl-react/components/code-block.md +276 -0
- package/skills/ndl-react/components/code.md +68 -0
- package/skills/ndl-react/components/color-picker.md +131 -0
- package/skills/ndl-react/components/conditional-wrap.md +46 -0
- package/skills/ndl-react/components/data-grid.md +3121 -0
- package/skills/ndl-react/components/date-picker.md +652 -0
- package/skills/ndl-react/components/dialog.md +485 -0
- package/skills/ndl-react/components/dismissible-tag.md +136 -0
- package/skills/ndl-react/components/divider.md +96 -0
- package/skills/ndl-react/components/drawer.md +543 -0
- package/skills/ndl-react/components/dropdown-button.md +161 -0
- package/skills/ndl-react/components/dropzone.md +371 -0
- package/skills/ndl-react/components/filled-button.md +26 -0
- package/skills/ndl-react/components/flex.md +82 -0
- package/skills/ndl-react/components/graph-label.md +167 -0
- package/skills/ndl-react/components/icon-button-array.md +187 -0
- package/skills/ndl-react/components/icon-button.md +193 -0
- package/skills/ndl-react/components/inline-edit.md +209 -0
- package/skills/ndl-react/components/kbd.md +63 -0
- package/skills/ndl-react/components/loading-bar.md +43 -0
- package/skills/ndl-react/components/loading-spinner.md +57 -0
- package/skills/ndl-react/components/logo.md +57 -0
- package/skills/ndl-react/components/menu.md +993 -0
- package/skills/ndl-react/components/modal.md +27 -0
- package/skills/ndl-react/components/next/tree-view.md +966 -0
- package/skills/ndl-react/components/outlined-button.md +26 -0
- package/skills/ndl-react/components/popover.md +283 -0
- package/skills/ndl-react/components/progress-bar.md +70 -0
- package/skills/ndl-react/components/radio.md +150 -0
- package/skills/ndl-react/components/read-only-tag.md +96 -0
- package/skills/ndl-react/components/segmented-control.md +200 -0
- package/skills/ndl-react/components/select-icon-button.md +183 -0
- package/skills/ndl-react/components/select.md +530 -0
- package/skills/ndl-react/components/selectable-tag.md +203 -0
- package/skills/ndl-react/components/side-navigation.md +652 -0
- package/skills/ndl-react/components/skeleton.md +274 -0
- package/skills/ndl-react/components/slider.md +308 -0
- package/skills/ndl-react/components/spotlight.md +796 -0
- package/skills/ndl-react/components/status-indicator.md +57 -0
- package/skills/ndl-react/components/status-label.md +132 -0
- package/skills/ndl-react/components/switch.md +167 -0
- package/skills/ndl-react/components/tabs.md +433 -0
- package/skills/ndl-react/components/tag.md +91 -0
- package/skills/ndl-react/components/text-area.md +178 -0
- package/skills/ndl-react/components/text-button.md +25 -0
- package/skills/ndl-react/components/text-input.md +475 -0
- package/skills/ndl-react/components/text-link.md +119 -0
- package/skills/ndl-react/components/time-picker.md +137 -0
- package/skills/ndl-react/components/timezone-picker.md +496 -0
- package/skills/ndl-react/components/tooltip.md +478 -0
- package/skills/ndl-react/components/tree-view.md +545 -0
- package/skills/ndl-react/components/typography.md +72 -0
- package/skills/ndl-react/components/wizard.md +152 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# CodeBlock
|
|
2
|
+
|
|
3
|
+
Import: `import { CodeBlock } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### CodeBlock
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `actions` | `(IconButtonButtonProps & { as?: "button"; } & BaseProps<"button">)[]` | | | |
|
|
12
|
+
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
13
|
+
| `code` | `string` | ✅ | | |
|
|
14
|
+
| `heading` | `ReactNode` | | | |
|
|
15
|
+
| `isDisabled` | `boolean` | | | |
|
|
16
|
+
| `language` | `'asciidoc' \| 'bash' \| 'c' \| 'csharp' \| 'css-extras' \| 'css' \| 'cypher' \| 'docker' \| 'go' \| 'graphql' \| 'java' \| 'javadoc' \| 'javascript' \| 'json' \| 'jsx' \| 'kotlin' \| 'php' \| 'python' \| 'regex' \| 'rust' \| 'sql' \| 'text' \| 'typescript' \| 'xml' \| 'yaml'` | ✅ | | |
|
|
17
|
+
| `maxHeight` | `number` | | | |
|
|
18
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
19
|
+
| `shouldShowLineNumbers` | `boolean` | | | |
|
|
20
|
+
| `theme` | `'base16-ateliersulphurpool.light' \| 'coy' \| 'duotone-light' \| 'ghcolors' \| 'ndl-code-dark' \| 'ndl-code-light' \| 'prism' \| 'solarizedlight' \| 'vs'` | | | |
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### Code Default
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
28
|
+
|
|
29
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
30
|
+
|
|
31
|
+
import { SHORT_CODE_EXAMPLE } from './example-code-snippets';
|
|
32
|
+
|
|
33
|
+
const Component = () => {
|
|
34
|
+
return <CodeBlock code={SHORT_CODE_EXAMPLE} language="typescript" />;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default Component;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Code Disabled
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
44
|
+
|
|
45
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
46
|
+
import {
|
|
47
|
+
PlayCircleIconOutline,
|
|
48
|
+
Square2StackIconOutline,
|
|
49
|
+
} from '@neo4j-ndl/react/icons';
|
|
50
|
+
|
|
51
|
+
import { SHORT_CODE_EXAMPLE } from './example-code-snippets';
|
|
52
|
+
|
|
53
|
+
const Component = () => {
|
|
54
|
+
return (
|
|
55
|
+
<CodeBlock
|
|
56
|
+
code={SHORT_CODE_EXAMPLE}
|
|
57
|
+
language="typescript"
|
|
58
|
+
heading="Code Header"
|
|
59
|
+
isDisabled
|
|
60
|
+
actions={[
|
|
61
|
+
{
|
|
62
|
+
children: (
|
|
63
|
+
<Square2StackIconOutline className="n-text-neutral-text-icon" />
|
|
64
|
+
),
|
|
65
|
+
description: 'copy',
|
|
66
|
+
htmlAttributes: { title: 'copy' },
|
|
67
|
+
onClick: () => alert('This should not trigger when disabled'),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
children: <PlayCircleIconOutline className="n-text-primary-icon" />,
|
|
71
|
+
description: 'run',
|
|
72
|
+
htmlAttributes: { title: 'run' },
|
|
73
|
+
onClick: () => alert('This should not trigger when disabled'),
|
|
74
|
+
},
|
|
75
|
+
]}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default Component;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Code Full
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
87
|
+
|
|
88
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
89
|
+
import {
|
|
90
|
+
PlayCircleIconOutline,
|
|
91
|
+
Square2StackIconOutline,
|
|
92
|
+
} from '@neo4j-ndl/react/icons';
|
|
93
|
+
|
|
94
|
+
import { LONG_CODE_EXAMPLE } from './example-code-snippets';
|
|
95
|
+
|
|
96
|
+
const Component = () => {
|
|
97
|
+
return (
|
|
98
|
+
<CodeBlock
|
|
99
|
+
code={LONG_CODE_EXAMPLE}
|
|
100
|
+
maxHeight={320}
|
|
101
|
+
language="typescript"
|
|
102
|
+
shouldShowLineNumbers
|
|
103
|
+
theme="ndl-code-light"
|
|
104
|
+
heading="Code Header"
|
|
105
|
+
actions={[
|
|
106
|
+
{
|
|
107
|
+
children: (
|
|
108
|
+
<Square2StackIconOutline className="n-text-neutral-text-icon" />
|
|
109
|
+
),
|
|
110
|
+
description: 'copy',
|
|
111
|
+
htmlAttributes: { title: 'copy' },
|
|
112
|
+
onClick: () => alert('copied'),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
children: <PlayCircleIconOutline className="n-text-primary-icon" />,
|
|
116
|
+
description: 'run',
|
|
117
|
+
htmlAttributes: { title: 'run' },
|
|
118
|
+
onClick: () => alert('running'),
|
|
119
|
+
},
|
|
120
|
+
]}
|
|
121
|
+
isDisabled={false}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default Component;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Code Languages
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
133
|
+
|
|
134
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
135
|
+
|
|
136
|
+
import { LANGUAGE_SYNTAX_HIGHLIGHTING_EXAMPLES } from './example-code-snippets';
|
|
137
|
+
|
|
138
|
+
const Component = () => {
|
|
139
|
+
return (
|
|
140
|
+
<div className="n-flex n-flex-col n-gap-token-8">
|
|
141
|
+
<CodeBlock
|
|
142
|
+
code={LANGUAGE_SYNTAX_HIGHLIGHTING_EXAMPLES.TYPESCRIPT}
|
|
143
|
+
language="typescript"
|
|
144
|
+
heading="TypeScript"
|
|
145
|
+
shouldShowLineNumbers
|
|
146
|
+
/>
|
|
147
|
+
|
|
148
|
+
<CodeBlock
|
|
149
|
+
code={LANGUAGE_SYNTAX_HIGHLIGHTING_EXAMPLES.CYPHER}
|
|
150
|
+
language="cypher"
|
|
151
|
+
heading="Cypher Query Language"
|
|
152
|
+
shouldShowLineNumbers
|
|
153
|
+
/>
|
|
154
|
+
|
|
155
|
+
<CodeBlock
|
|
156
|
+
code={LANGUAGE_SYNTAX_HIGHLIGHTING_EXAMPLES.JSON}
|
|
157
|
+
language="json"
|
|
158
|
+
heading="JSON Configuration"
|
|
159
|
+
shouldShowLineNumbers
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export default Component;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Code Overflow
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
172
|
+
|
|
173
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
174
|
+
|
|
175
|
+
import { LONG_CODE_EXAMPLE } from './example-code-snippets';
|
|
176
|
+
|
|
177
|
+
const Component = () => {
|
|
178
|
+
return (
|
|
179
|
+
<CodeBlock
|
|
180
|
+
code={LONG_CODE_EXAMPLE}
|
|
181
|
+
language="typescript"
|
|
182
|
+
heading="Code Header"
|
|
183
|
+
maxHeight={320}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export default Component;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Code With Actions
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
195
|
+
|
|
196
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
197
|
+
import {
|
|
198
|
+
PlayCircleIconOutline,
|
|
199
|
+
Square2StackIconOutline,
|
|
200
|
+
} from '@neo4j-ndl/react/icons';
|
|
201
|
+
|
|
202
|
+
import { SHORT_CODE_EXAMPLE } from './example-code-snippets';
|
|
203
|
+
|
|
204
|
+
const Component = () => {
|
|
205
|
+
return (
|
|
206
|
+
<CodeBlock
|
|
207
|
+
code={SHORT_CODE_EXAMPLE}
|
|
208
|
+
language="typescript"
|
|
209
|
+
maxHeight={320}
|
|
210
|
+
actions={[
|
|
211
|
+
{
|
|
212
|
+
children: (
|
|
213
|
+
<Square2StackIconOutline className="n-text-neutral-text-icon" />
|
|
214
|
+
),
|
|
215
|
+
description: 'copy',
|
|
216
|
+
htmlAttributes: { title: 'copy' },
|
|
217
|
+
onClick: () => alert('Code copied to clipboard!'),
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
children: <PlayCircleIconOutline className="n-text-primary-icon" />,
|
|
221
|
+
description: 'run',
|
|
222
|
+
htmlAttributes: { title: 'run' },
|
|
223
|
+
onClick: () => alert('Running code...'),
|
|
224
|
+
},
|
|
225
|
+
]}
|
|
226
|
+
/>
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export default Component;
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Code With Header
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
237
|
+
|
|
238
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
239
|
+
|
|
240
|
+
import { SHORT_CODE_EXAMPLE } from './example-code-snippets';
|
|
241
|
+
|
|
242
|
+
const Component = () => {
|
|
243
|
+
return (
|
|
244
|
+
<CodeBlock
|
|
245
|
+
code={SHORT_CODE_EXAMPLE}
|
|
246
|
+
language="typescript"
|
|
247
|
+
heading="Code Header"
|
|
248
|
+
/>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export default Component;
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Code With Line Numbers
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
259
|
+
|
|
260
|
+
import { CodeBlock } from '@neo4j-ndl/react';
|
|
261
|
+
|
|
262
|
+
import { SHORT_CODE_EXAMPLE } from './example-code-snippets';
|
|
263
|
+
|
|
264
|
+
const Component = () => {
|
|
265
|
+
return (
|
|
266
|
+
<CodeBlock
|
|
267
|
+
code={SHORT_CODE_EXAMPLE}
|
|
268
|
+
language="typescript"
|
|
269
|
+
heading="Code Header"
|
|
270
|
+
shouldShowLineNumbers
|
|
271
|
+
/>
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export default Component;
|
|
276
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Code
|
|
2
|
+
|
|
3
|
+
Import: `import { Code } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Code
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
12
|
+
| `children` | `ReactNode` | | | The content of the code |
|
|
13
|
+
| `description` | `string` | | | The description of the code, will be displayed in a tooltip |
|
|
14
|
+
| `isDisabled` | `boolean` | | `false` | Whether the code is disabled |
|
|
15
|
+
| `isRunnable` | `boolean` | | `false` | Whether the code is runnable |
|
|
16
|
+
| `onClick` | `((e: MouseEvent<HTMLElement, MouseEvent> \| KeyboardEvent<HTMLElement>) => void)` | | | The callback function triggered when the inline code is clicked |
|
|
17
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
18
|
+
|
|
19
|
+
## Accessibility
|
|
20
|
+
|
|
21
|
+
## Implementation guidelines
|
|
22
|
+
|
|
23
|
+
For inline code, when interactive (`isRunnable` is true), the component becomes focusable and supports keyboard navigation with Enter and Space keys. When a `description` is provided, it's properly associated with the element via ARIA attributes.
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
### Default
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
31
|
+
|
|
32
|
+
import { Code } from '@neo4j-ndl/react';
|
|
33
|
+
|
|
34
|
+
const Component = () => {
|
|
35
|
+
return (
|
|
36
|
+
<Code
|
|
37
|
+
description="Copy to clipboard"
|
|
38
|
+
onClick={() => alert('Copied to clipboard')}
|
|
39
|
+
>
|
|
40
|
+
:help cypher
|
|
41
|
+
</Code>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default Component;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Runnable
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
52
|
+
|
|
53
|
+
import { Code } from '@neo4j-ndl/react';
|
|
54
|
+
|
|
55
|
+
const Component = () => {
|
|
56
|
+
return (
|
|
57
|
+
<Code
|
|
58
|
+
isRunnable
|
|
59
|
+
description="Run query"
|
|
60
|
+
onClick={() => alert(`Executing: :help cypher`)}
|
|
61
|
+
>
|
|
62
|
+
:help cypher
|
|
63
|
+
</Code>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default Component;
|
|
68
|
+
```
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# ColorPicker
|
|
2
|
+
|
|
3
|
+
Import: `import { ColorPicker } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### ColorPicker
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `color` | `` HsvaColor \| RgbaColor \| `#${string}` `` | ✅ | | The current color value. Can be provided in HSVA, RGBA, or Hex format. The component will automatically convert between formats as needed. |
|
|
12
|
+
| `onChange` | `` (newColor: { hex: `#${string}`; rgb: RgbaColor; hsva: HsvaColor; }) => void `` | ✅ | | Callback function triggered when the color value changes. Receives an object containing the new color in all three formats (hex, rgb, hsva) for convenience. |
|
|
13
|
+
| `shouldShowEyeDropper` | `boolean` | | `true` | Whether to display the eye dropper tool that allows users to sample colors from anywhere on the screen. |
|
|
14
|
+
| `swatches` | `` (HsvaColor \| RgbaColor \| `#${string}`)[] `` | | `Object.values(tokens.graph).filter(validHex)` | Optional array of predefined color swatches for quick selection. Each swatch can be in HSVA, RGBA, or Hex format. |
|
|
15
|
+
|
|
16
|
+
By default the `swatches` prop is set to the available graph colors (`tokens.graph`) from `@neo4j-ndl/base`.
|
|
17
|
+
|
|
18
|
+
Where `HsvaColor`, `RgbaColor`, and `HexColor` types are from `@uiw/react-color`, and represent different color formats:
|
|
19
|
+
|
|
20
|
+
- `HexColor`: A string in the format `#RRGGBB` (e.g., `#ff0000`).
|
|
21
|
+
- `RgbaColor`: An object with numeric properties `{ r, g, b, a }` for red, green, blue (0–255), and alpha (0–1).
|
|
22
|
+
- `HsvaColor`: An object with numeric properties `{ h, s, v, a }` for hue (0–360), saturation (0–100), value (0–100), and alpha (0–1).
|
|
23
|
+
|
|
24
|
+
Visit [react-color](https://uiwjs.github.io/react-color/#/) for more information.
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### Default
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { useState } from 'react';
|
|
32
|
+
|
|
33
|
+
import { ColorPicker } from '../ColorPicker';
|
|
34
|
+
|
|
35
|
+
const Component = () => {
|
|
36
|
+
const [color, setColor] = useState({
|
|
37
|
+
a: 1,
|
|
38
|
+
b: 0,
|
|
39
|
+
g: 0,
|
|
40
|
+
r: 0,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ColorPicker
|
|
45
|
+
color={color}
|
|
46
|
+
onChange={(newColor) => setColor(newColor.rgb)}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default Component;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Custom Swatches
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { useState } from 'react';
|
|
58
|
+
|
|
59
|
+
import { ColorPicker } from '../ColorPicker';
|
|
60
|
+
|
|
61
|
+
const Component = () => {
|
|
62
|
+
const [color, setColor] = useState({
|
|
63
|
+
a: 1,
|
|
64
|
+
b: 0,
|
|
65
|
+
g: 0,
|
|
66
|
+
r: 0,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<ColorPicker
|
|
71
|
+
color={color}
|
|
72
|
+
onChange={(newColor) => setColor(newColor.rgb)}
|
|
73
|
+
swatches={[
|
|
74
|
+
{
|
|
75
|
+
a: 1,
|
|
76
|
+
b: 0,
|
|
77
|
+
g: 0,
|
|
78
|
+
r: 0,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
a: 1,
|
|
82
|
+
b: 255,
|
|
83
|
+
g: 0,
|
|
84
|
+
r: 0,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
a: 1,
|
|
88
|
+
b: 0,
|
|
89
|
+
g: 255,
|
|
90
|
+
r: 0,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
a: 1,
|
|
94
|
+
b: 0,
|
|
95
|
+
g: 0,
|
|
96
|
+
r: 255,
|
|
97
|
+
},
|
|
98
|
+
]}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default Component;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Without Eyedropper
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { useState } from 'react';
|
|
110
|
+
|
|
111
|
+
import { ColorPicker } from '../ColorPicker';
|
|
112
|
+
|
|
113
|
+
const Component = () => {
|
|
114
|
+
const [color, setColor] = useState({
|
|
115
|
+
a: 1,
|
|
116
|
+
b: 0,
|
|
117
|
+
g: 0,
|
|
118
|
+
r: 0,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<ColorPicker
|
|
123
|
+
color={color}
|
|
124
|
+
onChange={(newColor) => setColor(newColor.rgb)}
|
|
125
|
+
shouldShowEyeDropper={false}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default Component;
|
|
131
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# ConditionalWrap
|
|
2
|
+
|
|
3
|
+
Import: `import { ConditionalWrap } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### ConditionalWrap
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `children` | `ReactNode` | ✅ | | The children to potentially wrap |
|
|
12
|
+
| `shouldWrap` | `boolean` | ✅ | | If true, the children will be wrapped |
|
|
13
|
+
| `wrap` | `(children: ReactNode) => ReactNode` | ✅ | | Function that takes children and returns them wrapped in a component |
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Default
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { StatusLabel, Switch } from '@neo4j-ndl/react';
|
|
21
|
+
import { useState } from 'react';
|
|
22
|
+
|
|
23
|
+
import { ConditionalWrap } from '../ConditionalWrap';
|
|
24
|
+
|
|
25
|
+
const Component = () => {
|
|
26
|
+
const [shouldWrap, setShouldWrap] = useState(false);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="n-flex n-flex-col n-gap-6">
|
|
30
|
+
<Switch
|
|
31
|
+
isChecked={shouldWrap}
|
|
32
|
+
onChange={() => setShouldWrap(!shouldWrap)}
|
|
33
|
+
label="shouldWrap"
|
|
34
|
+
/>
|
|
35
|
+
<ConditionalWrap
|
|
36
|
+
shouldWrap={shouldWrap}
|
|
37
|
+
wrap={(children) => <StatusLabel>{children}</StatusLabel>}
|
|
38
|
+
>
|
|
39
|
+
Content
|
|
40
|
+
</ConditionalWrap>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default Component;
|
|
46
|
+
```
|