-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from aboutbits/form_error
added FormError and story of it
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 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
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 show an error in a form. The default style applies `col-span-2`, so that the error message is shown in one line in `SectionContentTwoColumn` forms. | ||
|
||
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 |
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,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> | ||
) | ||
} |
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