Skip to content

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

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

.de-dashboard-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
  min-height: 0;
  min-width: 0;

  canvas {
    width: 100% !important;
    height: 100% !important;
  }

  &__table {
    overflow: auto;
    font-size: var(--font-down-2);

    th,
    td {
      white-space: nowrap;
    }
  }

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

.de-cta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 1.5rem;
  border-top: 1px solid var(--primary-low);
  text-decoration: none;
  color: inherit;

  &__text {
    display: flex;
    flex-direction: column;
    gap: var(--space-half);
    flex: 1 1 auto;
    min-width: 0;
  }

  &__title {
    color: var(--tertiary);
    font-weight: bold;
  }

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

  &__chevron {
    color: var(--tertiary);
    font-size: var(--font-down-1);
  }
}

table.group-reports {
  width: 100%;
  table-layout: fixed;

  th:first-child {
    width: 30%;
  }

  th:nth-child(2) {
    width: 60%;
  }

  th:last-child {
    width: 20%;
    text-align: right;
  }

  tbody tr td {
    padding: 0.5em;

    &:first-child {
      font-size: $font-up-1;
    }

    &:last-child {
      text-align: right;
    }
  }
}

.query-editor {
  margin-bottom: 15px;

  .query-editor__header {
    margin-bottom: 0.5em;
  }

  .query-editor__label {
    margin: 0;
    font-size: var(--font-up-2);
  }

  .panels-flex {
    display: flex;
    height: 400px;
    border: 1px solid var(--primary-400);
    border-radius: var(--d-border-radius);
    overflow: hidden;

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

  /* The floor a resize may not cross, read from here by the separator. Declared
     rather than measured once, so it follows the layout rather than whichever
     state the editor opened in. Carried by a class, so panes without a separator
     keep their own sizing. */

  .query-editor__panes {
    min-height: 400px;

    @include viewport.until(sm) {
      min-height: 548px;
    }
  }

  &.no-schema .query-editor__panes {
    @include viewport.until(sm) {
      min-height: 300px;
    }
  }

  .editor-panel {
    flex: 1 0 50%;

    .ace-wrapper {
      --min-height: unset;
      min-height: var(--min-height);
      position: relative;
      height: 100%;
      width: 100%;
      box-sizing: border-box;
      border: none;

      @include viewport.until(sm) {
        --min-height: 300px;
      }
    }

    .ace_editor {
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
    }
  }

  .right-panel {
    --width: 345px;
    flex-shrink: 0;
    flex-grow: 0;
    position: relative;
    width: var(--width);

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

    .schema {
      height: 100%;
      overflow-y: scroll;
      overflow-x: hidden;
      color: var(--primary-high);
      font-size: var(--font-down-1);
      position: relative;

      @include viewport.until(sm) {
        .schema-container {
          height: 200px;
          overflow: auto;
        }
      }

      @include viewport.from(sm) {
        border-left: 1px solid var(--primary-low);
      }

      .schema-search {
        padding: 0.5em;
        position: sticky;
        background-color: var(--secondary);
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        gap: 0.4em;
        border-bottom: 1px solid var(--primary-low);

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

        .schema-search__icon {
          color: var(--primary-medium);
        }

        .schema-search__input {
          flex: 1;
          margin: 0;
          border: none;
          background: transparent;
          padding: 0.25em 0;

          &:focus {
            outline: none;
            box-shadow: none;
          }
        }
      }

      .schema__toggle {
        flex: 0 0 auto;
      }

      .schema-table-name {
        font-weight: bold;
        border-bottom: 1px solid var(--primary-low);
        padding-left: 5px;
      }

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

      dl {
        margin: 0;
      }

      dl > div > * {
        padding-top: 2px;
        padding-bottom: 2px;
      }

      dt {
        display: inline-block;
        vertical-align: text-top;
        overflow-wrap: break-word;
        width: 110px;
        margin-left: 5px;

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

      dd {
        display: inline-block;
        vertical-align: text-top;
        width: 110px;
        color: var(--tertiary);
        margin: 0;
        padding-left: 7px;
        border-left: 1px dotted var(--primary-low-mid);

        .schema-typenotes {
          color: var(--primary-medium);
          font-style: italic;
        }

        .popup-info {
          color: var(--primary-medium);

          .popup {
            display: none;
            width: 180px;
            padding: 4px;
            position: relative;
            border: 1px solid;
            background: var(--secondary);
            padding-right: calc(5px + 0.5em);
          }

          &:hover .popup {
            display: block;
          }

          &:focus .popup {
            display: block;
          }

          .popup ol {
            padding: 0;
            position: relative;
            list-style: none;

            > li::before {
              content: attr(value) ": ";
            }
          }
        }
      }
    }
  }

  &.no-schema {
    .editor-panel {
      flex-basis: 100%;
    }

    .right-panel {
      width: 0;
    }

    .schema__toggle.--expand {
      position: absolute;
      inset-block-start: var(--space-2);
      inset-inline-start: -2.75em;
      z-index: 1;
    }
  }

  .grippie {
    padding-bottom: var(--space-2);
    user-select: none;
  }
}

.query-edit {
  > .name {
    display: flex;
    align-items: center;
    margin-bottom: 1em;

    h1 {
      display: inline-block;
      margin: 0 0.5em 0 0;
      color: var(--primary);
    }
  }

  button.previous {
    margin-right: 0.5em;

    .d-icon {
      margin-left: -0.15em; // fixing fontawesome horizontal alignment
    }
  }

  .name-text-field {
    width: 100%;
  }

  .name input,
  .desc textarea {
    width: 100%;
    margin: 0;
  }

  &:not(.editing) .desc {
    margin: 10px 0;
    white-space: pre-wrap;
  }

  &__details {
    margin: 10px 0;
  }

  &__metadata-fields {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  &__metadata-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);

    @include viewport.from(md) {
      flex-direction: row;
      align-items: center;
    }

    .select-kit.multi-select {
      @include viewport.until(md) {
        width: min(22.5rem, 100%);
      }
    }
  }

  &__metadata-label {
    color: var(--primary-high);
  }
}

.query-run {
  margin-top: 25px;

  .query-run-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
    margin-top: 1em;
  }

  .query-run-actions__left,
  .query-run-actions__right {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-wrap: wrap;
  }
}

