Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: FormField component #372

Merged
merged 58 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f814d5c
feat: add input files
jordmccord May 30, 2024
2490114
feat: add input component
jordmccord Jun 4, 2024
8437896
chore: add input docs
jordmccord Jun 5, 2024
a89c14a
chore: changeset
jordmccord Jun 5, 2024
113a2eb
chore: update docs
jordmccord Jun 5, 2024
9c2ab4e
feat: add readonly styles
jordmccord Jun 7, 2024
fca3ee3
chore: rename styles and fix readonly bg
jordmccord Jun 7, 2024
a7d209c
fix: input styles
jordmccord Jun 10, 2024
92dcff7
chore: checks
jordmccord Jun 11, 2024
6b1526e
chore: update deps
jordmccord Jun 11, 2024
2c5852f
fix: type errors
jordmccord Jun 11, 2024
e1dd8a7
feat: add form field components
jordmccord Jun 10, 2024
f7cf9d0
feat: form field components and context
jordmccord Jun 11, 2024
ce93e5b
fix: disabled styles
jordmccord Jun 11, 2024
ac1ff32
fix: dark mode disabled styles
jordmccord Jun 12, 2024
67a65ff
fix: disabled styles
jordmccord Jun 12, 2024
d6f40e4
Merge branch 'main' into uwds-1641
jordmccord Jun 12, 2024
57dc832
Merge branch 'main' into uwds-1641
jordmccord Jun 14, 2024
5fb050a
feat: add form field components
jordmccord Jun 10, 2024
7bf5788
feat: form field components and context
jordmccord Jun 11, 2024
4c76a79
fix: disabled styles
jordmccord Jun 11, 2024
1b5cafd
fix: dark mode disabled styles
jordmccord Jun 12, 2024
1263a8f
fix: disabled styles
jordmccord Jun 12, 2024
403512b
Merge branch 'uwds-1631' of https://github.com/utilitywarehouse/desig…
jordmccord Jun 14, 2024
10a2c9d
chore: add form field docs
jordmccord Jun 18, 2024
3021782
fix: dark mode validation colours
jordmccord Jun 18, 2024
9ee99dc
Merge branch 'main' into uwds-1641
jordmccord Jun 20, 2024
29858f0
Merge branch 'uwds-1641' into uwds-1631
jordmccord Jun 20, 2024
2f5ad9b
Merge branch 'main' into uwds-1641
jordmccord Jul 16, 2024
138a37b
Merge branch 'uwds-1641' into uwds-1631
jordmccord Jul 16, 2024
6571701
chore: update form field docs
jordmccord Jul 16, 2024
71e9a9e
chore: update input docs
jordmccord Jul 16, 2024
0503e17
Merge branch 'uwds-1641' into uwds-1631
jordmccord Jul 16, 2024
6311f63
Merge branch 'main' into uwds-1641
jordmccord Oct 15, 2024
625ef6a
feat: add input root
jordmccord Oct 16, 2024
81ada7b
refactor: `Input` component styles
jordmccord Oct 17, 2024
89b2527
chore: update `Input` docs
jordmccord Oct 17, 2024
3f87236
chore: improve input playground
jordmccord Oct 17, 2024
f1b7388
fix: disabled input field
jordmccord Oct 17, 2024
5693feb
fix: input placeholder disabled colour
jordmccord Oct 17, 2024
a69faca
fix: remove unused props
jordmccord Oct 17, 2024
dfe3c7a
fix: types paths
jordmccord Oct 17, 2024
173dda9
chore: update xcode version
jordmccord Oct 17, 2024
8e04a9f
update expo versions
jordmccord Oct 17, 2024
22b4b60
revert: xcode version
jordmccord Oct 17, 2024
6d1eaf0
chore: hardcode color system package
jordmccord Oct 17, 2024
e84fc10
Merge branch 'uwds-1641' into uwds-1631
jordmccord Oct 17, 2024
6e1289b
chore: update colour system build
jordmccord Oct 18, 2024
fc9c394
chore: add build dep build to postinstall
jordmccord Oct 18, 2024
0cb4ff6
Merge branch 'main' into uwds-1641
jordmccord Oct 18, 2024
e1d5792
Merge branch 'uwds-1641' into uwds-1631
jordmccord Oct 18, 2024
f3db0a2
refactor: `FormField` style library
jordmccord Oct 21, 2024
bd5ee77
refactor: update props and playground
jordmccord Oct 22, 2024
9fee897
chore: update docs
jordmccord Oct 22, 2024
72e2555
chore: changeset
jordmccord Oct 22, 2024
ab7be23
feat: add validation and helpers to checkbox and radio
jordmccord Oct 22, 2024
a4ddc32
chore: figma code connect
jordmccord Oct 23, 2024
90f9865
Merge branch 'main' into uwds-1631
jordmccord Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-peas-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@utilitywarehouse/native-ui': minor
---

