UNPKG

@wordpress/components

Version:
49 lines (47 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _jsxRuntime = require("react/jsx-runtime"); /** * Internal dependencies */ /** * Shortcut component is used to display keyboard shortcuts, and it can be customized with a custom display and aria label if needed. * * ```jsx * import { Shortcut } from '@wordpress/components'; * * const MyShortcut = () => { * return ( * <Shortcut shortcut={{ display: 'Ctrl + S', ariaLabel: 'Save' }} /> * ); * }; * ``` */ function Shortcut(props) { const { shortcut, className } = props; if (!shortcut) { return null; } let displayText; let ariaLabel; if (typeof shortcut === 'string') { displayText = shortcut; } if (shortcut !== null && typeof shortcut === 'object') { displayText = shortcut.display; ariaLabel = shortcut.ariaLabel; } return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", { className: className, "aria-label": ariaLabel, children: displayText }); } var _default = exports.default = Shortcut; //# sourceMappingURL=index.js.map