iterative/vscode-dvc

View on GitHub
webview/src/experiments/components/table/styles.module.scss

Summary

Maintainability
Test Coverage
/* stylelint-disable no-descending-specificity */
/* stylelint-disable selector-max-class */
// Variables

@import '../../../shared/variables';
@import '../../../shared/mixins';

$nested-row-padding: 1.35rem;
$row-border: 1px solid $border-color;
$edge-padding: 0.8rem;
$cell-padding: 0.5rem;
$workspace-row-edge-margin: $edge-padding - $cell-padding;
$badge-size: 0.85rem;

// Extendable Silent Rules
%expandableRowArrow {
  width: 8px;
  height: 8px;
  top: 0;
  left: 0;
  display: inline-block;
  position: absolute;
  border: 2px solid $icon-color;
  border-top: unset;
  border-left: unset;
  transition:
    transform 0.2s,
    right 0.2s,
    bottom 0.2s;
  margin: 12px 6px;
}

%rowArrowContainer {
  width: 20px;
  height: 32px;
  padding: 0;
  flex: 0 0 20px;
  right: 6px;
  display: inline-block;
  position: relative;
  border: none;
  background: none;
}

%truncateLeftParent {
  overflow: hidden;
  text-overflow: ellipsis;
}

%truncateLeftChild {
  overflow: hidden;
  text-overflow: ellipsis;
  unicode-bidi: isolate;
  direction: ltr;
}

%headerCellPadding {
  padding: 0.1em 0;
}

%baseInnerCell {
  display: flex;
  flex-flow: row nowrap;
  padding: 0 $cell-padding;
  align-items: center;
  width: 100%;
  height: 100%;

  &:hover {
    & .copyButton {
      display: block;
    }
  }
}

%cellBorderLeft {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 100%;
  top: 0;
  background-color: transparent;
}

%headerCellBorderBottom {
  content: '';
  position: absolute;
  bottom: 0;
  top: auto;
  left: 1px;
  width: 100%;
  height: 1px;
  display: block;
  background-color: $header-border-color;
}

%cellContentsBase {
  overflow: hidden;
  text-overflow: ellipsis;
}

%noSelect {
  user-select: none;
}

%iconBox {
  background-color: $checkbox-background;
  border-radius: $checkbox-border-radius;
  border: $checkbox-border-width solid $checkbox-border;
  cursor: pointer;
  display: flex;
  height: $checkbox-size;
  width: $checkbox-size;
}

// Concrete selectors

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.isColumnResizing {
  @extend %noSelect;

  cursor: col-resize;

  * {
    cursor: col-resize;
  }
}

.experiments {
  box-sizing: border-box;
  height: 100%;
  display: flex;
  flex-flow: column nowrap;
}

.experimentsTable {
  display: inline-block;
  border-collapse: collapse;
}

.experimentsTr {
  position: relative;
  width: fit-content;
}

.experimentsTd,
.experimentsTh {
  white-space: nowrap;
  min-width: 0;
  position: relative;

  &:first-child {
    position: sticky;
    left: 0;
    z-index: 3;

    &::after {
      content: '';
      height: 100%;
      position: absolute;
      top: 0;
      width: 6px;
      right: 0;
      transition: box-shadow 0.25s;
    }
  }
}

.experimentsTable.withExpColumnShadow .experimentsTr > *:first-child {
  &::after {
    box-shadow: 3px 0 3px $shadow;
  }

  > div::after {
    display: none;
  }
}

.indicatorIcon {
  display: inline-block;
  position: relative;
  border: none;
  background: none;
  text-align: center;
  padding: 0.25rem;
  margin: 0.025rem;
  width: 1.5rem;
  height: 1.5rem;
  cursor: pointer;
  border-radius: $checkbox-border-radius;

  svg {
    fill: $icon-color;
  }

  &:disabled {
    opacity: 0.5;
    cursor: auto;
  }

  &:hover {
    background-color: $hover-background-color;
  }
}

