UNPKG

@wordpress/components

Version:
47 lines (38 loc) 873 B
import { createElement } from "@wordpress/element"; /** * External dependencies */ import { isString, isObject } from 'lodash'; /** @typedef {string | { display: string, ariaLabel: string }} Shortcut */ /** * @typedef Props * @property {Shortcut} shortcut Shortcut configuration * @property {string} [className] Classname */ /** * @param {Props} props Props * @return {JSX.Element | null} Element */ function Shortcut({ shortcut, className }) { if (!shortcut) { return null; } let displayText; let ariaLabel; if (isString(shortcut)) { displayText = shortcut; } if (isObject(shortcut)) { displayText = shortcut.display; ariaLabel = shortcut.ariaLabel; } return createElement("span", { className: className, "aria-label": ariaLabel }, displayText); } export default Shortcut; //# sourceMappingURL=index.js.map