Skip to content

A platform for community discussion. Free, open, simple.

13.1 KB
Raw Blame
@use "lib/viewport";

$db-bar-height: var(--space-2);

@import "admin/dashboard/engagement";
@import "admin/dashboard/highlights";
@import "admin/dashboard/reports";
@import "admin/dashboard/search";
@import "admin/dashboard/traffic";
@import "admin/dashboard/site-traffic-explorer";

.db-site-advice {
  border: 1px solid var(--content-border-color);
  border-radius: var(--d-border-radius-large);

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-very-low);
    padding: var(--space-2) var(--space-4);
    border-top-left-radius: var(--d-border-radius-large);
    border-top-right-radius: var(--d-border-radius-large);
    border-bottom: 1px solid var(--content-border-color);

    h3 {
      margin: 0;
      font-size: var(--font-0);
    }
  }

  ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  &__list {
    display: flex;
    flex-direction: column;
  }

  &__item {
    display: flex;
    align-items: center;

    &:has(ul) {
      align-items: flex-start;
    }

    @include viewport.until(sm) {
      align-items: flex-start;
    }
    gap: var(--space-3);
    padding: var(--space-4);

    &:not(:last-child) {
      border-bottom: 1px solid var(--content-border-color);
    }

    .btn {
      margin-left: auto;
    }
  }

  &__icon {
    flex-shrink: 0;
    margin-top: 0.125rem;

    &.--high {
      color: var(--danger);
    }

    &.--low {
      color: var(--tertiary);
    }
  }

  &__message {
    overflow-wrap: anywhere;
  }
}

.db-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  margin-bottom: var(--space-12);
}

.db-delta {
  font-size: var(--font-down-2-rem);
  font-weight: bold;

  table & {
    font-weight: normal;
  }

  &.--pos {
    color: var(--success);
  }

  &.--neg {
    color: var(--danger);
  }
}

.dashboard-next .d-page-header__actions {
  @include viewport.until(md) {
    flex-direction: row;
    gap: var(--space-1);
    margin-block: var(--space-4);
  }

  @include viewport.until(sm) {
    width: 100%;
  }
}

.db-pill {
  font-size: var(--font-down-3);
  border-radius: 6.25rem;
  padding: var(--space-half) var(--space-2);
  background: var(--primary-low);
  white-space: nowrap;

  &.--pos {
    background: var(--success);
    border: 1px solid var(--success);
    color: var(--secondary);
  }

  &.--neg {
    background: var(--danger);
    border: 1px solid var(--danger);
    color: var(--secondary);
  }
}

.db-bar-track {
  display: flex;
  height: $db-bar-height;
  border-radius: 1em;
  background: var(--primary-low);
  overflow: hidden;
}

.db-bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--tertiary);
  flex: 0 0 auto;

  // a real but tiny segment would otherwise round away to nothing
  min-width: 2px;

  &.--alt {
    background: var(--tertiary-medium);
  }
}

.db-configure {
  padding: var(--space-4);
  max-width: 100%;
  box-sizing: border-box;

  &__list {
    @include unstyled-list;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);

    @include viewport.until(sm) {
      gap: var(--space-5);
    }
  }

  &__section-name {
    @include ellipsis;
  }

  &__row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-1) 0;
    border-top: 2px solid transparent;
    border-bottom: 2px solid transparent;
    cursor: grab;

    &.dragging {
      opacity: 0.5;
    }

    &.drag-above {
      border-top-color: var(--tertiary);
    }

    &.drag-below {
      border-bottom-color: var(--tertiary);
    }
  }

  &__section-name {
    margin-right: var(--space-2);
  }

  &__drag-handle {
    color: var(--primary-low-mid);
    cursor: grab;

    @include viewport.until(sm) {
      display: none;
    }
  }

  &__arrows {
    display: flex;
    flex-direction: column;
  }

  &__arrow.btn {
    padding: 0 var(--space-1);
    min-height: 0;
  }

  .d-toggle-switch {
    margin-left: auto;

    .d-icon-check {
      display: none;
    }
  }
}

.db-main__empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--primary-medium);
  background: var(--primary-very-low);
  border-radius: var(--d-border-radius);
}

.db-main__error {
  padding: var(--space-8);
  text-align: center;
  color: var(--primary-medium);
  background: var(--primary-very-low);
  border-radius: var(--d-border-radius);
}

