Skip to content

The Open Standard for Generative UI

4.9 KB
Raw Blame
@use "../../cssUtils" as cssUtils;

.openui-icon-button {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  padding: 0;
  flex-shrink: 0;

  //icon
  &-icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  // variants
  &-primary {
    background-color: cssUtils.$interactive-accent-default;
    color: cssUtils.$text-accent-primary;
    border-color: cssUtils.$border-accent;
    box-shadow: cssUtils.$shadow-m;
    &:not(:disabled):hover {
      background-color: cssUtils.$interactive-accent-hover;
      box-shadow: none;
    }
    &:disabled {
      background-color: cssUtils.$interactive-accent-disabled;
      cursor: not-allowed;
      box-shadow: none;
    }
    &:not(:disabled):active {
      background-color: cssUtils.$interactive-accent-pressed;
    }
  }

  &-secondary {
    background-color: transparent;
    color: cssUtils.$text-neutral-primary;
    border-color: cssUtils.$border-interactive;
    box-shadow: cssUtils.$shadow-m;
    &:not(:disabled):hover {
      background-color: cssUtils.$highlight;
      box-shadow: none;
    }
    &:disabled {
      background-color: transparent;
      color: cssUtils.$text-neutral-tertiary;
      cursor: not-allowed;
      box-shadow: none;
    }
    &:not(:disabled):active {
      background-color: cssUtils.$highlight;
    }
  }

  &-tertiary {
    background-color: transparent;
    color: cssUtils.$text-neutral-primary;
    &:not(:disabled):hover {
      background-color: cssUtils.$highlight;
    }
    &:disabled {
      background-color: transparent;
      border-color: cssUtils.$border-default;
      color: cssUtils.$text-neutral-tertiary;
      cursor: not-allowed;
    }
    &:not(:disabled):active {
      background-color: cssUtils.$highlight;
      border-color: cssUtils.$border-interactive;
    }
  }

  // destructive variants
  &-destructive-primary {
    background-color: cssUtils.$interactive-destructive-accent-default;
    color: cssUtils.$text-danger-inverted-primary;
    border-color: cssUtils.$border-accent;
    &:not(:disabled):hover {
      background-color: cssUtils.$interactive-destructive-accent-hover;
    }
    &:disabled {
      background-color: cssUtils.$interactive-destructive-accent-disabled;
      cursor: not-allowed;
    }
    &:not(:disabled):active {
      background-color: cssUtils.$interactive-destructive-accent-pressed;
    }
  }

  &-destructive-secondary {
    background-color: cssUtils.$interactive-destructive-default;
    color: cssUtils.$text-danger-primary;
    border-color: cssUtils.$border-danger;
    &:not(:disabled):hover {
      background-color: cssUtils.$interactive-destructive-hover;
    }
    &:disabled {
      background-color: cssUtils.$interactive-destructive-disabled;
      color: cssUtils.$text-danger-tertiary;
      cursor: not-allowed;
    }
    &:not(:disabled):active {
      background-color: cssUtils.$interactive-destructive-hover;
    }
  }

  &-destructive-tertiary {
    background-color: transparent;
    border-color: transparent;
    color: cssUtils.$text-danger-primary;
    &:not(:disabled):hover {
      background-color: cssUtils.$interactive-destructive-hover;
    }
    &:disabled {
      color: cssUtils.$text-danger-tertiary;
      cursor: not-allowed;
    }
    &:not(:disabled):active {
      background-color: cssUtils.$interactive-destructive-hover;
      border-color: cssUtils.$border-danger;
    }
  }

  // sizes
  &-3-extra-small {
    width: 20px;
    height: 20px;

    & .openui-icon-button-icon {
      height: 10px;
      width: 10px;
    }
  }
  &-2-extra-small {
    width: 24px;
    height: 24px;

    & .openui-icon-button-icon {
      height: 12px;
      width: 12px;
    }
  }

  &-extra-small {
    width: 28px;
    height: 28px;

    & .openui-icon-button-icon {
      height: 14px;
      width: 14px;
    }
  }

  &-small {
    width: 32px;
    height: 32px;

    & .openui-icon-button-icon {
      height: 16px;
      width: 16px;
    }
  }

  &-medium {
    width: 36px;
    height: 36px;

    & .openui-icon-button-icon {
      height: 16px;
      width: 16px;
    }
  }

  &-large {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 16px;

    & .openui-icon-button-icon {
      height: 16px;
      width: 16px;
    }
  }

  // shapes
  &-square {
    border-radius: cssUtils.$radius-s;
    &.openui-icon-button-2-extra-small {
      border-radius: calc(cssUtils.$radius-s - 1px);
    }
    &.openui-icon-button-extra-small {
      border-radius: cssUtils.$radius-s;
    }
    &.openui-icon-button-small {
      border-radius: calc(cssUtils.$radius-s + 1px);
    }
    &.openui-icon-button-medium {
      border-radius: cssUtils.$radius-m;
    }
    &.openui-icon-button-large {
      border-radius: cssUtils.$radius-l;
    }
  }

  &-circle {
    border-radius: cssUtils.$radius-full;
  }
}