.onlyChanged {
  background-color: $indicator-badge-background;

  svg {
    fill: $indicator-badge-foreground;
  }

  &:hover {
    background-color: $indicator-badge-background !important;
    opacity: 0.8;
  }
}

.indicatorCount {
  position: absolute;
  bottom: 3px;
  right: -2px;
  font-weight: bold;
  background-color: $indicator-badge-background;
  color: $indicator-badge-foreground;
  border-radius: 100%;
  width: $badge-size;
  height: $badge-size;
  line-height: $badge-size;
  text-align: center;
  vertical-align: middle;
  font-size: 0.5rem;

  &[aria-label='0'] {
    display: none;
  }
}

.cellContents {
  @extend %cellContentsBase;
}

// table head styles

.tableIndicators {
  display: inline-block;
  position: absolute;
  height: 0;
  overflow: visible;
  top: 0;
  left: 0;
  font-size: 0.7rem;
  padding: 0.2rem 0.7rem;
}

.experimentsThead {
  background-color: $bg-color;
  transition: 0.25s all;
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 5;
}

.experimentsTh {
  height: auto;
  font-size: 0.7rem;
  background-color: $header-bg-color;

  &::before {
    @extend %cellBorderLeft;

    background-color: $header-border-color;
  }

  .cellContents {
    @extend %truncateLeftChild;

    display: block;

    span[draggable='true'] {
      cursor: grab;
    }

    span[draggable='true']:hover {
      background-color: $hover-background-color;
    }
  }
}

.placeholderHeaderCell {
  &:first-child::before {
    display: none;
  }
}

.headerCell {
  color: $header-fg-color;
  text-align: center;
  font-weight: 400;

  &::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1px;
    width: 100%;
    height: 1px;
    background-color: $header-border-color;
  }

  &:first-child {
    &::after {
      bottom: auto;
      left: auto;
      background-color: transparent;
    }

    &::before {
      @extend %headerCellBorderBottom;
    }
  }

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

.headRow:last-child,
.firstLevelHeaderCell {
  .paramHeaderCell,
  &.paramHeaderCell {
    color: $params-color;
  }

  .metricHeaderCell,
  &.metricHeaderCell {
    color: $metrics-color;
  }

  .depHeaderCell,
  &.depHeaderCell {
    color: $deps-color;
  }
}

.dropTargetHeaderCell {
  background: $header-dnd-drop-background;
  outline: $header-dnd-outline dashed 2px;
  outline-offset: -4px;

  .iconMenu ul[role='menu'] {
    background-color: transparent;
  }
}

.cellDraggable {
  display: block;
  padding: 0.31rem $cell-padding;
}

.oneRowHeaderCell {
  vertical-align: bottom;
  height: 50px;
}

.iconMenu {
  position: absolute;
  left: 0;
  bottom: 0;
  padding-bottom: 3.5px;

  ul[role='menu'] {
    background-color: $header-bg-color;
    padding-left: 2px;
    margin: 0 0 0 4px;
    border: none;

    button {
      width: 13px;
      height: 11px;
    }

    svg {
      fill: currentcolor;
      transform: scale(0.7);
    }
  }
}

.moveToRight {
  left: auto;
  right: 0;

  ul[role='menu'] {
    margin: 0 4px 0 0;
  }
}

.timestampHeader {
  @extend %headerCellPadding;

  overflow-x: hidden;
  text-overflow: ellipsis;
  text-align: left;
  pointer-events: none;
}

.experimentHeader {
  @extend %headerCellPadding;

  padding-left: $cell-padding;
  text-align: left;
  direction: ltr;
  overflow-x: hidden;
  text-overflow: ellipsis;
}

.headerWithTooltip {
  display: flex;
}

.headerWithTooltipContents {
  display: flex;
  gap: 2px;
  align-items: center;

  svg {
    width: 16px;
    height: 16px;
    fill: $accent-color;
  }
}

.headerCellText {
  @extend %truncateLeftParent;
  @extend %headerCellPadding;

  direction: rtl;
  opacity: 0.6;

  // to prevent extra dragLeave and dragEnter fired
  // should be on parent div, not span to work on text-overflow: ellipsis
  pointer-events: none;

  .headRow:last-child & {
    opacity: 1;
  }
}

