Files
WRNexusJS/packages/ui/components/Kbd.wrn
T

58 lines
1.7 KiB
Plaintext

// 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}' data-wrn-owner="Kbd" data-wrn-part="root" data-wrn-component="Kbd" data-wrn-axis-size='{size}' data-wrn-axis-color='{color}'>
<slot>{label}</slot>
</kbd>
}
style {
.wrn-kbd {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 1.5rem;
height: 1.5rem;
padding: 0 0.4rem;
border: 1px solid var(--wrn-color-border);
border-bottom-color: var(--wrn-color-border-strong, var(--wrn-color-border));
border-bottom-width: 2px;
border-radius: 0.375rem;
background: linear-gradient(180deg, var(--wrn-color-surface), var(--wrn-color-surface-soft, var(--wrn-color-surface)));
box-shadow: var(--wrn-highlight-edge, none), 0 1px 1px rgb(0 0 0 / 0.05);
color: var(--wrn-color-text-muted, var(--wrn-color-text));
font-family: var(--wrn-font-mono, monospace);
font-size: 0.72rem;
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;
}
}
}