Skip to content

Commit 27bbae1

Browse files
author
markcytian
committed
feat(form): add form is-disabled storybook
1 parent c4aec38 commit 27bbae1

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

story/inputs/checkboxes.template.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ import classNames from 'classnames';
33

44
export default () => {
55
const isDark = boolean('is-dark', false);
6+
const isDisabled = boolean('is-disabled', false);
67

78
const checkBoxClasses = classNames(
89
'nes-checkbox',
910
{
1011
'is-dark': isDark,
1112
},
13+
{
14+
'is-disabled': isDisabled,
15+
},
1216
);
1317

1418
return `
1519
<div style="${isDark ? 'background-color: black;' : ''}">
1620
<label>
17-
<input type="checkbox" class="${checkBoxClasses}" checked />
21+
<input type="checkbox" ${isDisabled && 'disabled'} class="${checkBoxClasses}" checked />
1822
<span>Enable</span>
1923
</label>
2024
</div>

story/inputs/input.template.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import classNames from 'classnames';
44
import sharedOptions from '../_helpers/shared';
55

66
export default () => {
7+
const disabled = 'is-disabled';
78
const inputOptions = select('Input Classes', {
89
default: '',
910
...sharedOptions,
11+
[disabled]: disabled,
1012
}, '');
1113

1214
const inputClasses = classNames(
@@ -15,6 +17,12 @@ export default () => {
1517
);
1618

1719
return `
18-
<input type="text" id="name_field" class="${inputClasses}" placeholder="NES.css">
20+
<input
21+
type="text"
22+
id="name_field"
23+
${inputOptions.includes(disabled) && 'disabled'}
24+
class="${inputClasses}"
25+
placeholder="NES.css"
26+
/>
1927
`;
2028
};

story/inputs/radio.template.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ import classNames from 'classnames';
44

55
export default () => {
66
const isDark = boolean('is-dark', false);
7+
const isDisabled = boolean('is-disabled', false);
78

89
const radioClasses = classNames(
910
'nes-radio',
1011
{
1112
'is-dark': isDark,
1213
},
14+
{
15+
'is-disabled': isDisabled,
16+
},
1317
);
1418

1519
return `
1620
<div style="${isDark ? 'background-color: black;' : ''}">
1721
<label>
18-
<input type="radio" class="${radioClasses}" name="answer" checked />
22+
<input type="radio" ${isDisabled && 'disabled'} class="${radioClasses}" name="answer" checked />
1923
<span>Yes</span>
2024
</label>
2125
<label>
22-
<input type="radio" class="${radioClasses}" name="answer" />
26+
<input type="radio" ${isDisabled && 'disabled'} class="${radioClasses}" name="answer" />
2327
<span>No</span>
2428
</label>
2529
</div>

story/select/select.template.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import sharedOptions from '../_helpers/shared';
55

66
export default () => {
77
const isDark = boolean('is-dark', false);
8+
const disabled = 'is-disabled';
89
const selectOptions = select('class', {
910
default: '',
1011
...sharedOptions,
12+
[disabled]: disabled,
1113
}, '');
1214

1315
const selectedClasses = classNames(
@@ -18,7 +20,7 @@ export default () => {
1820

1921
return `
2022
<div class="${selectedClasses}">
21-
<select required>
23+
<select required ${selectOptions.includes(disabled) && 'disabled'} >
2224
<option value="" disabled selected hidden>Select...</option>
2325
<option value="0">To be</option>
2426
<option value="1">Not to be</option>

0 commit comments

Comments
 (0)