Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript
3.2 KB
Raw Blame
/* =========================================
   CLICKABLE LABEL
   ========================================= */

.checkbox {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  gap: 4px;

  width: fit-content;

  border-radius: 6px;

  cursor: pointer;
  user-select: none;

  transition: background-color 120ms ease;
}

/* FULL HIT AREA HOVER */
.checkbox:hover {
  background: var(--color-surface-hover);
}

/* PRESSED */
.checkbox:active {
  background: var(--color-surface-active);
}

/* =========================================
   CUSTOM CHECKBOX
   ========================================= */

.checkbox input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;

  margin: 0;

  /* HIT AREA */
  width: 20px;
  height: 20px;

  min-width: 20px;
  min-height: 20px;

  position: relative;

  display: inline-grid;
  place-items: center;

  background: transparent;
  border: none;

  cursor: pointer;

  flex-shrink: 0;

  box-sizing: border-box;

  border-radius: 4px;

  /* VISUAL BOX SIZE */
  --box-size: 12px;

  /* CHECK SIZE */
  --check-size: 6px;
}

/* =========================================
   VISIBLE BOX
   ========================================= */

.checkbox input[type="checkbox"]::after {
  content: "";

  width: var(--box-size);
  height: var(--box-size);

  border: 1.5px solid var(--color-text-muted);
  border-radius: 2px;

  background: var(--color-bg-primary);

  box-sizing: border-box;

  display: block;

  transition:
    border-color 120ms ease,
    background-color 120ms ease;
}

/* Hover border */
.checkbox:hover input[type="checkbox"]::after {
  border-color: var(--color-text-secondary);
}

/* Streaming variant */
.checkbox input.streaming[type="checkbox"]::after {
  border-color: var(--color-success);
}

/* Streaming hover */
.checkbox:hover input.streaming[type="checkbox"]::after {
  border-color: var(--color-success-strong);
}

/* =========================================
   CENTER CHECK INDICATOR
   ========================================= */

.checkbox input[type="checkbox"]::before {
  content: "";

  position: absolute;

  top: 50%;
  left: 50%;

  width: var(--check-size);
  height: var(--check-size);

  border-radius: 1px;

  background: var(--color-info);

  transform: translate(-50%, -50%) scale(0);

  transition:
    transform 120ms ease,
    background-color 120ms ease;

  /* No permanent will-change: it forces a standing GPU layer for every checkbox
     mark (many in the camera config tree). The toggle transition is rare, so let
     the browser promote on demand instead. */

  z-index: 1;
}

/* Checked */
.checkbox input[type="checkbox"]:checked::before {
  transform: translate(-50%, -50%) scale(1);
}

/* Streaming checked */
.checkbox input.streaming[type="checkbox"]:checked::before {
  background: var(--color-success);
}

/* =========================================
   FOCUS
   ========================================= */

.checkbox input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-info-strong);
  outline-offset: 2px;
}

/* =========================================
   DISABLED
   ========================================= */

.checkbox input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}