@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,84 @@
|
|
|
1
|
+
# Suggestion
|
|
2
|
+
|
|
3
|
+
Import: `import { Suggestion } from '@neo4j-ndl/react/ai'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Suggestion
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `children` | `ReactNode` | | | The content of the suggestion |
|
|
12
|
+
| `isPrimary` | `boolean` | | | Whether the suggestion is primary. Renders an animated border. |
|
|
13
|
+
| `leadingVisual` | `ReactNode` | | | The visual to display before the content. Should be an icon. |
|
|
14
|
+
| `onClick` | `((e: MouseEvent<HTMLButtonElement, MouseEvent>) => void)` | | | Callback function triggered when the suggestion is clicked |
|
|
15
|
+
| `ref` | `Ref<HTMLButtonElement>` | | | A ref to apply to the root element. |
|
|
16
|
+
| `size` | `'large' \| 'small'` | | `small` | The size of the suggestion |
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
|
|
20
|
+
### Default
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
24
|
+
|
|
25
|
+
import { Suggestion } from '@neo4j-ndl/react/ai';
|
|
26
|
+
|
|
27
|
+
const Component = () => {
|
|
28
|
+
return <Suggestion>How do I get started with Aura?</Suggestion>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default Component;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Icon
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
38
|
+
|
|
39
|
+
import { Suggestion } from '@neo4j-ndl/react/ai';
|
|
40
|
+
import { MagnifyingGlassIconOutline } from '@neo4j-ndl/react/icons';
|
|
41
|
+
|
|
42
|
+
const Component = () => {
|
|
43
|
+
return (
|
|
44
|
+
<Suggestion size="small" leadingVisual={<MagnifyingGlassIconOutline />}>
|
|
45
|
+
How do I get started with Aura?
|
|
46
|
+
</Suggestion>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default Component;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Primary
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
57
|
+
|
|
58
|
+
import { Suggestion } from '@neo4j-ndl/react/ai';
|
|
59
|
+
|
|
60
|
+
const Component = () => {
|
|
61
|
+
return <Suggestion isPrimary>How do I get started with Aura?</Suggestion>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default Component;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Sizes
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
71
|
+
|
|
72
|
+
import { Suggestion } from '@neo4j-ndl/react/ai';
|
|
73
|
+
|
|
74
|
+
const Component = () => {
|
|
75
|
+
return (
|
|
76
|
+
<div className="n-flex n-flex-row n-gap-token-8">
|
|
77
|
+
<Suggestion size="small">This is a small suggestion</Suggestion>
|
|
78
|
+
<Suggestion size="large">This is a large suggestion</Suggestion>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default Component;
|
|
84
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Thinking
|
|
2
|
+
|
|
3
|
+
Import: `import { Thinking } from '@neo4j-ndl/react/ai'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Thinking
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `isThinking` | `boolean` | | `true` | Whether the AI is thinking. If true, will render a thinking presence icon and the text "Thinking". If false, will render the duration of the thinking. |
|
|
12
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
13
|
+
| `thinkingMs` | `number` | | `1000` | The duration of the thinking in milliseconds |
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Ai Thinking Default
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
21
|
+
|
|
22
|
+
import { Thinking } from '@neo4j-ndl/react/ai';
|
|
23
|
+
|
|
24
|
+
const Component = () => {
|
|
25
|
+
return <Thinking isThinking={true} thinkingMs={1400} />;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Component;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Ai Thinking Finished
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
35
|
+
|
|
36
|
+
import { Thinking } from '@neo4j-ndl/react/ai';
|
|
37
|
+
|
|
38
|
+
const Component = () => {
|
|
39
|
+
return <Thinking isThinking={false} thinkingMs={1400} />;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default Component;
|
|
43
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# ToolCall
|
|
2
|
+
|
|
3
|
+
Import: `import { ToolCall } from '@neo4j-ndl/react/ai'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### ToolCall
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `children` | `ReactNode` | | | The content of the suggestion |
|
|
12
|
+
| `isDone` | `boolean` | | `false` | Whether the AI is done with using the tool |
|
|
13
|
+
| `ref` | `Ref<HTMLSpanElement>` | | | A ref to apply to the root element. |
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Default
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
21
|
+
|
|
22
|
+
import { ToolCall } from '@neo4j-ndl/react/ai';
|
|
23
|
+
|
|
24
|
+
const Component = () => {
|
|
25
|
+
return <ToolCall>list_import_jobs</ToolCall>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Component;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Done
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
35
|
+
|
|
36
|
+
import { ToolCall } from '@neo4j-ndl/react/ai';
|
|
37
|
+
|
|
38
|
+
const Component = () => {
|
|
39
|
+
return <ToolCall isDone>list_import_jobs</ToolCall>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default Component;
|
|
43
|
+
```
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# UserBubbleComponent
|
|
2
|
+
|
|
3
|
+
Import: `import { UserBubbleComponent } from '@neo4j-ndl/react/ai'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### UserBubbleComponent
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `avatarProps` | `PolymorphicCommonProps<ElementType<any, keyof IntrinsicElements>, AvatarProps>` | | | The props for the avatar |
|
|
12
|
+
| `children` | `ReactNode` | | | The content of the user bubble |
|
|
13
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
14
|
+
| `trailingElement` | `ReactNode` | | | The element to display after the content. Could be a CleanIconButton to edit the user bubble. |
|
|
15
|
+
|
|
16
|
+
## Examples
|
|
17
|
+
|
|
18
|
+
### Default
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
22
|
+
|
|
23
|
+
import { UserBubble } from '@neo4j-ndl/react/ai';
|
|
24
|
+
|
|
25
|
+
const Component = () => {
|
|
26
|
+
return (
|
|
27
|
+
<UserBubble
|
|
28
|
+
avatarProps={{
|
|
29
|
+
name: 'KM',
|
|
30
|
+
source:
|
|
31
|
+
'https://media.istockphoto.com/id/1334716681/photo/a-smiling-man.jpg?s=612x612&w=0&k=20&c=U6rkSDpQMzkcJEqx2hAa63fNLIhqnZb31Xuc_QSi648=',
|
|
32
|
+
type: 'image',
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
Can you analyse my data and tell me about...?
|
|
36
|
+
</UserBubble>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default Component;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Action
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
47
|
+
|
|
48
|
+
import { CleanIconButton } from '@neo4j-ndl/react';
|
|
49
|
+
import { UserBubble } from '@neo4j-ndl/react/ai';
|
|
50
|
+
import { PencilSquareIconOutline } from '@neo4j-ndl/react/icons';
|
|
51
|
+
|
|
52
|
+
const Component = () => {
|
|
53
|
+
return (
|
|
54
|
+
<UserBubble
|
|
55
|
+
avatarProps={{
|
|
56
|
+
name: 'KM',
|
|
57
|
+
type: 'letters',
|
|
58
|
+
}}
|
|
59
|
+
trailingElement={
|
|
60
|
+
<CleanIconButton description="Edit" size="large">
|
|
61
|
+
<PencilSquareIconOutline />
|
|
62
|
+
</CleanIconButton>
|
|
63
|
+
}
|
|
64
|
+
>
|
|
65
|
+
Can you analyse my data and tell me about...?
|
|
66
|
+
</UserBubble>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default Component;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### And Files
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
77
|
+
|
|
78
|
+
import { Menu } from '@neo4j-ndl/react';
|
|
79
|
+
import { FileTag, ImageTag, MoreFiles, UserBubble } from '@neo4j-ndl/react/ai';
|
|
80
|
+
import {
|
|
81
|
+
DocumentIconOutline,
|
|
82
|
+
PhotoIconOutline,
|
|
83
|
+
TableCellsIconOutline,
|
|
84
|
+
} from '@neo4j-ndl/react/icons';
|
|
85
|
+
import { useRef, useState } from 'react';
|
|
86
|
+
|
|
87
|
+
const Component = () => {
|
|
88
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
89
|
+
const anchorRef = useRef<HTMLButtonElement | null>(null);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div className="n-flex n-flex-coln-gap-token-64 n-w-full n-justify-end">
|
|
93
|
+
<div className="n-flex n-flex-col n-gap-token-8 n-items-end">
|
|
94
|
+
<MoreFiles
|
|
95
|
+
count={3}
|
|
96
|
+
isActive={isMenuOpen}
|
|
97
|
+
onClick={() => setIsMenuOpen(!isMenuOpen)}
|
|
98
|
+
ref={anchorRef}
|
|
99
|
+
/>
|
|
100
|
+
<Menu
|
|
101
|
+
isOpen={isMenuOpen}
|
|
102
|
+
anchorRef={anchorRef}
|
|
103
|
+
onClose={() => setIsMenuOpen(false)}
|
|
104
|
+
>
|
|
105
|
+
<Menu.Item
|
|
106
|
+
leadingVisual={<DocumentIconOutline />}
|
|
107
|
+
title="Gardening tips"
|
|
108
|
+
description="PDF"
|
|
109
|
+
onClick={() => alert('Gardening tips')}
|
|
110
|
+
/>
|
|
111
|
+
<Menu.Item
|
|
112
|
+
leadingVisual={<TableCellsIconOutline />}
|
|
113
|
+
title="TvSeries"
|
|
114
|
+
description="CSV"
|
|
115
|
+
onClick={() => alert('TvSeries')}
|
|
116
|
+
/>
|
|
117
|
+
<Menu.Item
|
|
118
|
+
leadingVisual={<PhotoIconOutline />}
|
|
119
|
+
title="Family photo"
|
|
120
|
+
description="JPG"
|
|
121
|
+
onClick={() => alert('Family photo')}
|
|
122
|
+
/>
|
|
123
|
+
</Menu>
|
|
124
|
+
<ImageTag
|
|
125
|
+
src="https://plus.unsplash.com/premium_photo-1676496046182-356a6a0ed002?q=80&w=2952&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
126
|
+
alt="Landscape image"
|
|
127
|
+
fileName="Landscape image"
|
|
128
|
+
fileType="jpg"
|
|
129
|
+
/>
|
|
130
|
+
<FileTag
|
|
131
|
+
icon={<TableCellsIconOutline />}
|
|
132
|
+
fileName="MoviesDecade"
|
|
133
|
+
fileType="csv"
|
|
134
|
+
/>
|
|
135
|
+
<FileTag
|
|
136
|
+
icon={<DocumentIconOutline />}
|
|
137
|
+
fileName="Science Fiction Bestsellers"
|
|
138
|
+
fileType="pdf"
|
|
139
|
+
/>
|
|
140
|
+
<UserBubble
|
|
141
|
+
avatarProps={{
|
|
142
|
+
name: 'KM',
|
|
143
|
+
source:
|
|
144
|
+
'https://media.istockphoto.com/id/1334716681/photo/a-smiling-man.jpg?s=612x612&w=0&k=20&c=U6rkSDpQMzkcJEqx2hAa63fNLIhqnZb31Xuc_QSi648=',
|
|
145
|
+
type: 'image',
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
Can you analyse my data and tell me about...?
|
|
149
|
+
</UserBubble>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default Component;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Long
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
162
|
+
|
|
163
|
+
import { UserBubble } from '@neo4j-ndl/react/ai';
|
|
164
|
+
|
|
165
|
+
const Component = () => {
|
|
166
|
+
return (
|
|
167
|
+
<UserBubble
|
|
168
|
+
avatarProps={{
|
|
169
|
+
name: 'KM',
|
|
170
|
+
type: 'letters',
|
|
171
|
+
}}
|
|
172
|
+
>
|
|
173
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in rutrum
|
|
174
|
+
massa, ut congue nisi. Curabitur pulvinar odio id eros ornare dictum.
|
|
175
|
+
Aliquam faucibus dui ligula, ac gravida enim mattis at. Proin pretium
|
|
176
|
+
massa a risus eleifend consectetur. Fusce auctor maximus tellus sed
|
|
177
|
+
lobortis. Nulla congue leo posuere ante accumsan, vel maximus justo
|
|
178
|
+
cursus. Sed cursus varius ante at scelerisque. Fusce non venenatis diam.
|
|
179
|
+
Nam sed dolor ultricies, varius sem sed, vulputate felis. Ut facilisis
|
|
180
|
+
efficitur sem, et laoreet neque. Fusce congue vulputate magna. Mauris
|
|
181
|
+
euismod egestas imperdiet. Sed mollis venenatis nunc eget laoreet.
|
|
182
|
+
</UserBubble>
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export default Component;
|
|
187
|
+
```
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Avatar
|
|
2
|
+
|
|
3
|
+
Import: `import { Avatar } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Avatar
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `as` | `("button" & ElementType<any, keyof IntrinsicElements>) \| ("symbol" & ElementType<any, keyof IntrinsicElements>) \| ... 178 more ...` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
12
|
+
| `hasStatus` | `boolean` | | `false` | Whether to display a status indicator |
|
|
13
|
+
| `icon` | `ReactNode` | | | Custom icon to display when `type` is `"icon"`. Defaults to `UserIconOutline` |
|
|
14
|
+
| `isDisabled` | `boolean` | | `false` | Whether the avatar is disabled. When disabled, status indicators are hidden and `onClick` handlers are disabled when cast as a button |
|
|
15
|
+
| `name` | `string` | | | The name associated with the avatar. Used for alt text and aria-label. For letters type, this text is displayed |
|
|
16
|
+
| `onClick` | `() => void` | ✅ | | |
|
|
17
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
18
|
+
| `shape` | `'circle' \| 'square'` | | `circle` | The shape of the avatar |
|
|
19
|
+
| `size` | `'large' \| 'medium' \| 'small' \| 'x-large' \| 'x-small'` | | `medium` | The size of the avatar |
|
|
20
|
+
| `source` | `string` | | | Source URI for the image. When provided with `type="image`", displays the image |
|
|
21
|
+
| `status` | `'offline' \| 'online' \| 'unknown'` | | | The status to display. Only shown when `hasStatus` is `true` and component is not disabled |
|
|
22
|
+
| `type` | `'icon' \| 'image' \| 'letters'` | | `image` | The type of avatar content. If `type="image"` and no source is provided, automatically falls back to `icon` |
|
|
23
|
+
|
|
24
|
+
## Accessibility
|
|
25
|
+
|
|
26
|
+
## Implementation guidelines
|
|
27
|
+
|
|
28
|
+
The component has an `aria-label` set to `avatar ${name}` to provide context to screen readers. Status indicators include title attributes and proper role attributes. When displaying images, proper alt text is provided using the `name` prop.
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Default
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
36
|
+
|
|
37
|
+
import { Avatar } from '@neo4j-ndl/react';
|
|
38
|
+
|
|
39
|
+
const Component = () => {
|
|
40
|
+
return <Avatar />;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default Component;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Custom Icon
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
50
|
+
|
|
51
|
+
import { Avatar } from '@neo4j-ndl/react';
|
|
52
|
+
import {
|
|
53
|
+
BellIconOutline,
|
|
54
|
+
HeartIconOutline,
|
|
55
|
+
StarIconOutline,
|
|
56
|
+
} from '@neo4j-ndl/react/icons';
|
|
57
|
+
|
|
58
|
+
const Component = () => {
|
|
59
|
+
return (
|
|
60
|
+
<div className="n-flex n-gap-token-16">
|
|
61
|
+
<Avatar type="icon" name="Favorites" icon={<StarIconOutline />} />
|
|
62
|
+
<Avatar type="icon" name="Notifications" icon={<BellIconOutline />} />
|
|
63
|
+
<Avatar type="icon" name="Likes" icon={<HeartIconOutline />} />
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default Component;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Disabled
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
75
|
+
|
|
76
|
+
import { Avatar } from '@neo4j-ndl/react';
|
|
77
|
+
|
|
78
|
+
const Component = () => {
|
|
79
|
+
return <Avatar isDisabled as="button" onClick={() => alert('Clicked!')} />;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default Component;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Shapes
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
89
|
+
|
|
90
|
+
import { Avatar } from '@neo4j-ndl/react';
|
|
91
|
+
|
|
92
|
+
const Component = () => {
|
|
93
|
+
return (
|
|
94
|
+
<div className="n-flex n-gap-token-16">
|
|
95
|
+
<Avatar shape="circle" />
|
|
96
|
+
<Avatar shape="square" />
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default Component;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Sizes
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
108
|
+
|
|
109
|
+
import { Avatar } from '@neo4j-ndl/react';
|
|
110
|
+
|
|
111
|
+
const Component = () => {
|
|
112
|
+
return (
|
|
113
|
+
<div className="n-flex n-gap-token-16">
|
|
114
|
+
<Avatar size="x-small" />
|
|
115
|
+
<Avatar size="small" />
|
|
116
|
+
<Avatar size="medium" />
|
|
117
|
+
<Avatar size="large" />
|
|
118
|
+
<Avatar size="x-large" />
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default Component;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Statuses
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
130
|
+
|
|
131
|
+
import { Avatar } from '@neo4j-ndl/react';
|
|
132
|
+
|
|
133
|
+
const Component = () => {
|
|
134
|
+
return (
|
|
135
|
+
<div className="n-flex n-gap-token-16 n-items-center">
|
|
136
|
+
<Avatar hasStatus={false} />
|
|
137
|
+
<Avatar hasStatus status="online" />
|
|
138
|
+
<Avatar hasStatus status="offline" />
|
|
139
|
+
<Avatar hasStatus status="unknown" />
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export default Component;
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Types
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
151
|
+
|
|
152
|
+
import { Avatar } from '@neo4j-ndl/react';
|
|
153
|
+
|
|
154
|
+
const Component = () => {
|
|
155
|
+
return (
|
|
156
|
+
<div className="n-flex n-gap-token-16">
|
|
157
|
+
<Avatar type="icon" name="Karl Morrison" />
|
|
158
|
+
<Avatar type="letters" name="Karl Morrison" />
|
|
159
|
+
<Avatar
|
|
160
|
+
type="image"
|
|
161
|
+
name="Karl Morrison"
|
|
162
|
+
source="https://media.istockphoto.com/id/1334716681/photo/a-smiling-man.jpg?s=612x612&w=0&k=20&c=U6rkSDpQMzkcJEqx2hAa63fNLIhqnZb31Xuc_QSi648="
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export default Component;
|
|
169
|
+
```
|