aidos-ui 4.0.4 → 4.0.6
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/LICENSE +1 -1
- package/README.md +23 -3
- package/dist/index.d.ts +801 -68
- package/dist/index.js +3934 -68
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +6 -2
- package/dist/jsx-dev-runtime.js +87 -42
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +2 -2
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/vite-plugin-jss-debug.d.ts +3 -1
- package/dist/vite-plugin-jss-debug.js +57 -74
- package/dist/vite-plugin-jss-debug.js.map +1 -1
- package/package.json +61 -27
- package/.prettierrc +0 -4
- package/CLAUDE.md +0 -72
- package/dist/Badge.d.ts +0 -6
- package/dist/Badge.js +0 -22
- package/dist/Badge.js.map +0 -1
- package/dist/BaseButton.d.ts +0 -14
- package/dist/BaseButton.js +0 -23
- package/dist/BaseButton.js.map +0 -1
- package/dist/BaseInput.d.ts +0 -14
- package/dist/BaseInput.js +0 -15
- package/dist/BaseInput.js.map +0 -1
- package/dist/BaseLink.d.ts +0 -18
- package/dist/BaseLink.js +0 -29
- package/dist/BaseLink.js.map +0 -1
- package/dist/BaseList.d.ts +0 -6
- package/dist/BaseList.js +0 -14
- package/dist/BaseList.js.map +0 -1
- package/dist/BaseListAddOn.d.ts +0 -5
- package/dist/BaseListAddOn.js +0 -7
- package/dist/BaseListAddOn.js.map +0 -1
- package/dist/BaseListItem.d.ts +0 -26
- package/dist/BaseListItem.js +0 -29
- package/dist/BaseListItem.js.map +0 -1
- package/dist/BaseView.d.ts +0 -12
- package/dist/BaseView.js +0 -26
- package/dist/BaseView.js.map +0 -1
- package/dist/Box.d.ts +0 -4
- package/dist/Box.js +0 -6
- package/dist/Box.js.map +0 -1
- package/dist/Button.d.ts +0 -20
- package/dist/Button.js +0 -19
- package/dist/Button.js.map +0 -1
- package/dist/Calendar.d.ts +0 -18
- package/dist/Calendar.js +0 -57
- package/dist/Calendar.js.map +0 -1
- package/dist/Card.d.ts +0 -4
- package/dist/Card.js +0 -14
- package/dist/Card.js.map +0 -1
- package/dist/Checkbox.d.ts +0 -11
- package/dist/Checkbox.js +0 -32
- package/dist/Checkbox.js.map +0 -1
- package/dist/Circle.d.ts +0 -5
- package/dist/Circle.js +0 -12
- package/dist/Circle.js.map +0 -1
- package/dist/Column.d.ts +0 -6
- package/dist/Column.js +0 -7
- package/dist/Column.js.map +0 -1
- package/dist/DarkMode.d.ts +0 -13
- package/dist/DarkMode.js +0 -62
- package/dist/DarkMode.js.map +0 -1
- package/dist/DateInput.d.ts +0 -13
- package/dist/DateInput.js +0 -29
- package/dist/DateInput.js.map +0 -1
- package/dist/DatePicker.d.ts +0 -11
- package/dist/DatePicker.js +0 -34
- package/dist/DatePicker.js.map +0 -1
- package/dist/DatetimeInput.d.ts +0 -13
- package/dist/DatetimeInput.js +0 -31
- package/dist/DatetimeInput.js.map +0 -1
- package/dist/DesignBook.d.ts +0 -1
- package/dist/DesignBook.js +0 -55
- package/dist/DesignBook.js.map +0 -1
- package/dist/Dialog.d.ts +0 -17
- package/dist/Dialog.js +0 -92
- package/dist/Dialog.js.map +0 -1
- package/dist/Dropdown.d.ts +0 -14
- package/dist/Dropdown.js +0 -65
- package/dist/Dropdown.js.map +0 -1
- package/dist/Emitter.d.ts +0 -6
- package/dist/Emitter.js +0 -19
- package/dist/Emitter.js.map +0 -1
- package/dist/FlexLayout.d.ts +0 -11
- package/dist/FlexLayout.js +0 -18
- package/dist/FlexLayout.js.map +0 -1
- package/dist/Icon.d.ts +0 -12
- package/dist/Icon.js +0 -60
- package/dist/Icon.js.map +0 -1
- package/dist/IconButton.d.ts +0 -11
- package/dist/IconButton.js +0 -34
- package/dist/IconButton.js.map +0 -1
- package/dist/IconLink.d.ts +0 -9
- package/dist/IconLink.js +0 -32
- package/dist/IconLink.js.map +0 -1
- package/dist/IconType.d.ts +0 -1
- package/dist/IconType.js +0 -2
- package/dist/IconType.js.map +0 -1
- package/dist/Interactable.d.ts +0 -50
- package/dist/Interactable.js +0 -169
- package/dist/Interactable.js.map +0 -1
- package/dist/JSSComment.d.ts +0 -10
- package/dist/JSSComment.js +0 -52
- package/dist/JSSComment.js.map +0 -1
- package/dist/Link.d.ts +0 -22
- package/dist/Link.js +0 -29
- package/dist/Link.js.map +0 -1
- package/dist/List.d.ts +0 -15
- package/dist/List.js +0 -29
- package/dist/List.js.map +0 -1
- package/dist/ListButtonItem.d.ts +0 -14
- package/dist/ListButtonItem.js +0 -11
- package/dist/ListButtonItem.js.map +0 -1
- package/dist/ListDivider.d.ts +0 -1
- package/dist/ListDivider.js +0 -12
- package/dist/ListDivider.js.map +0 -1
- package/dist/ListHeaderItem.d.ts +0 -10
- package/dist/ListHeaderItem.js +0 -15
- package/dist/ListHeaderItem.js.map +0 -1
- package/dist/ListItem.d.ts +0 -9
- package/dist/ListItem.js +0 -9
- package/dist/ListItem.js.map +0 -1
- package/dist/ListLinkItem.d.ts +0 -16
- package/dist/ListLinkItem.js +0 -11
- package/dist/ListLinkItem.js.map +0 -1
- package/dist/ListSpacer.d.ts +0 -1
- package/dist/ListSpacer.js +0 -13
- package/dist/ListSpacer.js.map +0 -1
- package/dist/MenuIcon.d.ts +0 -5
- package/dist/MenuIcon.js +0 -31
- package/dist/MenuIcon.js.map +0 -1
- package/dist/NextJSRouter.d.ts +0 -1
- package/dist/NextJSRouter.js +0 -37
- package/dist/NextJSRouter.js.map +0 -1
- package/dist/NextJSRouterState.d.ts +0 -38
- package/dist/NextJSRouterState.js +0 -111
- package/dist/NextJSRouterState.js.map +0 -1
- package/dist/OnVisible.d.ts +0 -5
- package/dist/OnVisible.js +0 -28
- package/dist/OnVisible.js.map +0 -1
- package/dist/Popover.d.ts +0 -22
- package/dist/Popover.js +0 -90
- package/dist/Popover.js.map +0 -1
- package/dist/ProgressBar.d.ts +0 -7
- package/dist/ProgressBar.js +0 -42
- package/dist/ProgressBar.js.map +0 -1
- package/dist/ProgressCircle.d.ts +0 -5
- package/dist/ProgressCircle.js +0 -12
- package/dist/ProgressCircle.js.map +0 -1
- package/dist/Providers.d.ts +0 -9
- package/dist/Providers.js +0 -16
- package/dist/Providers.js.map +0 -1
- package/dist/RangeInput.d.ts +0 -14
- package/dist/RangeInput.js +0 -32
- package/dist/RangeInput.js.map +0 -1
- package/dist/ResultOrError.d.ts +0 -13
- package/dist/ResultOrError.js +0 -7
- package/dist/ResultOrError.js.map +0 -1
- package/dist/RootView.d.ts +0 -5
- package/dist/RootView.js +0 -35
- package/dist/RootView.js.map +0 -1
- package/dist/Row.d.ts +0 -6
- package/dist/Row.js +0 -7
- package/dist/Row.js.map +0 -1
- package/dist/Select.d.ts +0 -9
- package/dist/Select.js +0 -17
- package/dist/Select.js.map +0 -1
- package/dist/StackContext.d.ts +0 -8
- package/dist/StackContext.js +0 -25
- package/dist/StackContext.js.map +0 -1
- package/dist/StaticCheckbox.d.ts +0 -16
- package/dist/StaticCheckbox.js +0 -48
- package/dist/StaticCheckbox.js.map +0 -1
- package/dist/Storage.d.ts +0 -13
- package/dist/Storage.js +0 -146
- package/dist/Storage.js.map +0 -1
- package/dist/Stream.d.ts +0 -9
- package/dist/Stream.js +0 -36
- package/dist/Stream.js.map +0 -1
- package/dist/Sublist.d.ts +0 -12
- package/dist/Sublist.js +0 -18
- package/dist/Sublist.js.map +0 -1
- package/dist/SubmitIconInput.d.ts +0 -8
- package/dist/SubmitIconInput.js +0 -25
- package/dist/SubmitIconInput.js.map +0 -1
- package/dist/Tabs.d.ts +0 -23
- package/dist/Tabs.js +0 -39
- package/dist/Tabs.js.map +0 -1
- package/dist/Text.d.ts +0 -25
- package/dist/Text.js +0 -52
- package/dist/Text.js.map +0 -1
- package/dist/TextArea.d.ts +0 -11
- package/dist/TextArea.js +0 -27
- package/dist/TextArea.js.map +0 -1
- package/dist/TextInput.d.ts +0 -15
- package/dist/TextInput.js +0 -61
- package/dist/TextInput.js.map +0 -1
- package/dist/TextInputWithState.d.ts +0 -8
- package/dist/TextInputWithState.js +0 -14
- package/dist/TextInputWithState.js.map +0 -1
- package/dist/TextPairing.d.ts +0 -21
- package/dist/TextPairing.js +0 -26
- package/dist/TextPairing.js.map +0 -1
- package/dist/TimeInput.d.ts +0 -15
- package/dist/TimeInput.js +0 -58
- package/dist/TimeInput.js.map +0 -1
- package/dist/Tooltip.d.ts +0 -11
- package/dist/Tooltip.js +0 -73
- package/dist/Tooltip.js.map +0 -1
- package/dist/aria.d.ts +0 -8
- package/dist/aria.js +0 -42
- package/dist/aria.js.map +0 -1
- package/dist/guid.d.ts +0 -1
- package/dist/guid.js +0 -7
- package/dist/guid.js.map +0 -1
- package/dist/hash.d.ts +0 -1
- package/dist/hash.js +0 -20
- package/dist/hash.js.map +0 -1
- package/dist/isServer.d.ts +0 -1
- package/dist/isServer.js +0 -4
- package/dist/isServer.js.map +0 -1
- package/dist/jss.d.ts +0 -122
- package/dist/jss.js +0 -515
- package/dist/jss.js.map +0 -1
- package/dist/numberToBase.d.ts +0 -1
- package/dist/numberToBase.js +0 -44
- package/dist/numberToBase.js.map +0 -1
- package/dist/stateMachineContextFactory.d.ts +0 -36
- package/dist/stateMachineContextFactory.js +0 -48
- package/dist/stateMachineContextFactory.js.map +0 -1
- package/dist/useCookie.d.ts +0 -9
- package/dist/useCookie.js +0 -67
- package/dist/useCookie.js.map +0 -1
- package/dist/useKeyboard.d.ts +0 -8
- package/dist/useKeyboard.js +0 -26
- package/dist/useKeyboard.js.map +0 -1
- package/dist/useNavigation.d.ts +0 -5
- package/dist/useNavigation.js +0 -79
- package/dist/useNavigation.js.map +0 -1
- package/dist/usePromise.d.ts +0 -1
- package/dist/usePromise.js +0 -12
- package/dist/usePromise.js.map +0 -1
- package/dist/useRefEffect.d.ts +0 -1
- package/dist/useRefEffect.js +0 -15
- package/dist/useRefEffect.js.map +0 -1
- package/jss-debug-loader.mjs +0 -44
- package/next-env.d.ts +0 -6
- package/next.config.js +0 -33
- package/scripts/embeddings.js +0 -93
- package/scripts/openai_embeddings.js +0 -100
- package/scripts/publish.js +0 -28
- package/scripts/test_embeddings.js +0 -47
- package/src/Badge.tsx +0 -36
- package/src/BaseButton.tsx +0 -62
- package/src/BaseInput.tsx +0 -63
- package/src/BaseLink.tsx +0 -80
- package/src/BaseList.tsx +0 -26
- package/src/BaseListAddOn.tsx +0 -10
- package/src/BaseListItem.tsx +0 -119
- package/src/BaseView.tsx +0 -57
- package/src/Box.tsx +0 -20
- package/src/Button.tsx +0 -90
- package/src/Calendar.tsx +0 -123
- package/src/Card.tsx +0 -30
- package/src/Checkbox.tsx +0 -63
- package/src/Circle.tsx +0 -24
- package/src/Column.tsx +0 -12
- package/src/DarkMode.tsx +0 -100
- package/src/DateInput.tsx +0 -63
- package/src/DatePicker.tsx +0 -67
- package/src/DatetimeInput.tsx +0 -64
- package/src/DesignBook.tsx +0 -677
- package/src/Dialog.tsx +0 -150
- package/src/Dropdown.tsx +0 -146
- package/src/Emitter.ts +0 -26
- package/src/FlexLayout.tsx +0 -53
- package/src/Icon.tsx +0 -80
- package/src/IconButton.tsx +0 -81
- package/src/IconLink.tsx +0 -59
- package/src/IconType.ts +0 -787
- package/src/Interactable.tsx +0 -210
- package/src/JSSComment.tsx +0 -56
- package/src/Link.tsx +0 -110
- package/src/List.tsx +0 -58
- package/src/ListButtonItem.tsx +0 -69
- package/src/ListDivider.tsx +0 -13
- package/src/ListHeaderItem.tsx +0 -45
- package/src/ListItem.tsx +0 -24
- package/src/ListLinkItem.tsx +0 -76
- package/src/ListSpacer.tsx +0 -14
- package/src/MenuIcon.tsx +0 -50
- package/src/NextJSRouter.tsx +0 -60
- package/src/NextJSRouterState.tsx +0 -154
- package/src/OnVisible.tsx +0 -42
- package/src/Popover.tsx +0 -145
- package/src/ProgressBar.tsx +0 -63
- package/src/ProgressCircle.tsx +0 -38
- package/src/Providers.tsx +0 -33
- package/src/RangeInput.tsx +0 -82
- package/src/ResultOrError.ts +0 -15
- package/src/RootView.tsx +0 -55
- package/src/Row.tsx +0 -12
- package/src/Select.tsx +0 -39
- package/src/StackContext.tsx +0 -52
- package/src/StaticCheckbox.tsx +0 -72
- package/src/Storage.tsx +0 -198
- package/src/Stream.tsx +0 -50
- package/src/Sublist.tsx +0 -61
- package/src/SubmitIconInput.tsx +0 -45
- package/src/Tabs.tsx +0 -110
- package/src/Text.tsx +0 -111
- package/src/TextArea.tsx +0 -58
- package/src/TextInput.tsx +0 -123
- package/src/TextInputWithState.tsx +0 -32
- package/src/TextPairing.tsx +0 -115
- package/src/TimeInput.tsx +0 -109
- package/src/Tooltip.tsx +0 -109
- package/src/aria.ts +0 -72
- package/src/docs/mdx.tsx +0 -137
- package/src/docs/pages.ts +0 -115
- package/src/docs/searchIndex.ts +0 -1
- package/src/examples/ExampleDialog.tsx +0 -28
- package/src/guid.ts +0 -7
- package/src/hash.ts +0 -21
- package/src/index.ts +0 -68
- package/src/isServer.ts +0 -3
- package/src/jss.tsx +0 -712
- package/src/jsx-dev-runtime.ts +0 -74
- package/src/jsx-runtime.ts +0 -2
- package/src/numberToBase.ts +0 -52
- package/src/pages/Badge.mdx +0 -152
- package/src/pages/Button.mdx +0 -163
- package/src/pages/Calendar.mdx +0 -254
- package/src/pages/Card.mdx +0 -147
- package/src/pages/Checkbox.mdx +0 -131
- package/src/pages/Dialog.mdx +0 -197
- package/src/pages/FlexLayout.mdx +0 -211
- package/src/pages/Hashing.mdx +0 -211
- package/src/pages/Icon.mdx +0 -171
- package/src/pages/IconButton.mdx +0 -155
- package/src/pages/Link.mdx +0 -160
- package/src/pages/List.mdx +0 -262
- package/src/pages/ListHeader.mdx +0 -220
- package/src/pages/Popover.mdx +0 -223
- package/src/pages/ProgressBar.mdx +0 -200
- package/src/pages/ProgressCircle.mdx +0 -218
- package/src/pages/RangeInput.mdx +0 -237
- package/src/pages/Tabs.mdx +0 -281
- package/src/pages/Text.mdx +0 -154
- package/src/pages/TextInput.mdx +0 -235
- package/src/pages/TextPairing.mdx +0 -204
- package/src/pages/TimeInput.mdx +0 -178
- package/src/pages/Tooltip.mdx +0 -115
- package/src/pages/_app.tsx +0 -466
- package/src/pages/_document.tsx +0 -30
- package/src/pages/css-in-js.mdx +0 -240
- package/src/pages/index.mdx +0 -58
- package/src/pages/navigation.mdx +0 -158
- package/src/pages/prism.css +0 -3
- package/src/pages/useCookie.mdx +0 -176
- package/src/pages/useKeyboard.mdx +0 -257
- package/src/pages/useNavigation.mdx +0 -258
- package/src/pages/usePromise.mdx +0 -280
- package/src/pages/useRefEffect.mdx +0 -251
- package/src/stateMachineContextFactory.tsx +0 -111
- package/src/useCookie.tsx +0 -95
- package/src/useKeyboard.tsx +0 -43
- package/src/useNavigation.tsx +0 -89
- package/src/usePromise.tsx +0 -18
- package/src/useRefEffect.tsx +0 -18
- package/src/vite-plugin-jss-debug.ts +0 -77
- package/tsconfig.build.json +0 -23
- package/tsconfig.json +0 -38
package/src/pages/Hashing.mdx
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
# Hashing and Unique IDs
|
|
2
|
-
|
|
3
|
-
Utility functions for generating consistent hashes and converting numbers to different bases. Useful for creating unique identifiers, keys, and compact representations.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## hash
|
|
8
|
-
|
|
9
|
-
Generates a numeric hash from a string. The hash is deterministic - the same input always produces the same output.
|
|
10
|
-
|
|
11
|
-
### Signature
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
function hash(source: string, modulus?: number): number
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Parameters
|
|
18
|
-
|
|
19
|
-
| Parameter | Type | Default | Description |
|
|
20
|
-
|-----------|------|---------|-------------|
|
|
21
|
-
| `source` | `string` | Required | The string to hash |
|
|
22
|
-
| `modulus` | `number` | - | Optional modulus to constrain the hash range |
|
|
23
|
-
|
|
24
|
-
### Returns
|
|
25
|
-
|
|
26
|
-
A non-negative integer hash value.
|
|
27
|
-
|
|
28
|
-
### Basic usage
|
|
29
|
-
|
|
30
|
-
```js
|
|
31
|
-
import { hash } from "aidos-ui";
|
|
32
|
-
|
|
33
|
-
const id = hash("ABC"); // 64578
|
|
34
|
-
const id2 = hash("ABC"); // 64578 (same input = same output)
|
|
35
|
-
const id3 = hash("ABCD"); // Different value
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### With modulus
|
|
39
|
-
|
|
40
|
-
Constrain the hash to a specific range:
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
// Hash constrained to 0-9
|
|
44
|
-
const small_id = hash("ABC", 10); // 8
|
|
45
|
-
|
|
46
|
-
// Hash constrained to 0-99
|
|
47
|
-
const medium_id = hash("ABC", 100); // 78
|
|
48
|
-
|
|
49
|
-
// Useful for array indices
|
|
50
|
-
const colors = ["red", "blue", "green", "yellow"];
|
|
51
|
-
const colorIndex = hash("user123", colors.length);
|
|
52
|
-
const userColor = colors[colorIndex];
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Use cases
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
// Consistent avatar colors
|
|
59
|
-
function getUserColor(userId) {
|
|
60
|
-
const colors = ["#FF5733", "#33FF57", "#3357FF", "#FF33F5"];
|
|
61
|
-
return colors[hash(userId, colors.length)];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Cache keys
|
|
65
|
-
const cacheKey = hash(JSON.stringify(params));
|
|
66
|
-
|
|
67
|
-
// Partitioning
|
|
68
|
-
const partition = hash(userId, 10); // 0-9
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## numberToBase
|
|
74
|
-
|
|
75
|
-
Converts a number to a string representation in an arbitrary base using custom characters.
|
|
76
|
-
|
|
77
|
-
### Signature
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
function numberToBase(
|
|
81
|
-
value: number,
|
|
82
|
-
alphabet?: string[]
|
|
83
|
-
): string
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Parameters
|
|
87
|
-
|
|
88
|
-
| Parameter | Type | Default | Description |
|
|
89
|
-
|-----------|------|---------|-------------|
|
|
90
|
-
| `value` | `number` | Required | The number to convert |
|
|
91
|
-
| `alphabet` | `string[]` | `["a"-"z"]` | Characters to use for each digit |
|
|
92
|
-
|
|
93
|
-
### Returns
|
|
94
|
-
|
|
95
|
-
A string representation of the number in the given base.
|
|
96
|
-
|
|
97
|
-
### Basic usage
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
import { numberToBase } from "aidos-ui";
|
|
101
|
-
|
|
102
|
-
// Default: base-26 using lowercase letters
|
|
103
|
-
const id = numberToBase(hash("ABC")); // "cqmv"
|
|
104
|
-
const id2 = numberToBase(12345); // "wmt"
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Custom bases
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
// Binary (base-2)
|
|
111
|
-
numberToBase(8, ["0", "1"]); // "1000"
|
|
112
|
-
|
|
113
|
-
// With custom symbols
|
|
114
|
-
numberToBase(hash("ABC"), ["?", "!"]); // "!!!!!???!???!?!"
|
|
115
|
-
|
|
116
|
-
// Hexadecimal-like
|
|
117
|
-
const hex = ["0", "1", "2", "3", "4", "5", "6", "7",
|
|
118
|
-
"8", "9", "a", "b", "c", "d", "e", "f"];
|
|
119
|
-
numberToBase(255, hex); // "ff"
|
|
120
|
-
|
|
121
|
-
// URL-safe characters
|
|
122
|
-
const urlSafe = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("");
|
|
123
|
-
numberToBase(123456789, urlSafe); // Compact URL-safe ID
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Combining with hash
|
|
127
|
-
|
|
128
|
-
```js
|
|
129
|
-
// Generate compact, unique IDs
|
|
130
|
-
function generateId(input) {
|
|
131
|
-
return numberToBase(hash(input));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const userId = generateId("user@example.com"); // e.g., "xkcd"
|
|
135
|
-
const postId = generateId("blog-post-title"); // e.g., "qwer"
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## Common patterns
|
|
141
|
-
|
|
142
|
-
### Unique class names
|
|
143
|
-
|
|
144
|
-
```js
|
|
145
|
-
function uniqueClassName(styles) {
|
|
146
|
-
const styleString = JSON.stringify(styles);
|
|
147
|
-
return `_${numberToBase(hash(styleString))}`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const className = uniqueClassName({ color: "red" }); // e.g., "_abc"
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Consistent randomization
|
|
154
|
-
|
|
155
|
-
```js
|
|
156
|
-
// Same input always gives same "random" result
|
|
157
|
-
function pseudoRandom(seed, max) {
|
|
158
|
-
return hash(seed, max);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Consistent shuffle based on seed
|
|
162
|
-
function seededShuffle(array, seed) {
|
|
163
|
-
return array.slice().sort((a, b) => {
|
|
164
|
-
return hash(`${seed}-${a}`) - hash(`${seed}-${b}`);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Short URLs
|
|
170
|
-
|
|
171
|
-
```js
|
|
172
|
-
// Convert database IDs to short codes
|
|
173
|
-
function toShortCode(numericId) {
|
|
174
|
-
const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
175
|
-
return numberToBase(numericId, chars);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
toShortCode(123456); // e.g., "w7e"
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Color from string
|
|
182
|
-
|
|
183
|
-
```js
|
|
184
|
-
function stringToColor(str) {
|
|
185
|
-
const h = hash(str, 360);
|
|
186
|
-
return `hsl(${h}, 70%, 50%)`;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
stringToColor("John"); // Consistent color for "John"
|
|
190
|
-
stringToColor("Jane"); // Different color for "Jane"
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## Algorithm details
|
|
196
|
-
|
|
197
|
-
The `hash` function uses a simple but effective string hashing algorithm:
|
|
198
|
-
- Iterates through each character
|
|
199
|
-
- Combines character codes using bit shifting
|
|
200
|
-
- Produces a 32-bit integer hash
|
|
201
|
-
- Applies modulus if specified
|
|
202
|
-
|
|
203
|
-
This is suitable for:
|
|
204
|
-
- Generating consistent keys
|
|
205
|
-
- Distributing values evenly
|
|
206
|
-
- Creating pseudo-random but reproducible results
|
|
207
|
-
|
|
208
|
-
Not suitable for:
|
|
209
|
-
- Cryptographic purposes
|
|
210
|
-
- Security-sensitive hashing
|
|
211
|
-
- Password storage
|
package/src/pages/Icon.mdx
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { Icon } from "../Icon";
|
|
2
|
-
import { Row } from "../Row";
|
|
3
|
-
import { Column } from "../Column";
|
|
4
|
-
|
|
5
|
-
# Icon
|
|
6
|
-
|
|
7
|
-
The `Icon` component displays vector icons using [Iconify](https://iconify.design/) under the hood, giving you access to 200,000+ icons from 150+ icon sets including Font Awesome, Material Design, and more.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Props
|
|
12
|
-
|
|
13
|
-
| Prop | Type | Required | Description |
|
|
14
|
-
|------|------|----------|-------------|
|
|
15
|
-
| `icon` | `IconType` | Yes | The icon identifier (e.g., `"fa-check"`, `"fa-github"`) |
|
|
16
|
-
| `size` | `Size` | Yes | Icon size: `"xsmall"` (8px), `"small"` (12px), `"medium"` (18px), `"large"` (24px), `"xlarge"` (32px), `"xxlarge"` (48px), `"xxxlarge"` (64px) |
|
|
17
|
-
| `color` | `TextColor` | Yes | Icon color: `"primary"`, `"secondary"`, `"highlight"`, `"negative"`, `"subtle"`, `"light"` |
|
|
18
|
-
| `ariaLabel` | `string` | No | Accessible label for screen readers |
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Sizes
|
|
23
|
-
|
|
24
|
-
Icons come in seven predefined sizes to maintain consistency across your application.
|
|
25
|
-
|
|
26
|
-
<Column gap="medium">
|
|
27
|
-
<Row justify="space-around" align="center">
|
|
28
|
-
<Icon icon="fa-star" color="primary" size="xsmall" />
|
|
29
|
-
<Icon icon="fa-star" color="primary" size="small" />
|
|
30
|
-
<Icon icon="fa-star" color="primary" size="medium" />
|
|
31
|
-
<Icon icon="fa-star" color="primary" size="large" />
|
|
32
|
-
<Icon icon="fa-star" color="primary" size="xlarge" />
|
|
33
|
-
<Icon icon="fa-star" color="primary" size="xxlarge" />
|
|
34
|
-
<Icon icon="fa-star" color="primary" size="xxxlarge" />
|
|
35
|
-
</Row>
|
|
36
|
-
</Column>
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
<Icon icon="fa-star" color="primary" size="xsmall" /> // 8px
|
|
40
|
-
<Icon icon="fa-star" color="primary" size="small" /> // 12px
|
|
41
|
-
<Icon icon="fa-star" color="primary" size="medium" /> // 18px
|
|
42
|
-
<Icon icon="fa-star" color="primary" size="large" /> // 24px
|
|
43
|
-
<Icon icon="fa-star" color="primary" size="xlarge" /> // 32px
|
|
44
|
-
<Icon icon="fa-star" color="primary" size="xxlarge" /> // 48px
|
|
45
|
-
<Icon icon="fa-star" color="primary" size="xxxlarge" /> // 64px
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## Colors
|
|
51
|
-
|
|
52
|
-
Icons inherit semantic colors from the theme system, ensuring they adapt correctly to light and dark modes.
|
|
53
|
-
|
|
54
|
-
<Column gap="medium">
|
|
55
|
-
<Row justify="space-around">
|
|
56
|
-
<Icon icon="fa-heart" color="primary" size="large" />
|
|
57
|
-
<Icon icon="fa-heart" color="secondary" size="large" />
|
|
58
|
-
<Icon icon="fa-heart" color="highlight" size="large" />
|
|
59
|
-
<Icon icon="fa-heart" color="negative" size="large" />
|
|
60
|
-
<Icon icon="fa-heart" color="subtle" size="large" />
|
|
61
|
-
<Icon icon="fa-heart" color="light" size="large" />
|
|
62
|
-
</Row>
|
|
63
|
-
</Column>
|
|
64
|
-
|
|
65
|
-
```js
|
|
66
|
-
<Icon icon="fa-heart" color="primary" size="large" /> // Main content color
|
|
67
|
-
<Icon icon="fa-heart" color="secondary" size="large" /> // Secondary content
|
|
68
|
-
<Icon icon="fa-heart" color="highlight" size="large" /> // Accent/brand color
|
|
69
|
-
<Icon icon="fa-heart" color="negative" size="large" /> // Error/destructive
|
|
70
|
-
<Icon icon="fa-heart" color="subtle" size="large" /> // Muted/disabled
|
|
71
|
-
<Icon icon="fa-heart" color="light" size="large" /> // Light/inverted
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## Icon examples
|
|
77
|
-
|
|
78
|
-
A selection of commonly used icons:
|
|
79
|
-
|
|
80
|
-
<Column gap="medium">
|
|
81
|
-
<Row justify="space-around">
|
|
82
|
-
<Icon icon="fa-check" color="primary" size="medium" />
|
|
83
|
-
<Icon icon="fa-close" color="negative" size="medium" />
|
|
84
|
-
<Icon icon="fa-search" color="secondary" size="medium" />
|
|
85
|
-
<Icon icon="fa-user" color="primary" size="medium" />
|
|
86
|
-
<Icon icon="fa-cog" color="secondary" size="medium" />
|
|
87
|
-
<Icon icon="fa-bell" color="highlight" size="medium" />
|
|
88
|
-
</Row>
|
|
89
|
-
<Row justify="space-around">
|
|
90
|
-
<Icon icon="fa-github" color="primary" size="medium" />
|
|
91
|
-
<Icon icon="fa-twitter" color="primary" size="medium" />
|
|
92
|
-
<Icon icon="fa-linkedin" color="primary" size="medium" />
|
|
93
|
-
<Icon icon="fa-envelope" color="primary" size="medium" />
|
|
94
|
-
<Icon icon="fa-phone" color="primary" size="medium" />
|
|
95
|
-
<Icon icon="fa-globe" color="primary" size="medium" />
|
|
96
|
-
</Row>
|
|
97
|
-
</Column>
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
// Action icons
|
|
101
|
-
<Icon icon="fa-check" color="primary" size="medium" />
|
|
102
|
-
<Icon icon="fa-close" color="negative" size="medium" />
|
|
103
|
-
<Icon icon="fa-search" color="secondary" size="medium" />
|
|
104
|
-
|
|
105
|
-
// Social icons
|
|
106
|
-
<Icon icon="fa-github" color="primary" size="medium" />
|
|
107
|
-
<Icon icon="fa-twitter" color="primary" size="medium" />
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Accessibility
|
|
113
|
-
|
|
114
|
-
Always provide an `ariaLabel` when the icon conveys meaning that isn't available through surrounding text.
|
|
115
|
-
|
|
116
|
-
```js
|
|
117
|
-
// Decorative icon (no label needed if text explains it)
|
|
118
|
-
<Button>
|
|
119
|
-
<Icon icon="fa-download" color="light" size="small" />
|
|
120
|
-
Download
|
|
121
|
-
</Button>
|
|
122
|
-
|
|
123
|
-
// Meaningful icon (needs label for screen readers)
|
|
124
|
-
<Icon
|
|
125
|
-
icon="fa-warning"
|
|
126
|
-
color="negative"
|
|
127
|
-
size="medium"
|
|
128
|
-
ariaLabel="Warning"
|
|
129
|
-
/>
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Preloading icons
|
|
135
|
-
|
|
136
|
-
By default, Iconify loads icons asynchronously from a CDN. To prevent flickering on initial render, you can preload icons by bundling them with your application.
|
|
137
|
-
|
|
138
|
-
**Option 1: Preload an entire icon set**
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
npm install @iconify-json/fa
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
```js
|
|
145
|
-
import { addCollection } from "@iconify/react";
|
|
146
|
-
import faIcons from "@iconify-json/fa/icons.json";
|
|
147
|
-
|
|
148
|
-
// Call once at app initialization (e.g., in _app.tsx)
|
|
149
|
-
addCollection(faIcons);
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
**Option 2: Preload individual icons**
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
npm install @iconify-icons/fa
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
```js
|
|
159
|
-
import { addIcon } from "@iconify/react";
|
|
160
|
-
import faCheck from "@iconify-icons/fa/check";
|
|
161
|
-
import faClose from "@iconify-icons/fa/close";
|
|
162
|
-
|
|
163
|
-
addIcon("fa:check", faCheck);
|
|
164
|
-
addIcon("fa:close", faClose);
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## Finding icons
|
|
170
|
-
|
|
171
|
-
Browse available icons at [Iconify Icon Sets](https://icon-sets.iconify.design/). The component uses Font Awesome 4 icons by default (prefixed with `fa-`), but you can use any Iconify-supported icon set.
|
package/src/pages/IconButton.mdx
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { IconButton } from "../IconButton";
|
|
2
|
-
import { Row } from "../Row";
|
|
3
|
-
import { Column } from "../Column";
|
|
4
|
-
|
|
5
|
-
# IconButton
|
|
6
|
-
|
|
7
|
-
A circular button containing only an icon. Use IconButton for compact actions where space is limited or when the icon alone clearly communicates the action's purpose.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Props
|
|
12
|
-
|
|
13
|
-
| Prop | Type | Required | Default | Description |
|
|
14
|
-
|------|------|----------|---------|-------------|
|
|
15
|
-
| `icon` | `IconType` | Yes | - | The icon to display |
|
|
16
|
-
| `size` | `Size` | Yes | - | Button size: `"xsmall"` (20px), `"small"` (24px), `"medium"` (32px), `"large"` (40px), `"xlarge"` (48px) |
|
|
17
|
-
| `color` | `InteractableColor` | Yes | - | `"positive"`, `"secondary"`, `"negative"`, `"dark"`, `"light"` |
|
|
18
|
-
| `onClick` | `function` | Yes | - | Click handler |
|
|
19
|
-
| `bare` | `boolean` | No | `false` | Removes background for a lighter appearance |
|
|
20
|
-
| `border` | `boolean` | No | `false` | Adds a border |
|
|
21
|
-
| `disabled` | `boolean` | No | `false` | Disables interaction |
|
|
22
|
-
| `aria-label` | `string` | No | - | Accessible label (recommended) |
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Basic variants
|
|
27
|
-
|
|
28
|
-
IconButtons come in different colors to indicate their purpose. Always pair with a clear, recognizable icon.
|
|
29
|
-
|
|
30
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
31
|
-
<IconButton size="medium" icon="fa-check" color="positive" onClick={() => {}} />
|
|
32
|
-
<IconButton size="medium" icon="fa-pencil" color="secondary" onClick={() => {}} />
|
|
33
|
-
<IconButton size="medium" icon="fa-trash" color="negative" onClick={() => {}} />
|
|
34
|
-
<IconButton size="medium" icon="fa-check" color="positive" disabled onClick={() => {}} />
|
|
35
|
-
</Row>
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
<IconButton
|
|
39
|
-
icon="fa-check"
|
|
40
|
-
size="medium"
|
|
41
|
-
color="positive"
|
|
42
|
-
aria-label="Confirm"
|
|
43
|
-
onClick={() => {}}
|
|
44
|
-
/>
|
|
45
|
-
|
|
46
|
-
<IconButton
|
|
47
|
-
icon="fa-pencil"
|
|
48
|
-
size="medium"
|
|
49
|
-
color="secondary"
|
|
50
|
-
aria-label="Edit"
|
|
51
|
-
onClick={() => {}}
|
|
52
|
-
/>
|
|
53
|
-
|
|
54
|
-
<IconButton
|
|
55
|
-
icon="fa-trash"
|
|
56
|
-
size="medium"
|
|
57
|
-
color="negative"
|
|
58
|
-
aria-label="Delete"
|
|
59
|
-
onClick={() => {}}
|
|
60
|
-
/>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Bare variant
|
|
66
|
-
|
|
67
|
-
The `bare` variant removes the background, creating a subtle button that works well in toolbars or alongside other content.
|
|
68
|
-
|
|
69
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
70
|
-
<IconButton bare size="medium" icon="fa-check" color="positive" onClick={() => {}} />
|
|
71
|
-
<IconButton bare size="medium" icon="fa-pencil" color="secondary" onClick={() => {}} />
|
|
72
|
-
<IconButton bare size="medium" icon="fa-trash" color="negative" onClick={() => {}} />
|
|
73
|
-
<IconButton bare size="medium" icon="fa-check" color="positive" disabled onClick={() => {}} />
|
|
74
|
-
</Row>
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
<IconButton
|
|
78
|
-
bare
|
|
79
|
-
icon="fa-close"
|
|
80
|
-
size="medium"
|
|
81
|
-
color="secondary"
|
|
82
|
-
aria-label="Close"
|
|
83
|
-
onClick={() => {}}
|
|
84
|
-
/>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Sizes
|
|
90
|
-
|
|
91
|
-
IconButtons scale proportionally, maintaining their circular shape at all sizes.
|
|
92
|
-
|
|
93
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
94
|
-
<IconButton size="xsmall" icon="fa-star" color="positive" onClick={() => {}} />
|
|
95
|
-
<IconButton size="small" icon="fa-star" color="positive" onClick={() => {}} />
|
|
96
|
-
<IconButton size="medium" icon="fa-star" color="positive" onClick={() => {}} />
|
|
97
|
-
<IconButton size="large" icon="fa-star" color="positive" onClick={() => {}} />
|
|
98
|
-
<IconButton size="xlarge" icon="fa-star" color="positive" onClick={() => {}} />
|
|
99
|
-
</Row>
|
|
100
|
-
|
|
101
|
-
```js
|
|
102
|
-
<IconButton size="xsmall" icon="fa-star" color="positive" onClick={() => {}} /> // 20px
|
|
103
|
-
<IconButton size="small" icon="fa-star" color="positive" onClick={() => {}} /> // 24px
|
|
104
|
-
<IconButton size="medium" icon="fa-star" color="positive" onClick={() => {}} /> // 32px
|
|
105
|
-
<IconButton size="large" icon="fa-star" color="positive" onClick={() => {}} /> // 40px
|
|
106
|
-
<IconButton size="xlarge" icon="fa-star" color="positive" onClick={() => {}} /> // 48px
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Common use cases
|
|
112
|
-
|
|
113
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
114
|
-
<IconButton bare size="medium" icon="fa-heart" color="negative" aria-label="Like" onClick={() => {}} />
|
|
115
|
-
<IconButton bare size="medium" icon="fa-bookmark" color="secondary" aria-label="Save" onClick={() => {}} />
|
|
116
|
-
<IconButton bare size="medium" icon="fa-share" color="secondary" aria-label="Share" onClick={() => {}} />
|
|
117
|
-
<IconButton bare size="medium" icon="fa-ellipsis-h" color="secondary" aria-label="More options" onClick={() => {}} />
|
|
118
|
-
</Row>
|
|
119
|
-
|
|
120
|
-
```js
|
|
121
|
-
// Social actions
|
|
122
|
-
<IconButton bare icon="fa-heart" size="medium" color="negative" aria-label="Like" onClick={() => {}} />
|
|
123
|
-
<IconButton bare icon="fa-bookmark" size="medium" color="secondary" aria-label="Save" onClick={() => {}} />
|
|
124
|
-
<IconButton bare icon="fa-share" size="medium" color="secondary" aria-label="Share" onClick={() => {}} />
|
|
125
|
-
|
|
126
|
-
// Menu trigger
|
|
127
|
-
<IconButton bare icon="fa-ellipsis-h" size="medium" color="secondary" aria-label="More options" onClick={() => {}} />
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## Accessibility
|
|
133
|
-
|
|
134
|
-
Since IconButtons have no visible text, always provide an `aria-label` to describe the action for screen reader users.
|
|
135
|
-
|
|
136
|
-
```js
|
|
137
|
-
// Good - has accessible label
|
|
138
|
-
<IconButton
|
|
139
|
-
icon="fa-trash"
|
|
140
|
-
size="medium"
|
|
141
|
-
color="negative"
|
|
142
|
-
aria-label="Delete item"
|
|
143
|
-
onClick={() => {}}
|
|
144
|
-
/>
|
|
145
|
-
|
|
146
|
-
// Bad - no accessible label
|
|
147
|
-
<IconButton
|
|
148
|
-
icon="fa-trash"
|
|
149
|
-
size="medium"
|
|
150
|
-
color="negative"
|
|
151
|
-
onClick={() => {}}
|
|
152
|
-
/>
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Consider using a `Tooltip` component alongside IconButton to provide visual hints for all users.
|
package/src/pages/Link.mdx
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { Link } from "../Link";
|
|
2
|
-
import { Row } from "../Row";
|
|
3
|
-
import { Column } from "../Column";
|
|
4
|
-
|
|
5
|
-
# Link
|
|
6
|
-
|
|
7
|
-
The `Link` component provides styled navigation that looks like a button but renders as a semantic `<a>` anchor element. Use it for navigation actions where you want button-like styling.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Props
|
|
12
|
-
|
|
13
|
-
| Prop | Type | Required | Default | Description |
|
|
14
|
-
|------|------|----------|---------|-------------|
|
|
15
|
-
| `children` | `ReactNode` | Yes | - | Link text content |
|
|
16
|
-
| `href` | `string` | Yes | - | Navigation destination URL |
|
|
17
|
-
| `color` | `InteractableColor` | Yes | - | `"positive"`, `"primary"`, `"negative"`, `"dark"`, `"light"` |
|
|
18
|
-
| `bare` | `boolean` | No | `false` | Removes background for a lighter appearance |
|
|
19
|
-
| `border` | `boolean` | No | `false` | Adds a border matching the text color |
|
|
20
|
-
| `disabled` | `boolean` | No | `false` | Disables interaction |
|
|
21
|
-
| `underline` | `boolean` | No | `false` | Adds text underline decoration |
|
|
22
|
-
| `icon` | `IconType` | No | - | Icon to display alongside text |
|
|
23
|
-
| `iconPosition` | `"left"` \| `"right"` | No | `"left"` | Icon placement relative to text |
|
|
24
|
-
| `iconSize` | `Size` | No | `"medium"` | Icon size |
|
|
25
|
-
| `size` | `Size` | No | `"medium"` | Text size |
|
|
26
|
-
| `padding` | `Padding` | No | `"medium"` | Internal padding |
|
|
27
|
-
| `inline` | `boolean` | No | `true` | Display as inline-flex (true) or flex (false) |
|
|
28
|
-
| `bold` | `boolean` | No | `false` | Bold text |
|
|
29
|
-
| `target` | `string` | No | - | Link target (e.g., `"_blank"` for new tab) |
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Color variants
|
|
34
|
-
|
|
35
|
-
Links share the same color system as buttons, providing visual consistency across your application.
|
|
36
|
-
|
|
37
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
38
|
-
<Link color="positive" href="/">Positive</Link>
|
|
39
|
-
<Link color="primary" href="/">Primary</Link>
|
|
40
|
-
<Link color="negative" href="/">Negative</Link>
|
|
41
|
-
<Link color="dark" href="/">Dark</Link>
|
|
42
|
-
<Link color="light" href="/">Light</Link>
|
|
43
|
-
</Row>
|
|
44
|
-
|
|
45
|
-
```js
|
|
46
|
-
<Link color="positive" href="/signup">Sign up</Link>
|
|
47
|
-
<Link color="primary" href="/learn-more">Learn more</Link>
|
|
48
|
-
<Link color="negative" href="/delete">Delete account</Link>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Bare variant
|
|
54
|
-
|
|
55
|
-
The `bare` prop creates a lighter appearance without a background, ideal for inline links or secondary navigation.
|
|
56
|
-
|
|
57
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
58
|
-
<Link bare color="positive" href="/">Positive</Link>
|
|
59
|
-
<Link bare color="primary" href="/">Primary</Link>
|
|
60
|
-
<Link bare color="negative" href="/">Negative</Link>
|
|
61
|
-
</Row>
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
<Link bare color="positive" href="/docs">Documentation</Link>
|
|
65
|
-
<Link bare color="primary" href="/about">About us</Link>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## With border
|
|
71
|
-
|
|
72
|
-
Combine `bare` and `border` for outlined link styles.
|
|
73
|
-
|
|
74
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
75
|
-
<Link border bare color="positive" href="/">Positive</Link>
|
|
76
|
-
<Link border bare color="primary" href="/">Primary</Link>
|
|
77
|
-
<Link border bare color="negative" href="/">Negative</Link>
|
|
78
|
-
</Row>
|
|
79
|
-
|
|
80
|
-
```js
|
|
81
|
-
<Link border bare color="positive" href="/signup">
|
|
82
|
-
Get started
|
|
83
|
-
</Link>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## With underline
|
|
89
|
-
|
|
90
|
-
The `underline` prop adds a text decoration, useful for traditional link styling within paragraphs.
|
|
91
|
-
|
|
92
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
93
|
-
<Link bare underline color="positive" href="/">Learn more</Link>
|
|
94
|
-
<Link bare underline color="primary" href="/">Read docs</Link>
|
|
95
|
-
</Row>
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
<Link bare underline color="positive" href="/docs">
|
|
99
|
-
Learn more
|
|
100
|
-
</Link>
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
## With icon
|
|
106
|
-
|
|
107
|
-
Add icons to reinforce the link's purpose or indicate external navigation.
|
|
108
|
-
|
|
109
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
110
|
-
<Link color="positive" icon="fa-external-link" iconPosition="right" href="/" target="_blank">External</Link>
|
|
111
|
-
<Link color="primary" icon="fa-download" href="/">Download</Link>
|
|
112
|
-
<Link bare color="primary" icon="fa-arrow-left" href="/">Back</Link>
|
|
113
|
-
</Row>
|
|
114
|
-
|
|
115
|
-
```js
|
|
116
|
-
<Link
|
|
117
|
-
color="positive"
|
|
118
|
-
icon="fa-external-link"
|
|
119
|
-
iconPosition="right"
|
|
120
|
-
href="https://example.com"
|
|
121
|
-
target="_blank"
|
|
122
|
-
>
|
|
123
|
-
External link
|
|
124
|
-
</Link>
|
|
125
|
-
|
|
126
|
-
<Link color="primary" icon="fa-download" href="/file.pdf">
|
|
127
|
-
Download PDF
|
|
128
|
-
</Link>
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Disabled state
|
|
134
|
-
|
|
135
|
-
Disabled links prevent navigation and display a muted appearance.
|
|
136
|
-
|
|
137
|
-
<Row gap="large" align="center" padding="large" justify="center">
|
|
138
|
-
<Link color="positive" disabled href="/">Disabled</Link>
|
|
139
|
-
<Link bare color="positive" disabled href="/">Disabled bare</Link>
|
|
140
|
-
</Row>
|
|
141
|
-
|
|
142
|
-
```js
|
|
143
|
-
<Link color="positive" disabled href="/premium">
|
|
144
|
-
Premium only
|
|
145
|
-
</Link>
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## Link vs Button
|
|
151
|
-
|
|
152
|
-
Use `Link` when:
|
|
153
|
-
- The action navigates to a new page or URL
|
|
154
|
-
- You want the browser's native link behaviors (right-click, cmd+click)
|
|
155
|
-
- SEO matters for the destination
|
|
156
|
-
|
|
157
|
-
Use `Button` when:
|
|
158
|
-
- The action triggers an in-page operation
|
|
159
|
-
- No navigation occurs
|
|
160
|
-
- Form submissions
|