PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.2.0
Tableberg – Simple Gutenberg Table Block v1.2.0
1.2.0 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 All 43 releases
tableberg / components / editor / TypographyPanelItem.tsx

TypographyPanelItem.tsx in Tableberg – Simple Gutenberg Table Block 1.2.0, at components/editor/TypographyPanelItem.tsx

64 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { ReactNode } from "react";
2 import { useBlockEditContext } from "@wordpress/block-editor";
3 import { __experimentalToolsPanelItem as ToolsPanelItem } from "@wordpress/components";
4
5 /**
6 * What every typography control below takes. The value is the plain CSS value
7 * the control edits, so a block can keep it wherever its attributes live.
8 */
9 export interface TypographyControlProps {
10 label?: string;
11 value: string;
12 onChange: (newValue: string) => void;
13 /** Defaults to clearing the value. */
14 onDeselect?: () => void;
15 resetAllFilter?: () => void;
16 isShownByDefault?: boolean;
17 /** Half width, so two controls sit side by side. */
18 isSingleColumn?: boolean;
19 /** Defaults to the block being edited. */
20 panelId?: string;
21 }
22
23 interface Props {
24 label: string;
25 hasValue: () => boolean;
26 onDeselect: () => void;
27 resetAllFilter?: () => void;
28 isShownByDefault?: boolean;
29 isSingleColumn?: boolean;
30 panelId?: string;
31 children: ReactNode;
32 }
33
34 /**
35 * The ToolsPanel plumbing the typography controls share: the menu entry, its
36 * reset and the two-column layout.
37 */
38 export default function TypographyPanelItem({
39 label,
40 hasValue,
41 onDeselect,
42 resetAllFilter,
43 isShownByDefault = false,
44 isSingleColumn = false,
45 panelId,
46 children,
47 }: Props) {
48 const { clientId } = useBlockEditContext();
49
50 return (
51 <ToolsPanelItem
52 panelId={panelId ?? clientId}
53 className={isSingleColumn ? "single-column" : undefined}
54 label={label}
55 hasValue={hasValue}
56 onDeselect={onDeselect}
57 resetAllFilter={resetAllFilter ?? onDeselect}
58 isShownByDefault={isShownByDefault}
59 >
60 {children}
61 </ToolsPanelItem>
62 );
63 }
64