diff --git a/src/components/semantics/Keyboard.stories.jsx b/src/components/semantics/Keyboard.stories.jsx new file mode 100644 index 0000000..0da8351 --- /dev/null +++ b/src/components/semantics/Keyboard.stories.jsx @@ -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 => ( + Ctrl +) +Simple.args = { + builtinColor: "red", +} + + +export const Pressed = props => ( + ↓ Ctrl +) +Pressed.args = { + builtinColor: "red", + press: true, +} + + +export const Released = props => ( + ↑ Ctrl +) +Released.args = { + builtinColor: "red", + release: true, +} + + +export const Combination = props => ( + + + Ctrl + +  +  + + Alt + +  +  + + Del + + +) +Combination.args = { + builtinColor: "red", +} diff --git a/src/components/semantics/Keyboard.tsx b/src/components/semantics/Keyboard.tsx new file mode 100644 index 0000000..6b1eca4 --- /dev/null +++ b/src/components/semantics/Keyboard.tsx @@ -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 { + 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 ( + + ) +}