-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent-swatch-input.css
More file actions
87 lines (77 loc) · 3.01 KB
/
component-swatch-input.css
File metadata and controls
87 lines (77 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* swatch-input lives in its own file for reusability of the swatch in other areas than the product form context */
.swatch-input__input + .swatch-input__label {
--swatch-input--border-radius: 50%;
display: inline-block;
max-width: 100%;
border-radius: var(--swatch-input--border-radius);
cursor: pointer;
outline-offset: 0.2rem;
outline-color: transparent;
outline-style: solid;
transition-property: outline-color, outline-width, box-shadow;
transition-duration: var(--duration-short);
transition-timing-function: ease;
forced-color-adjust: none;
}
.swatch-input__input + .swatch-input__label.swatch-input__label--square {
--swatch-input--border-radius: 0.2rem;
}
/* Active state */
.swatch-input__input:active + .swatch-input__label,
.swatch-input__input:checked + .swatch-input__label {
outline: 0.1rem solid rgb(var(--color-foreground));
}
/* Hover state */
.swatch-input__input + .swatch-input__label:hover,
.swatch-input__input:hover + .swatch-input__label {
outline: 0.2rem solid rgba(var(--color-foreground), 0.4);
}
/* Focus visible */
.swatch-input__input:focus-visible + .swatch-input__label {
outline: 0.2rem solid rgba(var(--color-foreground), 0.5);
box-shadow: 0 0 0 0.2rem rgb(var(--color-background)), 0 0 0.1rem 0.5rem rgba(var(--color-foreground), 0.25);
}
/* Active and focused */
.swatch-input__input:active:focus-visible + .swatch-input__label,
.swatch-input__input:checked:focus-visible + .swatch-input__label {
outline: 0.1rem solid rgb(var(--color-foreground));
box-shadow: 0 0 0 0.2rem rgb(var(--color-background)), 0 0 0.1rem 0.4rem rgba(var(--color-foreground), 0.25);
}
/* Visually disabled */
.swatch-input__input.visually-disabled:not(:active):not(:checked) + .swatch-input__label {
transition: none;
}
.swatch-input__input.visually-disabled:not(:active):not(:checked) + .swatch-input__label:hover {
outline: none;
}
/* Actually disabled */
.swatch-input__input:disabled + .swatch-input__label {
pointer-events: none;
}
/* Overrides for swatch snippet when used inside disabled swatch-input */
.swatch-input__input:disabled + .swatch-input__label > .swatch,
.swatch-input__input.visually-disabled + .swatch-input__label > .swatch {
position: relative;
overflow: hidden;
}
/* Disabled styles */
.swatch-input__input:disabled + .swatch-input__label > .swatch,
.swatch-input__input.visually-disabled + .swatch-input__label > .swatch {
opacity: 0.4;
}
/* Display crossed out line over swatch when input is disabled */
.swatch-input__input:disabled + .swatch-input__label > .swatch::after,
.swatch-input__input.visually-disabled + .swatch-input__label > .swatch::after {
/* Diagonal of a square = length of the side * sqrt(2) */
--diagonal--size: calc(var(--swatch-input--size) * 1.414);
--crossed-line--size: 0.1rem;
content: '';
position: absolute;
bottom: calc(var(--crossed-line--size) * -0.5);
left: 0;
width: var(--diagonal--size);
height: var(--crossed-line--size);
background-color: rgb(var(--color-foreground));
transform: rotate(-45deg);
transform-origin: left;
}