// Kbd -- a keyboard key.
//
//   <Kbd label="Ctrl" />
//
// Deliberately small. A kbd element is a kbd element; the work here is making
// it look like a key and follow the theme.
//
// NOTE: the style block uses /* */ comments only -- // is not a CSS comment
// and silently swallows the rule that follows it.
component Kbd {
  props {
    size: string = "default"
    color: string = "primary"
    label: string = "K"
    class: string = ""
  }

  view {
    <kbd {...attrs} class='wrn-kbd {class}' data-size='{size}' data-color='{color}'>
      <slot>{label}</slot>
    </kbd>
  }

  style {
    .wrn-kbd {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 1.6rem;
      padding: 0.15rem 0.4rem;
      border: 1px solid var(--wrn-color-border);
      /* The lower edge is what reads as a physical key. */
      border-bottom-width: 2px;
      border-radius: var(--wrn-radius-sm);
      background: var(--wrn-color-surface-soft);
      color: var(--wrn-color-text);
      font-family: inherit;
      font-size: 0.78rem;
      font-weight: 600;
      line-height: 1;
    }

    .wrn-kbd[data-size="sm"] {
      min-width: 1.4rem;
      padding: 0.1rem 0.3rem;
      font-size: 0.7rem;
    }

    .wrn-kbd[data-size="lg"] {
      min-width: 2rem;
      padding: 0.3rem 0.55rem;
      font-size: 0.9rem;
    }
  }
}
