UNPKG

@wordpress/widget-dashboard

Version:

Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.

30 lines (29 loc) • 1.24 kB
import { __ } from "@wordpress/i18n"; import { drawerRight } from "@wordpress/icons"; import { IconButton } from "@wordpress/ui"; import { useWidgetSettingsToggle } from "./use-widget-settings-toggle.mjs"; import { jsx } from "react/jsx-runtime"; // packages/widget-dashboard/src/components/widget-settings/widget-settings-trigger.tsx /** * Per-instance control that toggles the shared settings surface; the single * `WidgetSettings` at the root reacts to it. Clicking the control of the * instance whose settings surface is already open closes it. Returns `null` * when no attribute needs that surface (none, or all already promoted to the * prominent one), so chrome can mount it unconditionally. * * @param {WidgetSettingsTriggerProps} props Component props. */ function WidgetSettingsTrigger({ widget, widgetType }) { const { toggle } = useWidgetSettingsToggle(widget); if (!widgetType.attributes?.some((attribute) => attribute.relevance !== "high")) return null; return /* @__PURE__ */ jsx(IconButton, { icon: drawerRight, label: __("Widget settings"), variant: "minimal", tone: "neutral", size: "compact", onClick: toggle }); } export { WidgetSettingsTrigger }; //# sourceMappingURL=widget-settings-trigger.mjs.map