-
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 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. * docs: make it clear that o3-forms is coming for other brands but currenlty users can use whitelabel --------- Co-authored-by: ben.freshwater <[email protected]>
- Loading branch information
Showing
39 changed files
with
2,884 additions
and
312 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const autoprefixer = require('autoprefixer'); | ||
const postcssPresetEnv = require('postcss-preset-env'); | ||
|
||
const config = { | ||
plugins: [ | ||
postcssPresetEnv({ | ||
stage: 3, | ||
features: { | ||
'nesting-rules': true, | ||
}, | ||
}), | ||
autoprefixer(), | ||
], | ||
}; | ||
|
||
module.exports = config; |
3 changes: 3 additions & 0 deletions
3
apps/for-everyone-website/public/assets/images/documentation/components/tip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions
28
apps/for-everyone-website/src/components/form/anatomy/Text-input.astro
Large diffs are not rendered by default.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
apps/for-everyone-website/src/components/form/examples/Disabled-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,16 @@ | ||
--- | ||
import Preview from '../../utils/Preview.astro' | ||
import FigmaSbLinks from '../../utils/FigmaSbLinks.astro'; | ||
import * as DisabledInput from '../preview/Input-disabled-state' | ||
const {brand} = Astro.props | ||
const component = DisabledInput | ||
const storybookId = `${brand}-o3-form--text-input` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybook={storybookId} /> | ||
</div> | ||
|
16 changes: 16 additions & 0 deletions
16
apps/for-everyone-website/src/components/form/examples/Input-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 InputValidatio from '../preview/Input-error' | ||
const {brand} = Astro.props | ||
const component = InputValidatio | ||
const storybookId = `${brand}-o3-form--text-input-error-state` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybook={storybookId} /> | ||
</div> | ||
|
16 changes: 16 additions & 0 deletions
16
apps/for-everyone-website/src/components/form/examples/Page-level-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 ErrorSummary from '../preview/Error-summary' | ||
const {brand} = Astro.props | ||
const component = ErrorSummary | ||
const storybookId = `${brand}-o3-form--error-summary` | ||
--- | ||
|
||
<div> | ||
<Preview {component} /> | ||
<FigmaSbLinks storybook={storybookId} /> | ||
</div> | ||
|
22 changes: 22 additions & 0 deletions
22
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
import {Form, TextInput} from '@financial-times/o3-form/esm' | ||
import { Button } from '@financial-times/o3-button/esm'; | ||
import Example from '../../Example.astro'; | ||
const {brand} = Astro.props | ||
--- | ||
|
||
<Example slot="examples" do title="Include a button with a clear call to action to submit data"> | ||
<div data-o3-brand={brand}> | ||
<Form> | ||
<TextInput label="City" attributes={{defaultValue: "London" }} /> | ||
<TextInput label="Address" attributes={{defaultValue: "1 Friday St"}} optional={true} /> | ||
<Button label='Save' type='primary' /> | ||
</Form> | ||
</Example> | ||
|
||
<style> | ||
div { | ||
width: 50%; | ||
} | ||
</style> |
25 changes: 25 additions & 0 deletions
25
apps/for-everyone-website/src/components/form/guidelines/Labels-grouping.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,25 @@ | ||
--- | ||
import {Form, TextInput} from '@financial-times/o3-form/esm' | ||
import Example from '../../Example.astro'; | ||
const {brand} = Astro.props | ||
--- | ||
|
||
<Example slot="examples" do title="Group similar inputs to ease the user"> | ||
<div data-o3-brand={brand}> | ||
<Form> | ||
<h4 class="o3-typography-h3 grouping-title">Your Details</h4> | ||
<TextInput label="Email address" attributes={{defaultValue: "[email protected]" }} /> | ||
|
||
<h4 class="o3-typography-h3 grouping-title">Your address</h4> | ||
<TextInput label="Country" attributes={{defaultValue: "United Kingdom" }} /> | ||
<TextInput label="Address" attributes={{defaultValue: "1 Friday St"}} optional={true} /> | ||
</form> | ||
</Form> | ||
</Example> | ||
|
||
<style> | ||
div { | ||
width: 50%; | ||
} | ||
</style> |
48 changes: 48 additions & 0 deletions
48
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
import {Form, TextInput} from '@financial-times/o3-form/esm' | ||
import Example from '../../Example.astro'; | ||
const {brand} = Astro.props | ||
--- | ||
|
||
<Example slot="examples" do title="Always left-Align components and stack vertically"> | ||
<div class="o3-form-vertical" data-o3-brand={brand}> | ||
<Form> | ||
<TextInput label="Country" attributes={{defaultValue: "United Kingdom"}} /> | ||
<TextInput label="City" attributes={{defaultValue: "London" }} /> | ||
<TextInput label="Address" attributes={{defaultValue: "1 Friday St"}} /> | ||
</Form> | ||
</div> | ||
</Example> | ||
|
||
<Example slot="examples" do={false} title="Avoid putting components next to each other and avoid centering them"> | ||
<div data-o3-brand={brand}> | ||
<form class="o3-form-horizontal"> | ||
<TextInput label="Country" attributes={{defaultValue: "United Kingdom"}} /> | ||
<TextInput label="City" attributes={{defaultValue: "London" }} /> | ||
<TextInput label="Address" attributes={{defaultValue: "1 Friday St"}} /> | ||
</form> | ||
</div> | ||
</Example> | ||
|
||
|
||
<style> | ||
div { | ||
width: 100%; | ||
} | ||
|
||
.o3-form-vertical { | ||
width: 50%; | ||
} | ||
|
||
.o3-form-horizontal { | ||
display: flex; | ||
gap: var(--o3-spacing-s); | ||
width: 100%; | ||
flex-wrap: wrap; | ||
} | ||
|
||
.o3-form-horizontal { | ||
justify-content: center; | ||
} | ||
</style> |
23 changes: 23 additions & 0 deletions
23
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
import {Form, TextInput} from '@financial-times/o3-form/esm' | ||
import Example from '../../Example.astro'; | ||
const {brand} = Astro.props | ||
--- | ||
|
||
<Example slot="examples" do title="Mark Optional Components"> | ||
<div data-o3-brand={brand}> | ||
|
||
<Form> | ||
<TextInput label="City" attributes={{defaultValue: "London" }} /> | ||
<TextInput label="Address" attributes={{defaultValue: "1 Friday St"}} optional={true} /> | ||
</Form> | ||
</div> | ||
</Example> | ||
|
||
<style> | ||
div { | ||
width: 50%; | ||
} | ||
|
||
</style> |
20 changes: 20 additions & 0 deletions
20
apps/for-everyone-website/src/components/form/preview/Error-summary.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,20 @@ | ||
import {Form, ErrorSummary} from '@financial-times/o3-form/esm'; | ||
|
||
function ButtonPreview() { | ||
return ( | ||
<> | ||
<meta itemProp="@preview" /> | ||
<Form> | ||
<ErrorSummary errors={[{ | ||
id: 'error-summary', | ||
fieldName: 'Email', | ||
message: 'Please enter a valid email address', | ||
}]} /> | ||
</Form> | ||
<meta itemProp="@preview" /> | ||
</> | ||
); | ||
} | ||
export const filePath = 'src/components/form/preview/Error-summary.tsx'; | ||
|
||
export {ButtonPreview as preview}; |
21 changes: 21 additions & 0 deletions
21
apps/for-everyone-website/src/components/form/preview/Input-disabled-state.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,21 @@ | ||
import {Form, TextInput} from '@financial-times/o3-form/esm'; | ||
|
||
function ButtonPreview() { | ||
return ( | ||
<> | ||
<meta itemProp="@preview" /> | ||
<Form> | ||
<TextInput | ||
label="Email" | ||
description='You need to confirm your email before you can change it' | ||
attributes={{defaultValue: '[email protected]'}} | ||
disabled={true} | ||
/> | ||
</Form> | ||
<meta itemProp="@preview" /> | ||
</> | ||
); | ||
} | ||
export const filePath = 'src/components/form/preview/Input-error.tsx'; | ||
|
||
export {ButtonPreview as preview}; |
23 changes: 23 additions & 0 deletions
23
apps/for-everyone-website/src/components/form/preview/Input-error.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, TextInput} from '@financial-times/o3-form/esm'; | ||
|
||
function ButtonPreview() { | ||
return ( | ||
<> | ||
<meta itemProp="@preview" /> | ||
<Form> | ||
<TextInput | ||
label="Email" | ||
attributes={{defaultValue: 'john@gmailcom'}} | ||
feedback={{ | ||
message: 'Please enter a valid email address', | ||
type: 'error', | ||
}} | ||
/> | ||
</Form> | ||
<meta itemProp="@preview" /> | ||
</> | ||
); | ||
} | ||
export const filePath = 'src/components/form/preview/Input-error.tsx'; | ||
|
||
export {ButtonPreview as preview}; |
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,84 @@ | ||
--- | ||
import tip from '../../../public/assets/images/documentation/components/tip.svg?raw'; | ||
interface Props { | ||
sources: { | ||
title: string; | ||
url: string; | ||
}[] | ||
} | ||
const {sources} = Astro.props; | ||
--- | ||
|
||
<div class="not-content tip-container"> | ||
<div class="tip-description"> | ||
<div class="icon"> | ||
<Fragment set:html={tip} /> | ||
</div> | ||
<slot name="tip-content" /> | ||
</div> | ||
{ | ||
sources?.length > 0 && ( | ||
<div class="tip-sources"> | ||
<strong>SOURCES:</strong> | ||
<div class="tip-sources-wrapper"> | ||
{sources.map((source, index) => ( | ||
<> | ||
<a href={source.url}>{source.title}</a> | ||
{index < sources.length - 1 && ' | '} | ||
</> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
</div> | ||
|
||
<style> | ||
.tip-container { | ||
--_icon-width: 24px; | ||
background-color: #f4f4f5; | ||
border: 1px solid var(--slate-white-15, #dedfe0); | ||
border-radius: var(--o3-spacing-5xs); | ||
box-shadow: var(--o3-spacing-5xs) var(--o3-spacing-5xs) | ||
var(--o3-spacing-3xs) 0px rgba(222, 223, 224, 0.08); | ||
} | ||
.tip-description { | ||
padding: var(--o3-spacing-2xs) 0px; | ||
position: relative; | ||
display: flex; | ||
.icon { | ||
width: var(--_icon-width); | ||
height: var(--_icon-width); | ||
margin: 0px var(--o3-spacing-4xs); | ||
} | ||
} | ||
|
||
.tip-sources { | ||
display: flex; | ||
/* Icon size plus its margins */ | ||
padding: var(--o3-spacing-3xs) 0 var(--o3-spacing-3xs) | ||
calc(var(--_icon-width) + 2 * var(--o3-spacing-4xs)); | ||
|
||
border-radius: 0px 0px var(--o3-spacing-5xs) var(--o3-spacing-5xs); | ||
border-right: 1px solid var(--slate-white-15, #dedfe0); | ||
border-bottom: 1px solid var(--slate-white-15, #dedfe0); | ||
border-left: 1px solid var(--slate-white-15, #dedfe0); | ||
background: #ececee; | ||
.tip-sources-wrapper { | ||
& a { | ||
all: unset; | ||
cursor: pointer; | ||
text-decoration-line: underline; | ||
} | ||
|
||
color: #8f8f8f; | ||
font-size: var(--o3-font-size-negative-2); | ||
} | ||
strong { | ||
color: #8f8f8f; | ||
font-size: var(--o3-font-size-negative-2); | ||
margin-right: var(--o3-spacing-5xs); | ||
} | ||
} | ||
</style> |
Oops, something went wrong.