178 lines
4.9 KiB
CSS
178 lines
4.9 KiB
CSS
/*
|
|
Copyright 2019 Adobe. All rights reserved.
|
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software distributed under
|
|
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
governing permissions and limitations under the License.
|
|
*/
|
|
|
|
@import "../vars/css/scales/spectrum-large.css";
|
|
@import "../vars/css/scales/spectrum-medium.css";
|
|
@import "../vars/css/components/spectrum-switch.css";
|
|
|
|
.spectrum-Switch {
|
|
@remapvars {
|
|
find: /--spectrum-switch-m(.*)/;
|
|
filter: color;
|
|
replace: --spectrum-switch$1;
|
|
}
|
|
|
|
/* Hardcoded for wrapping study.
|
|
Will be a DNA token in https://jira.corp.adobe.com/browse/SDS-4466 */
|
|
--spectrum-switch-label-margin-top: var(--spectrum-global-dimension-size-65);
|
|
|
|
/* Fix for inconsistent line-height between browsers that would push the label 1px below the intended baseline */
|
|
/* more info: https://stackoverflow.com/questions/47700568/css-fonts-render-differently-in-firefox-and-chrome */
|
|
--spectrum-switch-label-line-height: 1.49;
|
|
}
|
|
|
|
.spectrum-Switch {
|
|
display: inline-flex;
|
|
align-items: flex-start;
|
|
|
|
position: relative;
|
|
|
|
min-block-size: var(--spectrum-switch-height);
|
|
max-inline-size: 100%;
|
|
|
|
margin-inline-end: calc(var(--spectrum-switch-cursor-hit-x) * 2);
|
|
|
|
vertical-align: top;
|
|
}
|
|
|
|
.spectrum-Switch-input {
|
|
/* Remove the margin for input in Firefox and Safari. */
|
|
margin: 0;
|
|
|
|
/* Add the correct box sizing for [type="checkbox"] in IE 10-. */
|
|
box-sizing: border-box;
|
|
|
|
/* Remove the padding for [type="checkbox"] in IE 10-. */
|
|
padding: 0;
|
|
|
|
position: absolute;
|
|
inline-size: 100%;
|
|
block-size: 100%;
|
|
inset-block-start: 0;
|
|
inset-inline-start: 0;
|
|
opacity: 0.0001;
|
|
z-index: 1;
|
|
|
|
cursor: pointer;
|
|
|
|
&:checked + .spectrum-Switch-switch {
|
|
[dir="ltr"] &::before {
|
|
transform: translateX(
|
|
calc(var(--spectrum-switch-track-width) - 100%)
|
|
);
|
|
}
|
|
[dir="rtl"] &::before {
|
|
transform: translateX(
|
|
calc(-1 * (var(--spectrum-switch-track-width) - 100%))
|
|
);
|
|
}
|
|
}
|
|
|
|
&:disabled,
|
|
&[disabled] {
|
|
cursor: default;
|
|
}
|
|
|
|
&:focus-ring {
|
|
+ .spectrum-Switch-switch {
|
|
&:after {
|
|
margin: calc(var(--spectrum-alias-focus-ring-gap) * -1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.spectrum-Switch-label {
|
|
margin-inline: var(--spectrum-switch-text-gap);
|
|
margin-block-start: var(--spectrum-switch-label-margin-top);
|
|
margin-block-end: 0;
|
|
font-size: var(--spectrum-switch-text-size);
|
|
line-height: var(--spectrum-switch-label-line-height);
|
|
transition: color var(--spectrum-global-animation-duration-200) ease-in-out;
|
|
}
|
|
|
|
.spectrum-Switch-switch {
|
|
display: inline-block;
|
|
box-sizing: border-box;
|
|
/* positions the pseudo elements relative to this one */
|
|
position: relative;
|
|
|
|
inline-size: var(--spectrum-switch-track-width);
|
|
|
|
/* Fix vertical alignment when not wrapping since we're flex-start */
|
|
margin-block: calc(
|
|
(var(--spectrum-switch-height) - var(--spectrum-switch-track-height)) / 2
|
|
);
|
|
margin-inline: 0;
|
|
|
|
flex-grow: 0;
|
|
flex-shrink: 0;
|
|
|
|
vertical-align: middle;
|
|
|
|
transition: background var(--spectrum-global-animation-duration-100)
|
|
ease-in-out,
|
|
border var(--spectrum-global-animation-duration-100) ease-in-out;
|
|
|
|
block-size: var(--spectrum-switch-track-height);
|
|
|
|
inset-inline-start: 0;
|
|
inset-inline-end: 0;
|
|
|
|
border-radius: calc(var(--spectrum-switch-track-height) / 2);
|
|
|
|
&:before {
|
|
display: block;
|
|
position: absolute;
|
|
content: "";
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
/* :before is used for the handle of the switch */
|
|
&:before {
|
|
transition: background var(--spectrum-global-animation-duration-100)
|
|
ease-in-out,
|
|
border var(--spectrum-global-animation-duration-100) ease-in-out,
|
|
transform var(--spectrum-global-animation-duration-100) ease-in-out,
|
|
box-shadow var(--spectrum-global-animation-duration-100) ease-in-out;
|
|
|
|
inline-size: var(--spectrum-switch-handle-size);
|
|
block-size: var(--spectrum-switch-handle-size);
|
|
|
|
inset-block-start: 0;
|
|
inset-inline-start: 0;
|
|
|
|
border-width: var(--spectrum-switch-handle-border-size);
|
|
border-radius: var(--spectrum-switch-handle-border-radius);
|
|
border-style: solid;
|
|
}
|
|
|
|
/* :after is used for the focus halo */
|
|
&:after {
|
|
border-radius: calc(
|
|
calc(var(--spectrum-switch-track-height) / 2) +
|
|
var(--spectrum-alias-focus-ring-gap) * 2
|
|
);
|
|
content: "";
|
|
display: block;
|
|
position: absolute;
|
|
inset-inline-start: 0;
|
|
inset-inline-end: 0;
|
|
inset-block-end: 0;
|
|
inset-block-start: 0;
|
|
margin: 0;
|
|
|
|
transition: opacity var(--spectrum-global-animation-duration-100) ease-out,
|
|
margin var(--spectrum-global-animation-duration-100) ease-out;
|
|
}
|
|
}
|