Skip to content

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

1.7 KB
Raw Blame
.d-overflow-controls {
  --fade-width: 2rem;
  --fade-color: var(--secondary);

  // rem, because the button and the scroller resolve the value separately
  // and their font sizes can differ.
  --d-overflow-controls-btn-size: 1.5rem;
  position: relative;
  min-width: 0;
  min-height: 0;

  // The chevron is positioned against this wrapper, so it sits over the
  // strip's edge and the fade starts beyond it. Pad this wrapper on a
  // scrolling edge and that stops being true; pad the scroller instead.
  > [data-d-scroll-axis] {
    --fade-inset: var(--d-overflow-controls-btn-size);
  }

  &__content {
    @include scroll-strip;
  }

  &__btn {
    position: absolute;
    z-index: 2;
    background: var(--fade-color);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: var(--primary-high);
    user-select: none;
    -webkit-touch-callout: none;

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

    &.--left,
    &.--right {
      top: 0;
      bottom: 0;
      width: var(--d-overflow-controls-btn-size);
      margin-block: 1px;
    }

    &.--up,
    &.--down {
      left: 0;
      right: 0;
      height: var(--d-overflow-controls-btn-size);
      margin-inline: 1px;
    }

    &.--left {
      /*! rtl:ignore */
      left: 0;

      // Undo automatic icon flip since button stays in physical position
      .rtl & .d-icon {
        transform: scaleX(1);
      }
    }

    &.--right {
      /*! rtl:ignore */
      right: 0;

      // Undo automatic icon flip since button stays in physical position
      .rtl & .d-icon {
        transform: scaleX(1);
      }
    }

    &.--up {
      top: 0;
    }

    &.--down {
      bottom: 0;
    }
  }
}