.db-link-arrow {
  position: absolute;
  opacity: 0;
  font-size: var(--font-down-2-rem);
  transform: translateX(-4px);
  transition:
    opacity 0.15s,
    transform 0.15s;
  color: var(--tertiary);
}

.db-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);

  &__info {
    font-size: var(--font-down-1-rem);
    color: var(--primary-low-mid);
  }

  &__header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  &__header {
    font-size: var(--font-down-2-rem);
    font-weight: 600;
    color: var(--primary-medium);
    text-transform: uppercase;
    margin: 0;
    letter-spacing: 1px;
  }

  &__intro {
    max-width: 60ch;
    margin: 0;
  }

  &__error {
    grid-column: 1 / -1;
    flex: 1;
    padding: var(--space-8);
    text-align: center;
    color: var(--primary-medium);
    background: var(--primary-very-low);
    border-radius: var(--d-border-radius);
    font-size: var(--font-down-1-rem);
  }

  &__subheader {
    display: flex;
    justify-content: space-between;
    gap: var(--space-8);

    @include viewport.until(sm) {
      flex-direction: column;
      gap: var(--space-4);
    }
  }

  &__subintro {
    h3 {
      margin: 0;
    }

    p {
      font-size: var(--font-down-1-rem);
      color: var(--primary-high);
      margin-bottom: 0;
    }
  }

  &__metrics {
    display: flex;
    justify-content: flex-end;
    flex-grow: 1;
    gap: clamp(var(--space-2), var(--space-8), var(--space-8));

    @include viewport.until(sm) {
      border-top: 1px solid var(--primary-low);
      padding-top: var(--space-2);
    }
  }

  &__metric-number {
    white-space: nowrap;
    font-size: var(--font-up-3);

    @include viewport.until(sm) {
      font-size: var(--font-up-2);
    }
  }

  &__metric-label {
    white-space: nowrap;
    font-size: var(--font-down-2-rem);
    color: var(--primary-medium);

    a {
      color: inherit;
    }

    @include viewport.until(sm) {
      white-space: wrap;
    }
  }

  &__callout {
    background: var(--primary-very-low);
    border: 1px solid var(--content-border-color);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--d-border-radius-large);
    font-size: var(--font-down-1-rem);
  }

  &__traffic-chart {
    min-height: 260px;
    height: 360px;
  }

  &__traffic-chart-canvas,
  &__traffic-chart-canvas .chart-canvas,
  &__traffic-chart-canvas .chart-canvas-container {
    height: 100%;
  }

  &__traffic-chart &__traffic-chart-canvas.admin-report-stacked-chart {
    height: 100%;

    .chart-canvas-container {
      height: 100%;
    }
  }

  &__traffic-chart-shell {
    height: 100%;
    border-radius: var(--d-border-radius-large);
    background: linear-gradient(
      135deg,
      var(--primary-very-low),
      var(--primary-low)
    );
  }

  &__traffic-chart-message {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4);
    border-radius: var(--d-border-radius-large);
    background: var(--primary-very-low);
    color: var(--primary-medium);
    font-size: var(--font-down-1-rem);
  }

  &__row {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--space-4);
    border-top: 1px solid var(--primary-low);
    margin-inline: calc(var(--space-4) * -1);

    @include viewport.until(sm) {
      flex-direction: column;
    }
  }

  &__row-block {
    flex: 1;
    min-width: 0;
    padding: var(--space-4);
    box-sizing: border-box;

    &:not(:last-child) {
      border-right: 1px solid var(--content-border-color);
    }

    @include viewport.until(sm) {
      &:not(:last-child) {
        border-right: 0;
        border-bottom: 1px solid var(--content-border-color);
      }
    }
  }

  &__row-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);

    .select-kit.combo-box.category-chooser {
      width: 100%;
      max-width: 300px;
    }
  }

  &__row-block-title,
  &__row-block-title > a {
    color: var(--primary);
    font-weight: bold;
    font-size: var(--font-down-1-rem);
    white-space: nowrap;

    &:hover,
    &:focus,
    &:visited,
    &:active {
      color: var(--primary);
    }

    .db-link-arrow {
      top: 0;
      inset-inline-end: calc(var(--space-6) * -1);
      margin-inline-start: var(--space-4);
    }
  }

  &__wrapper {
    border-radius: var(--d-border-radius-large);
    border: 1px solid var(--content-border-color);

    &.--no-border {
      border: none;
      border-radius: 0;
      padding: 0;
    }

    &.--grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      grid-auto-rows: 320px;
      gap: var(--space-4);

      @include viewport.until(sm) {
        grid-template-columns: minmax(0, 1fr);
      }
    }

    &.--row {
      display: flex;
      flex-wrap: nowrap;

      @include viewport.until(sm) {
        flex-wrap: wrap;
        gap: var(--space-1);
        border: none;
      }
    }

    &.--column {
      display: flex;
      flex-direction: column;
      gap: var(--space-4);
      padding: var(--space-4);

      &:has(.db-section__row-block) {
        padding-bottom: 0;
      }
    }
  }

  &__footer {
    display: flex;
    justify-content: space-between;
  }
}

