-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add rest of the docs for o3 form (#1852)
* docs: add initial strucutre for forms documentation * chore: implement test version of tip component * chore: initialise guidlines for form elements craete tip component * chore: introduce copy, heading and tip content * fix: fix issues with tsx components in nested folders not compailing * feat: add optional on text-input and password element - display optional element with classnames instead of using complicated selector - update sb demos to display optional next to labels - update TextInputProps interface to extend BaseinputProps instead of FromFieldprops - Run code formating on passowrd.tsx and input.tsx * chore: generate sb-figma links for other brands * feat: - add new guidelines for required-optional example - update name of a placement-order guideline so there is some consistency * chore: add o3-form class wrapper so styles apply correctly * fix: fix issue with astro build by adding postcss config * feat: change Tip componene API and use array instead of slots for sources * feat: add styles to form wrapper so it has proper gap, is always aligned left and is stacked vertically * docs: - add examples and guidlines for form intro page - organise folders to make it clear where do preveiws, guidlines and exmaples go * fix: dont display other brands demos since we dont have tokens for it yet. * chore: merge staging docs * docs: add text-input docs - update tip.astro api and remove named slots since there is only one slot at the moment * chore: move password type to types file and fix ts error related to extending wrong type * docs: add password-input docs * docs: add error-summary to docs pages * docs: add checkbox to docs * docs: add radiobutton to docs * chore: update package.lock * chore: add types in compilation tool and generate links for o3-figma-sb-links package * fix: fix issue with astro build and development server * chore: generate new package-lock file and fix build issue * docs: Update apps/for-everyone-website/src/content/docs/components/Form/radio-button.mdx Co-authored-by: Ben Freshwater <[email protected]> * docs: Update apps/for-everyone-website/src/components/form/guidelines/Radio-button-exclusive-choices.astro Co-authored-by: Ben Freshwater <[email protected]> * docs: Update apps/for-everyone-website/src/content/docs/components/Form/checkbox.mdx Co-authored-by: Ben Freshwater <[email protected]> * docs: Update apps/for-everyone-website/src/content/docs/components/Form/error-summary.mdx Co-authored-by: Ben Freshwater <[email protected]> * docs: Update apps/for-everyone-website/src/content/docs/components/Form/password-input.mdx Co-authored-by: Ben Freshwater <[email protected]> * docs: Update apps/for-everyone-website/src/content/docs/components/Form/text-input.mdx Co-authored-by: Ben Freshwater <[email protected]> * docs: Update apps/for-everyone-website/src/content/docs/components/Form/password-input.mdx Co-authored-by: Ben Freshwater <[email protected]> * docs: Update apps/for-everyone-website/src/content/docs/components/Form/error-summary.mdx Co-authored-by: Ben Freshwater <[email protected]> * docs: make forms docs clearer --------- Co-authored-by: ben.freshwater <[email protected]>
- Loading branch information
Showing
43 changed files
with
36,512 additions
and
40,498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apps/for-everyone-website/src/components/form/anatomy/Checkbox.astro
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
apps/for-everyone-website/src/components/form/anatomy/Error-summary.astro
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
apps/for-everyone-website/src/components/form/anatomy/Password-input.astro
Large diffs are not rendered by default.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
apps/for-everyone-website/src/components/form/anatomy/Radio-button.astro
Large diffs are not rendered by default.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
apps/for-everyone-website/src/components/form/examples/Checkbox-group.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as CheckboxGrouptsx from '../preview/Checkbox-group' | ||
const {brand} = Astro.props | ||
const component = CheckboxGrouptsx | ||
const storybookId = `${brand}-o3-form--check-box-group` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybookId={storybookId} /> | ||
</div> | ||
|
22 changes: 22 additions & 0 deletions
22
apps/for-everyone-website/src/components/form/examples/Checkbox-selection-state.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as CheckboxStates from '../preview/Checkbox-selected-states' | ||
const {brand} = Astro.props | ||
const component = CheckboxStates | ||
const storybookId = `${brand}-o3-form--check-box-group` | ||
--- | ||
<script> | ||
const indeterminateElement = document.getElementById('indeterminate-checkbox') | ||
indeterminateElement.indeterminate = true | ||
</script> | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybookId={storybookId} /> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/for-everyone-website/src/components/form/examples/Input-password-validation.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as InputPasswordJSX from '../preview/Input-password-validation' | ||
const {brand} = Astro.props | ||
const component = InputPasswordJSX | ||
const storybookId = `${brand}-o3-form--password-input-error-state` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybookId={storybookId} /> | ||
</div> | ||
|
16 changes: 16 additions & 0 deletions
16
apps/for-everyone-website/src/components/form/examples/Input-password.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as InputPasswordJSX from '../preview/Input-password' | ||
const {brand} = Astro.props | ||
const component = InputPasswordJSX | ||
const storybookId = `${brand}-o3-form--password-input` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybookId={storybookId} /> | ||
</div> | ||
|
16 changes: 16 additions & 0 deletions
16
apps/for-everyone-website/src/components/form/examples/Input-short-text.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as InputShortJSX from '../preview/Input-short-text' | ||
const {brand} = Astro.props | ||
const component = InputShortJSX | ||
const storybookId = `${brand}-o3-form--short-text-input` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybookId={storybookId} /> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/for-everyone-website/src/components/form/examples/Input-width.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as InputWidthJSX from '../preview/Input-width' | ||
const {brand} = Astro.props | ||
const component = InputWidthJSX | ||
const storybookId = `${brand}-o3-form--text-input` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybookId={storybookId} /> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
apps/for-everyone-website/src/components/form/examples/Radio-button-group.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as RadioGroupTsx from '../preview/Radio-group' | ||
const {brand} = Astro.props | ||
const component = RadioGroupTsx | ||
const storybookId = `${brand}-o3-form--radio-button` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybookId={storybookId} /> | ||
</div> | ||
|
4 changes: 2 additions & 2 deletions
4
apps/for-everyone-website/src/components/form/guidelines/Form-submission.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/for-everyone-website/src/components/form/guidelines/Placement-order.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
.../for-everyone-website/src/components/form/guidelines/Radio-button-exclusive-choices.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
import Example from "../../Example.astro" | ||
import {RadioGroup, CheckboxGroup} from './RadioButtonGroup' | ||
const {brand} = Astro.props | ||
--- | ||
|
||
|
||
<Example do title="Use checkboxes for multiple choices"> | ||
<div data-o3-brand={brand}> | ||
<CheckboxGroup /> | ||
</div> | ||
</Example> | ||
|
||
<Example do={false} title="Don’t Use radio buttons when the choices are not mutually exclusive"> | ||
<div data-o3-brand={brand}> | ||
<RadioGroup /> | ||
</div> | ||
</Example> |
57 changes: 57 additions & 0 deletions
57
apps/for-everyone-website/src/components/form/guidelines/RadioButtonGroup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
Form, | ||
RadioButtonGroup, | ||
CheckBoxGroup, | ||
CheckBoxItem, | ||
RadioButtonItem, | ||
} from '@financial-times/o3-form'; | ||
|
||
const legend = 'Notification preferences'; | ||
const legendDescription = 'How would you like to be updated?'; | ||
|
||
const items: string[] = [ | ||
'Email notifications', | ||
'SMS notifications', | ||
'In-app notifications', | ||
]; | ||
|
||
function convertToLowercaseAndRemoveSpaces(item: string) { | ||
return item.toLowerCase().replace(/\s+/g, ''); | ||
} | ||
|
||
export function RadioGroup() { | ||
return ( | ||
<Form> | ||
<RadioButtonGroup label={legend} description={legendDescription}> | ||
{items.map((item) => { | ||
return ( | ||
<RadioButtonItem | ||
key={item} | ||
radioButtonLabel={item} | ||
inputId={convertToLowercaseAndRemoveSpaces(`radio-button-${item}`)} | ||
/> | ||
); | ||
})} | ||
</RadioButtonGroup> | ||
</Form> | ||
); | ||
} | ||
|
||
export function CheckboxGroup() { | ||
return ( | ||
<Form> | ||
<CheckBoxGroup label={legend} description={legendDescription}> | ||
{items.map((item) => { | ||
return ( | ||
<CheckBoxItem | ||
key={item} | ||
checkboxLabel={item} | ||
inputId={convertToLowercaseAndRemoveSpaces(`checkbox-${item}`)} | ||
/> | ||
) | ||
})} | ||
</CheckBoxGroup> | ||
</Form> | ||
); | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
apps/for-everyone-website/src/components/form/guidelines/Required-optional.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apps/for-everyone-website/src/components/form/preview/Checkbox-group.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {Form, CheckBoxGroup, CheckBoxItem} from '@financial-times/o3-form'; | ||
|
||
function ButtonPreview() { | ||
return ( | ||
<div style={{width: '50%'}}> | ||
<meta itemProp="@preview" /> | ||
<Form> | ||
<CheckBoxGroup | ||
label="Notification preferences" | ||
description="How would you like to be updated?"> | ||
<CheckBoxItem | ||
checkboxLabel="Email notifications" | ||
inputId="email-notification-checkbox" | ||
attributes={{defaultChecked: true}} | ||
/> | ||
<CheckBoxItem | ||
checkboxLabel="SMS notifications" | ||
inputId="sms-notification-checkbox" | ||
/> | ||
<CheckBoxItem | ||
checkboxLabel="In-app notifications" | ||
inputId="in-app-notification-checkbox" | ||
/> | ||
</CheckBoxGroup> | ||
</Form> | ||
<meta itemProp="@preview" /> | ||
</div> | ||
); | ||
} | ||
export const filePath = 'src/components/form/preview/Checkbox-group.tsx'; | ||
|
||
export {ButtonPreview as preview}; |
26 changes: 26 additions & 0 deletions
26
apps/for-everyone-website/src/components/form/preview/Checkbox-selected-states.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {Form, CheckBoxItem} from '@financial-times/o3-form'; | ||
|
||
function ButtonPreview() { | ||
return ( | ||
<div style={{width: '50%'}}> | ||
<meta itemProp="@preview" /> | ||
<Form> | ||
<CheckBoxItem checkboxLabel="Unchecked" inputId="unchecked-checkbox" /> | ||
<CheckBoxItem | ||
checkboxLabel="Checked" | ||
inputId="checked-checkbox" | ||
attributes={{defaultChecked: true}} | ||
/> | ||
<CheckBoxItem | ||
checkboxLabel="Indeterminate" | ||
inputId="indeterminate-checkbox" | ||
/> | ||
</Form> | ||
<meta itemProp="@preview" /> | ||
</div> | ||
); | ||
} | ||
export const filePath = | ||
'src/components/form/preview/Checkbox-selected-states.tsx'; | ||
|
||
export {ButtonPreview as preview}; |
23 changes: 23 additions & 0 deletions
23
apps/for-everyone-website/src/components/form/preview/Input-password-validation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {Form, PasswordInput} from '@financial-times/o3-form'; | ||
|
||
function ButtonPreview() { | ||
return ( | ||
<div style={{width: "50%"}}> | ||
<meta itemProp="@preview" /> | ||
<Form> | ||
<PasswordInput | ||
label="Password" | ||
description='Must be 8 characters or more and contain a number' | ||
feedback={{ | ||
type: 'error', | ||
message: 'Your password must contain a number' | ||
}} | ||
/> | ||
</Form> | ||
<meta itemProp="@preview" /> | ||
</div> | ||
); | ||
} | ||
export const filePath = 'src/components/form/preview/Input-password.tsx'; | ||
|
||
export {ButtonPreview as preview}; |
19 changes: 19 additions & 0 deletions
19
apps/for-everyone-website/src/components/form/preview/Input-password.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Form, PasswordInput} from '@financial-times/o3-form'; | ||
|
||
function ButtonPreview() { | ||
return ( | ||
<div style={{width: "50%"}}> | ||
<meta itemProp="@preview" /> | ||
<Form> | ||
<PasswordInput | ||
label="Password" | ||
description='Must be at least 8 characters long' | ||
/> | ||
</Form> | ||
<meta itemProp="@preview" /> | ||
</div> | ||
); | ||
} | ||
export const filePath = 'src/components/form/preview/Input-password.tsx'; | ||
|
||
export {ButtonPreview as preview}; |
Oops, something went wrong.