.query-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75em;
  flex-wrap: wrap;
}

.query-action-bar__left,
.query-action-bar__right {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  flex-wrap: wrap;
}

.query-run-split {
  display: inline-flex;
  align-items: stretch;
  gap: 1px;

  .query-run-split__primary,
  .query-run-split__chevron {
    margin: 0;
  }

  .query-run-split__primary {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  .query-run-split__chevron {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: 0 0.6em;
  }
}

.query-params {
  border: 1px solid var(--header_primary-medium);

  .params-form {
    margin: 5px;

    html.desktop-view & {
      flex-direction: row;
      flex-wrap: wrap;
    }
  }

  .param > input,
  .param > .select-kit {
    margin: 9px;
  }

  .param {
    display: flex;
    align-items: center;
    flex: 0;

    input,
    .select-kit {
      width: auto;
      max-width: 250px;
    }
  }
}

.query-edit,
.query-results,
.query-params,
.query-action-bar,
.result-header {
  margin-bottom: 2em;
}

.query-new__top-bar,
.query-edit__top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: 0.5em;

  .back-button {
    margin: 0;
  }
}

.query-ai-prompt {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 1em 0;

  &__label {
    margin: 0;
    color: var(--primary);
    font-size: var(--font-down-1-rem);
    font-weight: 600;
    line-height: var(--line-height-medium);
  }

  &__input {
    width: 100%;
    height: auto;
    min-height: 4em;
  }

  &__actions {
    display: flex;
    align-items: center;
    margin-block-start: var(--space-1);
  }
}

.data-explorer-workflow-ai-query {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-self: stretch;
  min-width: 0;
  margin-block: var(--space-3) 0;
  padding: var(--space-3);
  background: var(--primary-very-low);
  border: 1px solid var(--primary-low);
  border-inline-start: 3px solid var(--tertiary);
  border-radius: var(--d-border-radius);

  &__header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  &__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    color: var(--tertiary);
    background: var(--secondary);
    border: 1px solid var(--primary-low);
    border-radius: var(--d-border-radius-pill);
  }

  &__title {
    margin: 0;
    color: var(--primary);
    font-size: var(--font-up-1);
    line-height: var(--line-height-medium);
  }

  &__prompt {
    margin: 0;
  }
}

.query-new__ai-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

.query-new {
  .query-new__ai-section {
    max-width: 720px;
    margin-bottom: 1em;
  }

  .query-new__generating-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    color: var(--primary-medium);
    font-size: var(--font-down-1);
  }

  .query-new__divider {
    margin: 1.5em 0;
    border-top: 1px solid var(--primary-low-mid);
  }

  .query-new__sql-editor {
    margin-bottom: 1.5em;

    .ace-wrapper,
    .ace-wrapper > .loading-container {
      width: 100%;
    }

    // the grippie lets the editor grow; give it a sensible starting height
    .ace {
      min-height: 200px;
      width: 100%;
    }
  }

  .query-new__result-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 0.75em;
  }

  .query-new__result-about {
    margin-right: auto;
    color: var(--primary-medium);
  }

  // the count is shown in the result bar instead, on the same line as the toggle
  .query-new__preview .result-meta {
    display: none;
  }

  .query-new__fields {
    margin-top: 1.5em;
  }

  .query-new__preview {
    margin-top: 0.5em;
  }

  .query-group-select,
  .query-tag-chooser {
    width: 100%;
  }

  .query-new__sql-label {
    display: block;
    font-weight: 700;
    margin: 1em 0 0.5em;
  }

  .query-new__manual-form > .query-editor,
  .query-new__manual-form > .query-new__sql-label {
    width: 100%;
  }
}