Adds `Helper` and `Label` components
5 changes: 5 additions & 0 deletions .changeset/nine-bugs-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@utilitywarehouse/native-ui': minor
---

Adds `FormField` component
5 changes: 5 additions & 0 deletions .changeset/quiet-moose-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@utilitywarehouse/native-ui': minor
---

Adds `Helper` and validation helpers to `Checkbox` and `Radio` components and groups
5 changes: 5 additions & 0 deletions .changeset/sixty-pens-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@utilitywarehouse/native-ui': patch
---

Fixes `Checbox` and `Radio` label font weight
2 changes: 1 addition & 1 deletion .github/workflows/previews.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
uses: expo/expo-github-action@v8
if: steps.check_skip.outputs.skip == 'false'
with:
eas-version: '9.2.0'
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}

- name: 📦 Install dependencies
Expand Down
1 change: 1 addition & 0 deletions apps/native-ui-storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const preview: Preview = {
'Button',
'Center',
'Checkbox',
'Form Field',
'Heading',
'HStack',
'Icons',
Expand Down
57 changes: 31 additions & 26 deletions apps/native-ui-storybook/components/Checkbox/Checkbox.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Center,
Box,
Text,
FormField,
NativeUIProvider,
} from '@utilitywarehouse/native-ui';
import { TickSmallIcon } from '@utilitywarehouse/react-native-icons';
Expand All @@ -27,11 +28,11 @@ Whether you're building a simple form or a complex data collection system, the C
- [Usage](#usage)
- [Props](#props)
- [Components](#components)
- [Checkbox](#checkbox)
- [CheckboxIndicator](#checkboxindicator)
- [CheckboxIcon](#checkboxicon)
- [CheckboxLabel](#checkboxlabel)
- [CheckboxGroup](#checkboxgroup)
- [`Checkbox`](#checkbox)
- [`CheckboxIndicator`](#checkboxindicator)
- [`CheckboxIcon`](#checkboxicon)
- [`CheckboxLabel`](#checkboxlabel)
- [`CheckboxGroup`](#checkboxgroup)
- [Variants](#variants)
- [Advanced Usage](#advanced-usage)

Expand Down Expand Up @@ -74,13 +75,20 @@ const MyComponent = () => {

## Props

| Property | Type | Default | Description |
| ---------------- | -------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |
| `value` | `string` | - | The value to be used in the checkbox input. This is the value that will be returned on form submission. |
| `onChange` | `(value: boolean) => void` | - | Function called when the state of the checkbox changes. |
| `defaultchecked` | `bool` | `false` | If true, the checkbox will be initially checked. |
| `checked` | `bool` | `false` | When true, the checkbox will be checked. You'll need to pass onChange update it's value (since it's now controlled). |
| `disabled` | `bool` | `false` | To manually set disable to the checkbox. |
| Property | Type | Default | Description |
| -------------------- | ----------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |
| `value` | `string` | - | The value to be used in the checkbox input. This is the value that will be returned on form submission. |
| `onChange` | `(value: boolean) => void` | - | Function called when the state of the checkbox changes. |
| `defaultchecked` | `bool` | `false` | If true, the checkbox will be initially checked. |
| `checked` | `bool` | `false` | When true, the checkbox will be checked. You'll need to pass onChange update it's value (since it's now controlled). |
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | - | The validation status of the checkbox. |
| `disabled` | `bool` | `false` | To manually set disable to the checkbox. |
| `label` | `string` | - | The label to be displayed next to the checkbox. |
| `helperText` | `string` | - | The helper text to be displayed below the checkbox. |
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
| `invalidText` | `string` | - | The invalid text to be displayed below the checkbox. |
| `validText` | `string` | - | The valid text to be displayed below the checkbox. |
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |

## Components

Expand Down Expand Up @@ -197,13 +205,12 @@ const MyComponent = () => {
};
```

| Property | Type | Default | Description |
| ----------- | --------------------------------- | ------- | ---------------------------------------------------------------------- |
| `value` | `string[]` | - | The value of the checkbox group. |
| `onChange` | `(values: Array<string>) => void` | - | The callback fired when any children Checkbox is checked or unchecked. |
| `disabled` | `bool` | `false` | To manually set disable to the checkbox. |
| `isInvalid` | `bool` | `false` | To manually set invalid to the checkbox. |
| `readonly` | `bool` | `false` | To manually set read-only to the checkbox. |
| Property | Type | Default | Description |
| ------------------ | ----------------------------------- | ------- | ---------------------------------------------------------------------- |
| `value` | `string[]` | - | The value of the checkbox group. |
| `onChange` | `(values: Array<string>) => void` | - | The callback fired when any children Checkbox is checked or unchecked. |
| `disabled` | `bool` | `false` | To manually set disable to the checkbox. |
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | - | The validation status of the checkbox group. |

## Variants

Expand All @@ -216,8 +223,7 @@ You can create a custom checkbox by using the `CheckboxIndicator`, `CheckboxIcon
<Canvas>
<NativeUIProvider>
<Center>
<Box gap="$2">
<Text>Which fruit do you enjoy?</Text>
<FormField label="Which fruit do you enjoy?">
<CheckboxGroup>
<Checkbox
value="Apple"
Expand Down Expand Up @@ -252,7 +258,7 @@ You can create a custom checkbox by using the `CheckboxIndicator`, `CheckboxIcon
label='Grapes'
/>
</CheckboxGroup>
</Box>
</FormField>
</Center>

</NativeUIProvider>
Expand All @@ -264,15 +270,14 @@ import {
Checkbox,
CheckboxIndicator,
CheckboxLabel,
FormField,
Text,
} from '@utilitywarehouse/native-ui';
import { Box } from '@utilitywarehouse/native-ui/lab';

const MyComponent = () => {
const [values, setValues] = React.useState([]);
return (
<Box gap="$2">
<Text>Which fruit do you enjoy?</Text>
<FormField label="Which fruit do you enjoy?">
<CheckboxGroup
aria-label="Checkbox Group"
value={values}
Expand Down Expand Up @@ -304,7 +309,7 @@ const MyComponent = () => {
<CheckboxLabel>Grapes</CheckboxLabel>
</Checkbox>
</CheckboxGroup>
</Box>
</FormField>
);
};
```
35 changes: 34 additions & 1 deletion apps/native-ui-storybook/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ const CheckboxBasic: StoryFn<{
checked: boolean;
disabled: boolean;
label: string;
}> = ({ disabled, label: label }) => {
validationStatus: 'initial' | 'valid' | 'invalid';
showValidationIcon: boolean;
invalidText: string;
validText: string;
helperText: string;
}> = ({ disabled, label: label, checked: _checked, ...props }) => {
const [args, updateArgs] = useArgs();

return (
Expand All @@ -21,6 +26,7 @@ const CheckboxBasic: StoryFn<{
checked={args.checked as boolean}
disabled={disabled}
label={label}
{...props}
/>
);
};
Expand All @@ -41,12 +47,39 @@ CheckboxBasic.argTypes = {
control: 'text',
description: 'The label component for the checkbox.',
},
helperText: {
type: 'string',
control: 'text',
description: 'The helper text of the checkbox component',
defaultValue: 'Helper text',
},
validationStatus: {
control: 'select',
options: ['initial', 'valid', 'invalid'],
description: 'The validation status of the checkbox component',
defaultValue: 'initial',
},
showValidationIcon: {
control: 'boolean',
description: 'Show the validation icon.',
defaultValue: true,
},
invalidText: {
control: 'text',
description: 'The invalid text of the checkbox component',
defaultValue: 'Invalid text',
},
};

CheckboxBasic.args = {
checked: false,
disabled: false,
label: '',
helperText: '',
validationStatus: 'initial',
showValidationIcon: true,
invalidText: 'Invalid text',
validText: 'Valid text',
};

export default CheckboxBasic;
Expand Down
Loading
Loading