All files color-wheel.element.css

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 1971x                                                                                                                                                                                                                                                                                                                                                                                                        
:host {
    color-scheme: only light;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    --inner-radius: var(--color-wheel-inner-radius, 60%);
    --radius: 5cm;
    min-height: calc(2 * var(--radius) + 2*  var(--thumb-radius) + 12px);
    --thumb-radius: var(--color-wheel-thumb-radius-mobile, var(--color-wheel-thumb-radius, 0.6cm));
    --hue: 0;
    --value: 100;
    --lightness: 50;
    --saturation: 100;
    --default-ui-mode: desktop
}
 
:host([rotate-wheel]) {
    --ui-mode: "mobile"
}
 
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
    :host {
        --default-ui-mode: mobile
    }
}
 
.container {
    position: relative;
    display: inline-block;
    overflow: hidden;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: calc(var(--thumb-radius) + 6px);
    transition: --ui-mode 1ms step-start allow-discrete, --default-ui-mode 1ms step-start allow-discrete;
}
 
.container--desktop-ui {
  --inner-radius: var(--color-wheel-inner-radius, 0.1%);
  --thumb-radius: var(--color-wheel-thumb-radius-desktop, var(--color-wheel-thumb-radius, 0.5cm));
}
 
.color-wheel-container {
  width: 100%;
  height: 100%;
  min-height: calc(2 * var(--radius));
  min-width: calc(2 * var(--radius));
  display: inline-block;
  position: relative;
}
 
.color-wheel, .slider-container {
  position: absolute;
  inset: 0;
}
 
.color-wheel {
  --l-color: calc(var(--value) * 0.5%);
  --center-l-color: calc(var(--value) * 1%);
  pointer-events: auto;
  display: inline-block;
  touch-action: none;
  border-radius: 50%;
  background: radial-gradient(circle closest-side at center, hsl(0 0% var(--center-l-color)) var(--inner-radius),  transparent 100%), conic-gradient(
      hsl(360 100% var(--l-color)),
      hsl(345 100% var(--l-color)),
      hsl(330 100% var(--l-color)),
      hsl(315 100% var(--l-color)),
      hsl(300 100% var(--l-color)),
      hsl(285 100% var(--l-color)),
      hsl(270 100% var(--l-color)),
      hsl(255 100% var(--l-color)),
      hsl(240 100% var(--l-color)),
      hsl(225 100% var(--l-color)),
      hsl(210 100% var(--l-color)),
      hsl(195 100% var(--l-color)),
      hsl(180 100% var(--l-color)),
      hsl(150 100% var(--l-color)),
      hsl(135 100% var(--l-color)),
      hsl(120 100% var(--l-color)),
      hsl(105 100% var(--l-color)),
      hsl(90 100% var(--l-color)),
      hsl(60 100% var(--l-color)),
      hsl(45 100% var(--l-color)),
      hsl(30 100% var(--l-color)),
      hsl(15 100% var(--l-color)),
      hsl(0 100% var(--l-color))
  );
 
  /* calcs for antialiasing */
  mask-image: radial-gradient(circle closest-side at center, transparent calc(var(--inner-radius) - 1px), white var(--inner-radius), white calc(100% - 1px), transparent 100%);
  -webkit-mask-image: radial-gradient(circle closest-side at center, transparent calc(var(--inner-radius) - 1px), white var(--inner-radius),  white calc(100% - 1px), transparent 100%);
  transform-origin: center;
 
}
 
.container--hsl .color-wheel {
  --l-color: calc(var(--lightness) * 1%);
  --center-l-color: calc(var(--lightness) * 1%);
}
 
.container--mobile-ui .color-wheel {
  transform: rotateZ(calc(var(--hue) * 1deg));
}
 
.slider-container{
  pointer-events: none;
  position: absolute;
  aspect-ratio: 1 / 1;
  height: 100%;
  top: 50%;
  left: 50%;
  min-height: calc(2 * var(--radius));
  min-width: calc(2 * var(--radius));
  transform: translate(-50%, -50%) rotateZ(calc(var(--hue) * -1deg - 90deg));
 
}
 
.slider-container-half {
  position: absolute;
  inset: 0 0 0 50%;
}
 
.slider {
  pointer-events: none;
  touch-action: none;
  position: absolute;
  top: 50%;
  width: calc(2 * var(--thumb-radius));
  height: calc(2 * var(--thumb-radius));
  background: hsl(var(--hue), calc(var(--saturation) * 1%), calc((100% - var(--saturation) * 0.5%) * var(--value) / 100));
  border: 4px solid #888;
  border-radius: 50%;
  cursor: pointer;
  transform: translate(-50%, -50%);
  left: calc(var(--inner-radius) + (1% * var(--saturation)) - ( var(--saturation) * var(--inner-radius) / 100 ));
}
 
.container--hsl .slider {
  background: hsl(var(--hue), calc(var(--saturation) * 1%), calc(var(--lightness, 50) * 1%)) ;
}
 
.inner-radius-calc {
  z-index: -1;
  height: 1px;
  pointer-events: none;
  touch-action: none;
  width: var(--inner-radius);
}
 
.slider-track {
  display: none;
  pointer-events: none;
}
 
.slider::before {
  display: block;
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: -3px;
  right: -3px;
  background: transparent ;
  border-radius: 50%;
  border: 2px solid #ffffff;
  content: " ";
  pointer-events: none;
  touch-action: none;
}
 
 
.container--mobile-ui .slider-container{
  transform: translate(-50%, -50%) rotate(-90deg);
}
 
.container--mobile-ui .slider-track{
  position: absolute;
  inset: 0;
  display: inline;
  z-index: -1;
  overflow: hidden;
  mask-image: radial-gradient(circle closest-side at center, transparent calc(var(--inner-radius) - 1px), white var(--inner-radius), white calc(100% - 1px), transparent 100%);
  -webkit-mask-image: radial-gradient(circle closest-side at center, transparent calc(var(--inner-radius) - 1px), white var(--inner-radius),  white calc(100% - 1px), transparent 100%);
}
 
.container--mobile-ui .slider-track::after{
  content: " ";
  position: absolute;
  inset: calc(50% - 2px) -10px calc(50% - 2px) 50%;
  border: 1px solid black;
}
 
.container--mobile-ui .slider{
  pointer-events: auto;
}