@utilitywarehouse/hearth-react-native 0.20.0 → 0.21.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/.storybook/manager.ts +1 -0
- package/.storybook/preview.tsx +1 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +13 -13
- package/CHANGELOG.md +249 -0
- package/build/components/BodyText/BodyText.js +12 -5
- package/build/components/BodyText/BodyText.props.d.ts +5 -19
- package/build/components/Box/Box.js +23 -3
- package/build/components/Box/Box.props.d.ts +3 -95
- package/build/components/Card/Card.props.d.ts +2 -5
- package/build/components/Container/Container.props.d.ts +2 -78
- package/build/components/DateInput/DateInput.d.ts +1 -1
- package/build/components/DateInput/DateInput.js +2 -2
- package/build/components/DateInput/DateInput.props.d.ts +15 -1
- package/build/components/DateInput/DateInputSegment.d.ts +1 -1
- package/build/components/DateInput/DateInputSegment.js +2 -2
- package/build/components/DetailText/DetailText.js +14 -13
- package/build/components/DetailText/DetailText.props.d.ts +4 -17
- package/build/components/Flex/Flex.js +3 -1
- package/build/components/Flex/Flex.props.d.ts +2 -2
- package/build/components/Heading/Heading.js +34 -13
- package/build/components/Heading/Heading.props.d.ts +4 -18
- package/build/core/themes.d.ts +188 -8
- package/build/core/themes.js +18 -2
- package/build/hooks/useStyleProps.js +22 -5
- package/build/tokens/color.d.ts +4 -0
- package/build/tokens/color.js +2 -0
- package/build/tokens/components/dark/modal.d.ts +6 -0
- package/build/tokens/components/dark/modal.js +6 -0
- package/build/tokens/components/dark/navigation.d.ts +1 -0
- package/build/tokens/components/dark/navigation.js +1 -0
- package/build/tokens/components/light/modal.d.ts +6 -0
- package/build/tokens/components/light/modal.js +6 -0
- package/build/tokens/components/light/navigation.d.ts +1 -0
- package/build/tokens/components/light/navigation.js +1 -0
- package/build/tokens/components/light/skeleton.d.ts +1 -1
- package/build/tokens/components/light/skeleton.js +1 -1
- package/build/tokens/font.d.ts +2 -0
- package/build/tokens/font.js +2 -0
- package/build/tokens/line-height.d.ts +2 -0
- package/build/tokens/line-height.js +2 -0
- package/build/tokens/primitive.d.ts +4 -0
- package/build/tokens/primitive.js +4 -0
- package/build/tokens/semantic-dark.d.ts +1 -0
- package/build/tokens/semantic-dark.js +1 -0
- package/build/tokens/semantic-light.d.ts +1 -0
- package/build/tokens/semantic-light.js +1 -0
- package/build/tokens/typography.d.ts +30 -0
- package/build/tokens/typography.js +15 -0
- package/build/types/index.d.ts +4 -2
- package/build/types/index.js +4 -2
- package/build/types/semanticColorValues.d.ts +22 -0
- package/build/types/semanticColorValues.js +1 -0
- package/build/types/utilityProps.d.ts +326 -0
- package/build/types/utilityProps.js +1 -0
- package/build/types/values.d.ts +4 -3
- package/build/utils/coloursAsArray.d.ts +4 -0
- package/build/utils/coloursAsArray.js +5 -0
- package/build/utils/index.d.ts +1 -1
- package/build/utils/index.js +1 -1
- package/build/utils/styleUtils.d.ts +26 -2
- package/build/utils/styleUtils.js +42 -13
- package/build/utils/themeValueHelpers.d.ts +13 -0
- package/build/utils/themeValueHelpers.js +29 -0
- package/docs/changelog.mdx +74 -2
- package/docs/components/AllComponents.web.tsx +23 -24
- package/docs/components/UsageWrap.tsx +2 -2
- package/docs/introduction.mdx +0 -7
- package/package.json +5 -3
- package/src/components/BodyText/BodyText.props.ts +5 -19
- package/src/components/BodyText/BodyText.stories.tsx +2 -1
- package/src/components/BodyText/BodyText.tsx +17 -6
- package/src/components/Box/Box.docs.mdx +5 -4
- package/src/components/Box/Box.props.ts +3 -231
- package/src/components/Box/Box.stories.tsx +2 -2
- package/src/components/Box/Box.tsx +38 -9
- package/src/components/Button/Button.docs.mdx +46 -1
- package/src/components/Card/Card.docs.mdx +1 -1
- package/src/components/Card/Card.props.ts +2 -5
- package/src/components/Card/Card.stories.tsx +54 -23
- package/src/components/Carousel/Carousel.docs.mdx +49 -44
- package/src/components/Center/Center.docs.mdx +6 -4
- package/src/components/Container/Container.docs.mdx +13 -8
- package/src/components/Container/Container.props.ts +9 -80
- package/src/components/Container/Container.stories.tsx +81 -65
- package/src/components/DateInput/DateInput.docs.mdx +43 -0
- package/src/components/DateInput/DateInput.props.ts +15 -1
- package/src/components/DateInput/DateInput.stories.tsx +37 -2
- package/src/components/DateInput/DateInput.tsx +6 -0
- package/src/components/DateInput/DateInputSegment.tsx +2 -0
- package/src/components/DetailText/DetailText.props.ts +4 -17
- package/src/components/DetailText/DetailText.stories.tsx +2 -3
- package/src/components/DetailText/DetailText.tsx +16 -17
- package/src/components/Flex/Flex.props.ts +2 -2
- package/src/components/Flex/Flex.stories.tsx +1 -1
- package/src/components/Flex/Flex.tsx +4 -1
- package/src/components/Grid/Grid.docs.mdx +53 -49
- package/src/components/Heading/Heading.props.ts +4 -18
- package/src/components/Heading/Heading.stories.tsx +2 -1
- package/src/components/Heading/Heading.tsx +40 -18
- package/src/components/Toast/ToastItem.figma.tsx +1 -8
- package/src/core/themes.ts +19 -2
- package/src/hooks/useStyleProps.ts +40 -5
- package/src/tokens/color.ts +2 -0
- package/src/tokens/components/dark/modal.ts +6 -0
- package/src/tokens/components/dark/navigation.ts +1 -0
- package/src/tokens/components/light/modal.ts +6 -0
- package/src/tokens/components/light/navigation.ts +1 -0
- package/src/tokens/components/light/skeleton.ts +1 -1
- package/src/tokens/font.ts +2 -0
- package/src/tokens/line-height.ts +2 -0
- package/src/tokens/primitive.ts +4 -0
- package/src/tokens/semantic-dark.ts +1 -0
- package/src/tokens/semantic-light.ts +1 -0
- package/src/tokens/typography.ts +15 -0
- package/src/types/index.ts +4 -2
- package/src/types/semanticColorValues.ts +26 -0
- package/src/types/utilityProps.ts +410 -0
- package/src/types/values.ts +4 -7
- package/src/utils/coloursAsArray.ts +6 -0
- package/src/utils/index.ts +8 -1
- package/src/utils/styleUtils.ts +45 -14
- package/src/utils/themeValueHelpers.ts +38 -0
|
@@ -26,6 +26,7 @@ The `DateInput` component allows users to enter dates manually using separate in
|
|
|
26
26
|
- [Flexible Segments](#flexible-segments)
|
|
27
27
|
- [Grouping Inputs](#grouping-inputs)
|
|
28
28
|
- [With State](#with-state)
|
|
29
|
+
- [Segment Refs](#segment-refs)
|
|
29
30
|
- [Overriding Styles](#overriding-styles)
|
|
30
31
|
- [Accessibility](#accessibility)
|
|
31
32
|
|
|
@@ -86,6 +87,9 @@ const MyComponent = () => {
|
|
|
86
87
|
| `dayValue` | `string` | - | Controlled value for the day segment |
|
|
87
88
|
| `monthValue` | `string` | - | Controlled value for the month segment |
|
|
88
89
|
| `yearValue` | `string` | - | Controlled value for the year segment |
|
|
90
|
+
| `dayRef` | `Ref<TextInput>` | - | Ref for the day input segment |
|
|
91
|
+
| `monthRef` | `Ref<TextInput>` | - | Ref for the month input segment |
|
|
92
|
+
| `yearRef` | `Ref<TextInput>` | - | Ref for the year input segment |
|
|
89
93
|
| `onDayChange` | `(text: string) => void` | - | Callback fired when the day value changes |
|
|
90
94
|
| `onMonthChange` | `(text: string) => void` | - | Callback fired when the month value changes |
|
|
91
95
|
| `onYearChange` | `(text: string) => void` | - | Callback fired when the year value changes |
|
|
@@ -159,6 +163,45 @@ Programmatically control date values:
|
|
|
159
163
|
|
|
160
164
|
<Canvas of={Stories.WithState} />
|
|
161
165
|
|
|
166
|
+
### Segment Refs
|
|
167
|
+
|
|
168
|
+
Use `dayRef`, `monthRef`, and `yearRef` to focus each segment programmatically:
|
|
169
|
+
|
|
170
|
+
<Canvas of={Stories.WithRefs} />
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import { useRef, useState } from 'react';
|
|
174
|
+
import { TextInput } from 'react-native';
|
|
175
|
+
import { Button, DateInput } from '@utilitywarehouse/hearth-react-native';
|
|
176
|
+
|
|
177
|
+
const MyComponent = () => {
|
|
178
|
+
const [day, setDay] = useState('');
|
|
179
|
+
const [month, setMonth] = useState('');
|
|
180
|
+
const [year, setYear] = useState('');
|
|
181
|
+
|
|
182
|
+
const dayRef = useRef<TextInput>(null);
|
|
183
|
+
const monthRef = useRef<TextInput>(null);
|
|
184
|
+
const yearRef = useRef<TextInput>(null);
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<>
|
|
188
|
+
<DateInput
|
|
189
|
+
dayValue={day}
|
|
190
|
+
monthValue={month}
|
|
191
|
+
yearValue={year}
|
|
192
|
+
onDayChange={setDay}
|
|
193
|
+
onMonthChange={setMonth}
|
|
194
|
+
onYearChange={setYear}
|
|
195
|
+
dayRef={dayRef}
|
|
196
|
+
monthRef={monthRef}
|
|
197
|
+
yearRef={yearRef}
|
|
198
|
+
/>
|
|
199
|
+
<Button onPress={() => monthRef.current?.focus()}>Focus month</Button>
|
|
200
|
+
</>
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
```
|
|
204
|
+
|
|
162
205
|
### Overriding Styles
|
|
163
206
|
|
|
164
207
|
You can override the styles of the input containers, input fields, and input labels using the `inputContainerStyle`, `inputStyle`, and `inputLabelStyle` props respectively:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
import type { TextInput, TextInputProps, ViewProps } from 'react-native';
|
|
2
3
|
import type { FormFieldBaseProps } from '../FormField/FormField.props';
|
|
3
4
|
import LabelProps from '../Label/Label.props';
|
|
4
5
|
|
|
@@ -42,6 +43,18 @@ export interface DateInputProps extends FormFieldBaseProps {
|
|
|
42
43
|
* The controlled value for the year segment. Must be used with an `onYearChange` handler.
|
|
43
44
|
*/
|
|
44
45
|
yearValue?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Ref for the day segment input.
|
|
48
|
+
*/
|
|
49
|
+
dayRef?: Ref<TextInput>;
|
|
50
|
+
/**
|
|
51
|
+
* Ref for the month segment input.
|
|
52
|
+
*/
|
|
53
|
+
monthRef?: Ref<TextInput>;
|
|
54
|
+
/**
|
|
55
|
+
* Ref for the year segment input.
|
|
56
|
+
*/
|
|
57
|
+
yearRef?: Ref<TextInput>;
|
|
45
58
|
/**
|
|
46
59
|
* Callback fired when the day value changes.
|
|
47
60
|
*/
|
|
@@ -96,6 +109,7 @@ export interface DateInputSegmentProps {
|
|
|
96
109
|
label: string;
|
|
97
110
|
placeholder?: string;
|
|
98
111
|
value?: string;
|
|
112
|
+
inputRef?: Ref<TextInput>;
|
|
99
113
|
onChange?: (text: string) => void;
|
|
100
114
|
onFocus?: DateInputProps['onDayFocus'];
|
|
101
115
|
onBlur?: DateInputProps['onDayBlur'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-native';
|
|
2
2
|
import { TickSmallIcon, WarningSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { TextInput, View } from 'react-native';
|
|
5
5
|
import { Button, Card, Flex, Heading } from '../../components';
|
|
6
6
|
import { DateInput } from './';
|
|
7
7
|
|
|
@@ -268,6 +268,41 @@ export const WithState: Story = {
|
|
|
268
268
|
},
|
|
269
269
|
};
|
|
270
270
|
|
|
271
|
+
export const WithRefs: Story = {
|
|
272
|
+
render: () => {
|
|
273
|
+
const [day, setDay] = useState('');
|
|
274
|
+
const [month, setMonth] = useState('');
|
|
275
|
+
const [year, setYear] = useState('');
|
|
276
|
+
|
|
277
|
+
const dayRef = useRef<TextInput>(null);
|
|
278
|
+
const monthRef = useRef<TextInput>(null);
|
|
279
|
+
const yearRef = useRef<TextInput>(null);
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<Flex spacing="md">
|
|
283
|
+
<DateInput
|
|
284
|
+
label="Date"
|
|
285
|
+
helperText="Use buttons to focus each segment"
|
|
286
|
+
dayValue={day}
|
|
287
|
+
monthValue={month}
|
|
288
|
+
yearValue={year}
|
|
289
|
+
onDayChange={setDay}
|
|
290
|
+
onMonthChange={setMonth}
|
|
291
|
+
onYearChange={setYear}
|
|
292
|
+
dayRef={dayRef}
|
|
293
|
+
monthRef={monthRef}
|
|
294
|
+
yearRef={yearRef}
|
|
295
|
+
/>
|
|
296
|
+
<Flex spacing="xs">
|
|
297
|
+
<Button onPress={() => dayRef.current?.focus()}>Focus day</Button>
|
|
298
|
+
<Button onPress={() => monthRef.current?.focus()}>Focus month</Button>
|
|
299
|
+
<Button onPress={() => yearRef.current?.focus()}>Focus year</Button>
|
|
300
|
+
</Flex>
|
|
301
|
+
</Flex>
|
|
302
|
+
);
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
|
|
271
306
|
export const CustomWidth: Story = {
|
|
272
307
|
render: () => (
|
|
273
308
|
<DateInput
|
|
@@ -23,6 +23,9 @@ const DateInput = ({
|
|
|
23
23
|
dayValue,
|
|
24
24
|
monthValue,
|
|
25
25
|
yearValue,
|
|
26
|
+
dayRef,
|
|
27
|
+
monthRef,
|
|
28
|
+
yearRef,
|
|
26
29
|
onDayChange,
|
|
27
30
|
onMonthChange,
|
|
28
31
|
onYearChange,
|
|
@@ -57,6 +60,7 @@ const DateInput = ({
|
|
|
57
60
|
label="Day"
|
|
58
61
|
placeholder={dayPlaceholder}
|
|
59
62
|
value={dayValue}
|
|
63
|
+
inputRef={dayRef}
|
|
60
64
|
onChange={onDayChange}
|
|
61
65
|
onFocus={onDayFocus}
|
|
62
66
|
onBlur={onDayBlur}
|
|
@@ -76,6 +80,7 @@ const DateInput = ({
|
|
|
76
80
|
label="Month"
|
|
77
81
|
placeholder={monthPlaceholder}
|
|
78
82
|
value={monthValue}
|
|
83
|
+
inputRef={monthRef}
|
|
79
84
|
onChange={onMonthChange}
|
|
80
85
|
onFocus={onMonthFocus}
|
|
81
86
|
onBlur={onMonthBlur}
|
|
@@ -95,6 +100,7 @@ const DateInput = ({
|
|
|
95
100
|
label="Year"
|
|
96
101
|
placeholder={yearPlaceholder}
|
|
97
102
|
value={yearValue}
|
|
103
|
+
inputRef={yearRef}
|
|
98
104
|
onChange={onYearChange}
|
|
99
105
|
onFocus={onYearFocus}
|
|
100
106
|
onBlur={onYearBlur}
|
|
@@ -8,6 +8,7 @@ const DateInputSegment = ({
|
|
|
8
8
|
label,
|
|
9
9
|
placeholder,
|
|
10
10
|
value,
|
|
11
|
+
inputRef,
|
|
11
12
|
onChange,
|
|
12
13
|
onFocus,
|
|
13
14
|
onBlur,
|
|
@@ -27,6 +28,7 @@ const DateInputSegment = ({
|
|
|
27
28
|
{label}
|
|
28
29
|
</BodyText>
|
|
29
30
|
<Input
|
|
31
|
+
ref={inputRef}
|
|
30
32
|
value={value}
|
|
31
33
|
onChangeText={onChange}
|
|
32
34
|
onFocus={onFocus}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ColorValue } from '../../types';
|
|
1
|
+
import type { CommonTextProps } from '../../types';
|
|
3
2
|
|
|
4
|
-
interface
|
|
3
|
+
interface DetailTextProps extends CommonTextProps {
|
|
4
|
+
/** Text size variant. */
|
|
5
5
|
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
|
|
6
|
-
strikeThrough?: boolean;
|
|
7
|
-
underline?: boolean;
|
|
8
|
-
truncated?: boolean;
|
|
9
|
-
italic?: boolean;
|
|
10
|
-
color?: ColorValue;
|
|
11
|
-
textTransform?: TextStyle['textTransform'];
|
|
12
|
-
textAlign?: TextStyle['textAlign'];
|
|
13
|
-
textAlignVertical?: TextStyle['textAlignVertical'];
|
|
14
|
-
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
15
|
-
textDecorationStyle?: TextStyle['textDecorationStyle'];
|
|
16
|
-
textDecorationColor?: ColorValue;
|
|
17
|
-
userSelect?: TextStyle['userSelect'];
|
|
18
|
-
inverted?: boolean;
|
|
19
6
|
}
|
|
20
7
|
|
|
21
|
-
export default
|
|
8
|
+
export default DetailTextProps;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { DetailText } from '.';
|
|
3
3
|
import { VariantTitle } from '../../../docs/components';
|
|
4
|
-
import { coloursAsArray } from '../../utils';
|
|
4
|
+
import { coloursAsArray, textColorKeys } from '../../utils';
|
|
5
5
|
import { Box } from '../Box';
|
|
6
6
|
|
|
7
7
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
@@ -24,7 +24,6 @@ const meta = {
|
|
|
24
24
|
control: 'boolean',
|
|
25
25
|
description: 'Truncate the text.',
|
|
26
26
|
},
|
|
27
|
-
|
|
28
27
|
italic: {
|
|
29
28
|
type: 'boolean',
|
|
30
29
|
control: 'boolean',
|
|
@@ -41,7 +40,7 @@ const meta = {
|
|
|
41
40
|
description: 'Strike through the text.',
|
|
42
41
|
},
|
|
43
42
|
color: {
|
|
44
|
-
options:
|
|
43
|
+
options: textColorKeys,
|
|
45
44
|
control: 'select',
|
|
46
45
|
description: 'Color of the text. Use the color name from the theme.',
|
|
47
46
|
},
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
1
|
import { Text } from 'react-native';
|
|
3
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
-
import {
|
|
5
|
-
import { getFlattenedColorValue } from '../../utils';
|
|
3
|
+
import { useStyleProps } from '../../hooks';
|
|
4
|
+
import { getFlattenedColorValue, resolveThemeValueWithFallback } from '../../utils';
|
|
6
5
|
import type DetailTextProps from './DetailText.props';
|
|
7
6
|
|
|
8
7
|
const DetailText = ({
|
|
@@ -23,7 +22,8 @@ const DetailText = ({
|
|
|
23
22
|
inverted,
|
|
24
23
|
...props
|
|
25
24
|
}: DetailTextProps) => {
|
|
26
|
-
const {
|
|
25
|
+
const { computedStyles: utilityStyles, remainingProps } = useStyleProps(props);
|
|
26
|
+
|
|
27
27
|
styles.useVariants({
|
|
28
28
|
size,
|
|
29
29
|
underline,
|
|
@@ -31,19 +31,10 @@ const DetailText = ({
|
|
|
31
31
|
italic,
|
|
32
32
|
inverted,
|
|
33
33
|
});
|
|
34
|
-
|
|
35
|
-
() => getFlattenedColorValue(color, themeColor),
|
|
36
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
-
[color, colorMode]
|
|
38
|
-
);
|
|
39
|
-
const decorationColor = useMemo(
|
|
40
|
-
() => getFlattenedColorValue(textDecorationColor, themeColor),
|
|
41
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
-
[textDecorationColor, colorMode]
|
|
43
|
-
);
|
|
34
|
+
|
|
44
35
|
return (
|
|
45
36
|
<Text
|
|
46
|
-
{...
|
|
37
|
+
{...remainingProps}
|
|
47
38
|
{...(truncated
|
|
48
39
|
? {
|
|
49
40
|
numberOfLines: 1,
|
|
@@ -52,16 +43,16 @@ const DetailText = ({
|
|
|
52
43
|
: {})}
|
|
53
44
|
style={[
|
|
54
45
|
styles.text,
|
|
46
|
+
utilityStyles,
|
|
55
47
|
{
|
|
56
|
-
...(colorValue && { color: colorValue }),
|
|
57
48
|
...(textTransform && { textTransform }),
|
|
58
49
|
...(textAlign && { textAlign }),
|
|
59
|
-
...(decorationColor && { textDecorationColor: decorationColor }),
|
|
60
50
|
...(textDecorationLine && { textDecorationLine }),
|
|
61
51
|
...(textDecorationStyle && { textDecorationStyle }),
|
|
62
52
|
...(userSelect && { userSelect }),
|
|
63
53
|
...(textAlignVertical && { textAlignVertical }),
|
|
64
54
|
},
|
|
55
|
+
styles.getColours(color, textDecorationColor),
|
|
65
56
|
props.style,
|
|
66
57
|
]}
|
|
67
58
|
>
|
|
@@ -143,6 +134,14 @@ const styles = StyleSheet.create(theme => ({
|
|
|
143
134
|
},
|
|
144
135
|
},
|
|
145
136
|
},
|
|
137
|
+
getColours: (color?: string, textDecorationColor?: string) => ({
|
|
138
|
+
...(color
|
|
139
|
+
? { color: resolveThemeValueWithFallback(color, theme.helpers.semanticColor.text, theme.color) }
|
|
140
|
+
: {}),
|
|
141
|
+
...(textDecorationColor
|
|
142
|
+
? { textDecorationColor: getFlattenedColorValue(textDecorationColor, theme.color) }
|
|
143
|
+
: {}),
|
|
144
|
+
}),
|
|
146
145
|
}));
|
|
147
146
|
|
|
148
147
|
export default DetailText;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FlexAlignType, ViewProps, ViewStyle } from 'react-native';
|
|
2
|
-
import { SpacingValues } from '../../types';
|
|
2
|
+
import { FlexLayoutProps, GapProps, SpacingValues } from '../../types';
|
|
3
3
|
|
|
4
|
-
interface FlexProps extends ViewProps {
|
|
4
|
+
interface FlexProps extends ViewProps, FlexLayoutProps, GapProps {
|
|
5
5
|
direction?: ViewStyle['flexDirection'];
|
|
6
6
|
align?: FlexAlignType;
|
|
7
7
|
justify?: ViewStyle['justifyContent'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { View, ViewStyle } from 'react-native';
|
|
2
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
+
import { useStyleProps } from '../../hooks';
|
|
3
4
|
import FlexProps from './Flex.props';
|
|
4
5
|
|
|
5
6
|
const Flex = ({
|
|
@@ -20,10 +21,12 @@ const Flex = ({
|
|
|
20
21
|
flexWrap: wrap,
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
const { computedStyles, remainingProps } = useStyleProps(rest);
|
|
25
|
+
|
|
23
26
|
styles.useVariants({ spacing: space ?? spacing });
|
|
24
27
|
|
|
25
28
|
return (
|
|
26
|
-
<View style={[propStyle, styles.flex, style]} {...
|
|
29
|
+
<View style={[propStyle, styles.flex, computedStyles, style]} {...remainingProps}>
|
|
27
30
|
{children}
|
|
28
31
|
</View>
|
|
29
32
|
);
|
|
@@ -2,6 +2,7 @@ import { Canvas, Controls, Meta, Primary, Story } from '@storybook/addon-docs/bl
|
|
|
2
2
|
import { BodyText, Box, Center, Grid } from '../..';
|
|
3
3
|
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
4
4
|
import * as Stories from './Grid.stories';
|
|
5
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
5
6
|
|
|
6
7
|
<Meta title="Primitives / Grid" />
|
|
7
8
|
|
|
@@ -26,17 +27,17 @@ The Grid component helps you create responsive grid layouts with configurable co
|
|
|
26
27
|
<UsageWrap>
|
|
27
28
|
<Center>
|
|
28
29
|
<Grid columns={2} spacing="md" width={300}>
|
|
29
|
-
<Box backgroundColor=
|
|
30
|
-
<BodyText color="
|
|
30
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
31
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
31
32
|
</Box>
|
|
32
|
-
<Box backgroundColor=
|
|
33
|
-
<BodyText color="
|
|
33
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
34
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
34
35
|
</Box>
|
|
35
|
-
<Box backgroundColor=
|
|
36
|
-
<BodyText color="
|
|
36
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
37
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
37
38
|
</Box>
|
|
38
|
-
<Box backgroundColor=
|
|
39
|
-
<BodyText color="
|
|
39
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
40
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
40
41
|
</Box>
|
|
41
42
|
</Grid>
|
|
42
43
|
</Center>
|
|
@@ -44,20 +45,21 @@ The Grid component helps you create responsive grid layouts with configurable co
|
|
|
44
45
|
|
|
45
46
|
```jsx
|
|
46
47
|
import { Grid, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
48
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
47
49
|
|
|
48
50
|
const MyComponent = () => (
|
|
49
51
|
<Grid columns={2} spacing="md" width={300}>
|
|
50
|
-
<Box backgroundColor=
|
|
51
|
-
<BodyText color="
|
|
52
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
53
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
52
54
|
</Box>
|
|
53
|
-
<Box backgroundColor=
|
|
54
|
-
<BodyText color="
|
|
55
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
56
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
55
57
|
</Box>
|
|
56
|
-
<Box backgroundColor=
|
|
57
|
-
<BodyText color="
|
|
58
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
59
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
58
60
|
</Box>
|
|
59
|
-
<Box backgroundColor=
|
|
60
|
-
<BodyText color="
|
|
61
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
62
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
61
63
|
</Box>
|
|
62
64
|
</Grid>
|
|
63
65
|
);
|
|
@@ -79,17 +81,17 @@ The Grid component supports responsive column layouts based on screen size break
|
|
|
79
81
|
spacing="md"
|
|
80
82
|
width="100%"
|
|
81
83
|
>
|
|
82
|
-
<Box backgroundColor=
|
|
83
|
-
<BodyText color="
|
|
84
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
85
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
84
86
|
</Box>
|
|
85
|
-
<Box backgroundColor=
|
|
86
|
-
<BodyText color="
|
|
87
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
88
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
87
89
|
</Box>
|
|
88
|
-
<Box backgroundColor=
|
|
89
|
-
<BodyText color="
|
|
90
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
91
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
90
92
|
</Box>
|
|
91
|
-
<Box backgroundColor=
|
|
92
|
-
<BodyText color="
|
|
93
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
94
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
93
95
|
</Box>
|
|
94
96
|
</Grid>
|
|
95
97
|
</Center>
|
|
@@ -97,6 +99,7 @@ The Grid component supports responsive column layouts based on screen size break
|
|
|
97
99
|
|
|
98
100
|
```jsx
|
|
99
101
|
import { Grid, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
102
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
100
103
|
|
|
101
104
|
const MyComponent = () => (
|
|
102
105
|
<Grid
|
|
@@ -109,17 +112,17 @@ const MyComponent = () => (
|
|
|
109
112
|
spacing="md"
|
|
110
113
|
width="100%"
|
|
111
114
|
>
|
|
112
|
-
<Box backgroundColor=
|
|
113
|
-
<BodyText color="
|
|
115
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
116
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
114
117
|
</Box>
|
|
115
|
-
<Box backgroundColor=
|
|
116
|
-
<BodyText color="
|
|
118
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
119
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
117
120
|
</Box>
|
|
118
|
-
<Box backgroundColor=
|
|
119
|
-
<BodyText color="
|
|
121
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
122
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
120
123
|
</Box>
|
|
121
|
-
<Box backgroundColor=
|
|
122
|
-
<BodyText color="
|
|
124
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
125
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
123
126
|
</Box>
|
|
124
127
|
</Grid>
|
|
125
128
|
);
|
|
@@ -132,38 +135,39 @@ You can specify different horizontal and vertical spacing:
|
|
|
132
135
|
<UsageWrap>
|
|
133
136
|
<Center>
|
|
134
137
|
<Grid columns={2} columnGap={24} rowGap={16}>
|
|
135
|
-
<Box backgroundColor=
|
|
136
|
-
<BodyText color="
|
|
138
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
139
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
137
140
|
</Box>
|
|
138
|
-
<Box backgroundColor=
|
|
139
|
-
<BodyText color="
|
|
141
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
142
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
140
143
|
</Box>
|
|
141
|
-
<Box backgroundColor=
|
|
142
|
-
<BodyText color="
|
|
144
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
145
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
143
146
|
</Box>
|
|
144
|
-
<Box backgroundColor=
|
|
145
|
-
<BodyText color="
|
|
147
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
148
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
146
149
|
</Box>
|
|
147
150
|
</Grid>
|
|
148
151
|
</Center>
|
|
149
152
|
</UsageWrap>
|
|
150
153
|
|
|
151
154
|
```jsx
|
|
152
|
-
import { Grid, Box } from '@utilitywarehouse/hearth-react-native';
|
|
155
|
+
import { Grid, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
156
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
153
157
|
|
|
154
158
|
const MyComponent = () => (
|
|
155
159
|
<Grid columns={2} columnGap={24} rowGap={8}>
|
|
156
|
-
<Box backgroundColor=
|
|
157
|
-
<BodyText color="
|
|
160
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
161
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
158
162
|
</Box>
|
|
159
|
-
<Box backgroundColor=
|
|
160
|
-
<BodyText color="
|
|
163
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
164
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
161
165
|
</Box>
|
|
162
|
-
<Box backgroundColor=
|
|
163
|
-
<BodyText color="
|
|
166
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
167
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
164
168
|
</Box>
|
|
165
|
-
<Box backgroundColor=
|
|
166
|
-
<BodyText color="
|
|
169
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
170
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
167
171
|
</Box>
|
|
168
172
|
</Grid>
|
|
169
173
|
);
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Text, TextProps, TextStyle } from 'react-native';
|
|
3
|
-
import type { ColorValue } from '../../types';
|
|
1
|
+
import type { CommonTextProps } from '../../types';
|
|
4
2
|
|
|
5
|
-
interface HeadingProps extends
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
underline?: boolean;
|
|
9
|
-
truncated?: boolean;
|
|
10
|
-
color?: ColorValue;
|
|
11
|
-
textTransform?: TextStyle['textTransform'];
|
|
12
|
-
textAlign?: TextStyle['textAlign'];
|
|
13
|
-
textAlignVertical?: TextStyle['textAlignVertical'];
|
|
14
|
-
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
15
|
-
textDecorationStyle?: TextStyle['textDecorationStyle'];
|
|
16
|
-
textDecorationColor?: ColorValue;
|
|
17
|
-
userSelect?: TextStyle['userSelect'];
|
|
18
|
-
inverted?: boolean;
|
|
19
|
-
ref?: Ref<Text>;
|
|
3
|
+
interface HeadingProps extends CommonTextProps {
|
|
4
|
+
/** Heading size variant. */
|
|
5
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
20
6
|
}
|
|
21
7
|
|
|
22
8
|
export default HeadingProps;
|
|
@@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { Heading } from '.';
|
|
3
3
|
import { VariantTitle } from '../../../docs/components';
|
|
4
4
|
import { coloursAsArray } from '../../utils';
|
|
5
|
+
import { textColorKeys } from '../../utils/coloursAsArray';
|
|
5
6
|
import { Box } from '../Box';
|
|
6
7
|
|
|
7
8
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
@@ -35,7 +36,7 @@ const meta = {
|
|
|
35
36
|
description: 'Strike through the text.',
|
|
36
37
|
},
|
|
37
38
|
color: {
|
|
38
|
-
options:
|
|
39
|
+
options: textColorKeys,
|
|
39
40
|
control: 'select',
|
|
40
41
|
description: 'Color of the text. Use the color name from the theme.',
|
|
41
42
|
},
|