.query-result-export__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.query-results {
  .query-result-download-buttons {
    display: inline-flex;
    gap: 0.5em;
  }

  .result-header {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
  }

  .result-header__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75em 1.25em;
    flex-wrap: wrap;
  }

  .result-meta {
    display: flex;
    align-items: baseline;
    gap: 0.75em 1.25em;
    flex-wrap: wrap;
    color: var(--primary-medium);
  }

  .result-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
  }

  .query-results-modes {
    display: inline-flex;
    border: 1px solid var(--primary-low);
    border-radius: var(--d-button-border-radius, 0.25em);
    overflow: hidden;
  }

  section {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .query-results-chart {
    min-width: 0;
    margin-bottom: 1rem;
    animation: fadein 2s;

    .query-results-chart__form {
      max-width: 100%;
      margin-bottom: 0.75rem;
    }

    canvas {
      height: clamp(200px, 50vh, 350px) !important;
    }

    @media (prefers-reduced-motion) {
      animation-duration: 0s;
    }
  }

  .query-results-chart__footnote {
    margin: 0.5em 0 0;
    color: var(--primary-medium);
    font-size: var(--font-down-1);
  }

  .query-chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2em 1em;
    color: var(--primary-medium);
    text-align: center;
    border: 1px dashed var(--primary-low);
    border-radius: var(--d-button-border-radius, 0.25em);

    .query-chart-empty-state__icon {
      font-size: 2em;
      margin-bottom: 0.5em;
    }

    .query-chart-empty-state__message {
      margin: 0 0 1em;
    }
  }

  table {
    width: 100%;
    margin-top: 10px;

    td {
      padding: 8px;
    }
  }

  thead {
    th {
      position: sticky;
      top: 0;
      color: var(--primary);
      background: var(--primary-low);
      z-index: z("base");
    }
  }

  .query-results-table-wrapper {
    overflow: auto;

    // cap a long table at the chart height so the actions below stay reachable
    max-height: clamp(200px, 50vh, 350px);

    &.--expanded {
      max-height: none;
    }
  }

  .query-results-expand-btn {
    width: 100%;
  }
}

.recent-queries {
  .d-table__header-cell {
    // DTableHeaderToggle carries directory-table header styles that don't suit d-table
    .directory-table__column-header.sortable {
      display: inline-flex;
      justify-content: flex-start;
      padding: 0;
      border-bottom: none;
      color: inherit;

      &:hover,
      &:focus {
        background-color: transparent;
      }

      .header-contents {
        text-align: left;
      }
    }

    &.query-created-by,
    &.query-group-names,
    &.query-created-at {
      width: 12.5%;
    }
  }

  .d-table__row.query-row {
    .d-table__overview-link {
      @include viewport.until(md) {
        max-width: 75ch;
      }
    }

    .query-name {
      color: var(--primary);
      max-width: 100%;
    }

    .query-desc {
      @include line-clamp(2);
      color: var(--primary-high);
    }

    .query-created-by {
      color: var(--primary-high);

      &__link {
        display: flex;
        width: fit-content;
        align-items: center;
        gap: var(--space-2);
      }
    }

    .query-group-names {
      .share-report {
        color: var(--tertiary);

        a {
          display: inline;
        }
      }
    }

    .group-names {
      @include viewport.until(md) {
        text-align: right;
      }
    }

    .query-created-at {
      color: var(--primary-medium);
    }

    .d-table__cell-actions .btn {
      min-width: 4.5em;
    }
  }

  .query-row:hover {
    background-color: inherit;
  }
}

.result-about {
  color: var(--primary-high);
}

.cached-result-notice {
  color: var(--primary-medium);
  font-size: var(--font-down-1);
  margin-left: auto;
}

.result-explain {
  padding-top: 1em;
  margin-bottom: 0;
}

.result-post-link {
  display: block;
  color: inherit !important;
}

.result-json {
  display: flex;
}

.query-result-hidden {
  color: var(--primary-medium);
}

.result-json-value {
  flex: 1;
  margin-right: 0.5em;
  max-width: 250px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.share-report {
  cursor: pointer;

  label {
    color: var(--primary-high);
  }

  input {
    margin-right: 4px;
  }

  .popup {
    background-color: var(--secondary);
    position: absolute;
    box-shadow: var(--shadow-card);
    padding: 12px;
    z-index: 1;
  }
}

.query-group-bookmark {
  &.bookmarked .d-icon {
    color: var(--tertiary);
  }
}