.columnResizer {
  right: -4px;
  width: 10px;
  height: 500%;
  position: absolute;
  bottom: 0;
  z-index: 1;
  touch-action: none;
  cursor: col-resize;

  &::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background-color: $header-resizer-color;
    display: none;
  }

  &:hover::after,
  &.isResizing::after {
    display: block;
  }
}

// table body styles

.bodyRow {
  border-bottom: $row-border;

  &:hover {
    .experimentsTd:not(.experimentCell):hover::before,
    .experimentsTd:hover + .experimentsTd::before {
      background-color: $border-color;
    }
  }
}

.workspaceRowGroup {
  border: none;
  position: sticky;
  top: var(--table-head-height);
  z-index: 4;

  &.withShadow {
    box-shadow: 0 5px 8px -2px $shadow;

    .experimentsTr {
      border-bottom: none;
    }
  }

  .rowActions {
    visibility: hidden;
  }

  .plotBox {
    visibility: visible;
  }

  .timestampInnerCell,
  .branchInnerCell,
  .commitInnerCell {
    height: 42px;
  }
}

.rowSelected {
  border-color: $row-border-selected-color;

  &:hover {
    &::after {
      box-shadow: inset 0 0 20px $shadow;
      content: '';
      top: 0;
      right: 0;
      width: 100%;
      height: 100%;
      z-index: 4;
      position: absolute;
      pointer-events: none;
    }

    .experimentsTd:not(.experimentCell):hover::before,
    .experimentsTd:hover + .experimentsTd::before {
      background-color: $row-border-selected-color;
    }
  }
}

.lastRowGroup {
  & > .experimentsTr:last-child {
    border-color: $row-bg-color;

    &.rowSelected {
      border-color: $row-bg-selected-color;
    }
  }

  .experimentGroup:last-child .experimentsTr:last-child {
    border-color: $row-bg-color;

    &.rowSelected {
      border-color: $row-bg-selected-color;
    }
  }
}

.experimentsTd {
  height: auto;
  font-size: 0.8rem;
  line-height: 2rem;
  align-items: center;
  background-color: $row-bg-color;

  &:not(.experimentCell)::before {
    @extend %cellBorderLeft;
  }

  .rowSelected & {
    &:not(.experimentCell) {
      color: $row-fg-selected-color;
      background-color: $row-bg-selected-color;
    }

    &.experimentCell::before {
      background-color: $row-bg-selected-color;
    }
  }

  .bodyRow:not(.rowSelected):hover & {
    &:not(.experimentCell),
    &.experimentCell::before {
      background-color: $row-hover-background-color;
    }
  }

  &:first-child {
    .innerCell {
      padding-left: $edge-padding;
    }
  }

  &:last-child {
    .innerCell {
      padding-right: $edge-padding;
    }
  }
}

.innerCell {
  @extend %baseInnerCell;

  justify-content: flex-end;
}

.experimentCell {
  &::before {
    content: '';
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    position: absolute;
    background-color: transparent;
  }

  .innerCell {
    display: flex;
    flex-flow: row nowrap;
    justify-content: flex-start;

    .nestedRow & {
      padding-left: calc($nested-row-padding + $edge-padding);
    }
  }
}

.rowActions {
  display: inline-flex;
  align-items: center;
  position: relative;
  left: -$cell-padding;
  height: 100%;

  &:first-child {
    margin-right: 4px;
  }

  .nestedRow & {
    left: calc(($cell-padding + $nested-row-padding) * -1);
  }

  .indicatorIcon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 2rem;
    padding: 0;
    margin: 0;
  }

  .indicatorCount {
    z-index: 2;

    &[title='0'] {
      display: none;
    }
  }
}

.starSwitch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  cursor: pointer;

  svg {
    fill: $icon-color;

    .rowSelected & {
      fill: $selected-icon-color;
    }
  }

  &[aria-checked='true'] svg {
    fill: $row-action-star-checked;
  }
}

