1
0
mirror of https://github.com/nostalgic-css/NES.css.git synced 2025-09-02 18:42:47 +02:00

feat(radio): add is-dark to radio, changed inputs story

This commit is contained in:
Igor Guastalla de Lima
2019-02-25 21:08:06 -03:00
parent ea5293bb34
commit 53610cb83b
2 changed files with 37 additions and 14 deletions

View File

@@ -1,28 +1,30 @@
import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies
import { // eslint-disable-line import/no-extraneous-dependencies import { // eslint-disable-line import/no-extraneous-dependencies
withKnobs, radios, withKnobs, radios, boolean,
} from '@storybook/addon-knobs'; } from '@storybook/addon-knobs';
const stories = storiesOf('Inputs', module); const stories = storiesOf('Inputs', module);
stories.addDecorator(withKnobs); stories.addDecorator(withKnobs);
stories.add('input.radio', () => ` stories.add('input.radio', () => {
const isDark = boolean('is-dark', false) ? 'is-dark' : '';
return (`
<label> <label>
<input type="radio" class="nes-radio" name="answer" checked /> <input type="radio" class="nes-radio ${isDark}" name="answer" checked />
<span>Yes</span> <span>Yes</span>
</label> <label> </label> <label>
<input type="radio" class="nes-radio" name="answer" /> <input type="radio" class="nes-radio ${isDark}" name="answer" />
<span>No</span> <span>No</span>
</label>`) </label>`
);
})
.add('input.checkbox', () => { .add('input.checkbox', () => {
const selectedClass = radios('class', { const isDark = boolean('is-dark', false) ? 'is-dark' : '';
default: '',
'is-dark': 'is-dark',
}, '');
return ( return (
`<label> `<label>
<input type="checkbox" class="nes-checkbox ${selectedClass}" checked /> <input type="checkbox" class="nes-checkbox ${isDark}" checked />
<span>Enable</span> <span>Enable</span>
</label>` </label>`
); );

View File

@@ -20,6 +20,7 @@
(2,2,0,0,0,0), (2,2,0,0,0,0),
); );
$colors: ($base-color, map-get($default-colors, "shadow")); $colors: ($base-color, map-get($default-colors, "shadow"));
$colors-radio-dark: ($color-white, map-get($default-colors, "shadow"));
margin-right: 20px; margin-right: 20px;
-webkit-appearance: none; -webkit-appearance: none;
@@ -50,4 +51,24 @@
&:checked:focus + span::before { &:checked:focus + span::before {
@include pixelize(2px, $radio-checked-focus, $colors); @include pixelize(2px, $radio-checked-focus, $colors);
} }
&.is-dark {
+ span {
color: $color-white;
}
// prettier-ignore
+ span::before { /* stylelint-disable-line no-descending-specificity */
color: $color-white;
}
&:checked + span::before {
@include pixelize(2px, $radio-checked-focus, $colors-radio-dark);
color: $color-white;
}
&:checked:focus + span::before {
@include pixelize(2px, $radio-checked-focus, $colors-radio-dark);
color: $color-white;
}
}
} }