generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support more properties for textbox
- Loading branch information
Showing
8 changed files
with
438 additions
and
43 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
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,159 @@ | ||
<!-- | ||
@license EUPL-1.2 | ||
Copyright (c) 2021 Robbert Broersma | ||
--> | ||
|
||
import { Meta, Story, Canvas, ArgsTable } from "@storybook/addon-docs"; | ||
import "./bem.scss"; | ||
import clsx from "clsx"; | ||
|
||
export const Template = ({ | ||
disabled = false, | ||
focus = false, | ||
invalid = false, | ||
readOnly = false, | ||
required = false, | ||
value = "", | ||
}) => | ||
`<input class="${clsx( | ||
"utrecht-textbox", | ||
disabled && "utrecht-textbox--disabled", | ||
focus && "utrecht-textbox--focus", | ||
invalid && "utrecht-textbox--invalid", | ||
readOnly && "utrecht-textbox--readonly", | ||
required && "utrecht-textbox--required" | ||
)}" value="${value}">`; | ||
|
||
<Meta | ||
title="CSS Component/Text Box" | ||
argTypes={{ | ||
disabled: { | ||
description: "Disabled", | ||
control: "boolean", | ||
}, | ||
focus: { | ||
description: "Focus", | ||
control: "boolean", | ||
}, | ||
invalid: { | ||
description: "Invalid", | ||
control: "boolean", | ||
}, | ||
readOnly: { | ||
description: "Read-only", | ||
control: "boolean", | ||
}, | ||
required: { | ||
description: "Required", | ||
control: "boolean", | ||
}, | ||
value: { | ||
description: "Set the value of the text box", | ||
control: "text", | ||
}, | ||
}} | ||
parameters={{ | ||
docs: { | ||
transformSource: (_src, { args }) => Template(args), | ||
}, | ||
status: { | ||
type: "WORK IN PROGRESS", | ||
}, | ||
}} | ||
/> | ||
|
||
# Text box component | ||
|
||
Styling via the `<input>` element: | ||
|
||
<Canvas> | ||
<Story | ||
name="Text box" | ||
args={{ | ||
disabled: false, | ||
focus: false, | ||
invalid: false, | ||
readOnly: false, | ||
required: false, | ||
value: "The Quick Brown Fox Jumps Over The Lazy Dog", | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
<ArgsTable story="Text box" /> | ||
|
||
## States | ||
|
||
### Disabled | ||
|
||
<Canvas> | ||
<Story | ||
name="Disabled text box" | ||
args={{ | ||
disabled: true, | ||
value: "The Quick Brown Fox Jumps Over The Lazy Dog", | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
### Invalid | ||
|
||
<Canvas> | ||
<Story | ||
name="Invalid text box" | ||
args={{ | ||
invalid: true, | ||
value: "The Quick Brown Fox Jumps Over The Lazy Dog", | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
### Read-only | ||
|
||
<Canvas> | ||
<Story | ||
name="Read-only text box" | ||
args={{ | ||
readOnly: true, | ||
value: "The Quick Brown Fox Jumps Over The Lazy Dog", | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
### Required | ||
|
||
<Canvas> | ||
<Story | ||
name="Required text box" | ||
args={{ | ||
required: true, | ||
value: "The Quick Brown Fox Jumps Over The Lazy Dog", | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
## Interactive States | ||
|
||
### Focus | ||
|
||
<Canvas> | ||
<Story | ||
name="Text box with focus" | ||
args={{ | ||
focus: true, | ||
value: "The Quick Brown Fox Jumps Over The Lazy Dog", | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> |
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
Oops, something went wrong.