Skip to content

Commit

Permalink
added FormError and story of it
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzmock committed Sep 6, 2021
1 parent 4fa4367 commit 3bbbd4d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/components/form/FormError.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs'
import { FormError } from './FormError'

<Meta title="Components/Form/FormError" component={FormError} />

# FormError

This component is a variation of the [Alert](/docs/components-alert-alert--default-story) component.
Its main purpose is to provide an Alert which goes over to 2 columns, and it is used in combination with the component [SectionContentTwoColumn](/docs/components-section-sectioncontenttwocolumn--default-story).

export const Template = ({ children, ...args }) => (
<FormError {...args}>{children}</FormError>
)

<Canvas>
<Story name="Default" args={{ children: 'Critical Message.' }}>
{Template.bind({})}
</Story>
</Canvas>

### Props

<ArgsTable story="Default" />

### Theme

- `form.formError.base`: Defines base styles of container
12 changes: 12 additions & 0 deletions src/components/form/FormError.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useTheme } from '../../framework/theme/ThemeContext'
import { Alert, Tone } from '../alert'

export const FormError: React.FC = ({ children }) => {
const { form } = useTheme()

return (
<Alert tone={Tone.critical} className={form.formError.base}>
{children}
</Alert>
)
}
3 changes: 3 additions & 0 deletions src/framework/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export type OverrideTheme = RecursivePartial<Theme> & {

export const defaultTheme = {
form: {
formError: {
base: 'col-span-2',
},
input: {
base: 'block w-full border p-3 focus:ring-0 appearance-none outline-none rounded-md',
normal:
Expand Down

0 comments on commit 3bbbd4d

Please sign in to comment.