@redis-ui/components 43.0.2 → 43.2.1
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/dist/HighlightedIcon/HighlightedIcon.cjs +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.d.ts +3 -0
- package/dist/HighlightedIcon/HighlightedIcon.js +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.cjs +49 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.d.ts +5 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.js +47 -0
- package/dist/HighlightedIcon/HighlightedIcon.types.d.ts +8 -0
- package/dist/HighlightedIcon/index.d.ts +3 -0
- package/dist/Stepper/Stepper.cjs +14 -5
- package/dist/Stepper/Stepper.d.ts +2 -0
- package/dist/Stepper/Stepper.js +14 -5
- package/dist/Stepper/Stepper.utils.cjs +12 -0
- package/dist/Stepper/Stepper.utils.d.ts +2 -0
- package/dist/Stepper/Stepper.utils.js +12 -0
- package/dist/Stepper/components/Compose/Compose.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.cjs +2 -0
- package/dist/Stepper/components/Step/Step.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.js +2 -0
- package/dist/Stepper/components/Step/components/Compose/Compose.cjs +2 -9
- package/dist/Stepper/components/Step/components/Compose/Compose.js +2 -9
- package/dist/Stepper/components/Step/components/Separator/Separator.cjs +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.d.ts +3 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.js +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.cjs +24 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.d.ts +1 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.js +22 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.types.d.ts +5 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +74 -70
- package/package.json +2 -2
- package/skills/redis-ui-components/SKILL.md +0 -2
- package/skills/redis-ui-components/references/ActionIconButton.md +96 -0
- package/skills/redis-ui-components/references/AppBar.md +161 -0
- package/skills/redis-ui-components/references/AppSelectionMenu.md +184 -0
- package/skills/redis-ui-components/references/AutoCompleteSelect.md +193 -0
- package/skills/redis-ui-components/references/Badge.md +77 -0
- package/skills/redis-ui-components/references/Banner.md +563 -0
- package/skills/redis-ui-components/references/BoxSelectionGroup.md +487 -0
- package/skills/redis-ui-components/references/Breadcrumbs.md +214 -0
- package/skills/redis-ui-components/references/ButtonGroup.md +126 -0
- package/skills/redis-ui-components/references/Card.md +56 -0
- package/skills/redis-ui-components/references/Checkbox.md +171 -0
- package/skills/redis-ui-components/references/Chip.md +154 -0
- package/skills/redis-ui-components/references/ChipList.md +307 -0
- package/skills/redis-ui-components/references/CopyToClipboardButton.md +47 -0
- package/skills/redis-ui-components/references/CountryFlag.md +57 -0
- package/skills/redis-ui-components/references/Drawer.md +298 -0
- package/skills/redis-ui-components/references/Filters.md +162 -0
- package/skills/redis-ui-components/references/FormField.md +678 -0
- package/skills/redis-ui-components/references/IconButton.md +63 -0
- package/skills/redis-ui-components/references/Input.md +295 -0
- package/skills/redis-ui-components/references/KeyValueList.md +501 -0
- package/skills/redis-ui-components/references/Label.md +238 -0
- package/skills/redis-ui-components/references/Link.md +402 -0
- package/skills/redis-ui-components/references/Loader.md +100 -0
- package/skills/redis-ui-components/references/Menu.md +988 -0
- package/skills/redis-ui-components/references/MidBar.md +358 -0
- package/skills/redis-ui-components/references/Modal.md +525 -0
- package/skills/redis-ui-components/references/MoreInfoIcon.md +119 -0
- package/skills/redis-ui-components/references/MultiSelect.md +558 -0
- package/skills/redis-ui-components/references/NumericInput.md +322 -0
- package/skills/redis-ui-components/references/Overflow.md +127 -0
- package/skills/redis-ui-components/references/Pagination.md +151 -0
- package/skills/redis-ui-components/references/PasswordInput.md +262 -0
- package/skills/redis-ui-components/references/Popover.md +868 -0
- package/skills/redis-ui-components/references/ProfileIcon.md +65 -0
- package/skills/redis-ui-components/references/ProgressBar.md +103 -0
- package/skills/redis-ui-components/references/QuantityCounter.md +555 -0
- package/skills/redis-ui-components/references/RadioGroup.md +265 -0
- package/skills/redis-ui-components/references/ScreenReaderAnnounce.md +147 -0
- package/skills/redis-ui-components/references/SearchBar.md +242 -0
- package/skills/redis-ui-components/references/SearchInput.md +213 -0
- package/skills/redis-ui-components/references/Section.md +349 -0
- package/skills/redis-ui-components/references/SideBar.md +468 -0
- package/skills/redis-ui-components/references/Slider.md +398 -0
- package/skills/redis-ui-components/references/Stepper.md +288 -0
- package/skills/redis-ui-components/references/Switch.md +193 -0
- package/skills/redis-ui-components/references/Tabs.md +383 -0
- package/skills/redis-ui-components/references/TextArea.md +139 -0
- package/skills/redis-ui-components/references/TextButton.md +217 -0
- package/skills/redis-ui-components/references/Toast.md +399 -0
- package/skills/redis-ui-components/references/ToggleButton.md +163 -0
- package/skills/redis-ui-components/references/Tooltip.md +636 -0
- package/skills/redis-ui-components/references/Typography.md +323 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Label
|
|
2
|
+
|
|
3
|
+
Composable form label with required/optional markers, readonly handling, and an info icon backed by a tooltip. It also exposes a compound composition API for custom label layouts.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Label } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| label | `ReactNode` | - | Label content rendered by the default layout |
|
|
16
|
+
| infoIconProps | `InfoIconProps` | - | Info icon and tooltip configuration |
|
|
17
|
+
| required | `boolean` | `false` | Shows the required marker |
|
|
18
|
+
| optional | `boolean` | `false` | Shows the optional marker |
|
|
19
|
+
| readOnly | `boolean` | - | Renders the label text in readonly mode |
|
|
20
|
+
| native label props | `LabelHTMLAttributes<HTMLLabelElement>` | - | Standard label attributes forwarded to the root label element |
|
|
21
|
+
|
|
22
|
+
The component also accepts native `LabelHTMLAttributes<HTMLLabelElement>` props.
|
|
23
|
+
|
|
24
|
+
## Sub-components
|
|
25
|
+
|
|
26
|
+
- `Label.Compose` - Shared label wrapper that resolves `htmlFor` through the shared id helper and can be hidden with `show={false}`.
|
|
27
|
+
- `Label.Text` - Main text content for the label.
|
|
28
|
+
- `Label.Required` - Required marker rendered next to the label text.
|
|
29
|
+
- `Label.Optional` - Optional marker rendered next to the label text.
|
|
30
|
+
- `Label.InfoIcon` - Tooltip-backed info icon rendered at the end of the label.
|
|
31
|
+
|
|
32
|
+
### `Label.Compose` Props
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
|------|------|---------|-------------|
|
|
36
|
+
| show | `boolean` | `true` | Controls whether the label wrapper renders |
|
|
37
|
+
| native label props | `LabelHTMLAttributes<HTMLLabelElement>` | - | Standard label attributes forwarded to the wrapper |
|
|
38
|
+
|
|
39
|
+
### `Label.Text` Props
|
|
40
|
+
|
|
41
|
+
| Prop | Type | Default | Description |
|
|
42
|
+
|------|------|---------|-------------|
|
|
43
|
+
| children | `ReactNode` | - | Label text or custom content |
|
|
44
|
+
| readOnly | `boolean` | - | Overrides readonly styling from context |
|
|
45
|
+
| typography body props | `TypographyBodyProps` | - | Remaining body typography props forwarded to the text span |
|
|
46
|
+
|
|
47
|
+
### `Label.Required` Props
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
|------|------|---------|-------------|
|
|
51
|
+
| children | `ReactNode` | `*` | Required marker content |
|
|
52
|
+
| show | `boolean` | `true` | Controls whether the required marker renders |
|
|
53
|
+
| typography body props | `TypographyBodyProps` | - | Remaining body typography props forwarded to the marker; `size` falls back to `S` |
|
|
54
|
+
|
|
55
|
+
### `Label.Optional` Props
|
|
56
|
+
|
|
57
|
+
| Prop | Type | Default | Description |
|
|
58
|
+
|------|------|---------|-------------|
|
|
59
|
+
| children | `ReactNode` | `(Optional)` | Optional marker content |
|
|
60
|
+
| show | `boolean` | `true` | Controls whether the optional marker renders |
|
|
61
|
+
| typography body props | `TypographyBodyProps` | - | Remaining body typography props forwarded to the marker; `size` falls back to `S` |
|
|
62
|
+
|
|
63
|
+
### `Label.InfoIcon` Props
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
|------|------|---------|-------------|
|
|
67
|
+
| content | `ReactNode` | `text` | Tooltip content shown by the info icon |
|
|
68
|
+
| text | `string` | - | Deprecated alias for `content` |
|
|
69
|
+
| size | `IconSizeType` | - | Icon size |
|
|
70
|
+
| tooltip content props | `TooltipContentProps` without `backgroundColor` and `children` | - | Remaining tooltip configuration forwarded to the info icon |
|
|
71
|
+
|
|
72
|
+
## Examples
|
|
73
|
+
|
|
74
|
+
### Playground
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { Label } from '@redislabsdev/redis-ui-components';
|
|
78
|
+
|
|
79
|
+
<Label label="Label" optional={false} required={false} readOnly={false} infoIconProps={{ content: 'Info Tooltip' }} />
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### PartsAndProps
|
|
83
|
+
|
|
84
|
+
> `Label` can have text, required and optional markers, and an info icon. If no parts are provided, the label is not rendered.
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { Label } from '@redislabsdev/redis-ui-components';
|
|
88
|
+
import { ShardIcon } from '@redislabsdev/redis-ui-icons';
|
|
89
|
+
import { StoryHList } from '../../helpers/Story.style';
|
|
90
|
+
import * as S from './Label.style';
|
|
91
|
+
|
|
92
|
+
<>
|
|
93
|
+
<Label
|
|
94
|
+
label="Label with all parts"
|
|
95
|
+
required
|
|
96
|
+
optional
|
|
97
|
+
infoIconProps={{ content: 'Info tooltip' }}
|
|
98
|
+
/>
|
|
99
|
+
<Label label="Label 'required'" required />
|
|
100
|
+
<Label label="Label 'optional'" optional />
|
|
101
|
+
<Label label="Label with info icon" infoIconProps={{ content: 'Info tooltip' }} />
|
|
102
|
+
<Label
|
|
103
|
+
label={
|
|
104
|
+
<StoryHList $align="center" $gap="0.4rem">
|
|
105
|
+
<ShardIcon />
|
|
106
|
+
Label with <S.RichLabelContent>rich</S.RichLabelContent> content
|
|
107
|
+
</StoryHList>
|
|
108
|
+
}
|
|
109
|
+
/>
|
|
110
|
+
</>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Readonly
|
|
114
|
+
|
|
115
|
+
> Setting `readOnly` or the readonly field context renders the label in readonly mode.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { FieldReadonlyProvider, Input, Label } from '@redislabsdev/redis-ui-components';
|
|
119
|
+
|
|
120
|
+
<>
|
|
121
|
+
<Label
|
|
122
|
+
label="Label in normal mode"
|
|
123
|
+
required
|
|
124
|
+
optional
|
|
125
|
+
infoIconProps={{ content: 'Info tooltip' }}
|
|
126
|
+
/>
|
|
127
|
+
<Label
|
|
128
|
+
label="Label in readonly mode"
|
|
129
|
+
required
|
|
130
|
+
optional
|
|
131
|
+
infoIconProps={{ content: 'Info tooltip' }}
|
|
132
|
+
readOnly
|
|
133
|
+
/>
|
|
134
|
+
<FieldReadonlyProvider>
|
|
135
|
+
<Label
|
|
136
|
+
label="Label is readonly via context"
|
|
137
|
+
required
|
|
138
|
+
optional
|
|
139
|
+
infoIconProps={{ content: 'Info tooltip' }}
|
|
140
|
+
/>
|
|
141
|
+
<Input readOnly style={{ display: 'none' }} />
|
|
142
|
+
</FieldReadonlyProvider>
|
|
143
|
+
</>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### InfoIcon
|
|
147
|
+
|
|
148
|
+
> `infoIconProps` accepts tooltip content props and the icon sizing prop.
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { Label } from '@redislabsdev/redis-ui-components';
|
|
152
|
+
import { useViewMode } from '../../helpers/useViewMode';
|
|
153
|
+
import * as S from './Label.style';
|
|
154
|
+
|
|
155
|
+
function Render() {
|
|
156
|
+
const { inStory } = useViewMode();
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<>
|
|
160
|
+
<Label label="Icon is hidden - empty tooltip" infoIconProps={{ content: '' }} />
|
|
161
|
+
<Label label="Icon size" infoIconProps={{ content: 'tooltip', size: 'S' }} />
|
|
162
|
+
<Label
|
|
163
|
+
label="Icon with custom tooltip content"
|
|
164
|
+
infoIconProps={{
|
|
165
|
+
content: (
|
|
166
|
+
<>
|
|
167
|
+
<S.LabelInfoIconHeading>Custom</S.LabelInfoIconHeading>
|
|
168
|
+
<S.LabelInfoIconBody>colored content</S.LabelInfoIconBody>
|
|
169
|
+
<S.LabelInfoIconText>
|
|
170
|
+
with <strong>textColor</strong> prop
|
|
171
|
+
</S.LabelInfoIconText>
|
|
172
|
+
</>
|
|
173
|
+
),
|
|
174
|
+
placement: 'bottom',
|
|
175
|
+
defaultOpen: inStory
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
</>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### DefaultCompose
|
|
184
|
+
|
|
185
|
+
> This is how the label is composed internally.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import { Label } from '@redislabsdev/redis-ui-components';
|
|
189
|
+
|
|
190
|
+
<Label.Compose>
|
|
191
|
+
<Label.Required show />
|
|
192
|
+
<Label.Text readOnly>Label</Label.Text>
|
|
193
|
+
<Label.Optional show />
|
|
194
|
+
<Label.InfoIcon text="Tooltip" />
|
|
195
|
+
</Label.Compose>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### CustomCompose
|
|
199
|
+
|
|
200
|
+
> You can customize any part without restrictions.
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import { Label, Link } from '@redislabsdev/redis-ui-components';
|
|
204
|
+
import * as S from './Label.style';
|
|
205
|
+
|
|
206
|
+
<Label.Compose>
|
|
207
|
+
<S.CustomLabelComposeWrapper>Custom Label Compose</S.CustomLabelComposeWrapper>
|
|
208
|
+
<S.LabelRequired />
|
|
209
|
+
<S.LabelOptional />
|
|
210
|
+
<S.LabelInfoIcon text="Tooltip Content Text" />
|
|
211
|
+
<Link external variant="inline" href="https://www.redis.com" />
|
|
212
|
+
</Label.Compose>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### LabelWithEllipsisAndTooltip
|
|
216
|
+
|
|
217
|
+
> Text of the label can use ellipsis and tooltip when there is not enough space.
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
import { Label } from '@redislabsdev/redis-ui-components';
|
|
221
|
+
|
|
222
|
+
<Label.Compose style={{ width: '20rem' }}>
|
|
223
|
+
<Label.Required />
|
|
224
|
+
<Label.Text ellipsis tooltipOnEllipsis style={{ flex: 1 }}>
|
|
225
|
+
Long Label to show ellipsis and tooltip
|
|
226
|
+
</Label.Text>
|
|
227
|
+
<Label.Optional />
|
|
228
|
+
</Label.Compose>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Notes
|
|
232
|
+
|
|
233
|
+
- The default label only renders when at least one part is present.
|
|
234
|
+
- `Label.Compose` resolves `htmlFor` through the shared id helper and is the internal wrapper used by the default label layout.
|
|
235
|
+
- `Label.Text`, `Label.Required`, and `Label.Optional` are all body-typography-based building blocks.
|
|
236
|
+
- `readOnly` also responds to `FieldReadonlyProvider`, not just the local prop.
|
|
237
|
+
- `infoIconProps` accepts tooltip content props plus icon-related props such as `iconColor` and `size`.
|
|
238
|
+
- Empty `infoIconProps.content` hides the info icon entirely.
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# Link
|
|
2
|
+
|
|
3
|
+
A flexible link component that can behave like a button or inline anchor, supports optional icons, wrapping, disabled state, and a composed `LinkStyler` layout helper.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Link, LinkStyler } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
If you use icons, import them from `@redislabsdev/redis-ui-icons`.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
|------|------|---------|-------------|
|
|
17
|
+
| children | `ReactNode` | `Read More` | Link content |
|
|
18
|
+
| icon | `IconType` | - | Optional icon rendered inside the link |
|
|
19
|
+
| external | `boolean` | `false` | Appends the external-link styling/icon behavior |
|
|
20
|
+
| variant | `'button' \| 'inline'` | `button` | Link presentation variant |
|
|
21
|
+
| size | `'M' \| 'S'` | `M` | Link size |
|
|
22
|
+
| allowWrap | `boolean` | `false` | Allows the link content to wrap |
|
|
23
|
+
| disabled | `boolean` | - | Disables the link and prevents interaction |
|
|
24
|
+
| href | `string` | - | Anchor href; when omitted, the link behaves like a button |
|
|
25
|
+
| onClick | `UIEventHandler` | - | Click handler used when the link behaves like a button |
|
|
26
|
+
| other anchor props | `AnchorHTMLAttributes<HTMLAnchorElement>` | - | Remaining anchor props forwarded to the underlying link element |
|
|
27
|
+
|
|
28
|
+
## Sub-components
|
|
29
|
+
|
|
30
|
+
- `LinkStyler.LinkContent` - Content wrapper used by the composed styler.
|
|
31
|
+
|
|
32
|
+
### `LinkStyler` Props
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
|------|------|---------|-------------|
|
|
36
|
+
| children | `ReactNode` | required | Styled link content |
|
|
37
|
+
| variant | `'button' \| 'inline'` | `button` | Link presentation variant |
|
|
38
|
+
| size | `'M' \| 'S'` | `M` | Link size |
|
|
39
|
+
| allowWrap | `boolean` | `false` | Allows wrapping |
|
|
40
|
+
| className | `string` | - | Styled wrapper class name |
|
|
41
|
+
|
|
42
|
+
### `LinkStyler.LinkContent` Props
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default | Description |
|
|
45
|
+
|------|------|---------|-------------|
|
|
46
|
+
| icon | `IconType \| undefined` | - | Optional icon rendered before the link content |
|
|
47
|
+
| external | `boolean \| undefined` | - | Appends the external-link icon after the content |
|
|
48
|
+
| children | `ReactNode \| undefined` | - | Link content rendered inside the composed anchor |
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
### Playground
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Link } from '@redislabsdev/redis-ui-components';
|
|
56
|
+
|
|
57
|
+
<Link external disabled={false}>
|
|
58
|
+
Link
|
|
59
|
+
</Link>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### ExternalLink
|
|
63
|
+
|
|
64
|
+
> Setting `external` appends the external-link icon.
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { Link } from '@redislabsdev/redis-ui-components';
|
|
68
|
+
|
|
69
|
+
<>
|
|
70
|
+
<Link href="#">Normal Link</Link>
|
|
71
|
+
<Link href="#" external>
|
|
72
|
+
With External link icon
|
|
73
|
+
</Link>
|
|
74
|
+
</>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Variants
|
|
78
|
+
|
|
79
|
+
> Two variants are supported: `button` and `inline`. The default is `button`. Two sizes are supported: `M` and `S`.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { Link } from '@redislabsdev/redis-ui-components';
|
|
83
|
+
|
|
84
|
+
<>
|
|
85
|
+
<Link href="#" external>
|
|
86
|
+
Button - M (default)
|
|
87
|
+
</Link>
|
|
88
|
+
<Link href="#" external size="S">
|
|
89
|
+
Button - S
|
|
90
|
+
</Link>
|
|
91
|
+
<Link href="#" external variant="inline">
|
|
92
|
+
Inline - M
|
|
93
|
+
</Link>
|
|
94
|
+
<Link href="#" external variant="inline" size="S">
|
|
95
|
+
Inline - S
|
|
96
|
+
</Link>
|
|
97
|
+
</>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### WithIcon
|
|
101
|
+
|
|
102
|
+
> Use the `icon` prop to add an icon to the link.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { ContractIcon } from '@redislabsdev/redis-ui-icons';
|
|
106
|
+
import { Link } from '@redislabsdev/redis-ui-components';
|
|
107
|
+
|
|
108
|
+
<>
|
|
109
|
+
<Link href="#" external icon={ContractIcon}>
|
|
110
|
+
Button - M (default)
|
|
111
|
+
</Link>
|
|
112
|
+
<Link href="#" external icon={ContractIcon} size="S">
|
|
113
|
+
Button - S
|
|
114
|
+
</Link>
|
|
115
|
+
<Link href="#" external icon={ContractIcon} variant="inline">
|
|
116
|
+
Inline - M
|
|
117
|
+
</Link>
|
|
118
|
+
<Link href="#" external icon={ContractIcon} variant="inline" size="S">
|
|
119
|
+
Inline - S
|
|
120
|
+
</Link>
|
|
121
|
+
</>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Disabled
|
|
125
|
+
|
|
126
|
+
> Setting `disabled` disables focus, click, and keyboard interaction.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { ContractIcon } from '@redislabsdev/redis-ui-icons';
|
|
130
|
+
import { Link } from '@redislabsdev/redis-ui-components';
|
|
131
|
+
|
|
132
|
+
<>
|
|
133
|
+
<Link href="#" external icon={ContractIcon} disabled>
|
|
134
|
+
Button - M (default)
|
|
135
|
+
</Link>
|
|
136
|
+
<Link href="#" external icon={ContractIcon} disabled size="S">
|
|
137
|
+
Button - S
|
|
138
|
+
</Link>
|
|
139
|
+
<Link href="#" external icon={ContractIcon} disabled variant="inline">
|
|
140
|
+
Inline - M
|
|
141
|
+
</Link>
|
|
142
|
+
<Link href="#" external icon={ContractIcon} disabled variant="inline" size="S">
|
|
143
|
+
Inline - S
|
|
144
|
+
</Link>
|
|
145
|
+
</>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### AnchorAndButton
|
|
149
|
+
|
|
150
|
+
> If `href` is set, `Link` behaves as an anchor. Otherwise it behaves like a button and uses `onClick`. If neither `href` nor `onClick` is defined, the link is disabled by default.
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import { Link } from '@redislabsdev/redis-ui-components';
|
|
154
|
+
|
|
155
|
+
<>
|
|
156
|
+
<Link href="#">href Link</Link>
|
|
157
|
+
<Link onClick={() => alert('Link clicked')}>onClick Link</Link>
|
|
158
|
+
<Link href="#" onClick={() => alert('Link clicked')}>
|
|
159
|
+
onClick & href Link
|
|
160
|
+
</Link>
|
|
161
|
+
<Link>None - Auto disabled</Link>
|
|
162
|
+
</>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Wrapping
|
|
166
|
+
|
|
167
|
+
> Use `allowWrap` to let the link wrap in text flow or in constrained containers.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { ContractIcon } from '@redislabsdev/redis-ui-icons';
|
|
171
|
+
import { Link } from '@redislabsdev/redis-ui-components';
|
|
172
|
+
|
|
173
|
+
const baseProps = { href: '', onClick: () => false, icon: ContractIcon, external: true };
|
|
174
|
+
|
|
175
|
+
<>
|
|
176
|
+
<div style={{ textDecoration: 'underline', maxWidth: '80rem' }}>
|
|
177
|
+
text text text text text text text text text text text text text text text text text text
|
|
178
|
+
text text text text text text{' '}
|
|
179
|
+
<Link {...baseProps} variant="inline" allowWrap>
|
|
180
|
+
Wrapping inline Link content
|
|
181
|
+
</Link>{' '}
|
|
182
|
+
text text text text text text text text text text text text text text text text text text
|
|
183
|
+
text text{' '}
|
|
184
|
+
<Link {...baseProps} variant="inline">
|
|
185
|
+
Non-wrapping inline Link content
|
|
186
|
+
</Link>{' '}
|
|
187
|
+
text text text text text text text text text text text text text text text{' '}
|
|
188
|
+
<Link {...baseProps} variant="button" allowWrap>
|
|
189
|
+
Wrapping button Link content
|
|
190
|
+
</Link>
|
|
191
|
+
text text text text text text text text text text text text text text text text text
|
|
192
|
+
<Link {...baseProps} variant="button">
|
|
193
|
+
Non-wrapping button Link content
|
|
194
|
+
</Link>
|
|
195
|
+
text text text text text text text text text text text text text text text text text
|
|
196
|
+
</div>
|
|
197
|
+
<div style={{ textDecoration: 'underline', maxWidth: '15rem' }}>
|
|
198
|
+
<div>
|
|
199
|
+
<Link {...baseProps} variant="inline" allowWrap>
|
|
200
|
+
Wrapping inline Link content
|
|
201
|
+
</Link>
|
|
202
|
+
<Link {...baseProps} variant="inline">
|
|
203
|
+
Non-wrapping inline Link content
|
|
204
|
+
</Link>
|
|
205
|
+
<Link {...baseProps} variant="button" allowWrap>
|
|
206
|
+
Wrapping button Link content
|
|
207
|
+
</Link>
|
|
208
|
+
<Link {...baseProps} variant="button">
|
|
209
|
+
Non-wrapping button Link content
|
|
210
|
+
</Link>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### LinkStyler Playground
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
import { Link, LinkStyler } from '@redislabsdev/redis-ui-components';
|
|
220
|
+
|
|
221
|
+
<>
|
|
222
|
+
<Link href="#">Link</Link>
|
|
223
|
+
<LinkStyler>
|
|
224
|
+
<a href="#">
|
|
225
|
+
<LinkStyler.LinkContent>LinkStyler wrapped anchor</LinkStyler.LinkContent>
|
|
226
|
+
</a>
|
|
227
|
+
</LinkStyler>
|
|
228
|
+
</>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### LinkStyler ExternalLink
|
|
232
|
+
|
|
233
|
+
> Setting `external` on the `LinkStyler.LinkContent` appends external link icon.
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
import { LinkStyler } from '@redislabsdev/redis-ui-components';
|
|
237
|
+
|
|
238
|
+
<>
|
|
239
|
+
<LinkStyler>
|
|
240
|
+
<a href="#">
|
|
241
|
+
<LinkStyler.LinkContent external>Normal Link</LinkStyler.LinkContent>
|
|
242
|
+
</a>
|
|
243
|
+
</LinkStyler>
|
|
244
|
+
<LinkStyler>
|
|
245
|
+
<a href="#">
|
|
246
|
+
<LinkStyler.LinkContent external>With `external` icon</LinkStyler.LinkContent>
|
|
247
|
+
</a>
|
|
248
|
+
</LinkStyler>
|
|
249
|
+
</>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### LinkStyler Variants
|
|
253
|
+
|
|
254
|
+
> Two variants are supported, `button` and `inline` (as native anchor). The default is `button`. Two sizes are supported, `M` and `S`. The default is `M`.
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
import { LinkStyler } from '@redislabsdev/redis-ui-components';
|
|
258
|
+
|
|
259
|
+
<>
|
|
260
|
+
<LinkStyler>
|
|
261
|
+
<a href="#">
|
|
262
|
+
<LinkStyler.LinkContent external>Button - M (default)</LinkStyler.LinkContent>
|
|
263
|
+
</a>
|
|
264
|
+
</LinkStyler>
|
|
265
|
+
<LinkStyler size="S">
|
|
266
|
+
<a href="#">
|
|
267
|
+
<LinkStyler.LinkContent external>Button - S</LinkStyler.LinkContent>
|
|
268
|
+
</a>
|
|
269
|
+
</LinkStyler>
|
|
270
|
+
<LinkStyler variant="inline">
|
|
271
|
+
<a href="#">
|
|
272
|
+
<LinkStyler.LinkContent external>Inline - M</LinkStyler.LinkContent>
|
|
273
|
+
</a>
|
|
274
|
+
</LinkStyler>
|
|
275
|
+
<LinkStyler variant="inline" size="S">
|
|
276
|
+
<a href="#">
|
|
277
|
+
<LinkStyler.LinkContent external>Inline - S</LinkStyler.LinkContent>
|
|
278
|
+
</a>
|
|
279
|
+
</LinkStyler>
|
|
280
|
+
</>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### LinkStyler WithIcon
|
|
284
|
+
|
|
285
|
+
> To add an icon to a link content, use the `icon` prop of `LinkStyler.LinkContent`.
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import { ContractIcon } from '@redislabsdev/redis-ui-icons';
|
|
289
|
+
import { LinkStyler } from '@redislabsdev/redis-ui-components';
|
|
290
|
+
|
|
291
|
+
<>
|
|
292
|
+
<LinkStyler>
|
|
293
|
+
<a href="#">
|
|
294
|
+
<LinkStyler.LinkContent external icon={ContractIcon}>
|
|
295
|
+
Button - M (default)
|
|
296
|
+
</LinkStyler.LinkContent>
|
|
297
|
+
</a>
|
|
298
|
+
</LinkStyler>
|
|
299
|
+
<LinkStyler size="S">
|
|
300
|
+
<a href="#">
|
|
301
|
+
<LinkStyler.LinkContent external icon={ContractIcon}>
|
|
302
|
+
Button - S
|
|
303
|
+
</LinkStyler.LinkContent>
|
|
304
|
+
</a>
|
|
305
|
+
</LinkStyler>
|
|
306
|
+
<LinkStyler variant="inline">
|
|
307
|
+
<a href="#">
|
|
308
|
+
<LinkStyler.LinkContent external icon={ContractIcon}>
|
|
309
|
+
Inline - M
|
|
310
|
+
</LinkStyler.LinkContent>
|
|
311
|
+
</a>
|
|
312
|
+
</LinkStyler>
|
|
313
|
+
<LinkStyler variant="inline" size="S">
|
|
314
|
+
<a href="#">
|
|
315
|
+
<LinkStyler.LinkContent external icon={ContractIcon}>
|
|
316
|
+
Inline - S
|
|
317
|
+
</LinkStyler.LinkContent>
|
|
318
|
+
</a>
|
|
319
|
+
</LinkStyler>
|
|
320
|
+
</>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### LinkStyler Wrapping
|
|
324
|
+
|
|
325
|
+
> To allow text wrapping, use the `allowWrap` property.
|
|
326
|
+
> Wrapping behaves slightly differently for the `button` and `inline` variants.
|
|
327
|
+
> While the `inline` variant wraps the content along with the containing text, the `button` variant wraps the content within the anchor block.
|
|
328
|
+
|
|
329
|
+
```tsx
|
|
330
|
+
import { ContractIcon } from '@redislabsdev/redis-ui-icons';
|
|
331
|
+
import { LinkStyler } from '@redislabsdev/redis-ui-components';
|
|
332
|
+
|
|
333
|
+
const renderLink = ({ children, ...props }) => (
|
|
334
|
+
<LinkStyler {...props}>
|
|
335
|
+
<a href="#">
|
|
336
|
+
<LinkStyler.LinkContent external icon={ContractIcon}>
|
|
337
|
+
{children}
|
|
338
|
+
</LinkStyler.LinkContent>
|
|
339
|
+
</a>
|
|
340
|
+
</LinkStyler>
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
<>
|
|
344
|
+
<div style={{ textDecoration: 'underline', maxWidth: '80rem' }}>
|
|
345
|
+
text text text text text text text text text text text text text text text text text text
|
|
346
|
+
text text text text text text{' '}
|
|
347
|
+
{renderLink({
|
|
348
|
+
variant: 'inline',
|
|
349
|
+
allowWrap: true,
|
|
350
|
+
children: 'Wrapping inline Link content'
|
|
351
|
+
})}{' '}
|
|
352
|
+
text text text text text text text text text text text text text text text text text text
|
|
353
|
+
text text{' '}
|
|
354
|
+
{renderLink({
|
|
355
|
+
variant: 'inline',
|
|
356
|
+
children: 'Non-wrapping inline Link content'
|
|
357
|
+
})}{' '}
|
|
358
|
+
text text text text text text text text text text text text text text text{' '}
|
|
359
|
+
{renderLink({
|
|
360
|
+
variant: 'button',
|
|
361
|
+
allowWrap: true,
|
|
362
|
+
children: 'Wrapping button Link content'
|
|
363
|
+
})}
|
|
364
|
+
text text text text text text text text text text text text text text text text text
|
|
365
|
+
{renderLink({
|
|
366
|
+
variant: 'button',
|
|
367
|
+
children: 'Non-Wrapping button Link content'
|
|
368
|
+
})}
|
|
369
|
+
text text text text text text text text text text text text text text text text text
|
|
370
|
+
</div>
|
|
371
|
+
<div style={{ textDecoration: 'underline', maxWidth: '15rem' }}>
|
|
372
|
+
<div>
|
|
373
|
+
{renderLink({
|
|
374
|
+
variant: 'inline',
|
|
375
|
+
allowWrap: true,
|
|
376
|
+
children: 'Wrapping inline Link content'
|
|
377
|
+
})}
|
|
378
|
+
{renderLink({
|
|
379
|
+
variant: 'inline',
|
|
380
|
+
children: 'Non-wrapping inline Link content'
|
|
381
|
+
})}
|
|
382
|
+
{renderLink({
|
|
383
|
+
variant: 'button',
|
|
384
|
+
allowWrap: true,
|
|
385
|
+
children: 'Wrapping button Link content'
|
|
386
|
+
})}
|
|
387
|
+
{renderLink({
|
|
388
|
+
variant: 'button',
|
|
389
|
+
children: 'Non-Wrapping button Link content'
|
|
390
|
+
})}
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
</>
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Notes
|
|
397
|
+
|
|
398
|
+
- `Link` defaults to the `button` variant and `M` size.
|
|
399
|
+
- `disabled` prevents keyboard and pointer interaction whether `href` is present or not.
|
|
400
|
+
- `LinkStyler` is available for custom composed link layouts.
|
|
401
|
+
- `LinkStyler.LinkContent` appends the external arrow icon when `external` is set.
|
|
402
|
+
- `LinkStyler` supports the same `button` and `inline` variants as `Link`, plus `allowWrap` and `size`.
|