.starSwitch .cellHintTooltip {
  font-size: 0.65rem;
}

.plotBox {
  @extend %iconBox;

  padding: 2px;
}

.remoteStatusBox {
  @extend %iconBox;

  padding: 1px;

  &[aria-disabled='true'] {
    cursor: default;
    opacity: 0.4;
  }
}

.cloudIndicator {
  height: 16px;
  width: 16px;
  margin-left: 2px;
}

.running {
  display: inline-flex;
  height: 12px;
  width: 12px;
  margin-right: 8px;
  margin-left: -20px;
}

.upload {
  display: inline-flex;
  margin-right: -18px;
  transform: translateX(-24px);
}

.queued {
  color: $icon-color;
  display: flex;
  height: 16px;
  left: 2px;
  position: relative;
  width: 16px;
  margin-right: 4px;
}

.rowArrowContainer {
  @extend %rowArrowContainer;

  cursor: pointer;
}

.emptyRowArrowContainer {
  @extend %rowArrowContainer;

  cursor: default;
}

.expandedRowArrow {
  @extend %expandableRowArrow;

  transform: rotate(45deg);
  right: 1px;
  bottom: 2px;

  .rowSelected & {
    border-color: $selected-icon-color;
  }
}

.contractedRowArrow {
  @extend %expandableRowArrow;

  transform: rotate(-45deg);
  right: 4px;
  bottom: 0;

  .rowSelected & {
    border-color: $selected-icon-color;
  }
}

.experimentCellTextWrapper {
  @extend %cellContentsBase;
}

.experimentCellText {
  @extend %cellContentsBase;

  display: block;
  line-height: normal;
  direction: ltr;
  cursor: text;

  > * {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.experimentCellSecondaryName {
  color: $meta-cell-color;
  font-size: 0.75em;
  display: block;

  > * {
    vertical-align: middle;
  }

  svg {
    min-width: 14px;
    min-height: 14px;
  }

  svg + span {
    margin-left: -4px;
  }
}

.experimentCellSecondaryNameTooltip {
  white-space: normal;
  padding: 5px;
  width: min-content;
  width: 100%;

  &,
  p,
  div,
  .tag {
    font-size: 0.9em;
  }

  *:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .sha {
    margin: 0 auto 0 0;
    font-size: 1em;

    svg {
      min-width: 14px;
      min-height: 14px;
    }
  }

  .tag {
    margin-left: 5px;

    &:first-of-type {
      margin-left: 50px;
    }
  }

  .message {
    white-space: pre-wrap;
    margin: 0;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.timestampInnerCell,
.branchInnerCell,
.commitInnerCell {
  @extend %baseInnerCell;
  @extend %truncateLeftParent;

  line-height: normal;
  text-align: left;
  height: 32px;
}

.timestampDate {
  @extend %truncateLeftChild;

  font-size: 0.7em;
}

.timestampTime {
  @extend %truncateLeftChild;

  font-size: 0.9em;
}

.commitInnerCell .cellContents {
  font-size: 0.7rem;

  > * {
    vertical-align: middle;
  }
}

.branchInnerCell .cellContents {
  display: flex;
  align-items: center;

  svg {
    fill: $accent-color;
    margin-right: 2px;
    min-width: 13px;
    min-height: 13px;
  }
}

.branchCellList {
  @extend %truncateLeftParent;

  display: flex;
  flex-direction: column;
  gap: 2px;
  font-weight: 600;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.6rem;

  li {
    @extend %truncateLeftChild;
  }
}

.branchCellListSingleItem {
  font-size: 0.65rem;
}

.cellTooltip {
  padding: 2px 6px;
}

.workspaceChangeText,
.depChangeText {
  color: $changed-color;
}

.errorText {
  color: $error-color;
}

// below table styles

.buttonAsLink {
  @extend %buttonAsLink;

  font-size: 0.65rem;
}

.addConfigButton {
  margin: 20px auto;
  text-align: center;

  p {
    opacity: 0.6;
    font-family: $font;
  }
}