@wordpress/block-editor
Version:
67 lines (66 loc) • 2.26 kB
JavaScript
// packages/block-editor/src/components/block-variation-picker/index.js
import clsx from "clsx";
import { __ } from "@wordpress/i18n";
import { Button, Placeholder } from "@wordpress/components";
import { layout } from "@wordpress/icons";
import { jsx, jsxs } from "react/jsx-runtime";
function BlockVariationPicker({
icon = layout,
label = __("Choose variation"),
instructions = __("Select a variation to start with:"),
variations,
onSelect,
allowSkip
}) {
const classes = clsx("block-editor-block-variation-picker", {
"has-many-variations": variations.length > 4
});
return /* @__PURE__ */ jsxs(
Placeholder,
{
icon,
label,
instructions,
className: classes,
children: [
/* @__PURE__ */ jsx(
"ul",
{
className: "block-editor-block-variation-picker__variations",
role: "list",
"aria-label": __("Block variations"),
children: variations.map((variation) => /* @__PURE__ */ jsxs("li", { children: [
/* @__PURE__ */ jsx(
Button,
{
__next40pxDefaultSize: true,
variant: "tertiary",
icon: variation.icon && variation.icon.src ? variation.icon.src : variation.icon,
iconSize: 48,
onClick: () => onSelect(variation),
className: "block-editor-block-variation-picker__variation",
label: variation.description || variation.title
}
),
/* @__PURE__ */ jsx("span", { className: "block-editor-block-variation-picker__variation-label", children: variation.title })
] }, variation.name))
}
),
allowSkip && /* @__PURE__ */ jsx("div", { className: "block-editor-block-variation-picker__skip", children: /* @__PURE__ */ jsx(
Button,
{
__next40pxDefaultSize: true,
variant: "link",
onClick: () => onSelect(),
children: __("Skip")
}
) })
]
}
);
}
var block_variation_picker_default = BlockVariationPicker;
export {
block_variation_picker_default as default
};
//# sourceMappingURL=index.js.map