UNPKG

@wordpress/global-styles-ui

Version:
67 lines (66 loc) • 3.25 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); // \0rolldown/runtime.js var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); let _wordpress_i18n = require("@wordpress/i18n"); let _wordpress_element = require("@wordpress/element"); let _wordpress_components = require("@wordpress/components"); let _wordpress_icons = require("@wordpress/icons"); let __font_demo_tsx = require("./font-demo.cjs"); __font_demo_tsx = __toESM(__font_demo_tsx); let react_jsx_runtime = require("react/jsx-runtime"); // packages/global-styles-ui/src/font-library/font-card.tsx function FontCard({ font, onClick, variantsText, navigatorPath, shouldFocus }) { const variantsCount = font.fontFace?.length || 1; const style = { cursor: !!onClick ? "pointer" : "default" }; const navigator = (0, _wordpress_components.useNavigator)(); const ref = (0, _wordpress_element.useRef)(null); (0, _wordpress_element.useEffect)(() => { if (shouldFocus) ref.current?.focus(); }, [shouldFocus]); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, { ref, __next40pxDefaultSize: true, onClick: () => { onClick(); if (navigatorPath) navigator.goTo(navigatorPath); }, style, className: "font-library__font-card", children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_components.Flex, { justify: "space-between", wrap: false, children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__font_demo_tsx.default, { font }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_components.Flex, { justify: "flex-end", children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.FlexItem, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalText, { className: "font-library__font-card__count", children: variantsText || (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._n)("%d variant", "%d variants", variantsCount), variantsCount) }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.FlexItem, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_icons.Icon, { icon: (0, _wordpress_i18n.isRTL)() ? _wordpress_icons.chevronLeft : _wordpress_icons.chevronRight }) })] })] }) }); } exports.default = FontCard; //# sourceMappingURL=font-card.cjs.map