.db-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.db-system {
  &__block {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);

    &:first-of-type {
      border-top-left-radius: var(--d-border-radius-large);
      border-bottom-left-radius: var(--d-border-radius-large);
    }

    &:last-of-type {
      border-top-right-radius: var(--d-border-radius-large);
      border-bottom-right-radius: var(--d-border-radius-large);
    }
  }

  &__value {
    font-size: var(--font-up-3-rem);
    font-weight: 500;
    color: var(--primary);
  }

  &__label {
    font-size: var(--font-down-1-rem);
    color: var(--primary-medium);
  }

  &__breakdown {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--primary-medium);
    font-size: var(--font-down-1-rem);
  }

  &__link {
    font-size: var(--font-down-1-rem);
  }

  &__footer {
    display: flex;
    align-items: center;
    margin-top: auto;

    &.--critical {
      .db-system__label {
        color: var(--danger);
      }
    }

    .--storage & {
      justify-content: space-between;
    }

    .--status & {
      justify-content: flex-end;
    }
  }

  &__status-icon {
    .--ok & {
      color: var(--success);
    }

    .--warning &,
    .--critical & {
      color: var(--danger);
    }
  }
}

.--system {
  @include viewport.until(sm) {
    .db-section__row-block {
      border-radius: var(--d-border-radius-large);
      flex-basis: calc(50% - var(--space-1));
      border: 1px solid var(--content-border-color);
    }
  }
}

.db-bar-track {
  .--system & {
    margin-block: var(--space-2);
  }
}

.db-bar-fill {
  &:first-child {
    .--system & {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }
  }

  &:nth-child(2) {
    .--system & {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }
  }
}

/* The reordering surface behind `enable_new_reordering_controls`. Keyed on the
   classes the shared list puts on its own root and rows, so these rules are
   inert while the legacy rows render and need no flag scoping.

   TODO (ui-kit-reorderable-list-cleanup) fold back into the blocks above once
   the change ships. */

.db-configure__list.d-reorderable-list {
  /* Rows tile edge to edge instead. A gap belongs to the container, so a drag
     crossing it reaches no drop target and the above/below zones stop meeting. */
  gap: normal;
}

.db-configure__row.d-reorderable-list__row {
  padding: calc(var(--space-3) / 2 + var(--space-half)) 0;

  /* The grip carries its own cursor; promising the whole row drags would
     misdescribe a press on the label, which selects. */
  cursor: auto;

  @include viewport.until(sm) {
    padding: calc(var(--space-5) / 2 + var(--space-half)) 0;
  }

  /* One boundary, one line. A row's own top border and its predecessor's bottom
     border are adjacent bands rather than the same pixels, so drawing each state
     on its own row would shift the indicator by its own width as the pointer
     crossed the midpoint. "Above row N" is drawn on row N-1's bottom edge, and
     the shared primitive's inserted line is dropped rather than overridden so
     both never show at once. */

  &.--drag-below,
  &:not(.--dragging):has(+ .db-configure__row.--drag-above) {
    border-bottom-color: var(--d-drag-indicator-color);
  }

  /* No predecessor to borrow an edge from. */
  &.--drag-above:first-child {
    border-top-color: var(--d-drag-indicator-color);
  }

  &.--drag-above::before,
  &.--drag-below::after {
    content: none;
  }

  .d-reorderable-list__handle {
    color: var(--primary-low-mid);
  }
}