Adding focus handling for buttons and inputs
This commit is contained in:
parent
36cee2c1f7
commit
aaabaa5250
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hibas123/theme",
|
"name": "@hibas123/theme",
|
||||||
"version": "1.2.17",
|
"version": "1.2.18",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": " ",
|
"main": " ",
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -40,6 +40,13 @@ $on-button: #000000 !default;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @mixin focus-outline() {
|
||||||
|
// &:focus {
|
||||||
|
// outline: $on-background auto medium;
|
||||||
|
// outline-offset: -2px;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@import "./theme/_global.scss";
|
@import "./theme/_global.scss";
|
||||||
@import "./theme/_btn.scss";
|
@import "./theme/_btn.scss";
|
||||||
@import "./theme/_modal.scss";
|
@import "./theme/_modal.scss";
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
@mixin btn-flat() {
|
@mixin btn-flat() {
|
||||||
position: relative;
|
position: relative;
|
||||||
border: 0;
|
border: 0;
|
||||||
margin: .3rem;
|
margin: 0.3rem;
|
||||||
padding: .5rem;
|
padding: 0.5rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
transition: .05s background-color linear;
|
transition: 0.05s background-color linear;
|
||||||
text-decoration: unset;
|
text-decoration: unset;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-flat {
|
.btn-flat {
|
||||||
@ -25,7 +26,7 @@
|
|||||||
color: $text !important;
|
color: $text !important;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
filter: brightness(.95);
|
filter: brightness(0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
@ -33,7 +34,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
@include btn-color($primary, $on-primary);
|
@include btn-color($primary, $on-primary);
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 3.5rem;
|
width: 3.5rem;
|
||||||
height: 3.5rem;
|
height: 3.5rem;
|
||||||
margin: .5rem;
|
margin: 0.5rem;
|
||||||
line-height: 2rem;
|
line-height: 2rem;
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
|
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
.inp {
|
.inp {
|
||||||
background: unset;
|
background: unset;
|
||||||
border: 1px grey solid;
|
border: 1px grey solid;
|
||||||
padding: 0 .5rem;
|
padding: 0 0.5rem;
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
min-width: 10rem;
|
min-width: 10rem;
|
||||||
|
outline: none;
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
|
border-width: 1px;
|
||||||
border-color: $primary;
|
border-color: $primary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea.inp {
|
textarea.inp {
|
||||||
height: unset !important;
|
height: unset;
|
||||||
min-height: 6rem !important;
|
min-height: 6rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,13 +29,12 @@ textarea.inp {
|
|||||||
|
|
||||||
label {
|
label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: .3rem;
|
margin-bottom: 0.3rem;
|
||||||
margin-left: .5rem;
|
margin-left: 0.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-checkbox {
|
.input-checkbox {
|
||||||
|
|
||||||
@extend .margin;
|
@extend .margin;
|
||||||
|
|
||||||
display: block;
|
display: block;
|
||||||
@ -47,7 +48,6 @@ textarea.inp {
|
|||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
|
|
||||||
/* Hide the browser's default checkbox */
|
/* Hide the browser's default checkbox */
|
||||||
input {
|
input {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -64,7 +64,7 @@ textarea.inp {
|
|||||||
left: 0;
|
left: 0;
|
||||||
height: 26px;
|
height: 26px;
|
||||||
width: 26px;
|
width: 26px;
|
||||||
transition: background-color .2s;
|
transition: background-color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On mouse-over, add a grey background color */
|
/* On mouse-over, add a grey background color */
|
||||||
@ -89,7 +89,7 @@ textarea.inp {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=checkbox]+span:after {
|
input[type="checkbox"] + span:after {
|
||||||
/* Style the checkmark/indicator */
|
/* Style the checkmark/indicator */
|
||||||
left: 9px;
|
left: 9px;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
@ -100,7 +100,7 @@ textarea.inp {
|
|||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=radio]+span {
|
input[type="radio"] + span {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
|
||||||
&:after {
|
&:after {
|
||||||
|
@ -6,18 +6,16 @@ $disabled-brightness: 1.1;
|
|||||||
|
|
||||||
@mixin Elevation($dp, $imp: false) {
|
@mixin Elevation($dp, $imp: false) {
|
||||||
@if $imp==true {
|
@if $imp==true {
|
||||||
background: lighten($background, 10% + floor($dp * .7%)) !important;
|
background: lighten($background, 10% + floor($dp * 0.7%)) !important;
|
||||||
}
|
} @else {
|
||||||
|
background: lighten($background, 10% + floor($dp * 0.7%));
|
||||||
@else {
|
|
||||||
background: lighten($background, 10% + floor($dp * .7%));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
z-index: $dp;
|
z-index: $dp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin ElevationTransition() {
|
@mixin ElevationTransition($time: 0.5s) {
|
||||||
transition: background .5s;
|
transition: background $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@import "./_maketheme.scss";
|
@import "./_maketheme.scss";
|
147
src/light.scss
147
src/light.scss
@ -1,13 +1,11 @@
|
|||||||
$background: #f9f9f9;
|
$background: #f9f9f9;
|
||||||
$on-background: black;
|
$on-background: black;
|
||||||
$disabled-brightness: .9;
|
$disabled-brightness: 0.9;
|
||||||
|
|
||||||
@mixin MakeShadow($imp, $type) {
|
@mixin MakeShadow($imp, $type) {
|
||||||
@if $imp==true {
|
@if $imp==true {
|
||||||
box-shadow: $type !important;
|
box-shadow: $type !important;
|
||||||
}
|
} @else {
|
||||||
|
|
||||||
@else {
|
|
||||||
box-shadow: $type;
|
box-shadow: $type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,58 +13,107 @@ $disabled-brightness: .9;
|
|||||||
@mixin Elevation($dp, $imp: false) {
|
@mixin Elevation($dp, $imp: false) {
|
||||||
@if $dp==0 {
|
@if $dp==0 {
|
||||||
@include MakeShadow($imp, none);
|
@include MakeShadow($imp, none);
|
||||||
box-shadow: none
|
box-shadow: none;
|
||||||
}
|
} @else if $dp==1 {
|
||||||
|
@include MakeShadow(
|
||||||
@else if $dp==1 {
|
$imp,
|
||||||
@include MakeShadow($imp, (0 1px 1px 0 rgba(0, 0, 0, .14), 0 2px 1px -1px rgba(0, 0, 0, .12), 0 1px 3px 0 rgba(0, 0, 0, .20))) // box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .14), 0 2px 1px -1px rgba(0, 0, 0, .12), 0 1px 3px 0 rgba(0, 0, 0, .20)
|
(
|
||||||
}
|
0 1px 1px 0 rgba(0, 0, 0, 0.14),
|
||||||
|
0 2px 1px -1px rgba(0, 0, 0, 0.12),
|
||||||
@else if $dp==2 {
|
0 1px 3px 0 rgba(0, 0, 0, 0.2)
|
||||||
@include MakeShadow($imp, (0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .12), 0 1px 5px 0 rgba(0, 0, 0, .20)))
|
)
|
||||||
}
|
)
|
||||||
|
// box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .14), 0 2px 1px -1px rgba(0, 0, 0, .12), 0 1px 3px 0 rgba(0, 0, 0, .20);
|
||||||
@else if $dp==3 {
|
} @else if $dp==2 {
|
||||||
@include MakeShadow($imp, (0 3px 4px 0 rgba(0, 0, 0, .14), 0 3px 3px -2px rgba(0, 0, 0, .12), 0 1px 8px 0 rgba(0, 0, 0, .20)))
|
@include MakeShadow(
|
||||||
}
|
$imp,
|
||||||
|
(
|
||||||
@else if $dp==4 {
|
0 2px 2px 0 rgba(0, 0, 0, 0.14),
|
||||||
@include MakeShadow($imp, (0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .20)))
|
0 3px 1px -2px rgba(0, 0, 0, 0.12),
|
||||||
}
|
0 1px 5px 0 rgba(0, 0, 0, 0.2)
|
||||||
|
)
|
||||||
@else if $dp==6 {
|
);
|
||||||
@include MakeShadow($imp, (0 6px 10px 0 rgba(0, 0, 0, .14), 0 1px 18px 0 rgba(0, 0, 0, .12), 0 3px 5px -1px rgba(0, 0, 0, .20)))
|
} @else if $dp==3 {
|
||||||
}
|
@include MakeShadow(
|
||||||
|
$imp,
|
||||||
@else if $dp==8 {
|
(
|
||||||
@include MakeShadow($imp, (0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12), 0 5px 5px -3px rgba(0, 0, 0, .20)))
|
0 3px 4px 0 rgba(0, 0, 0, 0.14),
|
||||||
}
|
0 3px 3px -2px rgba(0, 0, 0, 0.12),
|
||||||
|
0 1px 8px 0 rgba(0, 0, 0, 0.2)
|
||||||
@else if $dp==9 {
|
)
|
||||||
@include MakeShadow($imp, (0 9px 12px 1px rgba(0, 0, 0, .14), 0 3px 16px 2px rgba(0, 0, 0, .12), 0 5px 6px -3px rgba(0, 0, 0, .20)))
|
);
|
||||||
}
|
} @else if $dp==4 {
|
||||||
|
@include MakeShadow(
|
||||||
@else if $dp==12 {
|
$imp,
|
||||||
@include MakeShadow($imp, (0 12px 17px 2px rgba(0, 0, 0, .14), 0 5px 22px 4px rgba(0, 0, 0, .12), 0 7px 8px -4px rgba(0, 0, 0, .20)))
|
(
|
||||||
}
|
0 4px 5px 0 rgba(0, 0, 0, 0.14),
|
||||||
|
0 1px 10px 0 rgba(0, 0, 0, 0.12),
|
||||||
@else if $dp==16 {
|
0 2px 4px -1px rgba(0, 0, 0, 0.2)
|
||||||
@include MakeShadow($imp, (0 16px 24px 2px rgba(0, 0, 0, .14), 0 6px 30px 5px rgba(0, 0, 0, .12), 0 8px 10px -5px rgba(0, 0, 0, .20)))
|
)
|
||||||
}
|
);
|
||||||
|
} @else if $dp==6 {
|
||||||
@else if $dp==24 {
|
@include MakeShadow(
|
||||||
@include MakeShadow($imp, (0 24px 38px 3px rgba(0, 0, 0, .14), 0 9px 46px 8px rgba(0, 0, 0, .12), 0 11px 15px -7px rgba(0, 0, 0, .20)))
|
$imp,
|
||||||
}
|
(
|
||||||
|
0 6px 10px 0 rgba(0, 0, 0, 0.14),
|
||||||
@else {
|
0 1px 18px 0 rgba(0, 0, 0, 0.12),
|
||||||
|
0 3px 5px -1px rgba(0, 0, 0, 0.2)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} @else if $dp==8 {
|
||||||
|
@include MakeShadow(
|
||||||
|
$imp,
|
||||||
|
(
|
||||||
|
0 8px 10px 1px rgba(0, 0, 0, 0.14),
|
||||||
|
0 3px 14px 2px rgba(0, 0, 0, 0.12),
|
||||||
|
0 5px 5px -3px rgba(0, 0, 0, 0.2)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} @else if $dp==9 {
|
||||||
|
@include MakeShadow(
|
||||||
|
$imp,
|
||||||
|
(
|
||||||
|
0 9px 12px 1px rgba(0, 0, 0, 0.14),
|
||||||
|
0 3px 16px 2px rgba(0, 0, 0, 0.12),
|
||||||
|
0 5px 6px -3px rgba(0, 0, 0, 0.2)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} @else if $dp==12 {
|
||||||
|
@include MakeShadow(
|
||||||
|
$imp,
|
||||||
|
(
|
||||||
|
0 12px 17px 2px rgba(0, 0, 0, 0.14),
|
||||||
|
0 5px 22px 4px rgba(0, 0, 0, 0.12),
|
||||||
|
0 7px 8px -4px rgba(0, 0, 0, 0.2)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} @else if $dp==16 {
|
||||||
|
@include MakeShadow(
|
||||||
|
$imp,
|
||||||
|
(
|
||||||
|
0 16px 24px 2px rgba(0, 0, 0, 0.14),
|
||||||
|
0 6px 30px 5px rgba(0, 0, 0, 0.12),
|
||||||
|
0 8px 10px -5px rgba(0, 0, 0, 0.2)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} @else if $dp==24 {
|
||||||
|
@include MakeShadow(
|
||||||
|
$imp,
|
||||||
|
(
|
||||||
|
0 24px 38px 3px rgba(0, 0, 0, 0.14),
|
||||||
|
0 9px 46px 8px rgba(0, 0, 0, 0.12),
|
||||||
|
0 11px 15px -7px rgba(0, 0, 0, 0.2)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} @else {
|
||||||
@error "Invalid argument for $dp: {"+$dp+"}, look at the method definition for possible values";
|
@error "Invalid argument for $dp: {"+$dp+"}, look at the method definition for possible values";
|
||||||
}
|
}
|
||||||
|
|
||||||
z-index: $dp;
|
z-index: $dp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin ElevationTransition() {
|
@mixin ElevationTransition($time: 0.5s) {
|
||||||
transition: box-shadow .5s;
|
transition: box-shadow $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@import "./_maketheme.scss";
|
@import "./_maketheme.scss";
|
@ -2,6 +2,8 @@
|
|||||||
background: $button-color;
|
background: $button-color;
|
||||||
color: $on-button;
|
color: $on-button;
|
||||||
|
|
||||||
|
// @include focus-outline();
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: darken($button-color, 5%);
|
background: darken($button-color, 5%);
|
||||||
}
|
}
|
||||||
@ -17,10 +19,18 @@
|
|||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
@include Elevation(1);
|
@include Elevation(1);
|
||||||
|
@include ElevationTransition(0.2s);
|
||||||
|
&:focus {
|
||||||
|
@include Elevation(6);
|
||||||
|
}
|
||||||
@include btn-flat();
|
@include btn-flat();
|
||||||
}
|
}
|
||||||
|
|
||||||
.fab {
|
.fab {
|
||||||
@include Elevation(8);
|
@include Elevation(8);
|
||||||
|
@include ElevationTransition(0.2s);
|
||||||
|
&:focus {
|
||||||
|
@include Elevation(16);
|
||||||
|
}
|
||||||
background: $button-color;
|
background: $button-color;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user