Skip to content

Commit 83fed16

Browse files
committed
chore(colorwheel): fix inset borders + improve comments
1 parent da361b6 commit 83fed16

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

components/colorwheel/dist/metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
".spectrum-ColorWheel-colorarea-container",
88
".spectrum-ColorWheel-handle",
99
".spectrum-ColorWheel-inner",
10-
".spectrum-ColorWheel-inner:before",
1110
".spectrum-ColorWheel-slider",
1211
".spectrum-ColorWheel-wheel",
1312
".spectrum-ColorWheel-wheel.is-disabled",
@@ -16,6 +15,7 @@
1615
".spectrum-ColorWheel.is-disabled:before",
1716
".spectrum-ColorWheel.is-dragged",
1817
".spectrum-ColorWheel.is-focused",
18+
".spectrum-ColorWheel:after",
1919
".spectrum-ColorWheel:before",
2020
"[dir=\"rtl\"] .spectrum-ColorWheel-ColorArea-handle"
2121
],

components/colorwheel/index.css

+21-15
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
user-select: none;
4242
cursor: default;
4343

44-
/* calcs wrapping --spectrum-colorwheel-border-width are used to properly position the border drawn using this ::before pseudo element over the exterior edge of the colorwheel. The size is reduced and positioning adjusted to create the border effect. */
44+
/**
45+
* Color wheel exterior border
46+
* - Calcs for `inline-size` and `block-size` subtract 4 times the component's border width
47+
* (to account for the inset width of the exterior border) from the component's width.
48+
*/
4549
&::before {
4650
inline-size: calc(var(--spectrum-colorwheel-width) - calc(4 * var(--spectrum-colorwheel-border-width)));
4751
block-size: calc(var(--spectrum-colorwheel-width) - calc(4 * var(--spectrum-colorwheel-border-width)));
@@ -56,6 +60,22 @@
5660
z-index: 1;
5761
}
5862

63+
/**
64+
* Color wheel interior border
65+
* - Calcs for `inset` 2 times the component's border width from the
66+
* track width (to account for the inset width of the interior border)
67+
*/
68+
&::after {
69+
inset: calc(var(--spectrum-colorwheel-track-width) - (calc(2 * var(--spectrum-colorwheel-border-width))));
70+
content: "";
71+
position: absolute;
72+
border-width: var(--spectrum-colorwheel-border-width);
73+
border-style: solid;
74+
border-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color));
75+
border-radius: 100%;
76+
z-index: 1;
77+
}
78+
5979
&.is-focused {
6080
z-index: 2;
6181
}
@@ -85,20 +105,6 @@
85105
inline-size: var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size));
86106
block-size: var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size));
87107
margin: auto;
88-
89-
/* calcs wrapping --spectrum-colorwheel-border-width are used to properly position the border drawn using this ::before pseudo element over the interior edge of the colorwheel. The size is increased and positioning adjusted to create the border effect. */
90-
&::before {
91-
inline-size: var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size));
92-
block-size: var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size));
93-
inset: calc(-1 * var(--spectrum-colorwheel-border-width));
94-
content: "";
95-
position: absolute;
96-
border-width: var(--spectrum-colorwheel-border-width);
97-
border-style: solid;
98-
border-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color));
99-
border-radius: 100%;
100-
z-index: 1;
101-
}
102108
}
103109

104110
.spectrum-ColorWheel-colorarea-container {

0 commit comments

Comments
 (0)