mirror of
https://github.com/picocss/pico.git
synced 2025-04-26 03:06:14 -04:00
refactor: modules and css vars
This commit is contained in:
parent
2e4d6c66ec
commit
ce2ed6826d
46 changed files with 3874 additions and 3534 deletions
|
@ -1,138 +1,141 @@
|
|||
@use "sass:map";
|
||||
@use "../settings" as *;
|
||||
|
||||
/**
|
||||
* Checkboxes, Radios and Switches
|
||||
*/
|
||||
@if map.get($modules, "forms/checkbox-radio-switch") {
|
||||
/**
|
||||
* Checkboxes, Radios and Switches
|
||||
*/
|
||||
|
||||
[type="checkbox"],
|
||||
[type="radio"] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
width: 1.25em;
|
||||
height: 1.25em;
|
||||
margin-top: -0.125em;
|
||||
margin-right: 0.375em;
|
||||
margin-left: 0;
|
||||
margin-inline-start: 0;
|
||||
margin-inline-end: 0.375em;
|
||||
border-width: var(#{$✨}border-width);
|
||||
font-size: inherit;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
|
||||
&::-ms-check {
|
||||
display: none; // unstyle IE checkboxes
|
||||
}
|
||||
|
||||
&:checked,
|
||||
&:checked:active,
|
||||
&:checked:focus {
|
||||
#{$✨}background-color: var(#{$✨}primary);
|
||||
#{$✨}border-color: var(#{$✨}primary);
|
||||
background-image: var(#{$✨}icon-checkbox);
|
||||
background-position: center;
|
||||
background-size: 0.75em auto;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
& ~ label {
|
||||
display: inline-block;
|
||||
[type="checkbox"],
|
||||
[type="radio"] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
width: 1.25em;
|
||||
height: 1.25em;
|
||||
margin-top: -0.125em;
|
||||
margin-right: 0.375em;
|
||||
margin-bottom: 0;
|
||||
margin-left: 0;
|
||||
margin-inline-start: 0;
|
||||
margin-inline-end: 0.375em;
|
||||
border-width: var(#{$✨}border-width);
|
||||
font-size: inherit;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
|
||||
&::-ms-check {
|
||||
display: none; // unstyle IE checkboxes
|
||||
}
|
||||
|
||||
&:checked,
|
||||
&:checked:active,
|
||||
&:checked:focus {
|
||||
#{$✨}background-color: var(#{$✨}primary);
|
||||
#{$✨}border-color: var(#{$✨}primary);
|
||||
background-image: var(#{$✨}icon-checkbox);
|
||||
background-position: center;
|
||||
background-size: 0.75em auto;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
& ~ label {
|
||||
display: inline-block;
|
||||
margin-right: 0.375em;
|
||||
margin-bottom: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Checkboxes
|
||||
[type="checkbox"] {
|
||||
&:indeterminate {
|
||||
#{$✨}background-color: var(#{$✨}primary);
|
||||
#{$✨}border-color: var(#{$✨}primary);
|
||||
background-image: var(#{$✨}icon-minus);
|
||||
background-position: center;
|
||||
background-size: 0.75em auto;
|
||||
background-repeat: no-repeat;
|
||||
// Checkboxes
|
||||
[type="checkbox"] {
|
||||
&:indeterminate {
|
||||
#{$✨}background-color: var(#{$✨}primary);
|
||||
#{$✨}border-color: var(#{$✨}primary);
|
||||
background-image: var(#{$✨}icon-minus);
|
||||
background-position: center;
|
||||
background-size: 0.75em auto;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Radios
|
||||
[type="radio"] {
|
||||
border-radius: 50%;
|
||||
// Radios
|
||||
[type="radio"] {
|
||||
border-radius: 50%;
|
||||
|
||||
&:checked,
|
||||
&:checked:active,
|
||||
&:checked:focus {
|
||||
#{$✨}background-color: var(#{$✨}primary-inverse);
|
||||
border-width: 0.35em;
|
||||
background-image: none;
|
||||
&:checked,
|
||||
&:checked:active,
|
||||
&:checked:focus {
|
||||
#{$✨}background-color: var(#{$✨}primary-inverse);
|
||||
border-width: 0.35em;
|
||||
background-image: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Switchs
|
||||
[type="checkbox"][role="switch"] {
|
||||
#{$✨}background-color: var(#{$✨}switch-background-color);
|
||||
#{$✨}border-color: var(#{$✨}switch-background-color);
|
||||
#{$✨}color: var(#{$✨}switch-color);
|
||||
|
||||
// Config
|
||||
$switch-height: 1.25em;
|
||||
$switch-width: 2.25em;
|
||||
$switch-transition: 0.1s ease-in-out;
|
||||
|
||||
// Styles
|
||||
width: $switch-width;
|
||||
height: $switch-height;
|
||||
border: var(#{$✨}border-width) solid var(#{$✨}border-color);
|
||||
border-radius: $switch-height;
|
||||
background-color: var(#{$✨}background-color);
|
||||
line-height: $switch-height;
|
||||
|
||||
&:focus {
|
||||
// Switchs
|
||||
[type="checkbox"][role="switch"] {
|
||||
#{$✨}background-color: var(#{$✨}switch-background-color);
|
||||
#{$✨}border-color: var(#{$✨}switch-background-color);
|
||||
}
|
||||
#{$✨}color: var(#{$✨}switch-color);
|
||||
|
||||
&:checked {
|
||||
#{$✨}background-color: var(#{$✨}switch-checked-background-color);
|
||||
#{$✨}border-color: var(#{$✨}switch-checked-background-color);
|
||||
}
|
||||
// Config
|
||||
$switch-height: 1.25em;
|
||||
$switch-width: 2.25em;
|
||||
$switch-transition: 0.1s ease-in-out;
|
||||
|
||||
&:before {
|
||||
display: block;
|
||||
width: calc(#{$switch-height} - (var(#{$✨}border-width) * 2));
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
background-color: var(#{$✨}color);
|
||||
content: "";
|
||||
// Styles
|
||||
width: $switch-width;
|
||||
height: $switch-height;
|
||||
border: var(#{$✨}border-width) solid var(#{$✨}border-color);
|
||||
border-radius: $switch-height;
|
||||
background-color: var(#{$✨}background-color);
|
||||
line-height: $switch-height;
|
||||
|
||||
@if $enable-transitions {
|
||||
transition: margin $switch-transition;
|
||||
&:focus {
|
||||
#{$✨}background-color: var(#{$✨}switch-background-color);
|
||||
#{$✨}border-color: var(#{$✨}switch-background-color);
|
||||
}
|
||||
|
||||
&:checked {
|
||||
#{$✨}background-color: var(#{$✨}switch-checked-background-color);
|
||||
#{$✨}border-color: var(#{$✨}switch-checked-background-color);
|
||||
}
|
||||
|
||||
&:before {
|
||||
display: block;
|
||||
width: calc(#{$switch-height} - (var(#{$✨}border-width) * 2));
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
background-color: var(#{$✨}color);
|
||||
content: "";
|
||||
|
||||
@if $enable-transitions {
|
||||
transition: margin $switch-transition;
|
||||
}
|
||||
}
|
||||
|
||||
&:checked {
|
||||
background-image: none;
|
||||
|
||||
&::before {
|
||||
margin-left: calc(#{$switch-width * 0.5} - var(#{$✨}border-width));
|
||||
margin-inline-start: calc(#{$switch-width * 0.5} - var(#{$✨}border-width));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:checked {
|
||||
background-image: none;
|
||||
// Aria-invalid
|
||||
[type="checkbox"],
|
||||
[type="checkbox"]:checked,
|
||||
[type="radio"],
|
||||
[type="radio"]:checked,
|
||||
[type="checkbox"][role="switch"],
|
||||
[type="checkbox"][role="switch"]:checked {
|
||||
&[aria-invalid="false"] {
|
||||
#{$✨}border-color: var(#{$✨}form-element-valid-border-color);
|
||||
}
|
||||
|
||||
&::before {
|
||||
margin-left: calc(#{$switch-width * 0.5} - var(#{$✨}border-width));
|
||||
margin-inline-start: calc(#{$switch-width * 0.5} - var(#{$✨}border-width));
|
||||
&[aria-invalid="true"] {
|
||||
#{$✨}border-color: var(#{$✨}form-element-invalid-border-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Aria-invalid
|
||||
[type="checkbox"],
|
||||
[type="checkbox"]:checked,
|
||||
[type="radio"],
|
||||
[type="radio"]:checked,
|
||||
[type="checkbox"][role="switch"],
|
||||
[type="checkbox"][role="switch"]:checked {
|
||||
&[aria-invalid="false"] {
|
||||
#{$✨}border-color: var(#{$✨}form-element-valid-border-color);
|
||||
}
|
||||
|
||||
&[aria-invalid="true"] {
|
||||
#{$✨}border-color: var(#{$✨}form-element-invalid-border-color);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue