Skip to content

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

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

.db-report {
  &__card {
    position: relative;
    border: 1px solid var(--content-border-color);
    border-radius: var(--d-border-radius-large);
    padding: var(--space-4);
    box-sizing: border-box;
    background: var(--secondary);
    height: 320px;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);

    @include viewport.until(sm) {
      padding-inline: 0;
      padding-bottom: 0;

      &::after {
        content: "";
        position: absolute;
        bottom: -1px;
        left: 0;
        right: 0;
        background: linear-gradient(
          to bottom,
          rgb(var(--secondary-rgb), 0),
          rgb(var(--secondary-rgb), 0.5)
        );
        height: var(--space-2);
      }
    }

    &.--wide {
      grid-column: 1 / -1;
    }

    &.--wide,
    &.--rows-2,
    &.--rows-3,
    &.--rows-4 {
      .db-report__chart {
        overflow-y: auto;
      }
    }

    @for $rows from 2 through 4 {
      &.--rows-#{$rows} {
        grid-row: span #{$rows};
        height: auto;
      }
    }

    &.--floating {
      position: fixed;
      z-index: 100;
    }

    &.--resize-placeholder {
      margin: calc(var(--space-2) * -1);
      border-style: dashed;
      border-color: var(--tertiary);
      background: var(--tertiary-low);

      &:not(.--rows-2, .--rows-3, .--rows-4) {
        height: calc(320px + var(--space-2) * 2);
      }
    }

    &:hover .db-report__resize-handle,
    &:focus-within .db-report__resize-handle {
      opacity: 1;
    }
  }

  &__resize-handle {
    position: absolute;
    bottom: 2px;
    width: 12px;
    height: 12px;
    opacity: 0.35;

    @media (prefers-reduced-motion: no-preference) {
      transition: opacity 0.15s ease;
    }

    &.--se {
      /*! rtl:ignore */
      right: 2px;

      /*! rtl:ignore */
      cursor: nwse-resize;

      /*! rtl:ignore */
      clip-path: polygon(100% 0, 100% 100%, 0 100%);

      /*! rtl:ignore */
      background: repeating-linear-gradient(
        135deg,
        var(--primary-medium) 0,
        var(--primary-medium) 1px,
        transparent 1px,
        transparent 4px
      );
    }

    &.--sw {
      /*! rtl:ignore */
      left: 2px;

      /*! rtl:ignore */
      cursor: nesw-resize;

      /*! rtl:ignore */
      clip-path: polygon(0 0, 100% 100%, 0 100%);

      /*! rtl:ignore */
      background: repeating-linear-gradient(
        45deg,
        var(--primary-medium) 0,
        var(--primary-medium) 1px,
        transparent 1px,
        transparent 4px
      );
    }

    &.--resizing {
      opacity: 1;
    }

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

  &__header {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;

    @include viewport.until(sm) {
      padding-inline: var(--space-4);

      &::after {
        content: "";
        position: absolute;
        bottom: calc(var(--space-4) * -1);
        left: 0;
        right: 0;
        background: linear-gradient(
          to top,
          rgb(var(--secondary-rgb), 0),
          rgb(var(--secondary-rgb), 0.5)
        );
        height: var(--space-2);
        z-index: 1;
      }
    }
  }

  &__name {
    display: flex;
    align-items: center;
    font-size: var(--font-down-1-rem);
    font-weight: 600;
    color: var(--primary);

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

  &__label {
    background: var(--tertiary-low);
    color: var(--tertiary);
    border-radius: 4px;
    font-size: var(--font-down-3);
    padding: var(--space-half) var(--space-2);
    font-weight: 400;
    white-space: nowrap;

    @include viewport.until(sm) {
      position: absolute;
      top: 0;
      right: var(--space-3);
      transform: translateY(-40%);
    }
  }

  &__remove {
    margin-left: auto;
  }

  &__chart {
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;

    .admin-report,
    .admin-report-chart,
    .chart-canvas-container,
    .chart-canvas {
      width: 100% !important; // no other way to overrule the JS inline styling
      height: 100% !important;
    }

    .loading-container {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
    }
  }

  &__empty,
  &__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 100%;
    color: var(--primary-medium);

    .d-icon {
      font-size: var(--font-up-3);
    }
  }

  &__error {
    color: var(--danger);
  }

  &__add-report {
    border: 1px dashed var(--content-border-color);
    border-radius: var(--d-border-radius-large);
    background: var(--secondary);
    color: var(--primary-medium);
    padding: var(--space-2);

    &:hover,
    &:focus {
      background: var(--tertiary-low);
      border-color: var(--tertiary);
      color: var(--tertiary);
    }
  }
}

.db-reports {
  display: contents;
}