@utilitywarehouse/hearth-react-native 0.19.0 → 0.20.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/preview.tsx +1 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +16 -16
- package/CHANGELOG.md +74 -2
- package/build/components/Menu/Menu.d.ts +1 -1
- package/build/components/Menu/Menu.js +2 -2
- package/build/components/Menu/Menu.props.d.ts +2 -6
- package/build/components/Modal/Modal.d.ts +1 -1
- package/build/components/Modal/Modal.js +2 -2
- package/build/components/Modal/Modal.props.d.ts +1 -0
- package/build/components/Modal/Modal.web.d.ts +1 -1
- package/build/components/Modal/Modal.web.js +2 -2
- package/build/components/Select/Select.d.ts +1 -1
- package/build/components/Select/Select.js +9 -10
- package/build/components/Select/Select.props.d.ts +16 -0
- package/build/components/Toast/ToastItem.js +3 -1
- package/docs/changelog.mdx +687 -0
- package/package.json +6 -6
- package/scripts/copyChangelog.js +50 -0
- package/src/components/Checkbox/CheckboxGroup.figma.tsx +21 -1
- package/src/components/Menu/Menu.docs.mdx +8 -5
- package/src/components/Menu/Menu.figma.tsx +27 -27
- package/src/components/Menu/Menu.props.ts +2 -6
- package/src/components/Menu/Menu.tsx +3 -6
- package/src/components/Menu/MenuItem.figma.tsx +26 -18
- package/src/components/Modal/Modal.docs.mdx +22 -21
- package/src/components/Modal/Modal.figma.tsx +58 -47
- package/src/components/Modal/Modal.props.ts +1 -0
- package/src/components/Modal/Modal.stories.tsx +4 -0
- package/src/components/Modal/Modal.tsx +2 -1
- package/src/components/Modal/Modal.web.tsx +2 -1
- package/src/components/PillGroup/Pill.figma.tsx +4 -17
- package/src/components/PillGroup/PillGroup.figma.tsx +8 -9
- package/src/components/ProgressStepper/ProgressStep.figma.tsx +4 -15
- package/src/components/ProgressStepper/ProgressStepper.figma.tsx +9 -16
- package/src/components/Radio/Radio.figma.tsx +35 -22
- package/src/components/Radio/RadioGroup.figma.tsx +69 -41
- package/src/components/Radio/RadioTile.figma.tsx +34 -0
- package/src/components/RadioCard/RadioCard.figma.tsx +24 -0
- package/src/components/SectionHeader/SectionHeader.figma.tsx +31 -25
- package/src/components/Select/Select.docs.mdx +76 -28
- package/src/components/Select/Select.figma.tsx +44 -43
- package/src/components/Select/Select.props.ts +16 -0
- package/src/components/Select/Select.tsx +42 -35
- package/src/components/Select/SelectOption.figma.tsx +3 -21
- package/src/components/Spinner/Spinner.figma.tsx +12 -25
- package/src/components/Switch/Switch.figma.tsx +2 -23
- package/src/components/Tabs/Tab.figma.tsx +21 -0
- package/src/components/Tabs/Tabs.figma.tsx +18 -27
- package/src/components/Textarea/Textarea.figma.tsx +64 -0
- package/src/components/Toast/ToastItem.tsx +3 -1
- package/src/components/ToggleButtonCard/ToggleButtonCard.figma.tsx +24 -0
- package/src/components/VerificationInput/VerificationInput.figma.tsx +53 -0
- package/src/components/Radio/RadioTileRoot.figma.tsx +0 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilitywarehouse/hearth-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Utility Warehouse React Native UI library",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"vite-plugin-svgr": "^4.5.0",
|
|
57
57
|
"vitest": "^3.2.4",
|
|
58
58
|
"@utilitywarehouse/hearth-fonts": "^0.0.4",
|
|
59
|
+
"@utilitywarehouse/hearth-tokens": "^0.2.2",
|
|
59
60
|
"@utilitywarehouse/hearth-react-icons": "^0.8.0",
|
|
60
61
|
"@utilitywarehouse/hearth-react-native-icons": "^0.8.0",
|
|
61
|
-
"@utilitywarehouse/hearth-svg-assets": "^0.3.0"
|
|
62
|
-
"@utilitywarehouse/hearth-tokens": "^0.2.2"
|
|
62
|
+
"@utilitywarehouse/hearth-svg-assets": "^0.3.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@gorhom/bottom-sheet": "^5.0.0",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"clean": "rm -rf node_modules rm -rf build .turbo",
|
|
77
77
|
"generateColours": "node ./scripts/generateColours.js",
|
|
78
78
|
"copyTokens": "node ./scripts/copyTokens.js",
|
|
79
|
+
"copyChangelog": "node ./scripts/copyChangelog.js",
|
|
79
80
|
"lint:fix": "TIMING=1 eslint --fix .",
|
|
80
81
|
"lint": "TIMING=1 eslint .",
|
|
81
82
|
"build": "tsc",
|
|
@@ -83,9 +84,8 @@
|
|
|
83
84
|
"figma:create": "figma connect create",
|
|
84
85
|
"figma:publish": "figma connect publish",
|
|
85
86
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
86
|
-
"dev": "storybook dev -p 6006",
|
|
87
|
-
"build:storybook": "storybook build",
|
|
88
|
-
"build-storybook": "storybook build",
|
|
87
|
+
"dev": "npm run copyChangelog && storybook dev -p 6006",
|
|
88
|
+
"build:storybook": "npm run copyChangelog && storybook build",
|
|
89
89
|
"chromatic": "npx chromatic --project-token=chpt_cce0fb1ebd95d2a --build-script-name build:storybook"
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script to copy CHANGELOG.md to docs folder and convert it to changelog.mdx
|
|
3
|
+
* with proper Meta and BackToTopButton components
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
// Get the directory name in ES modules
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
|
|
14
|
+
// Define paths
|
|
15
|
+
const sourceFile = path.resolve(__dirname, '../CHANGELOG.md');
|
|
16
|
+
const targetFile = path.resolve(__dirname, '../docs/changelog.mdx');
|
|
17
|
+
|
|
18
|
+
// Read the changelog content
|
|
19
|
+
console.log('Reading CHANGELOG.md...');
|
|
20
|
+
if (!fs.existsSync(sourceFile)) {
|
|
21
|
+
console.error('Error: CHANGELOG.md not found at', sourceFile);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let changelogContent = fs.readFileSync(sourceFile, 'utf-8');
|
|
26
|
+
|
|
27
|
+
// Remove the first line (package name heading)
|
|
28
|
+
changelogContent = changelogContent.split('\n').slice(1).join('\n');
|
|
29
|
+
|
|
30
|
+
// Create the MDX content with imports and components
|
|
31
|
+
const mdxContent = `import { Meta } from '@storybook/addon-docs/blocks';
|
|
32
|
+
import { BackToTopButton } from './components';
|
|
33
|
+
|
|
34
|
+
<Meta title="Changelog" />
|
|
35
|
+
<BackToTopButton />
|
|
36
|
+
|
|
37
|
+
# Changelog - ${'`@utilitywarehouse/hearth-react-native`'}
|
|
38
|
+
|
|
39
|
+
The changelog for the Hearth React Native library. Here you can find all the changes, improvements, and bug fixes for each version.
|
|
40
|
+
|
|
41
|
+
${changelogContent}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
// Write the new MDX file
|
|
45
|
+
console.log('Writing changelog.mdx...');
|
|
46
|
+
fs.writeFileSync(targetFile, mdxContent);
|
|
47
|
+
|
|
48
|
+
console.log('✅ Changelog copied and transformed successfully!');
|
|
49
|
+
console.log(` Source: ${sourceFile}`);
|
|
50
|
+
console.log(` Target: ${targetFile}`);
|
|
@@ -3,6 +3,10 @@ import { CheckboxGroup } from '../';
|
|
|
3
3
|
|
|
4
4
|
const props = {
|
|
5
5
|
label: figma.string('Group label'),
|
|
6
|
+
labelVariant: figma.enum('Label variant', {
|
|
7
|
+
Heading: 'heading',
|
|
8
|
+
Body: 'body',
|
|
9
|
+
}),
|
|
6
10
|
helperText: figma.boolean('Helper text?', {
|
|
7
11
|
true: figma.string('Helper text'),
|
|
8
12
|
false: undefined,
|
|
@@ -13,6 +17,12 @@ const props = {
|
|
|
13
17
|
}),
|
|
14
18
|
tiles: figma.children('Checkbox Tile'),
|
|
15
19
|
checkboxes: figma.children('Checkbox'),
|
|
20
|
+
validationStatus: figma.enum('State', {
|
|
21
|
+
Invalid: 'invalid',
|
|
22
|
+
}),
|
|
23
|
+
invalidText: figma.enum('State', {
|
|
24
|
+
Invalid: figma.string('Validation text'),
|
|
25
|
+
}),
|
|
16
26
|
};
|
|
17
27
|
|
|
18
28
|
figma.connect(
|
|
@@ -27,8 +37,11 @@ figma.connect(
|
|
|
27
37
|
<CheckboxGroup
|
|
28
38
|
type="tile"
|
|
29
39
|
label={props.label}
|
|
40
|
+
labelVariant={props.labelVariant}
|
|
30
41
|
helperText={props.helperText}
|
|
31
42
|
direction={props.direction}
|
|
43
|
+
validationStatus={props.validationStatus}
|
|
44
|
+
invalidText={props.invalidText}
|
|
32
45
|
>
|
|
33
46
|
{props.tiles}
|
|
34
47
|
</CheckboxGroup>
|
|
@@ -45,7 +58,14 @@ figma.connect(
|
|
|
45
58
|
},
|
|
46
59
|
props,
|
|
47
60
|
example: props => (
|
|
48
|
-
<CheckboxGroup
|
|
61
|
+
<CheckboxGroup
|
|
62
|
+
label={props.label}
|
|
63
|
+
labelVariant={props.labelVariant}
|
|
64
|
+
helperText={props.helperText}
|
|
65
|
+
direction={props.direction}
|
|
66
|
+
validationStatus={props.validationStatus}
|
|
67
|
+
invalidText={props.invalidText}
|
|
68
|
+
>
|
|
49
69
|
{props.checkboxes}
|
|
50
70
|
</CheckboxGroup>
|
|
51
71
|
),
|
|
@@ -67,11 +67,14 @@ const MyComponent = () => {
|
|
|
67
67
|
|
|
68
68
|
### Menu
|
|
69
69
|
|
|
70
|
-
| Prop
|
|
71
|
-
|
|
|
72
|
-
| `heading`
|
|
73
|
-
| `children`
|
|
74
|
-
|
|
70
|
+
| Prop | Type | Default | Description |
|
|
71
|
+
| ---------- | ----------- | ------- | --------------------------------------------- |
|
|
72
|
+
| `heading` | `string` | - | Heading text displayed at the top of the menu |
|
|
73
|
+
| `children` | `ReactNode` | - | Menu items to display |
|
|
74
|
+
|
|
75
|
+
The rest of the props are passed down to the underlying `BottomSheetModal` component, so you can use any of its
|
|
76
|
+
props for additional configuration (e.g. `snapPoints`, `backgroundStyle`, etc.).
|
|
77
|
+
See the [BottomSheetModal docs](/?path=/docs/components-bottomsheet--docs) for more details.
|
|
75
78
|
|
|
76
79
|
### MenuItem
|
|
77
80
|
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { Button, Menu, MenuTrigger } from '../';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
figma.connect(Menu, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3263%3A18832', {
|
|
6
|
+
props: {
|
|
7
|
+
menuItems: figma.children('Menu Item'),
|
|
8
|
+
heading: figma.boolean('Heading?', {
|
|
9
|
+
true: figma.string('Heading'),
|
|
10
|
+
}),
|
|
11
|
+
showHandle: figma.boolean('Grabber?', {
|
|
12
|
+
true: true,
|
|
13
|
+
}),
|
|
14
|
+
},
|
|
15
|
+
example: props => {
|
|
16
|
+
const menuRef = useRef(null);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<MenuTrigger onPress={() => menuRef.current?.present()}>
|
|
21
|
+
<Button>Open Menu</Button>
|
|
22
|
+
</MenuTrigger>
|
|
11
23
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// These props were automatically mapped based on your linked code:
|
|
18
|
-
heading: figma.string("Heading"),
|
|
19
|
-
// No matching props could be found for these Figma properties:
|
|
20
|
-
// "heading": figma.string('Heading'),
|
|
21
|
-
// "heading": figma.boolean('Heading?'),
|
|
22
|
-
// "grabber": figma.boolean('Grabber?'),
|
|
23
|
-
// "deviceType": figma.enum('Device type', {
|
|
24
|
-
// "Web": "web",
|
|
25
|
-
// "App": "app"
|
|
26
|
-
// })
|
|
27
|
-
},
|
|
28
|
-
example: (props) => <Menu heading={props.heading} />,
|
|
24
|
+
<Menu ref={menuRef} heading={props.heading} showHandle={props.showHandle}>
|
|
25
|
+
{props.menuItems}
|
|
26
|
+
</Menu>
|
|
27
|
+
</>
|
|
28
|
+
);
|
|
29
29
|
},
|
|
30
|
-
)
|
|
30
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { BottomSheetModalProps } from '@gorhom/bottom-sheet';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import { BottomSheetProps } from '../BottomSheet';
|
|
3
3
|
|
|
4
4
|
export interface MenuMethods {
|
|
5
5
|
present: () => void;
|
|
6
6
|
dismiss: () => void;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface MenuProps {
|
|
9
|
+
export interface MenuProps extends BottomSheetProps {
|
|
10
10
|
/**
|
|
11
11
|
* Heading text displayed at the top of the menu
|
|
12
12
|
*/
|
|
@@ -15,10 +15,6 @@ export interface MenuProps {
|
|
|
15
15
|
* Menu items to display
|
|
16
16
|
*/
|
|
17
17
|
children: ReactNode;
|
|
18
|
-
/**
|
|
19
|
-
* Optional bottom sheet modal props to customise the menu behavior
|
|
20
|
-
*/
|
|
21
|
-
bottomSheetProps?: Partial<BottomSheetModalProps>;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
export default MenuProps;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { forwardRef, useCallback, useImperativeHandle, useMemo, useRef } from 'react';
|
|
2
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
3
3
|
import { BodyText } from '../BodyText';
|
|
4
|
-
import { BottomSheetModal,
|
|
4
|
+
import { BottomSheetModal, BottomSheetScrollView } from '../BottomSheet';
|
|
5
5
|
import { MenuContext } from './Menu.context';
|
|
6
6
|
import type MenuProps from './Menu.props';
|
|
7
7
|
import type { MenuMethods } from './Menu.props';
|
|
8
8
|
|
|
9
|
-
const Menu = forwardRef<MenuMethods, MenuProps>(({ heading, children,
|
|
9
|
+
const Menu = forwardRef<MenuMethods, MenuProps>(({ heading, children, ...props }, ref) => {
|
|
10
10
|
const bottomSheetModalRef = useRef<BottomSheetModal>(null);
|
|
11
11
|
|
|
12
12
|
useImperativeHandle(
|
|
@@ -25,10 +25,7 @@ const Menu = forwardRef<MenuMethods, MenuProps>(({ heading, children, bottomShee
|
|
|
25
25
|
const contextValue = useMemo(() => ({ close: handleClose }), [handleClose]);
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<BottomSheetModal
|
|
29
|
-
ref={bottomSheetModalRef}
|
|
30
|
-
{...(bottomSheetProps as Partial<BottomSheetProps>)}
|
|
31
|
-
>
|
|
28
|
+
<BottomSheetModal ref={bottomSheetModalRef} {...props}>
|
|
32
29
|
<BottomSheetScrollView contentContainerStyle={styles.container}>
|
|
33
30
|
<MenuContext.Provider value={contextValue}>
|
|
34
31
|
{heading && (
|
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import MenuItem from '
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* -- This file was auto-generated by Code Connect --
|
|
6
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
7
|
-
* You should check this is correct, and update the `example` function
|
|
8
|
-
* to return the code example you'd like to see in Figma
|
|
9
|
-
*/
|
|
2
|
+
import { MenuItem } from '../';
|
|
10
3
|
|
|
11
4
|
figma.connect(
|
|
12
5
|
MenuItem,
|
|
13
|
-
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3253-8193',
|
|
14
7
|
{
|
|
15
8
|
props: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
text: figma.string('Text'),
|
|
10
|
+
icon: figma.boolean('Icon left?', {
|
|
11
|
+
true: figma.instance('Icon left-20'),
|
|
12
|
+
false: figma.boolean('Icon right?', {
|
|
13
|
+
true: figma.instance('Icon right-20'),
|
|
14
|
+
}),
|
|
15
|
+
}),
|
|
16
|
+
iconPosition: figma.boolean('Icon left?', {
|
|
17
|
+
true: 'left',
|
|
18
|
+
false: figma.boolean('Icon right?', {
|
|
19
|
+
true: 'right',
|
|
20
|
+
}),
|
|
19
21
|
}),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
colorScheme: figma.enum('Color Scheme', {
|
|
23
|
+
Destructive: 'destructive',
|
|
24
|
+
}),
|
|
25
|
+
disabled: figma.enum('State', {
|
|
26
|
+
Disabled: true,
|
|
22
27
|
}),
|
|
23
|
-
// No matching props could be found for these Figma properties:
|
|
24
|
-
// "number": figma.string('Number'),
|
|
25
|
-
// "selected": figma.boolean('Selected?')
|
|
26
28
|
},
|
|
27
29
|
example: props => (
|
|
28
|
-
<MenuItem
|
|
30
|
+
<MenuItem
|
|
31
|
+
text={props.text}
|
|
32
|
+
disabled={props.disabled}
|
|
33
|
+
colorScheme={props.colorScheme}
|
|
34
|
+
icon={props.icon}
|
|
35
|
+
iconPosition={props.iconPosition}
|
|
36
|
+
/>
|
|
29
37
|
),
|
|
30
38
|
}
|
|
31
39
|
);
|
|
@@ -87,27 +87,28 @@ const MyComponent = () => {
|
|
|
87
87
|
|
|
88
88
|
The Modal component extends the `BottomSheetModal` component and accepts all of its props, plus the following additional props:
|
|
89
89
|
|
|
90
|
-
| Property | Type | Description | Default
|
|
91
|
-
| ----------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
92
|
-
| `heading` | `string` | The heading text displayed at the top of the modal | -
|
|
93
|
-
| `description` | `string` | The description text displayed below the heading | -
|
|
94
|
-
| `showCloseButton` | `boolean` | Whether to show the close button in the top-right corner | `true`
|
|
95
|
-
| `primaryButtonText` | `string` | Text for the primary action button | -
|
|
96
|
-
| `secondaryButtonText` | `string` | Text for the secondary action button | -
|
|
97
|
-
| `onPressPrimaryButton` | `() => void` | Callback function called when the primary button is pressed | -
|
|
98
|
-
| `onPressSecondaryButton` | `() => void` | Callback function called when the secondary button is pressed | -
|
|
99
|
-
| `onPressCloseButton` | `() => void` | Callback function called when the close button is pressed | -
|
|
100
|
-
| `closeOnPrimaryButtonPress` | `boolean` | Whether to automatically close the modal when the primary button is pressed | `true`
|
|
101
|
-
| `closeOnSecondaryButtonPress` | `boolean` | Whether to automatically close the modal when the secondary button is pressed | `true`
|
|
102
|
-
| `onChange` | `(index: number, position: number, `<br />` type: number) => void` | Callback function called when the modal's position changes \* | -
|
|
103
|
-
| `loading` | `boolean` | Whether to show a loading state with spinner | `false`
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
90
|
+
| Property | Type | Description | Default |
|
|
91
|
+
| ----------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | -------------- |
|
|
92
|
+
| `heading` | `string` | The heading text displayed at the top of the modal | - |
|
|
93
|
+
| `description` | `string` | The description text displayed below the heading | - |
|
|
94
|
+
| `showCloseButton` | `boolean` | Whether to show the close button in the top-right corner | `true` |
|
|
95
|
+
| `primaryButtonText` | `string` | Text for the primary action button | - |
|
|
96
|
+
| `secondaryButtonText` | `string` | Text for the secondary action button | - |
|
|
97
|
+
| `onPressPrimaryButton` | `() => void` | Callback function called when the primary button is pressed | - |
|
|
98
|
+
| `onPressSecondaryButton` | `() => void` | Callback function called when the secondary button is pressed | - |
|
|
99
|
+
| `onPressCloseButton` | `() => void` | Callback function called when the close button is pressed | - |
|
|
100
|
+
| `closeOnPrimaryButtonPress` | `boolean` | Whether to automatically close the modal when the primary button is pressed | `true` |
|
|
101
|
+
| `closeOnSecondaryButtonPress` | `boolean` | Whether to automatically close the modal when the secondary button is pressed | `true` |
|
|
102
|
+
| `onChange` | `(index: number, position: number, `<br />` type: number) => void` | Callback function called when the modal's position changes \* | - |
|
|
103
|
+
| `loading` | `boolean` | Whether to show a loading state with spinner | `false` |
|
|
104
|
+
| `loadingHeading` | `string` | The heading text to be displayed when loading is true. If not provided, the regular heading will be shown. | `'Loading...'` |
|
|
105
|
+
| `image` | `ImageProps` | Image to display in the modal (shows as centered content with text below) | - |
|
|
106
|
+
| `children` | `ReactNode` | Custom content to display in the modal body | - |
|
|
107
|
+
| `primaryButtonProps` | `Omit<ButtonWithoutChildrenProps, 'children'>` | Additional props to pass to the primary button (colorScheme defaults to 'highlight', variant to 'solid') | - |
|
|
108
|
+
| `secondaryButtonProps` | `Omit<ButtonWithoutChildrenProps, 'children'>` | Additional props to pass to the secondary button (colorScheme defaults to 'functional', variant to 'outline') | - |
|
|
109
|
+
| `closeButtonProps` | `Omit<UnstyledIconButtonProps, 'children'>` | Additional props to pass to the close button | - |
|
|
110
|
+
| `fullscreen` | `boolean` | Whether the modal should take up the full screen height | `false` |
|
|
111
|
+
| `inNavModal` | `boolean` | Renders the modal correctly when used inside a navigation modal | `false` |
|
|
111
112
|
|
|
112
113
|
\* use this to detect if the modal has been opened or closed, index 0 indicates open state and -1 indicates closed state
|
|
113
114
|
|
|
@@ -1,56 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* -- This file was auto-generated by Code Connect --
|
|
7
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
8
|
-
* You should check this is correct, and update the `example` function
|
|
9
|
-
* to return the code example you'd like to see in Figma
|
|
10
|
-
*/
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { useCallback, useRef } from 'react';
|
|
3
|
+
import { BottomSheetModal, Button, Modal } from '../';
|
|
11
4
|
|
|
12
5
|
figma.connect(
|
|
13
6
|
Modal,
|
|
14
|
-
|
|
7
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=6300-2825',
|
|
15
8
|
{
|
|
16
9
|
props: {
|
|
17
|
-
|
|
18
|
-
loading: figma.enum("State", {
|
|
10
|
+
loading: figma.enum('State', {
|
|
19
11
|
Loading: true,
|
|
20
12
|
}),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
heading: figma.string('Heading'),
|
|
14
|
+
description: figma.string('Description'),
|
|
15
|
+
fullscreen: figma.boolean('Full screen?'),
|
|
16
|
+
showHandle: figma.boolean('Handle?'),
|
|
17
|
+
customContent: figma.boolean('Custom content?', {
|
|
18
|
+
true: figma.instance('Custom content'),
|
|
19
|
+
}),
|
|
20
|
+
buttons: figma.boolean('Buttons?', {
|
|
21
|
+
true: figma.nestedProps('Button', {
|
|
22
|
+
primaryButtonText: figma.string('Text'),
|
|
23
|
+
}),
|
|
24
24
|
}),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
close: figma.boolean('Close?'),
|
|
26
|
+
image: figma.boolean('Image?', {
|
|
27
|
+
true: figma.instance('Modal illustration'),
|
|
28
|
+
}),
|
|
29
|
+
loadingHeading: figma.string('Loading heading'),
|
|
30
|
+
},
|
|
31
|
+
example: props => {
|
|
32
|
+
const modalRef = useRef<BottomSheetModal>(null);
|
|
33
|
+
|
|
34
|
+
const handleOpenModal = useCallback(() => {
|
|
35
|
+
modalRef.current?.present();
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const handleCloseModal = useCallback(() => {
|
|
39
|
+
modalRef.current?.dismiss();
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<Button onPress={handleOpenModal}>Open Modal</Button>
|
|
45
|
+
|
|
46
|
+
<Modal
|
|
47
|
+
ref={modalRef}
|
|
48
|
+
heading={props.heading}
|
|
49
|
+
description={props.description}
|
|
50
|
+
loading={props.loading}
|
|
51
|
+
loadingHeading={props.loadingHeading}
|
|
52
|
+
showCloseButton={props.close}
|
|
53
|
+
fullscreen={props.fullscreen}
|
|
54
|
+
image={props.image}
|
|
55
|
+
showHandle={props.showHandle}
|
|
56
|
+
primaryButtonText={props.buttons.primaryButtonText}
|
|
57
|
+
secondaryButtonText={props.buttons.primaryButtonText}
|
|
58
|
+
onPressPrimaryButton={handleCloseModal}
|
|
59
|
+
onPressSecondaryButton={handleCloseModal}
|
|
60
|
+
>
|
|
61
|
+
{props.customContent}
|
|
62
|
+
</Modal>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
44
65
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
loading={props.loading}
|
|
48
|
-
image={props.image}
|
|
49
|
-
heading={props.heading}
|
|
50
|
-
description={props.description}
|
|
51
|
-
fullscreen={props.fullscreen}
|
|
52
|
-
showHandle={props.showHandle}
|
|
53
|
-
/>
|
|
54
|
-
),
|
|
55
|
-
},
|
|
56
|
-
)
|
|
66
|
+
}
|
|
67
|
+
);
|
|
@@ -41,6 +41,10 @@ const meta = {
|
|
|
41
41
|
control: 'boolean',
|
|
42
42
|
description: 'Whether the modal is in a loading state.',
|
|
43
43
|
},
|
|
44
|
+
loadingHeading: {
|
|
45
|
+
control: 'text',
|
|
46
|
+
description: 'The heading text to be displayed when loading is true.',
|
|
47
|
+
},
|
|
44
48
|
fullscreen: {
|
|
45
49
|
control: 'boolean',
|
|
46
50
|
description: 'Whether the modal should take up the full screen height.',
|
|
@@ -42,6 +42,7 @@ const Modal = ({
|
|
|
42
42
|
closeOnPrimaryButtonPress = true,
|
|
43
43
|
closeOnSecondaryButtonPress = true,
|
|
44
44
|
loading,
|
|
45
|
+
loadingHeading = 'Loading...',
|
|
45
46
|
fullscreen = false,
|
|
46
47
|
image,
|
|
47
48
|
primaryButtonProps,
|
|
@@ -206,7 +207,7 @@ const Modal = ({
|
|
|
206
207
|
>
|
|
207
208
|
<Spinner size="lg" />
|
|
208
209
|
<Heading size="lg" textAlign="center">
|
|
209
|
-
|
|
210
|
+
{loadingHeading}
|
|
210
211
|
</Heading>
|
|
211
212
|
</View>
|
|
212
213
|
) : (
|
|
@@ -37,6 +37,7 @@ const Modal = ({
|
|
|
37
37
|
closeOnPrimaryButtonPress = true,
|
|
38
38
|
closeOnSecondaryButtonPress = true,
|
|
39
39
|
loading,
|
|
40
|
+
loadingHeading = 'Loading...',
|
|
40
41
|
image,
|
|
41
42
|
primaryButtonProps,
|
|
42
43
|
secondaryButtonProps,
|
|
@@ -166,7 +167,7 @@ const Modal = ({
|
|
|
166
167
|
>
|
|
167
168
|
<Spinner size="lg" />
|
|
168
169
|
<Heading size="lg" textAlign="center">
|
|
169
|
-
|
|
170
|
+
{loadingHeading}
|
|
170
171
|
</Heading>
|
|
171
172
|
</View>
|
|
172
173
|
) : (
|
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import { Pill } from '
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* -- This file was auto-generated by Code Connect --
|
|
6
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
7
|
-
* You should check this is correct, and update the `example` function
|
|
8
|
-
* to return the code example you'd like to see in Figma
|
|
9
|
-
*/
|
|
2
|
+
import { Pill } from '../';
|
|
10
3
|
|
|
11
4
|
figma.connect(Pill, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=4348%3A15595', {
|
|
12
5
|
props: {
|
|
13
|
-
// These props were automatically mapped based on your linked code:
|
|
14
6
|
label: figma.string('Label'),
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
icon: figma.boolean('Icon?', {
|
|
8
|
+
true: figma.instance('Icon-20'),
|
|
17
9
|
}),
|
|
18
|
-
// No matching props could be found for these Figma properties:
|
|
19
|
-
// "label": figma.string('Label'),
|
|
20
|
-
// "icon": figma.boolean('Icon?'),
|
|
21
|
-
// "icon20": figma.instance('Icon-20'),
|
|
22
|
-
// "selected": figma.boolean('Selected?')
|
|
23
10
|
},
|
|
24
|
-
example: props => <Pill value={
|
|
11
|
+
example: props => <Pill value={props.label} label={props.label} />,
|
|
25
12
|
});
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import { PillGroup } from '
|
|
2
|
+
import { PillGroup } from '../';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* -- This file was auto-generated by Code Connect --
|
|
6
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
7
|
-
* You should check this is correct, and update the `example` function
|
|
8
|
-
* to return the code example you'd like to see in Figma
|
|
9
|
-
*/
|
|
4
|
+
const value = '';
|
|
10
5
|
|
|
11
6
|
figma.connect(
|
|
12
7
|
PillGroup,
|
|
13
8
|
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=4348%3A15988',
|
|
14
9
|
{
|
|
15
10
|
props: {
|
|
16
|
-
// These props were automatically mapped based on your linked code:
|
|
17
11
|
wrap: figma.boolean('Wrap?'),
|
|
12
|
+
pills: figma.children('Pill'),
|
|
18
13
|
},
|
|
19
|
-
example: props =>
|
|
14
|
+
example: props => (
|
|
15
|
+
<PillGroup value={value} wrap={props.wrap}>
|
|
16
|
+
{props.pills}
|
|
17
|
+
</PillGroup>
|
|
18
|
+
),
|
|
20
19
|
}
|
|
21
20
|
);
|