1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-22 19:44:21 +00:00

Add support for Keyboard element

This commit is contained in:
Steffo 2022-03-12 05:16:49 +01:00
parent 87aa38b542
commit a66bc5a420
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,57 @@
import * as React from "react"
import * as ReactDOM from "react-dom"
import * as Decorators from "../../utils/Decorators"
import { Keyboard as KeyboardComponent } from "./Keyboard"
export default {
component: KeyboardComponent,
title: "Semantics/Keyboard",
decorators: [Decorators.Bluelib],
}
export const Simple = props => (
<KeyboardComponent {...props}>Ctrl</KeyboardComponent>
)
Simple.args = {
builtinColor: "red",
}
export const Pressed = props => (
<KeyboardComponent {...props}> Ctrl</KeyboardComponent>
)
Pressed.args = {
builtinColor: "red",
press: true,
}
export const Released = props => (
<KeyboardComponent {...props}> Ctrl</KeyboardComponent>
)
Released.args = {
builtinColor: "red",
release: true,
}
export const Combination = props => (
<KeyboardComponent {...props}>
<KeyboardComponent>
Ctrl
</KeyboardComponent>
&nbsp;+&nbsp;
<KeyboardComponent>
Alt
</KeyboardComponent>
&nbsp;+&nbsp;
<KeyboardComponent>
Del
</KeyboardComponent>
</KeyboardComponent>
)
Combination.args = {
builtinColor: "red",
}

View file

@ -0,0 +1,25 @@
import * as React from "react"
import * as ReactDOM from "react-dom"
import * as Types from "../../types"
import {BaseElement} from "../BaseElement"
import mergeClassNames from "classnames"
export interface KeyboardProps extends Types.BluelibHTMLProps<HTMLPreElement> {
press?: boolean,
release?: boolean,
}
export function Keyboard({press = false, release = false, ...props}: KeyboardProps): JSX.Element {
props.bluelibClassNames = mergeClassNames(
props.bluelibClassNames,
"semantic-kbd",
press && !release ? "semantic-kbd-press" : null,
release && !press ? "semantic-kbd-release" : null,
)
return (
<BaseElement kind={"kbd"} {...props}/>
)
}