@butternutbox/pawprint-native 0.0.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/.turbo/turbo-build.log +30 -0
- package/COMPONENT_GUIDELINES.md +610 -0
- package/README.md +72 -0
- package/dist/ibm-plex-sans-condensed-400-normal-I2XLJNNB.woff2 +0 -0
- package/dist/ibm-plex-sans-condensed-500-normal-IEQBNVGX.woff2 +0 -0
- package/dist/ibm-plex-sans-condensed-600-normal-UX5ZU5T6.woff2 +0 -0
- package/dist/ibm-plex-sans-condensed-700-normal-4PFYFTSO.woff2 +0 -0
- package/dist/ida-narrow-500-normal-C6I2PK4T.woff2 +0 -0
- package/dist/ida-narrow-700-normal-UPHPRIN6.woff2 +0 -0
- package/dist/index.cjs +2686 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +780 -0
- package/dist/index.d.ts +780 -0
- package/dist/index.js +2617 -0
- package/dist/index.js.map +1 -0
- package/eslint.config.js +3 -0
- package/llms.txt +458 -0
- package/package.json +57 -0
- package/src/components/atoms/Avatar/Avatar.stories.tsx +125 -0
- package/src/components/atoms/Avatar/Avatar.tsx +159 -0
- package/src/components/atoms/Avatar/index.ts +7 -0
- package/src/components/atoms/Badge/Badge.stories.tsx +231 -0
- package/src/components/atoms/Badge/Badge.tsx +184 -0
- package/src/components/atoms/Badge/index.ts +2 -0
- package/src/components/atoms/Button/Button.stories.tsx +145 -0
- package/src/components/atoms/Button/Button.tsx +261 -0
- package/src/components/atoms/Button/index.ts +7 -0
- package/src/components/atoms/Hint/Hint.stories.tsx +84 -0
- package/src/components/atoms/Hint/Hint.tsx +59 -0
- package/src/components/atoms/Hint/index.ts +2 -0
- package/src/components/atoms/Icon/Icon.stories.tsx +200 -0
- package/src/components/atoms/Icon/Icon.tsx +112 -0
- package/src/components/atoms/Icon/index.ts +8 -0
- package/src/components/atoms/IconButton/IconButton.stories.tsx +162 -0
- package/src/components/atoms/IconButton/IconButton.tsx +227 -0
- package/src/components/atoms/IconButton/index.ts +7 -0
- package/src/components/atoms/Illustration/Illustration.stories.tsx +167 -0
- package/src/components/atoms/Illustration/Illustration.tsx +81 -0
- package/src/components/atoms/Illustration/index.ts +6 -0
- package/src/components/atoms/Input/Input.stories.tsx +142 -0
- package/src/components/atoms/Input/Input.tsx +110 -0
- package/src/components/atoms/Input/InputDescription.tsx +49 -0
- package/src/components/atoms/Input/InputError.tsx +39 -0
- package/src/components/atoms/Input/InputField.tsx +119 -0
- package/src/components/atoms/Input/InputLabel.tsx +61 -0
- package/src/components/atoms/Input/index.ts +10 -0
- package/src/components/atoms/Link/Link.stories.tsx +119 -0
- package/src/components/atoms/Link/Link.tsx +118 -0
- package/src/components/atoms/Link/index.ts +2 -0
- package/src/components/atoms/Logo/Logo.registry.ts +39 -0
- package/src/components/atoms/Logo/Logo.tsx +68 -0
- package/src/components/atoms/Logo/index.ts +4 -0
- package/src/components/atoms/Spinner/Spinner.stories.tsx +98 -0
- package/src/components/atoms/Spinner/Spinner.tsx +91 -0
- package/src/components/atoms/Spinner/index.ts +2 -0
- package/src/components/atoms/Switch/Switch.stories.tsx +120 -0
- package/src/components/atoms/Switch/Switch.tsx +196 -0
- package/src/components/atoms/Switch/index.ts +2 -0
- package/src/components/atoms/Tag/Tag.stories.tsx +89 -0
- package/src/components/atoms/Tag/Tag.tsx +122 -0
- package/src/components/atoms/Tag/index.ts +2 -0
- package/src/components/atoms/Typography/Typography.stories.tsx +315 -0
- package/src/components/atoms/Typography/Typography.tsx +284 -0
- package/src/components/atoms/Typography/index.ts +2 -0
- package/src/components/atoms/index.ts +14 -0
- package/src/components/index.ts +2 -0
- package/src/components/molecules/ButtonDock/ButtonDock.stories.tsx +95 -0
- package/src/components/molecules/ButtonDock/ButtonDock.tsx +148 -0
- package/src/components/molecules/ButtonDock/index.ts +2 -0
- package/src/components/molecules/ButtonGroup/ButtonGroup.stories.tsx +82 -0
- package/src/components/molecules/ButtonGroup/ButtonGroup.tsx +94 -0
- package/src/components/molecules/ButtonGroup/index.ts +2 -0
- package/src/components/molecules/Checkbox/Checkbox.stories.tsx +148 -0
- package/src/components/molecules/Checkbox/Checkbox.tsx +279 -0
- package/src/components/molecules/Checkbox/CheckboxGroup.tsx +53 -0
- package/src/components/molecules/Checkbox/index.ts +4 -0
- package/src/components/molecules/Radio/Radio.stories.tsx +182 -0
- package/src/components/molecules/Radio/Radio.tsx +249 -0
- package/src/components/molecules/Radio/RadioGroup.tsx +142 -0
- package/src/components/molecules/Radio/index.ts +4 -0
- package/src/components/molecules/SegmentedControl/SegmentedControl.stories.tsx +151 -0
- package/src/components/molecules/SegmentedControl/SegmentedControl.tsx +323 -0
- package/src/components/molecules/SegmentedControl/index.ts +5 -0
- package/src/components/molecules/Slider/Slider.stories.tsx +144 -0
- package/src/components/molecules/Slider/Slider.tsx +303 -0
- package/src/components/molecules/Slider/index.ts +2 -0
- package/src/components/molecules/index.ts +6 -0
- package/src/fonts/ibm-plex-sans-condensed-400-normal.woff2 +0 -0
- package/src/fonts/ibm-plex-sans-condensed-500-normal.woff2 +0 -0
- package/src/fonts/ibm-plex-sans-condensed-600-normal.woff2 +0 -0
- package/src/fonts/ibm-plex-sans-condensed-700-normal.woff2 +0 -0
- package/src/fonts/ida-narrow-500-normal.woff2 +0 -0
- package/src/fonts/ida-narrow-700-normal.woff2 +0 -0
- package/src/fonts/index.ts +49 -0
- package/src/index.ts +9 -0
- package/src/theme/PawprintProvider.tsx +26 -0
- package/src/theme/ThemeProvider.tsx +63 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/theme.ts +3 -0
- package/src/theme/utils.ts +31 -0
- package/src/types/fonts.d.ts +4 -0
- package/src/types/index.ts +1 -0
- package/src/types/theme.ts +24 -0
- package/tsconfig.json +5 -0
- package/tsup.config.ts +11 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { View, PressableProps } from "react-native"
|
|
3
|
+
import styled from "@emotion/native"
|
|
4
|
+
import { useTheme } from "@emotion/react"
|
|
5
|
+
import * as CheckboxPrimitive from "@rn-primitives/checkbox"
|
|
6
|
+
import { Check } from "@butternutbox/pawprint-icons/core"
|
|
7
|
+
import { Icon } from "../../atoms/Icon"
|
|
8
|
+
import { Typography } from "../../atoms/Typography"
|
|
9
|
+
|
|
10
|
+
export type CheckboxVariant = "standalone" | "tile"
|
|
11
|
+
|
|
12
|
+
type CheckboxOwnProps = {
|
|
13
|
+
variant?: CheckboxVariant
|
|
14
|
+
label: string
|
|
15
|
+
subText?: string
|
|
16
|
+
illustration?: React.ReactNode
|
|
17
|
+
checked?: boolean
|
|
18
|
+
defaultChecked?: boolean
|
|
19
|
+
onCheckedChange?: (checked: boolean) => void
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
name?: string
|
|
22
|
+
value?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type CheckboxProps = CheckboxOwnProps &
|
|
26
|
+
Omit<PressableProps, keyof CheckboxOwnProps | "children">
|
|
27
|
+
|
|
28
|
+
const parseTokenValue = (value: string): number => parseFloat(value)
|
|
29
|
+
|
|
30
|
+
const StyledRoot = styled(CheckboxPrimitive.Root)<{
|
|
31
|
+
rootFlexAlign: string
|
|
32
|
+
rootGap: number
|
|
33
|
+
rootOpacity: number
|
|
34
|
+
rootPaddingVertical?: number
|
|
35
|
+
rootPaddingHorizontal?: number
|
|
36
|
+
rootMaxWidth?: number
|
|
37
|
+
rootBgColor?: string
|
|
38
|
+
rootBorderWidth?: number
|
|
39
|
+
rootBorderColor?: string
|
|
40
|
+
rootBorderRadius?: number
|
|
41
|
+
}>(
|
|
42
|
+
({
|
|
43
|
+
rootFlexAlign,
|
|
44
|
+
rootGap,
|
|
45
|
+
rootOpacity,
|
|
46
|
+
rootPaddingVertical,
|
|
47
|
+
rootPaddingHorizontal,
|
|
48
|
+
rootMaxWidth,
|
|
49
|
+
rootBgColor,
|
|
50
|
+
rootBorderWidth,
|
|
51
|
+
rootBorderColor,
|
|
52
|
+
rootBorderRadius
|
|
53
|
+
}) => ({
|
|
54
|
+
flexDirection: "row",
|
|
55
|
+
alignItems: rootFlexAlign as "center" | "flex-start",
|
|
56
|
+
gap: rootGap,
|
|
57
|
+
opacity: rootOpacity,
|
|
58
|
+
...(rootPaddingVertical !== undefined
|
|
59
|
+
? { paddingVertical: rootPaddingVertical }
|
|
60
|
+
: {}),
|
|
61
|
+
...(rootPaddingHorizontal !== undefined
|
|
62
|
+
? { paddingHorizontal: rootPaddingHorizontal }
|
|
63
|
+
: {}),
|
|
64
|
+
...(rootMaxWidth !== undefined
|
|
65
|
+
? { maxWidth: rootMaxWidth, width: "100%" }
|
|
66
|
+
: {}),
|
|
67
|
+
...(rootBgColor ? { backgroundColor: rootBgColor } : {}),
|
|
68
|
+
...(rootBorderWidth !== undefined
|
|
69
|
+
? { borderWidth: rootBorderWidth, borderColor: rootBorderColor }
|
|
70
|
+
: {}),
|
|
71
|
+
...(rootBorderRadius !== undefined
|
|
72
|
+
? { borderRadius: rootBorderRadius }
|
|
73
|
+
: {})
|
|
74
|
+
})
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
const StyledControl = styled(View)<{
|
|
78
|
+
controlSize: number
|
|
79
|
+
controlBorderWidth: number
|
|
80
|
+
controlBorderColor: string
|
|
81
|
+
controlBorderRadius: number
|
|
82
|
+
controlBgColor: string
|
|
83
|
+
}>(
|
|
84
|
+
({
|
|
85
|
+
controlSize,
|
|
86
|
+
controlBorderWidth,
|
|
87
|
+
controlBorderColor,
|
|
88
|
+
controlBorderRadius,
|
|
89
|
+
controlBgColor
|
|
90
|
+
}) => ({
|
|
91
|
+
flexShrink: 0,
|
|
92
|
+
width: controlSize,
|
|
93
|
+
height: controlSize,
|
|
94
|
+
borderWidth: controlBorderWidth,
|
|
95
|
+
borderColor: controlBorderColor,
|
|
96
|
+
borderRadius: controlBorderRadius,
|
|
97
|
+
backgroundColor: controlBgColor,
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
justifyContent: "center"
|
|
100
|
+
})
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
const StyledContent = styled(View)<{
|
|
104
|
+
contentGap: number
|
|
105
|
+
}>(({ contentGap }) => ({
|
|
106
|
+
flexDirection: "column",
|
|
107
|
+
gap: contentGap,
|
|
108
|
+
flex: 1,
|
|
109
|
+
minWidth: 0
|
|
110
|
+
}))
|
|
111
|
+
|
|
112
|
+
const StyledIllustration = styled(View)<{
|
|
113
|
+
illustrationSize: number
|
|
114
|
+
}>(({ illustrationSize }) => ({
|
|
115
|
+
flexShrink: 0,
|
|
116
|
+
width: illustrationSize,
|
|
117
|
+
height: illustrationSize,
|
|
118
|
+
overflow: "hidden"
|
|
119
|
+
}))
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Checkbox component for binary selection, supporting standalone and tile layouts.
|
|
123
|
+
*
|
|
124
|
+
* @param {"standalone" | "tile"} [variant="standalone"] - Visual layout variant.
|
|
125
|
+
* @param {string} label - Visible label text.
|
|
126
|
+
* @param {string} [subText] - Optional secondary descriptive text.
|
|
127
|
+
* @param {React.ReactNode} [illustration] - Optional decorative slot (tile variant only).
|
|
128
|
+
* @param {boolean} [checked] - Controlled checked state.
|
|
129
|
+
* @param {boolean} [defaultChecked] - Uncontrolled initial checked state.
|
|
130
|
+
* @param {(checked: boolean) => void} [onCheckedChange] - Callback when state changes.
|
|
131
|
+
* @param {boolean} [disabled=false] - Prevents interaction.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* <Checkbox label="Accept terms" subText="Required to proceed" />
|
|
135
|
+
* <Checkbox variant="tile" label="Newsletters" subText="Stay up to date" />
|
|
136
|
+
*/
|
|
137
|
+
export const Checkbox = React.forwardRef<View, CheckboxProps>(
|
|
138
|
+
(
|
|
139
|
+
{
|
|
140
|
+
variant = "standalone",
|
|
141
|
+
label,
|
|
142
|
+
subText,
|
|
143
|
+
illustration,
|
|
144
|
+
checked: controlledChecked,
|
|
145
|
+
defaultChecked = false,
|
|
146
|
+
onCheckedChange,
|
|
147
|
+
disabled = false,
|
|
148
|
+
style,
|
|
149
|
+
...rest
|
|
150
|
+
},
|
|
151
|
+
ref
|
|
152
|
+
) => {
|
|
153
|
+
const theme = useTheme()
|
|
154
|
+
const { checkbox } = theme.tokens.components
|
|
155
|
+
const { dimensions } = theme.tokens.semantics
|
|
156
|
+
|
|
157
|
+
const isControlled = controlledChecked !== undefined
|
|
158
|
+
const [internalChecked, setInternalChecked] = React.useState(defaultChecked)
|
|
159
|
+
const isChecked = isControlled ? controlledChecked : internalChecked
|
|
160
|
+
|
|
161
|
+
const handleCheckedChange = (checked: boolean) => {
|
|
162
|
+
if (!isControlled) {
|
|
163
|
+
setInternalChecked(checked)
|
|
164
|
+
}
|
|
165
|
+
onCheckedChange?.(checked)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const isTile = variant === "tile"
|
|
169
|
+
const controlSize = parseTokenValue(checkbox.size.control.default)
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<StyledRoot
|
|
173
|
+
ref={ref}
|
|
174
|
+
checked={isChecked}
|
|
175
|
+
onCheckedChange={handleCheckedChange}
|
|
176
|
+
disabled={disabled}
|
|
177
|
+
rootFlexAlign={isTile ? "center" : "flex-start"}
|
|
178
|
+
rootGap={parseTokenValue(
|
|
179
|
+
isTile ? checkbox.checkboxTile.spacing.gap : checkbox.spacing.gap
|
|
180
|
+
)}
|
|
181
|
+
rootOpacity={
|
|
182
|
+
disabled ? parseFloat(theme.tokens.primitives.opacity["40"]) : 1
|
|
183
|
+
}
|
|
184
|
+
rootPaddingVertical={
|
|
185
|
+
isTile
|
|
186
|
+
? parseTokenValue(checkbox.checkboxTile.spacing.verticalPadding)
|
|
187
|
+
: undefined
|
|
188
|
+
}
|
|
189
|
+
rootPaddingHorizontal={
|
|
190
|
+
isTile
|
|
191
|
+
? parseTokenValue(checkbox.checkboxTile.spacing.horizontalPadding)
|
|
192
|
+
: undefined
|
|
193
|
+
}
|
|
194
|
+
rootMaxWidth={
|
|
195
|
+
isTile
|
|
196
|
+
? parseTokenValue(checkbox.checkboxTile.size.maxWidth)
|
|
197
|
+
: undefined
|
|
198
|
+
}
|
|
199
|
+
rootBgColor={
|
|
200
|
+
isTile
|
|
201
|
+
? isChecked
|
|
202
|
+
? checkbox.checkboxTile.colour.background.selected
|
|
203
|
+
: checkbox.checkboxTile.colour.background.default
|
|
204
|
+
: undefined
|
|
205
|
+
}
|
|
206
|
+
rootBorderWidth={
|
|
207
|
+
isTile
|
|
208
|
+
? parseTokenValue(checkbox.checkboxTile.borderWidth.default)
|
|
209
|
+
: undefined
|
|
210
|
+
}
|
|
211
|
+
rootBorderColor={
|
|
212
|
+
isTile
|
|
213
|
+
? isChecked
|
|
214
|
+
? checkbox.checkboxTile.colour.border.selected
|
|
215
|
+
: checkbox.checkboxTile.colour.border.default
|
|
216
|
+
: undefined
|
|
217
|
+
}
|
|
218
|
+
rootBorderRadius={
|
|
219
|
+
isTile
|
|
220
|
+
? parseTokenValue(checkbox.checkboxTile.borderRadius.default)
|
|
221
|
+
: undefined
|
|
222
|
+
}
|
|
223
|
+
style={typeof style === "function" ? undefined : style}
|
|
224
|
+
{...rest}
|
|
225
|
+
>
|
|
226
|
+
<StyledControl
|
|
227
|
+
controlSize={controlSize}
|
|
228
|
+
controlBorderWidth={parseTokenValue(checkbox.control.border.default)}
|
|
229
|
+
controlBorderColor={
|
|
230
|
+
isChecked
|
|
231
|
+
? checkbox.colour.background.selected
|
|
232
|
+
: checkbox.colour.border.default
|
|
233
|
+
}
|
|
234
|
+
controlBorderRadius={parseTokenValue(dimensions.borderRadius.xs)}
|
|
235
|
+
controlBgColor={
|
|
236
|
+
isChecked ? checkbox.colour.background.selected : "transparent"
|
|
237
|
+
}
|
|
238
|
+
>
|
|
239
|
+
<CheckboxPrimitive.Indicator>
|
|
240
|
+
<Icon icon={Check} size="xs" colour="alt" />
|
|
241
|
+
</CheckboxPrimitive.Indicator>
|
|
242
|
+
</StyledControl>
|
|
243
|
+
|
|
244
|
+
<StyledContent
|
|
245
|
+
contentGap={parseTokenValue(checkbox.spacing.content.gap)}
|
|
246
|
+
>
|
|
247
|
+
{label && (
|
|
248
|
+
<Typography
|
|
249
|
+
token={checkbox.typography.label}
|
|
250
|
+
color={checkbox.colour.text.title}
|
|
251
|
+
>
|
|
252
|
+
{label}
|
|
253
|
+
</Typography>
|
|
254
|
+
)}
|
|
255
|
+
{subText && (
|
|
256
|
+
<Typography
|
|
257
|
+
token={checkbox.typography.subText}
|
|
258
|
+
color={checkbox.colour.text.subtext}
|
|
259
|
+
>
|
|
260
|
+
{subText}
|
|
261
|
+
</Typography>
|
|
262
|
+
)}
|
|
263
|
+
</StyledContent>
|
|
264
|
+
|
|
265
|
+
{isTile && illustration && (
|
|
266
|
+
<StyledIllustration
|
|
267
|
+
illustrationSize={parseTokenValue(
|
|
268
|
+
checkbox.checkboxTile.size.illustration.default
|
|
269
|
+
)}
|
|
270
|
+
>
|
|
271
|
+
{illustration}
|
|
272
|
+
</StyledIllustration>
|
|
273
|
+
)}
|
|
274
|
+
</StyledRoot>
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
Checkbox.displayName = "Checkbox"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { View, ViewProps } from "react-native"
|
|
3
|
+
import styled from "@emotion/native"
|
|
4
|
+
import { useTheme } from "@emotion/react"
|
|
5
|
+
|
|
6
|
+
type CheckboxGroupOwnProps = {
|
|
7
|
+
children: React.ReactNode
|
|
8
|
+
orientation?: "horizontal" | "vertical"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type CheckboxGroupProps = CheckboxGroupOwnProps &
|
|
12
|
+
Omit<ViewProps, keyof CheckboxGroupOwnProps>
|
|
13
|
+
|
|
14
|
+
const parseTokenValue = (value: string): number => parseFloat(value)
|
|
15
|
+
|
|
16
|
+
const StyledGroup = styled(View)<{
|
|
17
|
+
groupDirection: "row" | "column"
|
|
18
|
+
groupGap: number
|
|
19
|
+
}>(({ groupDirection, groupGap }) => ({
|
|
20
|
+
flexDirection: groupDirection,
|
|
21
|
+
gap: groupGap
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* CheckboxGroup manages layout for a collection of Checkboxes.
|
|
26
|
+
*
|
|
27
|
+
* @param {"horizontal" | "vertical"} [orientation="vertical"] - Layout direction.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* <CheckboxGroup>
|
|
31
|
+
* <Checkbox label="Chicken" />
|
|
32
|
+
* <Checkbox label="Beef" />
|
|
33
|
+
* </CheckboxGroup>
|
|
34
|
+
*/
|
|
35
|
+
export const CheckboxGroup = React.forwardRef<View, CheckboxGroupProps>(
|
|
36
|
+
({ orientation = "vertical", children, ...rest }, ref) => {
|
|
37
|
+
const theme = useTheme()
|
|
38
|
+
const { checkbox } = theme.tokens.components
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<StyledGroup
|
|
42
|
+
ref={ref}
|
|
43
|
+
groupDirection={orientation === "horizontal" ? "row" : "column"}
|
|
44
|
+
groupGap={parseTokenValue(checkbox.spacing.gap)}
|
|
45
|
+
{...rest}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</StyledGroup>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
CheckboxGroup.displayName = "CheckboxGroup"
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import { View, StyleSheet } from "react-native"
|
|
3
|
+
import { RadioGroup } from "./RadioGroup"
|
|
4
|
+
import type { RadioGroupProps } from "./RadioGroup"
|
|
5
|
+
import { Typography } from "../../atoms/Typography"
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Molecules/Radio",
|
|
9
|
+
component: RadioGroup,
|
|
10
|
+
argTypes: {
|
|
11
|
+
orientation: {
|
|
12
|
+
control: { type: "select" },
|
|
13
|
+
options: ["vertical", "horizontal"],
|
|
14
|
+
description: "Layout direction of radio options"
|
|
15
|
+
},
|
|
16
|
+
disabled: {
|
|
17
|
+
control: { type: "boolean" },
|
|
18
|
+
description: "Disables entire radio group"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const basicOptions = [
|
|
24
|
+
{ value: "chicken", label: "Chicken" },
|
|
25
|
+
{ value: "beef", label: "Beef" },
|
|
26
|
+
{ value: "lamb", label: "Lamb" }
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
const optionsWithSubText = [
|
|
30
|
+
{ value: "chicken", label: "Chicken", subText: "Tender & tasty" },
|
|
31
|
+
{ value: "beef", label: "Beef", subText: "Rich & hearty" },
|
|
32
|
+
{ value: "lamb", label: "Lamb", subText: "Slow cooked" }
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
export const OptionsAPI = () => (
|
|
36
|
+
<View style={styles.column}>
|
|
37
|
+
<View style={styles.section}>
|
|
38
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
39
|
+
Vertical
|
|
40
|
+
</Typography>
|
|
41
|
+
<RadioGroup
|
|
42
|
+
name="vertical"
|
|
43
|
+
options={basicOptions}
|
|
44
|
+
orientation="vertical"
|
|
45
|
+
/>
|
|
46
|
+
</View>
|
|
47
|
+
|
|
48
|
+
<View style={styles.section}>
|
|
49
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
50
|
+
Horizontal
|
|
51
|
+
</Typography>
|
|
52
|
+
<RadioGroup
|
|
53
|
+
name="horizontal"
|
|
54
|
+
options={basicOptions}
|
|
55
|
+
orientation="horizontal"
|
|
56
|
+
/>
|
|
57
|
+
</View>
|
|
58
|
+
|
|
59
|
+
<View style={styles.section}>
|
|
60
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
61
|
+
With subtext
|
|
62
|
+
</Typography>
|
|
63
|
+
<RadioGroup
|
|
64
|
+
name="subtext"
|
|
65
|
+
options={optionsWithSubText}
|
|
66
|
+
orientation="vertical"
|
|
67
|
+
/>
|
|
68
|
+
</View>
|
|
69
|
+
</View>
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
export const TileVariant = () => (
|
|
73
|
+
<View style={styles.column}>
|
|
74
|
+
<View style={styles.section}>
|
|
75
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
76
|
+
Vertical tile
|
|
77
|
+
</Typography>
|
|
78
|
+
<RadioGroup
|
|
79
|
+
name="tile-vertical"
|
|
80
|
+
options={basicOptions.map((o) => ({ ...o, variant: "tile" as const }))}
|
|
81
|
+
orientation="vertical"
|
|
82
|
+
/>
|
|
83
|
+
</View>
|
|
84
|
+
|
|
85
|
+
<View style={styles.section}>
|
|
86
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
87
|
+
Horizontal tile
|
|
88
|
+
</Typography>
|
|
89
|
+
<RadioGroup
|
|
90
|
+
name="tile-horizontal"
|
|
91
|
+
options={basicOptions.map((o) => ({ ...o, variant: "tile" as const }))}
|
|
92
|
+
orientation="horizontal"
|
|
93
|
+
/>
|
|
94
|
+
</View>
|
|
95
|
+
</View>
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
export const States = () => (
|
|
99
|
+
<View style={styles.column}>
|
|
100
|
+
<View style={styles.section}>
|
|
101
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
102
|
+
Enabled
|
|
103
|
+
</Typography>
|
|
104
|
+
<RadioGroup name="enabled" options={basicOptions} />
|
|
105
|
+
</View>
|
|
106
|
+
|
|
107
|
+
<View style={styles.section}>
|
|
108
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
109
|
+
Disabled (group)
|
|
110
|
+
</Typography>
|
|
111
|
+
<RadioGroup name="disabled-group" options={basicOptions} disabled />
|
|
112
|
+
</View>
|
|
113
|
+
|
|
114
|
+
<View style={styles.section}>
|
|
115
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
116
|
+
Disabled (single item)
|
|
117
|
+
</Typography>
|
|
118
|
+
<RadioGroup
|
|
119
|
+
name="disabled-item"
|
|
120
|
+
options={[
|
|
121
|
+
{ value: "chicken", label: "Chicken" },
|
|
122
|
+
{ value: "beef", label: "Beef", disabled: true },
|
|
123
|
+
{ value: "lamb", label: "Lamb" }
|
|
124
|
+
]}
|
|
125
|
+
/>
|
|
126
|
+
</View>
|
|
127
|
+
</View>
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
export const CompoundComponents = () => (
|
|
131
|
+
<View style={styles.column}>
|
|
132
|
+
<RadioGroup name="compound" defaultValue="medium">
|
|
133
|
+
<RadioGroup.Radio value="small" label="Small" subText="For tiny dogs" />
|
|
134
|
+
<RadioGroup.Radio
|
|
135
|
+
value="medium"
|
|
136
|
+
label="Medium"
|
|
137
|
+
subText="For medium dogs"
|
|
138
|
+
/>
|
|
139
|
+
<RadioGroup.Radio value="large" label="Large" subText="For big dogs" />
|
|
140
|
+
</RadioGroup>
|
|
141
|
+
</View>
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
export const Controlled = () => {
|
|
145
|
+
const [value, setValue] = useState("chicken")
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<View style={styles.column}>
|
|
149
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
150
|
+
Selected: {value}
|
|
151
|
+
</Typography>
|
|
152
|
+
<RadioGroup
|
|
153
|
+
name="controlled"
|
|
154
|
+
options={basicOptions}
|
|
155
|
+
value={value}
|
|
156
|
+
onValueChange={setValue}
|
|
157
|
+
/>
|
|
158
|
+
</View>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const Playground = {
|
|
163
|
+
args: {
|
|
164
|
+
name: "playground",
|
|
165
|
+
orientation: "vertical",
|
|
166
|
+
disabled: false
|
|
167
|
+
},
|
|
168
|
+
render: (args: RadioGroupProps) => (
|
|
169
|
+
<RadioGroup {...args} options={basicOptions} />
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const styles = StyleSheet.create({
|
|
174
|
+
column: {
|
|
175
|
+
flexDirection: "column",
|
|
176
|
+
gap: 32
|
|
177
|
+
},
|
|
178
|
+
section: {
|
|
179
|
+
flexDirection: "column",
|
|
180
|
+
gap: 12
|
|
181
|
+
}
|
|
182
|
+
})
|