aidos-ui 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +4 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/Badge.d.ts +7 -0
- package/dist/Badge.js +22 -0
- package/dist/Badge.js.map +1 -0
- package/dist/BaseButton.d.ts +13 -0
- package/dist/BaseButton.js +22 -0
- package/dist/BaseButton.js.map +1 -0
- package/dist/BaseInput.d.ts +15 -0
- package/dist/BaseInput.js +14 -0
- package/dist/BaseInput.js.map +1 -0
- package/dist/BaseLink.d.ts +17 -0
- package/dist/BaseLink.js +28 -0
- package/dist/BaseLink.js.map +1 -0
- package/dist/BaseList.d.ts +6 -0
- package/dist/BaseList.js +14 -0
- package/dist/BaseList.js.map +1 -0
- package/dist/BaseListAddOn.d.ts +5 -0
- package/dist/BaseListAddOn.js +7 -0
- package/dist/BaseListAddOn.js.map +1 -0
- package/dist/BaseListItem.d.ts +27 -0
- package/dist/BaseListItem.js +26 -0
- package/dist/BaseListItem.js.map +1 -0
- package/dist/BaseView.d.ts +12 -0
- package/dist/BaseView.js +26 -0
- package/dist/BaseView.js.map +1 -0
- package/dist/Box.d.ts +5 -0
- package/dist/Box.js +6 -0
- package/dist/Box.js.map +1 -0
- package/dist/Button.d.ts +20 -0
- package/dist/Button.js +20 -0
- package/dist/Button.js.map +1 -0
- package/dist/Calendar.d.ts +18 -0
- package/dist/Calendar.js +57 -0
- package/dist/Calendar.js.map +1 -0
- package/dist/Card.d.ts +4 -0
- package/dist/Card.js +12 -0
- package/dist/Card.js.map +1 -0
- package/dist/Checkbox.d.ts +12 -0
- package/dist/Checkbox.js +32 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Circle.d.ts +6 -0
- package/dist/Circle.js +12 -0
- package/dist/Circle.js.map +1 -0
- package/dist/Column.d.ts +6 -0
- package/dist/Column.js +7 -0
- package/dist/Column.js.map +1 -0
- package/dist/DarkMode.d.ts +13 -0
- package/dist/DarkMode.js +61 -0
- package/dist/DarkMode.js.map +1 -0
- package/dist/DateInput.d.ts +13 -0
- package/dist/DateInput.js +29 -0
- package/dist/DateInput.js.map +1 -0
- package/dist/DatePicker.d.ts +12 -0
- package/dist/DatePicker.js +34 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatetimeInput.d.ts +13 -0
- package/dist/DatetimeInput.js +31 -0
- package/dist/DatetimeInput.js.map +1 -0
- package/dist/DesignBook.d.ts +2 -0
- package/dist/DesignBook.js +55 -0
- package/dist/DesignBook.js.map +1 -0
- package/dist/Dialog.d.ts +17 -0
- package/dist/Dialog.js +86 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Dropdown.d.ts +10 -0
- package/dist/Dropdown.js +64 -0
- package/dist/Dropdown.js.map +1 -0
- package/dist/Emitter.d.ts +6 -0
- package/dist/Emitter.js +19 -0
- package/dist/Emitter.js.map +1 -0
- package/dist/FlexLayout.d.ts +11 -0
- package/dist/FlexLayout.js +18 -0
- package/dist/FlexLayout.js.map +1 -0
- package/dist/Icon.d.ts +12 -0
- package/dist/Icon.js +69 -0
- package/dist/Icon.js.map +1 -0
- package/dist/IconButton.d.ts +9 -0
- package/dist/IconButton.js +31 -0
- package/dist/IconButton.js.map +1 -0
- package/dist/IconLink.d.ts +9 -0
- package/dist/IconLink.js +31 -0
- package/dist/IconLink.js.map +1 -0
- package/dist/IconType.d.ts +1 -0
- package/dist/IconType.js +2 -0
- package/dist/IconType.js.map +1 -0
- package/dist/Interactable.d.ts +48 -0
- package/dist/Interactable.js +131 -0
- package/dist/Interactable.js.map +1 -0
- package/dist/Link.d.ts +20 -0
- package/dist/Link.js +22 -0
- package/dist/Link.js.map +1 -0
- package/dist/List.d.ts +11 -0
- package/dist/List.js +17 -0
- package/dist/List.js.map +1 -0
- package/dist/ListButtonItem.d.ts +15 -0
- package/dist/ListButtonItem.js +9 -0
- package/dist/ListButtonItem.js.map +1 -0
- package/dist/ListDivider.d.ts +2 -0
- package/dist/ListDivider.js +12 -0
- package/dist/ListDivider.js.map +1 -0
- package/dist/ListHeaderItem.d.ts +11 -0
- package/dist/ListHeaderItem.js +13 -0
- package/dist/ListHeaderItem.js.map +1 -0
- package/dist/ListItem.d.ts +10 -0
- package/dist/ListItem.js +7 -0
- package/dist/ListItem.js.map +1 -0
- package/dist/ListLinkItem.d.ts +17 -0
- package/dist/ListLinkItem.js +9 -0
- package/dist/ListLinkItem.js.map +1 -0
- package/dist/ListSpacer.d.ts +2 -0
- package/dist/ListSpacer.js +13 -0
- package/dist/ListSpacer.js.map +1 -0
- package/dist/OnVisible.d.ts +5 -0
- package/dist/OnVisible.js +28 -0
- package/dist/OnVisible.js.map +1 -0
- package/dist/Popover.d.ts +21 -0
- package/dist/Popover.js +88 -0
- package/dist/Popover.js.map +1 -0
- package/dist/ProgressBar.d.ts +8 -0
- package/dist/ProgressBar.js +42 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/ProgressCircle.d.ts +6 -0
- package/dist/ProgressCircle.js +12 -0
- package/dist/ProgressCircle.js.map +1 -0
- package/dist/Providers.d.ts +9 -0
- package/dist/Providers.js +16 -0
- package/dist/Providers.js.map +1 -0
- package/dist/RangeInput.d.ts +14 -0
- package/dist/RangeInput.js +32 -0
- package/dist/RangeInput.js.map +1 -0
- package/dist/ResultOrError.d.ts +13 -0
- package/dist/ResultOrError.js +7 -0
- package/dist/ResultOrError.js.map +1 -0
- package/dist/RootView.d.ts +5 -0
- package/dist/RootView.js +35 -0
- package/dist/RootView.js.map +1 -0
- package/dist/Router.d.ts +2 -0
- package/dist/Router.js +37 -0
- package/dist/Router.js.map +1 -0
- package/dist/RouterState.d.ts +38 -0
- package/dist/RouterState.js +111 -0
- package/dist/RouterState.js.map +1 -0
- package/dist/Row.d.ts +6 -0
- package/dist/Row.js +7 -0
- package/dist/Row.js.map +1 -0
- package/dist/StackContext.d.ts +8 -0
- package/dist/StackContext.js +25 -0
- package/dist/StackContext.js.map +1 -0
- package/dist/StaticCheckbox.d.ts +17 -0
- package/dist/StaticCheckbox.js +48 -0
- package/dist/StaticCheckbox.js.map +1 -0
- package/dist/Storage.d.ts +12 -0
- package/dist/Storage.js +148 -0
- package/dist/Storage.js.map +1 -0
- package/dist/Stream.d.ts +9 -0
- package/dist/Stream.js +36 -0
- package/dist/Stream.js.map +1 -0
- package/dist/Sublist.d.ts +12 -0
- package/dist/Sublist.js +18 -0
- package/dist/Sublist.js.map +1 -0
- package/dist/SubmitIconInput.d.ts +9 -0
- package/dist/SubmitIconInput.js +25 -0
- package/dist/SubmitIconInput.js.map +1 -0
- package/dist/Tabs.d.ts +20 -0
- package/dist/Tabs.js +35 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Text.d.ts +25 -0
- package/dist/Text.js +50 -0
- package/dist/Text.js.map +1 -0
- package/dist/TextArea.d.ts +10 -0
- package/dist/TextArea.js +22 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextInput.d.ts +14 -0
- package/dist/TextInput.js +52 -0
- package/dist/TextInput.js.map +1 -0
- package/dist/TextInputWithState.d.ts +10 -0
- package/dist/TextInputWithState.js +14 -0
- package/dist/TextInputWithState.js.map +1 -0
- package/dist/TextPairing.d.ts +21 -0
- package/dist/TextPairing.js +26 -0
- package/dist/TextPairing.js.map +1 -0
- package/dist/TimeInput.d.ts +15 -0
- package/dist/TimeInput.js +58 -0
- package/dist/TimeInput.js.map +1 -0
- package/dist/Tooltip.d.ts +11 -0
- package/dist/Tooltip.js +72 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/aria.d.ts +8 -0
- package/dist/aria.js +42 -0
- package/dist/aria.js.map +1 -0
- package/dist/guid.d.ts +1 -0
- package/dist/guid.js +7 -0
- package/dist/guid.js.map +1 -0
- package/dist/hash.d.ts +1 -0
- package/dist/hash.js +20 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/jss.d.ts +110 -0
- package/dist/jss.js +438 -0
- package/dist/jss.js.map +1 -0
- package/dist/numberToBase.d.ts +1 -0
- package/dist/numberToBase.js +44 -0
- package/dist/numberToBase.js.map +1 -0
- package/dist/stateMachineContextFactory.d.ts +36 -0
- package/dist/stateMachineContextFactory.js +48 -0
- package/dist/stateMachineContextFactory.js.map +1 -0
- package/dist/useCookie.d.ts +9 -0
- package/dist/useCookie.js +65 -0
- package/dist/useCookie.js.map +1 -0
- package/dist/useKeyboard.d.ts +8 -0
- package/dist/useKeyboard.js +26 -0
- package/dist/useKeyboard.js.map +1 -0
- package/dist/useNavigation.d.ts +5 -0
- package/dist/useNavigation.js +79 -0
- package/dist/useNavigation.js.map +1 -0
- package/dist/usePromise.d.ts +1 -0
- package/dist/usePromise.js +12 -0
- package/dist/usePromise.js.map +1 -0
- package/dist/useRefEffect.d.ts +1 -0
- package/dist/useRefEffect.js +15 -0
- package/dist/useRefEffect.js.map +1 -0
- package/next-env.d.ts +5 -0
- package/next.config.js +21 -0
- package/package.json +40 -0
- package/scripts/publish.js +27 -0
- package/src/Badge.tsx +36 -0
- package/src/BaseButton.tsx +58 -0
- package/src/BaseInput.tsx +57 -0
- package/src/BaseLink.tsx +77 -0
- package/src/BaseList.tsx +29 -0
- package/src/BaseListAddOn.tsx +10 -0
- package/src/BaseListItem.tsx +117 -0
- package/src/BaseView.tsx +57 -0
- package/src/Box.tsx +20 -0
- package/src/Button.tsx +84 -0
- package/src/Calendar.tsx +125 -0
- package/src/Card.tsx +17 -0
- package/src/Checkbox.tsx +63 -0
- package/src/Circle.tsx +24 -0
- package/src/Column.tsx +12 -0
- package/src/DarkMode.tsx +99 -0
- package/src/DateInput.tsx +63 -0
- package/src/DatePicker.tsx +67 -0
- package/src/DatetimeInput.tsx +71 -0
- package/src/DesignBook.tsx +697 -0
- package/src/Dialog.tsx +144 -0
- package/src/Dropdown.tsx +129 -0
- package/src/Emitter.ts +26 -0
- package/src/FlexLayout.tsx +53 -0
- package/src/Icon.tsx +96 -0
- package/src/IconButton.tsx +66 -0
- package/src/IconLink.tsx +58 -0
- package/src/IconType.ts +787 -0
- package/src/Interactable.tsx +159 -0
- package/src/Link.tsx +86 -0
- package/src/List.tsx +41 -0
- package/src/ListButtonItem.tsx +69 -0
- package/src/ListDivider.tsx +13 -0
- package/src/ListHeaderItem.tsx +45 -0
- package/src/ListItem.tsx +27 -0
- package/src/ListLinkItem.tsx +76 -0
- package/src/ListSpacer.tsx +14 -0
- package/src/OnVisible.tsx +42 -0
- package/src/Popover.tsx +141 -0
- package/src/ProgressBar.tsx +63 -0
- package/src/ProgressCircle.tsx +38 -0
- package/src/Providers.tsx +33 -0
- package/src/RangeInput.tsx +82 -0
- package/src/ResultOrError.ts +15 -0
- package/src/RootView.tsx +55 -0
- package/src/Router.tsx +62 -0
- package/src/RouterState.tsx +154 -0
- package/src/Row.tsx +12 -0
- package/src/StackContext.tsx +52 -0
- package/src/StaticCheckbox.tsx +74 -0
- package/src/Storage.tsx +200 -0
- package/src/Stream.tsx +50 -0
- package/src/Sublist.tsx +62 -0
- package/src/SubmitIconInput.tsx +45 -0
- package/src/Tabs.tsx +103 -0
- package/src/Text.tsx +102 -0
- package/src/TextArea.tsx +45 -0
- package/src/TextInput.tsx +111 -0
- package/src/TextInputWithState.tsx +35 -0
- package/src/TextPairing.tsx +115 -0
- package/src/TimeInput.tsx +109 -0
- package/src/Tooltip.tsx +108 -0
- package/src/aria.ts +72 -0
- package/src/examples/ExampleDialog.tsx +28 -0
- package/src/guid.ts +7 -0
- package/src/hash.ts +21 -0
- package/src/index.ts +65 -0
- package/src/jss.tsx +607 -0
- package/src/numberToBase.ts +52 -0
- package/src/pages/Badge.mdx +30 -0
- package/src/pages/Button.mdx +57 -0
- package/src/pages/Calendar.mdx +60 -0
- package/src/pages/Checkbox.mdx +56 -0
- package/src/pages/Dialog.mdx +32 -0
- package/src/pages/FlexLayout.mdx +77 -0
- package/src/pages/Hashing.mdx +20 -0
- package/src/pages/Icon.mdx +63 -0
- package/src/pages/IconButton.mdx +144 -0
- package/src/pages/Link.mdx +57 -0
- package/src/pages/List.mdx +292 -0
- package/src/pages/ListHeader.mdx +94 -0
- package/src/pages/Popover.mdx +101 -0
- package/src/pages/ProgressBar.mdx +20 -0
- package/src/pages/ProgressCircle.mdx +35 -0
- package/src/pages/RangeInput.mdx +109 -0
- package/src/pages/Tabs.mdx +168 -0
- package/src/pages/Text.mdx +133 -0
- package/src/pages/TextInput.mdx +110 -0
- package/src/pages/TextPairing.mdx +155 -0
- package/src/pages/TimeInput.mdx +73 -0
- package/src/pages/Tooltip.mdx +28 -0
- package/src/pages/_app.tsx +561 -0
- package/src/pages/_document.tsx +30 -0
- package/src/pages/css-in-js.mdx +127 -0
- package/src/pages/index.mdx +58 -0
- package/src/pages/navigation.mdx +56 -0
- package/src/pages/prism.css +3 -0
- package/src/pages/useCookie.mdx +15 -0
- package/src/pages/useKeyboard.mdx +20 -0
- package/src/pages/useNavigation.mdx +30 -0
- package/src/pages/usePromise.mdx +15 -0
- package/src/pages/useRefEffect.mdx +49 -0
- package/src/stateMachineContextFactory.tsx +111 -0
- package/src/useCookie.tsx +89 -0
- package/src/useKeyboard.tsx +43 -0
- package/src/useNavigation.tsx +89 -0
- package/src/usePromise.tsx +18 -0
- package/src/useRefEffect.tsx +18 -0
- package/tsconfig.build.json +23 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { JSStyle, Padding, TextColor, cssVar, getPadding } from "./jss";
|
|
2
|
+
|
|
3
|
+
export type InteractableColor = "positive" | "secondary" | "negative";
|
|
4
|
+
|
|
5
|
+
const jsStyles = {
|
|
6
|
+
root: {
|
|
7
|
+
cursor: "pointer",
|
|
8
|
+
display: "inline-flex",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
transition: "opacity 0.1s ease-in",
|
|
11
|
+
outlineColor: "var(--outline)",
|
|
12
|
+
"[aria-disabled=true]": {
|
|
13
|
+
color: "var(--secondary-text)",
|
|
14
|
+
backgroundColor: "var(--background-button-secondary)",
|
|
15
|
+
},
|
|
16
|
+
":focus-visible": {
|
|
17
|
+
outlineWidth: "2px",
|
|
18
|
+
outlineStyle: "solid",
|
|
19
|
+
outlineOffset: -2,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
positive: {
|
|
23
|
+
backgroundColor: "var(--background-button-positive)",
|
|
24
|
+
"[aria-disabled=true]": {
|
|
25
|
+
backgroundColor: "var(--background-button-disabled)",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
secondary: {
|
|
29
|
+
backgroundColor: "var(--background-button-secondary)",
|
|
30
|
+
"[aria-disabled=true]": {
|
|
31
|
+
backgroundColor: "var(--background-button-disabled)",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
negative: {
|
|
35
|
+
backgroundColor: "var(--background-button-negative)",
|
|
36
|
+
"[aria-disabled=true]": {
|
|
37
|
+
backgroundColor: "var(--background-button-disabled)",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
disabled: {
|
|
41
|
+
cursor: "default",
|
|
42
|
+
},
|
|
43
|
+
bare: {
|
|
44
|
+
backgroundColor: "inherit",
|
|
45
|
+
outlineColor: "var(--outline)",
|
|
46
|
+
"[aria-disabled=true]": {
|
|
47
|
+
backgroundColor: "inherit",
|
|
48
|
+
},
|
|
49
|
+
"[aria-disabled=true]:hover": {
|
|
50
|
+
backgroundColor: "inherit",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
opacityHover: {
|
|
54
|
+
":hover": {
|
|
55
|
+
opacity: 0.8,
|
|
56
|
+
},
|
|
57
|
+
"[aria-disabled=true]:hover": {
|
|
58
|
+
opacity: 1,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
colorHover: {},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export function getInteractableJSStyles({
|
|
65
|
+
color,
|
|
66
|
+
bare,
|
|
67
|
+
disabled,
|
|
68
|
+
animateInteraction,
|
|
69
|
+
padding,
|
|
70
|
+
}: {
|
|
71
|
+
color: InteractableColor;
|
|
72
|
+
bare: boolean;
|
|
73
|
+
disabled: boolean;
|
|
74
|
+
animateInteraction: boolean;
|
|
75
|
+
padding: Padding;
|
|
76
|
+
}): Array<JSStyle> {
|
|
77
|
+
return [
|
|
78
|
+
jsStyles.root,
|
|
79
|
+
color === "positive" && jsStyles.positive,
|
|
80
|
+
color === "secondary" && jsStyles.secondary,
|
|
81
|
+
color === "negative" && jsStyles.negative,
|
|
82
|
+
bare && jsStyles.bare,
|
|
83
|
+
disabled && jsStyles.disabled,
|
|
84
|
+
!bare && jsStyles.opacityHover,
|
|
85
|
+
animateInteraction &&
|
|
86
|
+
!disabled && {
|
|
87
|
+
position: "relative",
|
|
88
|
+
":active": {
|
|
89
|
+
opacity: 0.95,
|
|
90
|
+
top: 1,
|
|
91
|
+
},
|
|
92
|
+
"[aria-disabled=true]:active": {
|
|
93
|
+
top: 0,
|
|
94
|
+
opacity: 1,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
getPadding(padding),
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const getGlyphColor = (
|
|
102
|
+
color: InteractableColor,
|
|
103
|
+
disabled: boolean | undefined,
|
|
104
|
+
bare: boolean | undefined
|
|
105
|
+
): TextColor => {
|
|
106
|
+
if (disabled) {
|
|
107
|
+
return "subtle";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
switch (color) {
|
|
111
|
+
case "positive":
|
|
112
|
+
return bare ? "highlight" : "light";
|
|
113
|
+
case "negative":
|
|
114
|
+
return bare ? "negative" : "light";
|
|
115
|
+
case "secondary":
|
|
116
|
+
return bare ? "primary" : "secondary";
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const getInteractableListItemJSStyles = ({
|
|
121
|
+
bare,
|
|
122
|
+
selected,
|
|
123
|
+
}: {
|
|
124
|
+
bare: boolean;
|
|
125
|
+
selected: boolean;
|
|
126
|
+
}) => {
|
|
127
|
+
return [
|
|
128
|
+
{
|
|
129
|
+
overflow: "hidden",
|
|
130
|
+
flexGrow: 1,
|
|
131
|
+
borderRadius: bare ? cssVar("--border-radius-m") : null,
|
|
132
|
+
textDecoration: "none",
|
|
133
|
+
":hover": {
|
|
134
|
+
backgroundColor: "var(--hovered-background)",
|
|
135
|
+
},
|
|
136
|
+
":active:hover": {
|
|
137
|
+
backgroundColor: "var(--pressed-background)",
|
|
138
|
+
},
|
|
139
|
+
"[aria-disabled=true]": {
|
|
140
|
+
backgroundColor: "var(--primary-background)",
|
|
141
|
+
},
|
|
142
|
+
"[aria-disabled=true]:active:hover": {
|
|
143
|
+
backgroundColor: "var(--primary-background)",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
selected && {
|
|
147
|
+
backgroundColor: bare
|
|
148
|
+
? cssVar("--light-highlight")
|
|
149
|
+
: cssVar("--selected-background"),
|
|
150
|
+
boxShadow: bare ? "" : "inset 1px 1px 2px -1px #0000004a",
|
|
151
|
+
":hover": {
|
|
152
|
+
backgroundColor: "var(--hovered-background)",
|
|
153
|
+
},
|
|
154
|
+
":active:hover": {
|
|
155
|
+
backgroundColor: "var(--pressed-background)",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
};
|
package/src/Link.tsx
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { BaseLink, BaseLinkProps } from "./BaseLink";
|
|
4
|
+
import { Text } from "./Text";
|
|
5
|
+
import { IconType } from "./IconType";
|
|
6
|
+
import { Row } from "./Row";
|
|
7
|
+
import { Icon } from "./Icon";
|
|
8
|
+
import { FlexLayoutProps } from "./FlexLayout";
|
|
9
|
+
import { InteractableColor, getGlyphColor } from "./Interactable";
|
|
10
|
+
import { Size, Align, Gap, Justify, cssVar } from "./jss";
|
|
11
|
+
|
|
12
|
+
export interface LinkProps extends BaseLinkProps {
|
|
13
|
+
label: string;
|
|
14
|
+
color: InteractableColor;
|
|
15
|
+
size?: Size;
|
|
16
|
+
icon?: IconType;
|
|
17
|
+
iconSize?: Size;
|
|
18
|
+
children?: undefined;
|
|
19
|
+
iconPosition?: "left" | "right";
|
|
20
|
+
rowProps?: FlexLayoutProps;
|
|
21
|
+
align?: Align;
|
|
22
|
+
gap?: Gap;
|
|
23
|
+
justify?: Justify;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const Link = React.forwardRef(
|
|
27
|
+
(
|
|
28
|
+
{
|
|
29
|
+
label,
|
|
30
|
+
color,
|
|
31
|
+
bare,
|
|
32
|
+
disabled,
|
|
33
|
+
icon,
|
|
34
|
+
iconSize = "medium",
|
|
35
|
+
iconPosition = "left",
|
|
36
|
+
align = "center",
|
|
37
|
+
gap = "small",
|
|
38
|
+
justify = "center",
|
|
39
|
+
jsStyle,
|
|
40
|
+
size = "medium",
|
|
41
|
+
...otherProps
|
|
42
|
+
}: LinkProps,
|
|
43
|
+
ref?: React.Ref<HTMLAnchorElement>
|
|
44
|
+
) => {
|
|
45
|
+
return (
|
|
46
|
+
<BaseLink
|
|
47
|
+
{...otherProps}
|
|
48
|
+
bare={bare}
|
|
49
|
+
ref={ref}
|
|
50
|
+
color={color}
|
|
51
|
+
disabled={disabled}
|
|
52
|
+
jsStyle={[
|
|
53
|
+
{
|
|
54
|
+
borderRadius: "var(--border-radius-m)",
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
userSelect: "none",
|
|
57
|
+
padding: cssVar("--spacing-m"),
|
|
58
|
+
display: "inline-flex",
|
|
59
|
+
textDecoration: "none",
|
|
60
|
+
},
|
|
61
|
+
jsStyle,
|
|
62
|
+
]}
|
|
63
|
+
>
|
|
64
|
+
<Row grow={true} align={align} gap={gap} justify={justify}>
|
|
65
|
+
{icon && iconPosition === "left" && (
|
|
66
|
+
<Icon
|
|
67
|
+
icon={icon}
|
|
68
|
+
size={iconSize}
|
|
69
|
+
color={getGlyphColor(color, disabled, bare)}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
<Text size={size} color={getGlyphColor(color, disabled, bare)}>
|
|
73
|
+
{label}
|
|
74
|
+
</Text>
|
|
75
|
+
{icon && iconPosition === "right" && (
|
|
76
|
+
<Icon
|
|
77
|
+
icon={icon}
|
|
78
|
+
size={iconSize}
|
|
79
|
+
color={getGlyphColor(color, disabled, bare)}
|
|
80
|
+
/>
|
|
81
|
+
)}
|
|
82
|
+
</Row>
|
|
83
|
+
</BaseLink>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
package/src/List.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseList, BaseListProps } from "./BaseList";
|
|
3
|
+
import { useNavigation } from "./useNavigation";
|
|
4
|
+
import { cssVar } from "./jss";
|
|
5
|
+
|
|
6
|
+
interface ListProps extends BaseListProps {
|
|
7
|
+
ariaLabel: string;
|
|
8
|
+
bare?: boolean;
|
|
9
|
+
autofocus?: boolean;
|
|
10
|
+
role?: undefined;
|
|
11
|
+
navigation?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function List({
|
|
15
|
+
ariaLabel,
|
|
16
|
+
jsStyle,
|
|
17
|
+
autofocus = false,
|
|
18
|
+
navigation = true,
|
|
19
|
+
bare,
|
|
20
|
+
...otherProps
|
|
21
|
+
}: ListProps) {
|
|
22
|
+
const rootRef = useNavigation({ autofocus, enabled: navigation });
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<BaseList
|
|
26
|
+
role="grid"
|
|
27
|
+
aria-label={ariaLabel}
|
|
28
|
+
ref={rootRef}
|
|
29
|
+
jsStyle={[
|
|
30
|
+
{ overflow: "hidden" },
|
|
31
|
+
!bare && {
|
|
32
|
+
border: `1px solid ${cssVar("--divider")}`,
|
|
33
|
+
borderRadius: cssVar("--border-radius-l"),
|
|
34
|
+
backgroundColor: cssVar("--overlay-background"),
|
|
35
|
+
},
|
|
36
|
+
jsStyle,
|
|
37
|
+
]}
|
|
38
|
+
{...otherProps}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { BaseListItem, BaseListItemProps } from "./BaseListItem";
|
|
4
|
+
import {
|
|
5
|
+
InteractableColor,
|
|
6
|
+
getGlyphColor,
|
|
7
|
+
getInteractableListItemJSStyles,
|
|
8
|
+
} from "./Interactable";
|
|
9
|
+
import { BaseButton } from "./BaseButton";
|
|
10
|
+
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
interface ListButtonItemProps extends BaseListItemProps {
|
|
13
|
+
color: InteractableColor;
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
headline: string;
|
|
16
|
+
body?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
bare?: boolean;
|
|
20
|
+
children?: void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ListButtonItem = React.forwardRef(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
onClick,
|
|
27
|
+
color = "secondary",
|
|
28
|
+
disabled = false,
|
|
29
|
+
padding = "medium",
|
|
30
|
+
jsStyle,
|
|
31
|
+
gap,
|
|
32
|
+
selected,
|
|
33
|
+
bare,
|
|
34
|
+
...otherProps
|
|
35
|
+
}: ListButtonItemProps,
|
|
36
|
+
ref?: React.Ref<HTMLButtonElement>
|
|
37
|
+
) => {
|
|
38
|
+
return (
|
|
39
|
+
<BaseListItem
|
|
40
|
+
withDivider={!bare}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
padding="none"
|
|
43
|
+
gap={gap}
|
|
44
|
+
headlineColor={getGlyphColor(color, disabled, true)}
|
|
45
|
+
bodyColor={getGlyphColor(color, disabled, true)}
|
|
46
|
+
selected={selected}
|
|
47
|
+
aria-selected={selected}
|
|
48
|
+
bare={bare}
|
|
49
|
+
{...otherProps}
|
|
50
|
+
jsStyle={jsStyle}
|
|
51
|
+
>
|
|
52
|
+
{({ content }) => (
|
|
53
|
+
<BaseButton
|
|
54
|
+
padding={padding}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
animateInteraction={false}
|
|
57
|
+
bare={true}
|
|
58
|
+
color={bare ? "secondary" : color}
|
|
59
|
+
ref={ref}
|
|
60
|
+
jsStyle={getInteractableListItemJSStyles({ bare, selected })}
|
|
61
|
+
onClick={onClick}
|
|
62
|
+
>
|
|
63
|
+
{content}
|
|
64
|
+
</BaseButton>
|
|
65
|
+
)}
|
|
66
|
+
</BaseListItem>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseView } from "./BaseView";
|
|
3
|
+
|
|
4
|
+
const jsStyles = {
|
|
5
|
+
root: {
|
|
6
|
+
width: "100%",
|
|
7
|
+
borderBottom: "1px solid var(--divider)",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function ListDivider() {
|
|
12
|
+
return <BaseView jsStyle={jsStyles.root} />;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { BaseListItem } from "./BaseListItem";
|
|
3
|
+
import { Position, cssVar } from "./jss";
|
|
4
|
+
|
|
5
|
+
export function ListHeaderItem({
|
|
6
|
+
bare,
|
|
7
|
+
highlight,
|
|
8
|
+
headline,
|
|
9
|
+
body,
|
|
10
|
+
withDivider,
|
|
11
|
+
addOn,
|
|
12
|
+
addOnPosition,
|
|
13
|
+
}: {
|
|
14
|
+
bare?: boolean;
|
|
15
|
+
highlight?: boolean;
|
|
16
|
+
headline: string;
|
|
17
|
+
body?: string;
|
|
18
|
+
withDivider?: boolean;
|
|
19
|
+
addOn?: ReactNode;
|
|
20
|
+
addOnPosition?: Position;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<BaseListItem
|
|
24
|
+
bare={bare}
|
|
25
|
+
headline={headline}
|
|
26
|
+
headlineColor={highlight ? (bare ? "highlight" : "light") : "primary"}
|
|
27
|
+
headlineBold={true}
|
|
28
|
+
body={body}
|
|
29
|
+
addOn={addOn}
|
|
30
|
+
addOnPosition={addOnPosition}
|
|
31
|
+
withDivider={bare ? false : withDivider}
|
|
32
|
+
jsStyle={
|
|
33
|
+
bare
|
|
34
|
+
? null
|
|
35
|
+
: {
|
|
36
|
+
backgroundColor: highlight
|
|
37
|
+
? cssVar("--highlight")
|
|
38
|
+
: cssVar("--secondary-background"),
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
{({ content }) => content}
|
|
43
|
+
</BaseListItem>
|
|
44
|
+
);
|
|
45
|
+
}
|
package/src/ListItem.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { BaseListItem, BaseListItemProps } from "./BaseListItem";
|
|
4
|
+
import { cssVar } from "./jss";
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
interface ListItemProps extends BaseListItemProps {
|
|
8
|
+
headline: string;
|
|
9
|
+
body?: string;
|
|
10
|
+
bare?: boolean;
|
|
11
|
+
children?: void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ListItem = React.forwardRef(
|
|
15
|
+
(props: ListItemProps, ref?: React.Ref<HTMLLIElement>) => {
|
|
16
|
+
return (
|
|
17
|
+
<BaseListItem
|
|
18
|
+
withDivider={!props.bare}
|
|
19
|
+
{...props}
|
|
20
|
+
jsStyle={props.jsStyle}
|
|
21
|
+
ref={ref}
|
|
22
|
+
>
|
|
23
|
+
{({ content }) => content}
|
|
24
|
+
</BaseListItem>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { BaseListItem, BaseListItemProps } from "./BaseListItem";
|
|
4
|
+
import {
|
|
5
|
+
InteractableColor,
|
|
6
|
+
getGlyphColor,
|
|
7
|
+
getInteractableListItemJSStyles,
|
|
8
|
+
} from "./Interactable";
|
|
9
|
+
import { BaseLink } from "./BaseLink";
|
|
10
|
+
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
interface ListLinkItemProps extends BaseListItemProps {
|
|
13
|
+
color?: InteractableColor;
|
|
14
|
+
children?: void;
|
|
15
|
+
onClick?: () => void;
|
|
16
|
+
href: string;
|
|
17
|
+
headline: string;
|
|
18
|
+
body?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
selected?: boolean;
|
|
21
|
+
bare?: boolean;
|
|
22
|
+
target?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const ListLinkItem = React.forwardRef(
|
|
26
|
+
(
|
|
27
|
+
{
|
|
28
|
+
onClick,
|
|
29
|
+
href,
|
|
30
|
+
disabled = false,
|
|
31
|
+
padding = "medium",
|
|
32
|
+
jsStyle,
|
|
33
|
+
gap,
|
|
34
|
+
selected,
|
|
35
|
+
bare,
|
|
36
|
+
color = "secondary",
|
|
37
|
+
target,
|
|
38
|
+
...otherProps
|
|
39
|
+
}: ListLinkItemProps,
|
|
40
|
+
ref?: React.Ref<HTMLAnchorElement>
|
|
41
|
+
) => {
|
|
42
|
+
return (
|
|
43
|
+
<BaseListItem
|
|
44
|
+
withDivider={!bare}
|
|
45
|
+
disabled={disabled}
|
|
46
|
+
aria-selected={selected}
|
|
47
|
+
padding="none"
|
|
48
|
+
gap={gap}
|
|
49
|
+
headlineColor={getGlyphColor(color, disabled, true)}
|
|
50
|
+
bodyColor={getGlyphColor(color, disabled, true)}
|
|
51
|
+
selected={selected}
|
|
52
|
+
bare={bare}
|
|
53
|
+
{...otherProps}
|
|
54
|
+
jsStyle={jsStyle}
|
|
55
|
+
>
|
|
56
|
+
{({ content }) => (
|
|
57
|
+
<BaseLink
|
|
58
|
+
target={target}
|
|
59
|
+
padding={padding}
|
|
60
|
+
aria-current={selected ? "page" : undefined}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
animateInteraction={false}
|
|
63
|
+
bare={true}
|
|
64
|
+
color={color}
|
|
65
|
+
href={href}
|
|
66
|
+
ref={ref}
|
|
67
|
+
jsStyle={getInteractableListItemJSStyles({ bare, selected })}
|
|
68
|
+
onClick={onClick}
|
|
69
|
+
>
|
|
70
|
+
{content}
|
|
71
|
+
</BaseLink>
|
|
72
|
+
)}
|
|
73
|
+
</BaseListItem>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseView } from "./BaseView";
|
|
3
|
+
|
|
4
|
+
const jsStyles = {
|
|
5
|
+
root: {
|
|
6
|
+
height: "var(--spacing-xl)",
|
|
7
|
+
backgroundColor: "var(--secondary-background)",
|
|
8
|
+
width: "100%",
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function ListSpacer() {
|
|
13
|
+
return <BaseView jsStyle={jsStyles.root} />;
|
|
14
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useRef, useCallback, ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
export function OnVisible({
|
|
4
|
+
children,
|
|
5
|
+
onVisible,
|
|
6
|
+
}: {
|
|
7
|
+
children: (refCallback: React.RefCallback<HTMLElement>) => ReactElement;
|
|
8
|
+
onVisible: () => void;
|
|
9
|
+
}) {
|
|
10
|
+
const intersectionObserverRef = useRef<IntersectionObserver | null>(null);
|
|
11
|
+
|
|
12
|
+
const refCallback = useCallback((element) => {
|
|
13
|
+
if (element == null) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const intersectionObserver = new IntersectionObserver(
|
|
18
|
+
(entries) => {
|
|
19
|
+
entries.forEach((entry) => {
|
|
20
|
+
if (entry.isIntersecting || entry.intersectionRatio > 0) {
|
|
21
|
+
onVisible();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
root: null,
|
|
27
|
+
rootMargin: "0px",
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
intersectionObserverRef.current = intersectionObserver;
|
|
32
|
+
intersectionObserver.observe(element);
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
intersectionObserver.unobserve(element);
|
|
36
|
+
intersectionObserverRef.current = null;
|
|
37
|
+
};
|
|
38
|
+
// eslint-disable-next-line
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
return children(refCallback);
|
|
42
|
+
}
|