@brilo/base-blocks 0.1.34 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.tsbuildinfo +1 -1
- package/build/blocks/sections/base-section/attributes.d.ts +4 -0
- package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
- package/build/blocks/sections/base-section/attributes.js +4 -0
- package/build/blocks/sections/base-section/constants.d.ts +48 -0
- package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.js +29 -0
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/controls.js +21 -3
- package/build/blocks/sections/base-section/types.d.ts +15 -1
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blocks/sections/base-section/attributes.ts +4 -0
- package/src/blocks/sections/base-section/constants.ts +36 -0
- package/src/blocks/sections/base-section/controls.tsx +142 -2
- package/src/blocks/sections/base-section/types.ts +18 -1
|
@@ -18,6 +18,10 @@ export declare const baseAttributes: {
|
|
|
18
18
|
readonly type: 'string';
|
|
19
19
|
readonly default: '';
|
|
20
20
|
};
|
|
21
|
+
readonly decoration: {
|
|
22
|
+
readonly type: 'object';
|
|
23
|
+
readonly default: {};
|
|
24
|
+
};
|
|
21
25
|
readonly decorations: {
|
|
22
26
|
readonly type: 'object';
|
|
23
27
|
readonly default: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/attributes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;aACzB,EAAE;iBACA,IAAI,EAAE,QAAQ;iBACd,OAAO,EAAE,EAAE;;aAEb,OAAO;iBACL,IAAI,EAAE,QAAQ;iBACd,OAAO;qBACL,QAAQ,EAAE,SAAS;qBACnB,IAAI,EAAE,SAAS;;;aAGnB,UAAU;iBACR,IAAI,EAAE,QAAQ;iBACd,OAAO,EAAE,EAAE;;aAEb,SAAS;iBACP,IAAI,EAAE,QAAQ;iBACd,OAAO,EAAE,EAAE;;aAEb,WAAW;iBACT,IAAI,EAAE,QAAQ;iBACd,OAAO;;CAED,CAAA"}
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/attributes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;aACzB,EAAE;iBACA,IAAI,EAAE,QAAQ;iBACd,OAAO,EAAE,EAAE;;aAEb,OAAO;iBACL,IAAI,EAAE,QAAQ;iBACd,OAAO;qBACL,QAAQ,EAAE,SAAS;qBACnB,IAAI,EAAE,SAAS;;;aAGnB,UAAU;iBACR,IAAI,EAAE,QAAQ;iBACd,OAAO,EAAE,EAAE;;aAEb,SAAS;iBACP,IAAI,EAAE,QAAQ;iBACd,OAAO,EAAE,EAAE;;aAEb,UAAU;iBACR,IAAI,EAAE,QAAQ;iBACd,OAAO;;aAET,WAAW;iBACT,IAAI,EAAE,QAAQ;iBACd,OAAO;;CAED,CAAA"}
|
|
@@ -19,4 +19,52 @@ export declare const FLUID_DECORATION_UNITS: {
|
|
|
19
19
|
label: string;
|
|
20
20
|
default: number;
|
|
21
21
|
}[];
|
|
22
|
+
export declare const DECORATION_POSITIONS: readonly [{
|
|
23
|
+
readonly value: 'top-left';
|
|
24
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Nahoře vlevo">;
|
|
25
|
+
}, {
|
|
26
|
+
readonly value: 'top-right';
|
|
27
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Nahoře vpravo">;
|
|
28
|
+
}, {
|
|
29
|
+
readonly value: 'center-left';
|
|
30
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Uprostřed vlevo">;
|
|
31
|
+
}, {
|
|
32
|
+
readonly value: 'center-right';
|
|
33
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Uprostřed vpravo">;
|
|
34
|
+
}, {
|
|
35
|
+
readonly value: 'bottom-left';
|
|
36
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Dole vlevo">;
|
|
37
|
+
}, {
|
|
38
|
+
readonly value: 'bottom-right';
|
|
39
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Dole vpravo">;
|
|
40
|
+
}];
|
|
41
|
+
export declare const DECORATION_DEPTHS: readonly [{
|
|
42
|
+
readonly value: 'front';
|
|
43
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Před obsahem">;
|
|
44
|
+
}, {
|
|
45
|
+
readonly value: 'under';
|
|
46
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Pod obsahem">;
|
|
47
|
+
}];
|
|
48
|
+
export declare const DECORATION_TRANSLATES: readonly [{
|
|
49
|
+
readonly value: 'in';
|
|
50
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Uvnitř">;
|
|
51
|
+
}, {
|
|
52
|
+
readonly value: 'center';
|
|
53
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Na okraji">;
|
|
54
|
+
}, {
|
|
55
|
+
readonly value: 'out';
|
|
56
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Venku">;
|
|
57
|
+
}];
|
|
58
|
+
export declare const DECORATION_MAX_WIDTH_DEFAULT = "120px";
|
|
59
|
+
export declare const DECORATION_MAX_WIDTH_UNITS: {
|
|
60
|
+
value: string;
|
|
61
|
+
label: string;
|
|
62
|
+
default: number;
|
|
63
|
+
}[];
|
|
64
|
+
export declare const DECORATION_OFFSET_DEFAULT = "0px";
|
|
65
|
+
export declare const DECORATION_OFFSET_UNITS: {
|
|
66
|
+
value: string;
|
|
67
|
+
label: string;
|
|
68
|
+
default: number;
|
|
69
|
+
}[];
|
|
22
70
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;aAC3B,KAAK,EAAE,SAAS;aAAE,KAAK;;aACvB,KAAK,EAAE,MAAM;aAAE,KAAK;;aACpB,KAAK,EAAE,UAAU;aAAE,KAAK;;aACxB,KAAK,EAAE,OAAO;aAAE,KAAK;EACd,CAAA;AAEV,eAAO,MAAM,aAAa,YAAI,SAAS,EAAE,IAAI,EAAE,IAAI,CAAU,CAAA;AAE7D,eAAO,MAAM,+BAA+B,YAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAU,CAAA;AAEzE,eAAO,MAAM,+BAA+B,SAAS,CAAA;AAErD,eAAO,MAAM,sBAAsB;;;;GAIlC,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;aAC3B,KAAK,EAAE,SAAS;aAAE,KAAK;;aACvB,KAAK,EAAE,MAAM;aAAE,KAAK;;aACpB,KAAK,EAAE,UAAU;aAAE,KAAK;;aACxB,KAAK,EAAE,OAAO;aAAE,KAAK;EACd,CAAA;AAEV,eAAO,MAAM,aAAa,YAAI,SAAS,EAAE,IAAI,EAAE,IAAI,CAAU,CAAA;AAE7D,eAAO,MAAM,+BAA+B,YAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAU,CAAA;AAEzE,eAAO,MAAM,+BAA+B,SAAS,CAAA;AAErD,eAAO,MAAM,sBAAsB;;;;GAIlC,CAAA;AAED,eAAO,MAAM,oBAAoB;aAC9B,KAAK,EAAE,UAAU;aAAE,KAAK;;aACxB,KAAK,EAAE,WAAW;aAAE,KAAK;;aACzB,KAAK,EAAE,aAAa;aAAE,KAAK;;aAC3B,KAAK,EAAE,cAAc;aAAE,KAAK;;aAC5B,KAAK,EAAE,aAAa;aAAE,KAAK;;aAC3B,KAAK,EAAE,cAAc;aAAE,KAAK;EACrB,CAAA;AAEV,eAAO,MAAM,iBAAiB;aAC3B,KAAK,EAAE,OAAO;aAAE,KAAK;;aACrB,KAAK,EAAE,OAAO;aAAE,KAAK;EACd,CAAA;AAEV,eAAO,MAAM,qBAAqB;aAC/B,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,QAAQ;aAAE,KAAK;;aACtB,KAAK,EAAE,KAAK;aAAE,KAAK;EACZ,CAAA;AAEV,eAAO,MAAM,4BAA4B,UAAU,CAAA;AAEnD,eAAO,MAAM,0BAA0B;;;;GAItC,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAQ,CAAA;AAE9C,eAAO,MAAM,uBAAuB;;;;GAInC,CAAA"}
|
|
@@ -13,3 +13,32 @@ export const FLUID_DECORATION_UNITS = [
|
|
|
13
13
|
{ value: 'rem', label: 'rem', default: 3.5 },
|
|
14
14
|
{ value: '%', label: '%', default: 10 },
|
|
15
15
|
];
|
|
16
|
+
export const DECORATION_POSITIONS = [
|
|
17
|
+
{ value: 'top-left', label: __('Nahoře vlevo', 'brilo-blocks') },
|
|
18
|
+
{ value: 'top-right', label: __('Nahoře vpravo', 'brilo-blocks') },
|
|
19
|
+
{ value: 'center-left', label: __('Uprostřed vlevo', 'brilo-blocks') },
|
|
20
|
+
{ value: 'center-right', label: __('Uprostřed vpravo', 'brilo-blocks') },
|
|
21
|
+
{ value: 'bottom-left', label: __('Dole vlevo', 'brilo-blocks') },
|
|
22
|
+
{ value: 'bottom-right', label: __('Dole vpravo', 'brilo-blocks') },
|
|
23
|
+
];
|
|
24
|
+
export const DECORATION_DEPTHS = [
|
|
25
|
+
{ value: 'front', label: __('Před obsahem', 'brilo-blocks') },
|
|
26
|
+
{ value: 'under', label: __('Pod obsahem', 'brilo-blocks') },
|
|
27
|
+
];
|
|
28
|
+
export const DECORATION_TRANSLATES = [
|
|
29
|
+
{ value: 'in', label: __('Uvnitř', 'brilo-blocks') },
|
|
30
|
+
{ value: 'center', label: __('Na okraji', 'brilo-blocks') },
|
|
31
|
+
{ value: 'out', label: __('Venku', 'brilo-blocks') },
|
|
32
|
+
];
|
|
33
|
+
export const DECORATION_MAX_WIDTH_DEFAULT = '120px';
|
|
34
|
+
export const DECORATION_MAX_WIDTH_UNITS = [
|
|
35
|
+
{ value: 'px', label: 'px', default: 120 },
|
|
36
|
+
{ value: 'rem', label: 'rem', default: 7.5 },
|
|
37
|
+
{ value: '%', label: '%', default: 50 },
|
|
38
|
+
];
|
|
39
|
+
export const DECORATION_OFFSET_DEFAULT = '0px';
|
|
40
|
+
export const DECORATION_OFFSET_UNITS = [
|
|
41
|
+
{ value: 'px', label: 'px', default: 0 },
|
|
42
|
+
{ value: 'rem', label: 'rem', default: 0 },
|
|
43
|
+
{ value: '%', label: '%', default: 0 },
|
|
44
|
+
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/controls.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/controls.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,mBAAmB,EAMnB,kBAAkB,EAGnB,MAAM,SAAS,CAAA;AAqMhB,UAAU,iBAAiB;IACzB,UAAU,EAAE,mBAAmB,CAAA;IAC/B,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;IAC5D,OAAO,EAAE,kBAAkB,EAAE,CAAA;CAC9B;AAED,wBAAgB,YAAY,CAAC,EAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAC,EAAE,iBAAiB,+BA4EnF"}
|
|
@@ -3,7 +3,7 @@ import { ColorPalette, ContrastChecker, MediaUpload, MediaUploadCheck } from '@w
|
|
|
3
3
|
import { BaseControl, Button, ButtonGroup, PanelBody, PanelRow, SelectControl, TextControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalUnitControl as UnitControl, } from '@wordpress/components';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useTenantColorPalette } from '../../../hooks/useTenantColorPalette';
|
|
6
|
-
import { FLUID_DECORATION_DEFAULT_HEIGHT, FLUID_DECORATION_HEIGHT_PRESETS, FLUID_DECORATION_UNITS, SPACING_POSITIONS, SPACING_SIZES, } from './constants';
|
|
6
|
+
import { DECORATION_DEPTHS, DECORATION_MAX_WIDTH_DEFAULT, DECORATION_MAX_WIDTH_UNITS, DECORATION_OFFSET_DEFAULT, DECORATION_OFFSET_UNITS, DECORATION_POSITIONS, DECORATION_TRANSLATES, FLUID_DECORATION_DEFAULT_HEIGHT, FLUID_DECORATION_HEIGHT_PRESETS, FLUID_DECORATION_UNITS, SPACING_POSITIONS, SPACING_SIZES, } from './constants';
|
|
7
7
|
function FluidDecorationControl({ label, value, onChange }) {
|
|
8
8
|
var _a;
|
|
9
9
|
const img = value === null || value === void 0 ? void 0 : value.img;
|
|
@@ -16,14 +16,32 @@ function FluidDecorationControl({ label, value, onChange }) {
|
|
|
16
16
|
const handleRemove = () => onChange(undefined);
|
|
17
17
|
return (_jsxs(BaseControl, { label: label, __nextHasNoMarginBottom: true, children: [_jsx(MediaUploadCheck, { children: _jsx(MediaUpload, { onSelect: handleSelect, allowedTypes: ['image'], value: (img === null || img === void 0 ? void 0 : img.id) || 0, render: ({ open }) => (_jsxs(PanelRow, { children: [(img === null || img === void 0 ? void 0 : img.src) && _jsx("img", { src: img.src, alt: img.alt, style: { maxWidth: 48, maxHeight: 48, objectFit: 'contain' } }), _jsx(Button, { onClick: open, variant: "secondary", size: "small", children: (img === null || img === void 0 ? void 0 : img.src) ? __('Změnit', 'brilo-blocks') : __('Vybrat obrázek', 'brilo-blocks') }), !!(img === null || img === void 0 ? void 0 : img.src) && (_jsx(Button, { onClick: handleRemove, variant: "tertiary", size: "small", isDestructive: true, children: __('Odebrat', 'brilo-blocks') }))] })) }) }), !!(img === null || img === void 0 ? void 0 : img.src) && (_jsxs(_Fragment, { children: [_jsx(UnitControl, { label: __('Výška', 'brilo-blocks'), value: height, units: FLUID_DECORATION_UNITS, onChange: (next) => { var _a; return onChange({ img, height: (_a = next) !== null && _a !== void 0 ? _a : FLUID_DECORATION_DEFAULT_HEIGHT }); } }), _jsx(ButtonGroup, { children: FLUID_DECORATION_HEIGHT_PRESETS.map((preset) => (_jsx(Button, { variant: "secondary", size: "small", onClick: () => onChange({ img, height: `${preset}px` }), children: preset }, preset))) })] }))] }));
|
|
18
18
|
}
|
|
19
|
+
function DecorationControl({ value, onChange }) {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
|
+
const img = value === null || value === void 0 ? void 0 : value.img;
|
|
22
|
+
const position = (_a = value === null || value === void 0 ? void 0 : value.position) !== null && _a !== void 0 ? _a : 'top-right';
|
|
23
|
+
const depth = (_b = value === null || value === void 0 ? void 0 : value.depth) !== null && _b !== void 0 ? _b : 'front';
|
|
24
|
+
const translate = (_c = value === null || value === void 0 ? void 0 : value.translate) !== null && _c !== void 0 ? _c : 'center';
|
|
25
|
+
const maxWidth = (_d = value === null || value === void 0 ? void 0 : value.maxWidth) !== null && _d !== void 0 ? _d : DECORATION_MAX_WIDTH_DEFAULT;
|
|
26
|
+
const offsetX = (_e = value === null || value === void 0 ? void 0 : value.offsetX) !== null && _e !== void 0 ? _e : DECORATION_OFFSET_DEFAULT;
|
|
27
|
+
const offsetY = (_f = value === null || value === void 0 ? void 0 : value.offsetY) !== null && _f !== void 0 ? _f : DECORATION_OFFSET_DEFAULT;
|
|
28
|
+
const update = (patch) => onChange({ img, position, depth, translate, maxWidth, offsetX, offsetY, ...value, ...patch });
|
|
29
|
+
const handleSelect = (media) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const nextImg = { id: media.id, src: media.url, alt: (_a = media.alt) !== null && _a !== void 0 ? _a : '', width: media.width, height: media.height };
|
|
32
|
+
update({ img: nextImg });
|
|
33
|
+
};
|
|
34
|
+
const handleRemove = () => onChange(undefined);
|
|
35
|
+
return (_jsxs(BaseControl, { label: __('Obrázek', 'brilo-blocks'), __nextHasNoMarginBottom: true, children: [_jsx(MediaUploadCheck, { children: _jsx(MediaUpload, { onSelect: handleSelect, allowedTypes: ['image'], value: (img === null || img === void 0 ? void 0 : img.id) || 0, render: ({ open }) => (_jsxs(PanelRow, { children: [(img === null || img === void 0 ? void 0 : img.src) && _jsx("img", { src: img.src, alt: img.alt, style: { maxWidth: 48, maxHeight: 48, objectFit: 'contain' } }), _jsx(Button, { onClick: open, variant: "secondary", size: "small", children: (img === null || img === void 0 ? void 0 : img.src) ? __('Změnit', 'brilo-blocks') : __('Vybrat obrázek', 'brilo-blocks') }), !!(img === null || img === void 0 ? void 0 : img.src) && (_jsx(Button, { onClick: handleRemove, variant: "tertiary", size: "small", isDestructive: true, children: __('Odebrat', 'brilo-blocks') }))] })) }) }), !!(img === null || img === void 0 ? void 0 : img.src) && (_jsxs(_Fragment, { children: [_jsx(BaseControl, { label: __('Pozice', 'brilo-blocks'), __nextHasNoMarginBottom: true, children: _jsx("div", { style: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 4 }, children: DECORATION_POSITIONS.map((p) => (_jsx(Button, { variant: "secondary", size: "small", isPressed: position === p.value, onClick: () => update({ position: p.value }), children: p.label }, p.value))) }) }), _jsx(ToggleGroupControl, { label: __('Vrstva', 'brilo-blocks'), value: depth, onChange: (next) => update({ depth: next }), isBlock: true, children: DECORATION_DEPTHS.map((d) => (_jsx(ToggleGroupControlOption, { value: d.value, label: d.label }, d.value))) }), _jsx(ToggleGroupControl, { label: __('Přesah', 'brilo-blocks'), value: translate, onChange: (next) => update({ translate: next }), isBlock: true, children: DECORATION_TRANSLATES.map((t) => (_jsx(ToggleGroupControlOption, { value: t.value, label: t.label }, t.value))) }), _jsx(UnitControl, { label: __('Max. šířka obrázku', 'brilo-blocks'), value: maxWidth, units: DECORATION_MAX_WIDTH_UNITS, onChange: (next) => { var _a; return update({ maxWidth: (_a = next) !== null && _a !== void 0 ? _a : DECORATION_MAX_WIDTH_DEFAULT }); } }), _jsxs(BaseControl, { label: __('Doladění pozice', 'brilo-blocks'), __nextHasNoMarginBottom: true, help: __('Ruční posun obrázku navíc k vybrané pozici.', 'brilo-blocks'), children: [_jsx(UnitControl, { label: __('Posun X', 'brilo-blocks'), value: offsetX, units: DECORATION_OFFSET_UNITS, onChange: (next) => { var _a; return update({ offsetX: (_a = next) !== null && _a !== void 0 ? _a : DECORATION_OFFSET_DEFAULT }); } }), _jsx(UnitControl, { label: __('Posun Y', 'brilo-blocks'), value: offsetY, units: DECORATION_OFFSET_UNITS, onChange: (next) => { var _a; return update({ offsetY: (_a = next) !== null && _a !== void 0 ? _a : DECORATION_OFFSET_DEFAULT }); } })] })] }))] }));
|
|
36
|
+
}
|
|
19
37
|
export function BaseControls({ attributes, setAttributes, exclude }) {
|
|
20
38
|
var _a;
|
|
21
|
-
const { id, spacing, background, textColor, decorations } = attributes;
|
|
39
|
+
const { id, spacing, background, textColor, decoration, decorations } = attributes;
|
|
22
40
|
const { paletteColors, resolveHex } = useTenantColorPalette();
|
|
23
41
|
const fluid = (_a = decorations === null || decorations === void 0 ? void 0 : decorations.fluid) !== null && _a !== void 0 ? _a : {};
|
|
24
42
|
const setFluid = (position, value) => {
|
|
25
43
|
const nextFluid = { ...fluid, [position]: value };
|
|
26
44
|
setAttributes({ decorations: { ...decorations, fluid: nextFluid } });
|
|
27
45
|
};
|
|
28
|
-
return (_jsxs(_Fragment, { children: [!exclude.includes('spacing') && (_jsxs(PanelBody, { title: __('Rozestupy', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Pozice', 'brilo-blocks'), value: spacing.position, options: [...SPACING_POSITIONS], onChange: (value) => setAttributes({ spacing: { ...spacing, position: value } }) }), _jsx(ToggleGroupControl, { label: __('Velikost', 'brilo-blocks'), value: spacing.size, onChange: (value) => setAttributes({ spacing: { ...spacing, size: value } }), isBlock: true, children: SPACING_SIZES.map((s) => (_jsx(ToggleGroupControlOption, { value: s, label: s === 'default' ? __('Výchozí', 'brilo-blocks') : s.toUpperCase() }, s))) })] })), !exclude.includes('background') && (_jsxs(PanelBody, { title: __('Barvy', 'brilo-blocks'), children: [_jsx("p", { children: __('Pozadí', 'brilo-blocks') }), _jsx(ColorPalette, { colors: paletteColors, value: background || undefined, onChange: (value) => setAttributes({ background: value !== null && value !== void 0 ? value : '' }) }), _jsx("p", { children: __('Barva textu', 'brilo-blocks') }), _jsx(ColorPalette, { colors: paletteColors, value: textColor || undefined, onChange: (value) => setAttributes({ textColor: value !== null && value !== void 0 ? value : '' }) }), !!background && !!textColor && _jsx(ContrastChecker, { backgroundColor: resolveHex(background), textColor: resolveHex(textColor) })] })), !exclude.includes('decorations') && (_jsxs(PanelBody, { title: __('Fluidní dekorace', 'brilo-blocks'), initialOpen: false, children: [_jsx(FluidDecorationControl, { label: __('Nahoře', 'brilo-blocks'), value: fluid.top, onChange: (value) => setFluid('top', value) }), _jsx(FluidDecorationControl, { label: __('Dole', 'brilo-blocks'), value: fluid.bottom, onChange: (value) => setFluid('bottom', value) })] })), !exclude.includes('id') && (_jsx(PanelBody, { title: __('Kotva', 'brilo-blocks'), initialOpen: false, children: _jsx(TextControl, { label: __('ID sekce', 'brilo-blocks'), value: id !== null && id !== void 0 ? id : '', onChange: (value) => setAttributes({ id: value }), help: __('Použije se jako HTML atribut id pro kotevní odkaz.', 'brilo-blocks') }) }))] }));
|
|
46
|
+
return (_jsxs(_Fragment, { children: [!exclude.includes('spacing') && (_jsxs(PanelBody, { title: __('Rozestupy', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Pozice', 'brilo-blocks'), value: spacing.position, options: [...SPACING_POSITIONS], onChange: (value) => setAttributes({ spacing: { ...spacing, position: value } }) }), _jsx(ToggleGroupControl, { label: __('Velikost', 'brilo-blocks'), value: spacing.size, onChange: (value) => setAttributes({ spacing: { ...spacing, size: value } }), isBlock: true, children: SPACING_SIZES.map((s) => (_jsx(ToggleGroupControlOption, { value: s, label: s === 'default' ? __('Výchozí', 'brilo-blocks') : s.toUpperCase() }, s))) })] })), !exclude.includes('background') && (_jsxs(PanelBody, { title: __('Barvy', 'brilo-blocks'), children: [_jsx("p", { children: __('Pozadí', 'brilo-blocks') }), _jsx(ColorPalette, { colors: paletteColors, value: background || undefined, onChange: (value) => setAttributes({ background: value !== null && value !== void 0 ? value : '' }) }), _jsx("p", { children: __('Barva textu', 'brilo-blocks') }), _jsx(ColorPalette, { colors: paletteColors, value: textColor || undefined, onChange: (value) => setAttributes({ textColor: value !== null && value !== void 0 ? value : '' }) }), !!background && !!textColor && _jsx(ContrastChecker, { backgroundColor: resolveHex(background), textColor: resolveHex(textColor) })] })), !exclude.includes('decoration') && (_jsx(PanelBody, { title: __('Dekorace', 'brilo-blocks'), initialOpen: false, children: _jsx(DecorationControl, { value: decoration, onChange: (value) => setAttributes({ decoration: value !== null && value !== void 0 ? value : {} }) }) })), !exclude.includes('decorations') && (_jsxs(PanelBody, { title: __('Fluidní dekorace', 'brilo-blocks'), initialOpen: false, children: [_jsx(FluidDecorationControl, { label: __('Nahoře', 'brilo-blocks'), value: fluid.top, onChange: (value) => setFluid('top', value) }), _jsx(FluidDecorationControl, { label: __('Dole', 'brilo-blocks'), value: fluid.bottom, onChange: (value) => setFluid('bottom', value) })] })), !exclude.includes('id') && (_jsx(PanelBody, { title: __('Kotva', 'brilo-blocks'), initialOpen: false, children: _jsx(TextControl, { label: __('ID sekce', 'brilo-blocks'), value: id !== null && id !== void 0 ? id : '', onChange: (value) => setAttributes({ id: value }), help: __('Použije se jako HTML atribut id pro kotevní odkaz.', 'brilo-blocks') }) }))] }));
|
|
29
47
|
}
|
|
@@ -12,6 +12,19 @@ export interface FluidDecoration {
|
|
|
12
12
|
img?: FluidDecorationImage;
|
|
13
13
|
height: string;
|
|
14
14
|
}
|
|
15
|
+
export type DecorationImage = FluidDecorationImage;
|
|
16
|
+
export type DecorationPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center-left' | 'center-right';
|
|
17
|
+
export type DecorationDepth = 'front' | 'under';
|
|
18
|
+
export type DecorationTranslate = 'in' | 'center' | 'out';
|
|
19
|
+
export interface Decoration {
|
|
20
|
+
img?: DecorationImage;
|
|
21
|
+
position?: DecorationPosition;
|
|
22
|
+
depth?: DecorationDepth;
|
|
23
|
+
translate?: DecorationTranslate;
|
|
24
|
+
maxWidth?: string;
|
|
25
|
+
offsetX?: string;
|
|
26
|
+
offsetY?: string;
|
|
27
|
+
}
|
|
15
28
|
export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
16
29
|
id: string;
|
|
17
30
|
spacing: {
|
|
@@ -20,6 +33,7 @@ export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
|
20
33
|
};
|
|
21
34
|
background: string;
|
|
22
35
|
textColor: string;
|
|
36
|
+
decoration: Decoration;
|
|
23
37
|
decorations: {
|
|
24
38
|
fluid?: {
|
|
25
39
|
top?: FluidDecoration;
|
|
@@ -27,7 +41,7 @@ export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
|
27
41
|
};
|
|
28
42
|
};
|
|
29
43
|
}
|
|
30
|
-
export type ExcludableBaseAttr = 'spacing' | 'background' | 'id' | 'decorations';
|
|
44
|
+
export type ExcludableBaseAttr = 'spacing' | 'background' | 'id' | 'decorations' | 'decoration';
|
|
31
45
|
export interface BaseSectionOptions<TExtra extends Record<string, unknown> = Record<string, never>> extends BriloBlockType {
|
|
32
46
|
supports?: BlockConfiguration['supports'];
|
|
33
47
|
extraAttributes?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAA;AACpC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,oBAAoB,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE;QACX,KAAK,CAAC,EAAE;YACN,GAAG,CAAC,EAAE,eAAe,CAAA;YACrB,MAAM,CAAC,EAAE,eAAe,CAAA;SACzB,CAAA;KACF,CAAA;CACF;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,GAAG,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAA;AACpC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,oBAAoB,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAA;AAElD,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,cAAc,CAAA;AAC3H,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,CAAA;AAC/C,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAA;AAEzD,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,eAAe,CAAA;IACrB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,SAAS,CAAC,EAAE,mBAAmB,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE;QACX,KAAK,CAAC,EAAE;YACN,GAAG,CAAC,EAAE,eAAe,CAAA;YACrB,MAAM,CAAC,EAAE,eAAe,CAAA;SACzB,CAAA;KACF,CAAA;CACF;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,GAAG,aAAa,GAAG,YAAY,CAAA;AAE/F,MAAM,WAAW,kBAAkB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAE,SAAQ,cAAc;IACxH,QAAQ,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAA;IACzC,eAAe,CAAC,EAAE;SACf,CAAC,IAAI,MAAM,MAAM,GAAG;YACnB,IAAI,EAAE,MAAM,CAAA;YACZ,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;SACnB;KACF,CAAA;IACD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,mBAAmB,GAAG,MAAM,CAAC,KAAK,SAAS,CAAA;IAClF,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAC/B"}
|
package/package.json
CHANGED
|
@@ -18,3 +18,39 @@ export const FLUID_DECORATION_UNITS = [
|
|
|
18
18
|
{value: 'rem', label: 'rem', default: 3.5},
|
|
19
19
|
{value: '%', label: '%', default: 10},
|
|
20
20
|
]
|
|
21
|
+
|
|
22
|
+
export const DECORATION_POSITIONS = [
|
|
23
|
+
{value: 'top-left', label: __('Nahoře vlevo', 'brilo-blocks')},
|
|
24
|
+
{value: 'top-right', label: __('Nahoře vpravo', 'brilo-blocks')},
|
|
25
|
+
{value: 'center-left', label: __('Uprostřed vlevo', 'brilo-blocks')},
|
|
26
|
+
{value: 'center-right', label: __('Uprostřed vpravo', 'brilo-blocks')},
|
|
27
|
+
{value: 'bottom-left', label: __('Dole vlevo', 'brilo-blocks')},
|
|
28
|
+
{value: 'bottom-right', label: __('Dole vpravo', 'brilo-blocks')},
|
|
29
|
+
] as const
|
|
30
|
+
|
|
31
|
+
export const DECORATION_DEPTHS = [
|
|
32
|
+
{value: 'front', label: __('Před obsahem', 'brilo-blocks')},
|
|
33
|
+
{value: 'under', label: __('Pod obsahem', 'brilo-blocks')},
|
|
34
|
+
] as const
|
|
35
|
+
|
|
36
|
+
export const DECORATION_TRANSLATES = [
|
|
37
|
+
{value: 'in', label: __('Uvnitř', 'brilo-blocks')},
|
|
38
|
+
{value: 'center', label: __('Na okraji', 'brilo-blocks')},
|
|
39
|
+
{value: 'out', label: __('Venku', 'brilo-blocks')},
|
|
40
|
+
] as const
|
|
41
|
+
|
|
42
|
+
export const DECORATION_MAX_WIDTH_DEFAULT = '120px'
|
|
43
|
+
|
|
44
|
+
export const DECORATION_MAX_WIDTH_UNITS = [
|
|
45
|
+
{value: 'px', label: 'px', default: 120},
|
|
46
|
+
{value: 'rem', label: 'rem', default: 7.5},
|
|
47
|
+
{value: '%', label: '%', default: 50},
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
export const DECORATION_OFFSET_DEFAULT = '0px'
|
|
51
|
+
|
|
52
|
+
export const DECORATION_OFFSET_UNITS = [
|
|
53
|
+
{value: 'px', label: 'px', default: 0},
|
|
54
|
+
{value: 'rem', label: 'rem', default: 0},
|
|
55
|
+
{value: '%', label: '%', default: 0},
|
|
56
|
+
]
|
|
@@ -13,8 +13,25 @@ import {
|
|
|
13
13
|
} from '@wordpress/components'
|
|
14
14
|
import {__} from '@wordpress/i18n'
|
|
15
15
|
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
16
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
BaseBlockAttributes,
|
|
18
|
+
Decoration,
|
|
19
|
+
DecorationDepth,
|
|
20
|
+
DecorationImage,
|
|
21
|
+
DecorationPosition,
|
|
22
|
+
DecorationTranslate,
|
|
23
|
+
ExcludableBaseAttr,
|
|
24
|
+
FluidDecoration,
|
|
25
|
+
FluidDecorationImage,
|
|
26
|
+
} from './types'
|
|
17
27
|
import {
|
|
28
|
+
DECORATION_DEPTHS,
|
|
29
|
+
DECORATION_MAX_WIDTH_DEFAULT,
|
|
30
|
+
DECORATION_MAX_WIDTH_UNITS,
|
|
31
|
+
DECORATION_OFFSET_DEFAULT,
|
|
32
|
+
DECORATION_OFFSET_UNITS,
|
|
33
|
+
DECORATION_POSITIONS,
|
|
34
|
+
DECORATION_TRANSLATES,
|
|
18
35
|
FLUID_DECORATION_DEFAULT_HEIGHT,
|
|
19
36
|
FLUID_DECORATION_HEIGHT_PRESETS,
|
|
20
37
|
FLUID_DECORATION_UNITS,
|
|
@@ -83,6 +100,123 @@ function FluidDecorationControl({label, value, onChange}: FluidDecorationControl
|
|
|
83
100
|
)
|
|
84
101
|
}
|
|
85
102
|
|
|
103
|
+
interface DecorationControlProps {
|
|
104
|
+
value?: Decoration
|
|
105
|
+
onChange: (value: Decoration | undefined) => void
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function DecorationControl({value, onChange}: DecorationControlProps) {
|
|
109
|
+
const img = value?.img
|
|
110
|
+
const position = value?.position ?? 'top-right'
|
|
111
|
+
const depth = value?.depth ?? 'front'
|
|
112
|
+
const translate = value?.translate ?? 'center'
|
|
113
|
+
const maxWidth = value?.maxWidth ?? DECORATION_MAX_WIDTH_DEFAULT
|
|
114
|
+
const offsetX = value?.offsetX ?? DECORATION_OFFSET_DEFAULT
|
|
115
|
+
const offsetY = value?.offsetY ?? DECORATION_OFFSET_DEFAULT
|
|
116
|
+
|
|
117
|
+
const update = (patch: Partial<Decoration>) => onChange({img, position, depth, translate, maxWidth, offsetX, offsetY, ...value, ...patch})
|
|
118
|
+
|
|
119
|
+
const handleSelect = (media: {id: number; url: string; alt: string; width?: number; height?: number}) => {
|
|
120
|
+
const nextImg: DecorationImage = {id: media.id, src: media.url, alt: media.alt ?? '', width: media.width, height: media.height}
|
|
121
|
+
update({img: nextImg})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const handleRemove = () => onChange(undefined)
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<BaseControl label={__('Obrázek', 'brilo-blocks')} __nextHasNoMarginBottom>
|
|
128
|
+
<MediaUploadCheck>
|
|
129
|
+
<MediaUpload
|
|
130
|
+
onSelect={handleSelect}
|
|
131
|
+
allowedTypes={['image']}
|
|
132
|
+
value={img?.id || 0}
|
|
133
|
+
render={({open}: {open: () => void}) => (
|
|
134
|
+
<PanelRow>
|
|
135
|
+
{img?.src && <img src={img.src} alt={img.alt} style={{maxWidth: 48, maxHeight: 48, objectFit: 'contain'}} />}
|
|
136
|
+
<Button onClick={open} variant="secondary" size="small">
|
|
137
|
+
{img?.src ? __('Změnit', 'brilo-blocks') : __('Vybrat obrázek', 'brilo-blocks')}
|
|
138
|
+
</Button>
|
|
139
|
+
{!!img?.src && (
|
|
140
|
+
<Button onClick={handleRemove} variant="tertiary" size="small" isDestructive>
|
|
141
|
+
{__('Odebrat', 'brilo-blocks')}
|
|
142
|
+
</Button>
|
|
143
|
+
)}
|
|
144
|
+
</PanelRow>
|
|
145
|
+
)}
|
|
146
|
+
/>
|
|
147
|
+
</MediaUploadCheck>
|
|
148
|
+
|
|
149
|
+
{!!img?.src && (
|
|
150
|
+
<>
|
|
151
|
+
<BaseControl label={__('Pozice', 'brilo-blocks')} __nextHasNoMarginBottom>
|
|
152
|
+
<div style={{display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 4}}>
|
|
153
|
+
{DECORATION_POSITIONS.map((p) => (
|
|
154
|
+
<Button
|
|
155
|
+
key={p.value}
|
|
156
|
+
variant="secondary"
|
|
157
|
+
size="small"
|
|
158
|
+
isPressed={position === p.value}
|
|
159
|
+
onClick={() => update({position: p.value as DecorationPosition})}
|
|
160
|
+
>
|
|
161
|
+
{p.label}
|
|
162
|
+
</Button>
|
|
163
|
+
))}
|
|
164
|
+
</div>
|
|
165
|
+
</BaseControl>
|
|
166
|
+
|
|
167
|
+
<ToggleGroupControl
|
|
168
|
+
label={__('Vrstva', 'brilo-blocks')}
|
|
169
|
+
value={depth}
|
|
170
|
+
onChange={(next) => update({depth: next as DecorationDepth})}
|
|
171
|
+
isBlock
|
|
172
|
+
>
|
|
173
|
+
{DECORATION_DEPTHS.map((d) => (
|
|
174
|
+
<ToggleGroupControlOption key={d.value} value={d.value} label={d.label} />
|
|
175
|
+
))}
|
|
176
|
+
</ToggleGroupControl>
|
|
177
|
+
|
|
178
|
+
<ToggleGroupControl
|
|
179
|
+
label={__('Přesah', 'brilo-blocks')}
|
|
180
|
+
value={translate}
|
|
181
|
+
onChange={(next) => update({translate: next as DecorationTranslate})}
|
|
182
|
+
isBlock
|
|
183
|
+
>
|
|
184
|
+
{DECORATION_TRANSLATES.map((t) => (
|
|
185
|
+
<ToggleGroupControlOption key={t.value} value={t.value} label={t.label} />
|
|
186
|
+
))}
|
|
187
|
+
</ToggleGroupControl>
|
|
188
|
+
|
|
189
|
+
<UnitControl
|
|
190
|
+
label={__('Max. šířka obrázku', 'brilo-blocks')}
|
|
191
|
+
value={maxWidth}
|
|
192
|
+
units={DECORATION_MAX_WIDTH_UNITS}
|
|
193
|
+
onChange={(next) => update({maxWidth: (next as string) ?? DECORATION_MAX_WIDTH_DEFAULT})}
|
|
194
|
+
/>
|
|
195
|
+
|
|
196
|
+
<BaseControl
|
|
197
|
+
label={__('Doladění pozice', 'brilo-blocks')}
|
|
198
|
+
__nextHasNoMarginBottom
|
|
199
|
+
help={__('Ruční posun obrázku navíc k vybrané pozici.', 'brilo-blocks')}
|
|
200
|
+
>
|
|
201
|
+
<UnitControl
|
|
202
|
+
label={__('Posun X', 'brilo-blocks')}
|
|
203
|
+
value={offsetX}
|
|
204
|
+
units={DECORATION_OFFSET_UNITS}
|
|
205
|
+
onChange={(next) => update({offsetX: (next as string) ?? DECORATION_OFFSET_DEFAULT})}
|
|
206
|
+
/>
|
|
207
|
+
<UnitControl
|
|
208
|
+
label={__('Posun Y', 'brilo-blocks')}
|
|
209
|
+
value={offsetY}
|
|
210
|
+
units={DECORATION_OFFSET_UNITS}
|
|
211
|
+
onChange={(next) => update({offsetY: (next as string) ?? DECORATION_OFFSET_DEFAULT})}
|
|
212
|
+
/>
|
|
213
|
+
</BaseControl>
|
|
214
|
+
</>
|
|
215
|
+
)}
|
|
216
|
+
</BaseControl>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
86
220
|
type SpacingPosition = BaseBlockAttributes['spacing']['position']
|
|
87
221
|
type SpacingSize = BaseBlockAttributes['spacing']['size']
|
|
88
222
|
|
|
@@ -93,7 +227,7 @@ interface BaseControlsProps {
|
|
|
93
227
|
}
|
|
94
228
|
|
|
95
229
|
export function BaseControls({attributes, setAttributes, exclude}: BaseControlsProps) {
|
|
96
|
-
const {id, spacing, background, textColor, decorations} = attributes
|
|
230
|
+
const {id, spacing, background, textColor, decoration, decorations} = attributes
|
|
97
231
|
const {paletteColors, resolveHex} = useTenantColorPalette()
|
|
98
232
|
const fluid = decorations?.fluid ?? {}
|
|
99
233
|
|
|
@@ -143,6 +277,12 @@ export function BaseControls({attributes, setAttributes, exclude}: BaseControlsP
|
|
|
143
277
|
</PanelBody>
|
|
144
278
|
)}
|
|
145
279
|
|
|
280
|
+
{!exclude.includes('decoration') && (
|
|
281
|
+
<PanelBody title={__('Dekorace', 'brilo-blocks')} initialOpen={false}>
|
|
282
|
+
<DecorationControl value={decoration} onChange={(value) => setAttributes({decoration: value ?? {}})} />
|
|
283
|
+
</PanelBody>
|
|
284
|
+
)}
|
|
285
|
+
|
|
146
286
|
{!exclude.includes('decorations') && (
|
|
147
287
|
<PanelBody title={__('Fluidní dekorace', 'brilo-blocks')} initialOpen={false}>
|
|
148
288
|
<FluidDecorationControl label={__('Nahoře', 'brilo-blocks')} value={fluid.top} onChange={(value) => setFluid('top', value)} />
|
|
@@ -15,6 +15,22 @@ export interface FluidDecoration {
|
|
|
15
15
|
height: string
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export type DecorationImage = FluidDecorationImage
|
|
19
|
+
|
|
20
|
+
export type DecorationPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center-left' | 'center-right'
|
|
21
|
+
export type DecorationDepth = 'front' | 'under'
|
|
22
|
+
export type DecorationTranslate = 'in' | 'center' | 'out'
|
|
23
|
+
|
|
24
|
+
export interface Decoration {
|
|
25
|
+
img?: DecorationImage
|
|
26
|
+
position?: DecorationPosition
|
|
27
|
+
depth?: DecorationDepth
|
|
28
|
+
translate?: DecorationTranslate
|
|
29
|
+
maxWidth?: string
|
|
30
|
+
offsetX?: string
|
|
31
|
+
offsetY?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
19
35
|
id: string
|
|
20
36
|
spacing: {
|
|
@@ -23,6 +39,7 @@ export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
|
23
39
|
}
|
|
24
40
|
background: string
|
|
25
41
|
textColor: string
|
|
42
|
+
decoration: Decoration
|
|
26
43
|
decorations: {
|
|
27
44
|
fluid?: {
|
|
28
45
|
top?: FluidDecoration
|
|
@@ -31,7 +48,7 @@ export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
|
31
48
|
}
|
|
32
49
|
}
|
|
33
50
|
|
|
34
|
-
export type ExcludableBaseAttr = 'spacing' | 'background' | 'id' | 'decorations'
|
|
51
|
+
export type ExcludableBaseAttr = 'spacing' | 'background' | 'id' | 'decorations' | 'decoration'
|
|
35
52
|
|
|
36
53
|
export interface BaseSectionOptions<TExtra extends Record<string, unknown> = Record<string, never>> extends BriloBlockType {
|
|
37
54
|
supports?: BlockConfiguration['supports']
|