Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scss/form/checkboxes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,32 @@
color: $color-white;
}
}
&.is-disabled {
$color: map-get($disabled-colors, "normal");
$colors-radio-disabled: ($color, map-get($disabled-colors, "shadow"));

+ span {
color: $color;
cursor: not-allowed;
}

/* stylelint-disable-next-line no-descending-specificity */
+ span::before {
color: $color;
cursor: not-allowed;
}

/* stylelint-disable-next-line no-descending-specificity */
&:checked + span::before {
@include pixelize(2px, $checkbox-checked-focus, $colors-radio-disabled);

color: $color;
}

&:checked:focus + span::before {
@include pixelize(2px, $checkbox-checked-focus, $colors-radio-disabled);

color: $color;
}
}
}
6 changes: 6 additions & 0 deletions scss/form/inputs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
&.is-error {
@include border-style(map-get($error-colors, "normal"), map-get($error-colors, "hover"));
}
&.is-disabled {
@include border-style(map-get($disabled-colors, "normal"), map-get($disabled-colors, "shadow"));

color: map-get($disabled-colors, "normal");
cursor: not-allowed;
}
}

.nes-field {
Expand Down
35 changes: 35 additions & 0 deletions scss/form/radios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,39 @@
color: $color-white;
}
}
&.is-disabled {
$color: map-get($disabled-colors, "normal");
$colors-radio-disabled: ($color, map-get($disabled-colors, "shadow"));

+ span {
color: $color;
cursor: not-allowed;
}

/* stylelint-disable-next-line no-descending-specificity */
+ span::before {
color: $color;
cursor: not-allowed;
}

&:checked:hover,
&:checked:focus {
& + span::before {
animation: unset;
}
}

/* stylelint-disable-next-line no-descending-specificity */
&:checked + span::before {
@include pixelize(2px, $radio-checked-focus, $colors-radio-disabled);

color: $color;
}

&:checked:focus + span::before {
@include pixelize(2px, $radio-checked-focus, $colors-radio-disabled);

color: $color;
}
}
}
10 changes: 9 additions & 1 deletion scss/form/selects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"dark" map-get($default-colors, "normal") map-get($default-colors, "hover"),
"success" map-get($success-colors, "normal") map-get($success-colors, "hover"),
"warning" map-get($warning-colors, "normal") map-get($warning-colors, "hover"),
"error" map-get($error-colors, "normal") map-get($error-colors, "hover");
"error" map-get($error-colors, "normal") map-get($error-colors, "hover"),
"disable" map-get($disabled-colors, "normal") map-get($disabled-colors, "shadow");
@each $type in $types {
&.is-#{nth($type, 1)} {
$color: nth($type, 2);
Expand All @@ -66,4 +67,11 @@
}
}
}
&.is-disabled {
@extend .is-disable;
select {
color: map-get($disabled-colors, "normal");
cursor: not-allowed;
}
}
}
6 changes: 5 additions & 1 deletion story/inputs/checkboxes.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ import classNames from 'classnames';

export default () => {
const isDark = boolean('is-dark', false);
const isDisabled = boolean('is-disabled', false);

const checkBoxClasses = classNames(
'nes-checkbox',
{
'is-dark': isDark,
},
{
'is-disabled': isDisabled,
},
);

return `
<div style="${isDark ? 'background-color: black;' : ''}">
<label>
<input type="checkbox" class="${checkBoxClasses}" checked />
<input type="checkbox" ${isDisabled && 'disabled'} class="${checkBoxClasses}" checked />
<span>Enable</span>
</label>
</div>
Expand Down
10 changes: 9 additions & 1 deletion story/inputs/input.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import classNames from 'classnames';
import sharedOptions from '../_helpers/shared';

export default () => {
const disabled = 'is-disabled';
const inputOptions = select('Input Classes', {
default: '',
...sharedOptions,
[disabled]: disabled,
}, '');

const inputClasses = classNames(
Expand All @@ -15,6 +17,12 @@ export default () => {
);

return `
<input type="text" id="name_field" class="${inputClasses}" placeholder="NES.css">
<input
type="text"
id="name_field"
${inputOptions.includes(disabled) && 'disabled'}
class="${inputClasses}"
placeholder="NES.css"
/>
`;
};
8 changes: 6 additions & 2 deletions story/inputs/radio.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ import classNames from 'classnames';

export default () => {
const isDark = boolean('is-dark', false);
const isDisabled = boolean('is-disabled', false);

const radioClasses = classNames(
'nes-radio',
{
'is-dark': isDark,
},
{
'is-disabled': isDisabled,
},
);

return `
<div style="${isDark ? 'background-color: black;' : ''}">
<label>
<input type="radio" class="${radioClasses}" name="answer" checked />
<input type="radio" ${isDisabled && 'disabled'} class="${radioClasses}" name="answer" checked />
<span>Yes</span>
</label>
<label>
<input type="radio" class="${radioClasses}" name="answer" />
<input type="radio" ${isDisabled && 'disabled'} class="${radioClasses}" name="answer" />
<span>No</span>
</label>
</div>
Expand Down
4 changes: 3 additions & 1 deletion story/select/select.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import sharedOptions from '../_helpers/shared';

export default () => {
const isDark = boolean('is-dark', false);
const disabled = 'is-disabled';
const selectOptions = select('class', {
default: '',
...sharedOptions,
[disabled]: disabled,
}, '');

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

return `
<div class="${selectedClasses}">
<select required>
<select required ${selectOptions.includes(disabled) && 'disabled'} >
<option value="" disabled selected hidden>Select...</option>
<option value="0">To be</option>
<option value="1">Not to be</option>
Expand Down