@brilo/base-blocks 0.1.31 → 0.1.32
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/groups/text-and-media-group/edit.d.ts.map +1 -1
- package/build/blocks/groups/text-and-media-group/edit.js +5 -3
- package/build/blocks/groups/text-and-media-group/factory.js +1 -1
- package/build/blocks/groups/text-and-media-group/types.d.ts +1 -0
- package/build/blocks/groups/text-and-media-group/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blocks/groups/text-and-media-group/edit.tsx +13 -1
- package/src/blocks/groups/text-and-media-group/factory.tsx +1 -1
- package/src/blocks/groups/text-and-media-group/types.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/text-and-media-group/edit.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/text-and-media-group/edit.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EASV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,wBAAwB,oCAWxE;IACD,UAAU,EAAE,2BAA2B,CAAA;IACvC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,KAAK,IAAI,CAAA;CACjE,iCAuMF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { BlockControls, InspectorControls, RichText } from '@wordpress/block-editor';
|
|
3
|
-
import { PanelBody, TextControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, ToolbarButton, ToolbarGroup, } from '@wordpress/components';
|
|
3
|
+
import { BaseControl, ColorPalette, PanelBody, TextControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, ToolbarButton, ToolbarGroup, } from '@wordpress/components';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { ImagePickerBody, ImagePickerControl } from '../../../components/ImagePicker';
|
|
7
7
|
import { useGroupBlock } from '../../../hooks/useGroupBlock';
|
|
8
|
+
import { useTenantColorPalette } from '../../../hooks/useTenantColorPalette';
|
|
8
9
|
import { CHIP_POSITIONS, DEFAULT_CHIP_VARIANTS, DEFAULT_CONTENT_SIZES, DEFAULT_GRID_STYLES, DEFAULT_HEADING_STYLES, DEFAULT_MEDIA_POSITIONS, DEFAULT_RATIOS, HEADING_LEVELS, } from './constants';
|
|
9
10
|
export function createTextAndMediaGroupEdit(options) {
|
|
10
11
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -18,6 +19,7 @@ export function createTextAndMediaGroupEdit(options) {
|
|
|
18
19
|
var _a, _b;
|
|
19
20
|
const { header, mediaPosition, img, ratio, gridStyle, content } = attributes;
|
|
20
21
|
const isMediaLeft = mediaPosition === 'left';
|
|
22
|
+
const { paletteColors } = useTenantColorPalette();
|
|
21
23
|
const { blockProps, innerBlocksProps } = useGroupBlock({
|
|
22
24
|
blockClassName: [
|
|
23
25
|
(_a = options.blockClassName) !== null && _a !== void 0 ? _a : 'g-text-and-media wp-block-section',
|
|
@@ -30,7 +32,7 @@ export function createTextAndMediaGroupEdit(options) {
|
|
|
30
32
|
template: options.template,
|
|
31
33
|
});
|
|
32
34
|
const mediaColumn = (_jsxs("div", { className: "g-text-and-media__media", children: [_jsx(ImagePickerBody, { value: { id: img.id, alt: img.alt }, onChange: (val) => setAttributes({ img: { ...img, ...val } }), placeholder: __('Vybrat obrázek', 'brilo-blocks') }), img.id > 0 && img.chip.title && (_jsx("span", { className: clsx('g-text-and-media__chip', `--${img.chip.position}`, `--${img.chip.variant}`), children: img.chip.title }))] }));
|
|
33
|
-
const textColumn = (_jsxs("div", { className: "g-text-and-media__text", children: [_jsx(RichText, { tagName: "span", className: "g-text-and-media__overline u-text-editable", value: header.overline.title, onChange: (value) => setAttributes({ header: { ...header, overline: { title: value } } }), placeholder: __('Overline...', 'brilo-blocks'), allowedFormats: [] }), _jsx(RichText, { tagName: `h${header.heading.level}`, className: clsx('g-text-and-media__heading', `--heading-style-${header.heading.style}`, 'u-text-editable'), value: header.heading.title, onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, title: value } } }), placeholder: __('Nadpis...', 'brilo-blocks'), allowedFormats: ['core/bold', 'core/italic'] }), _jsx("div", { ...innerBlocksProps })] }));
|
|
34
|
-
return (_jsxs(_Fragment, { children: [_jsx(BlockControls, { children: _jsxs(ToolbarGroup, { children: [_jsx(ToolbarButton, { icon: "align-pull-left", label: __('Média vlevo', 'brilo-blocks'), isActive: isMediaLeft, onClick: () => setAttributes({ mediaPosition: 'left' }) }), _jsx(ToolbarButton, { icon: "align-pull-right", label: __('Média vpravo', 'brilo-blocks'), isActive: !isMediaLeft, onClick: () => setAttributes({ mediaPosition: 'right' }) })] }) }), _jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Obrázek', 'brilo-blocks'), children: [_jsx(ImagePickerControl, { value: { id: img.id, alt: img.alt }, onChange: (val) => setAttributes({ img: { ...img, ...val } }) }), _jsx(ToggleGroupControl, { label: __('Poměr stran', 'brilo-blocks'), value: ratio, onChange: (value) => setAttributes({ ratio: value }), isBlock: true, children: RATIOS.map((r) => (_jsx(ToggleGroupControlOption, { value: r.value, label: r.label }, r.value))) }), _jsx(TextControl, { label: __('URL videa', 'brilo-blocks'), value: img.video.src, onChange: (value) => setAttributes({ img: { ...img, video: { src: value } } }) })] }), _jsxs(PanelBody, { title: __('Chip', 'brilo-blocks'), initialOpen: false, children: [_jsx(TextControl, { label: __('Text chipu', 'brilo-blocks'), value: img.chip.title, onChange: (value) => setAttributes({ img: { ...img, chip: { ...img.chip, title: value } } }) }), _jsx(ToggleGroupControl, { label: __('Pozice chipu', 'brilo-blocks'), value: img.chip.position, onChange: (value) => setAttributes({ img: { ...img, chip: { ...img.chip, position: value } } }), isBlock: true, children: CHIP_POSITIONS.map((p) => (_jsx(ToggleGroupControlOption, { value: p.value, label: p.label }, p.value))) }), _jsx(ToggleGroupControl, { label: __('Varianta chipu', 'brilo-blocks'), value: img.chip.variant, onChange: (value) => setAttributes({ img: { ...img, chip: { ...img.chip, variant: value } } }), isBlock: true, children: CHIP_VARIANTS.map((v) => (_jsx(ToggleGroupControlOption, { value: v.value, label: v.label }, v.value))) })] }), _jsxs(PanelBody, { title: __('Rozložení', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { label: __('Pozice médií', 'brilo-blocks'), value: mediaPosition, onChange: (value) => setAttributes({ mediaPosition: value }), isBlock: true, children: MEDIA_POSITIONS.map((p) => (_jsx(ToggleGroupControlOption, { value: p.value, label: p.label }, p.value))) }), _jsx(ToggleGroupControl, { label: __('Styl mřížky', 'brilo-blocks'), value: gridStyle, onChange: (value) => setAttributes({ gridStyle: value }), isBlock: true, children: GRID_STYLES.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) }), _jsx(ToggleGroupControl, { label: __('Velikost textu', 'brilo-blocks'), value: content.size, onChange: (value) => setAttributes({ content: { size: value } }), isBlock: true, children: CONTENT_SIZES.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) })] }), _jsxs(PanelBody, { title: __('Nadpis', 'brilo-blocks'), initialOpen: false, children: [_jsx(ToggleGroupControl, { label: __('Úroveň nadpisu', 'brilo-blocks'), value: String(header.heading.level), onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, level: Number(value) } } }), isBlock: true, children: HEADING_LEVELS.map((l) => (_jsx(ToggleGroupControlOption, { value: String(l), label: `H${l}` }, l))) }), _jsx(ToggleGroupControl, { label: __('Styl nadpisu', 'brilo-blocks'), value: header.heading.style, onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, style: value } } }), isBlock: true, children: HEADING_STYLES.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) })] })] }), _jsx("div", { ...blockProps, children: _jsx("div", { className: clsx('u-grid-responsive --col-2 g-text-and-media__grid', `--grid-style-${gridStyle}`), children: isMediaLeft ? (_jsxs(_Fragment, { children: [mediaColumn, textColumn] })) : (_jsxs(_Fragment, { children: [textColumn, mediaColumn] })) }) })] }));
|
|
35
|
+
const textColumn = (_jsxs("div", { className: "g-text-and-media__text", children: [_jsx(RichText, { tagName: "span", className: "g-text-and-media__overline u-text-editable", value: header.overline.title, onChange: (value) => setAttributes({ header: { ...header, overline: { title: value } } }), placeholder: __('Overline...', 'brilo-blocks'), allowedFormats: [] }), _jsx(RichText, { tagName: `h${header.heading.level}`, className: clsx('g-text-and-media__heading', `--heading-style-${header.heading.style}`, 'u-text-editable'), style: header.heading.color ? { color: header.heading.color } : undefined, value: header.heading.title, onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, title: value } } }), placeholder: __('Nadpis...', 'brilo-blocks'), allowedFormats: ['core/bold', 'core/italic', 'core/text-color'] }), _jsx("div", { ...innerBlocksProps })] }));
|
|
36
|
+
return (_jsxs(_Fragment, { children: [_jsx(BlockControls, { children: _jsxs(ToolbarGroup, { children: [_jsx(ToolbarButton, { icon: "align-pull-left", label: __('Média vlevo', 'brilo-blocks'), isActive: isMediaLeft, onClick: () => setAttributes({ mediaPosition: 'left' }) }), _jsx(ToolbarButton, { icon: "align-pull-right", label: __('Média vpravo', 'brilo-blocks'), isActive: !isMediaLeft, onClick: () => setAttributes({ mediaPosition: 'right' }) })] }) }), _jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Obrázek', 'brilo-blocks'), children: [_jsx(ImagePickerControl, { value: { id: img.id, alt: img.alt }, onChange: (val) => setAttributes({ img: { ...img, ...val } }) }), _jsx(ToggleGroupControl, { label: __('Poměr stran', 'brilo-blocks'), value: ratio, onChange: (value) => setAttributes({ ratio: value }), isBlock: true, children: RATIOS.map((r) => (_jsx(ToggleGroupControlOption, { value: r.value, label: r.label }, r.value))) }), _jsx(TextControl, { label: __('URL videa', 'brilo-blocks'), value: img.video.src, onChange: (value) => setAttributes({ img: { ...img, video: { src: value } } }) })] }), _jsxs(PanelBody, { title: __('Chip', 'brilo-blocks'), initialOpen: false, children: [_jsx(TextControl, { label: __('Text chipu', 'brilo-blocks'), value: img.chip.title, onChange: (value) => setAttributes({ img: { ...img, chip: { ...img.chip, title: value } } }) }), _jsx(ToggleGroupControl, { label: __('Pozice chipu', 'brilo-blocks'), value: img.chip.position, onChange: (value) => setAttributes({ img: { ...img, chip: { ...img.chip, position: value } } }), isBlock: true, children: CHIP_POSITIONS.map((p) => (_jsx(ToggleGroupControlOption, { value: p.value, label: p.label }, p.value))) }), _jsx(ToggleGroupControl, { label: __('Varianta chipu', 'brilo-blocks'), value: img.chip.variant, onChange: (value) => setAttributes({ img: { ...img, chip: { ...img.chip, variant: value } } }), isBlock: true, children: CHIP_VARIANTS.map((v) => (_jsx(ToggleGroupControlOption, { value: v.value, label: v.label }, v.value))) })] }), _jsxs(PanelBody, { title: __('Rozložení', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { label: __('Pozice médií', 'brilo-blocks'), value: mediaPosition, onChange: (value) => setAttributes({ mediaPosition: value }), isBlock: true, children: MEDIA_POSITIONS.map((p) => (_jsx(ToggleGroupControlOption, { value: p.value, label: p.label }, p.value))) }), _jsx(ToggleGroupControl, { label: __('Styl mřížky', 'brilo-blocks'), value: gridStyle, onChange: (value) => setAttributes({ gridStyle: value }), isBlock: true, children: GRID_STYLES.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) }), _jsx(ToggleGroupControl, { label: __('Velikost textu', 'brilo-blocks'), value: content.size, onChange: (value) => setAttributes({ content: { size: value } }), isBlock: true, children: CONTENT_SIZES.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) })] }), _jsxs(PanelBody, { title: __('Nadpis', 'brilo-blocks'), initialOpen: false, children: [_jsx(ToggleGroupControl, { label: __('Úroveň nadpisu', 'brilo-blocks'), value: String(header.heading.level), onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, level: Number(value) } } }), isBlock: true, children: HEADING_LEVELS.map((l) => (_jsx(ToggleGroupControlOption, { value: String(l), label: `H${l}` }, l))) }), _jsx(ToggleGroupControl, { label: __('Styl nadpisu', 'brilo-blocks'), value: header.heading.style, onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, style: value } } }), isBlock: true, children: HEADING_STYLES.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) }), _jsx(BaseControl, { label: __('Barva nadpisu', 'brilo-blocks'), children: _jsx(ColorPalette, { colors: paletteColors, value: header.heading.color || undefined, onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, color: value !== null && value !== void 0 ? value : '' } } }) }) })] })] }), _jsx("div", { ...blockProps, children: _jsx("div", { className: clsx('u-grid-responsive --col-2 g-text-and-media__grid', `--grid-style-${gridStyle}`), children: isMediaLeft ? (_jsxs(_Fragment, { children: [mediaColumn, textColumn] })) : (_jsxs(_Fragment, { children: [textColumn, mediaColumn] })) }) })] }));
|
|
35
37
|
};
|
|
36
38
|
}
|
|
@@ -25,7 +25,7 @@ export function createTextAndMediaGroupBlock(options) {
|
|
|
25
25
|
header: {
|
|
26
26
|
type: 'object',
|
|
27
27
|
default: {
|
|
28
|
-
heading: { title: '', level: HEADING_LEVELS[1], style: (_p = (_a = headingStyles[1]) === null || _a === void 0 ? void 0 : _a.value) !== null && _p !== void 0 ? _p : headingStyles[0].value },
|
|
28
|
+
heading: { title: '', level: HEADING_LEVELS[1], style: (_p = (_a = headingStyles[1]) === null || _a === void 0 ? void 0 : _a.value) !== null && _p !== void 0 ? _p : headingStyles[0].value, color: '' },
|
|
29
29
|
overline: { title: '' },
|
|
30
30
|
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,GAAG,OAAO,uBAAuB,EACpE,WAAW,SAAS,WAAW,GAAG,OAAO,mBAAmB,EAC5D,cAAc,SAAS,WAAW,GAAG,OAAO,sBAAsB,EAClE,aAAa,SAAS,WAAW,GAAG,OAAO,qBAAqB,EAChE,aAAa,SAAS,WAAW,GAAG,OAAO,qBAAqB,CAChE,SAAQ,cAAc;IACtB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,eAAe,CAAA;IAChC,UAAU,CAAC,EAAE,WAAW,CAAA;IACxB,aAAa,CAAC,EAAE,cAAc,CAAA;IAC9B,YAAY,CAAC,EAAE,aAAa,CAAA;IAC5B,YAAY,CAAC,EAAE,aAAa,CAAA;CAC7B"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {BlockControls, InspectorControls, RichText} from '@wordpress/block-editor'
|
|
2
2
|
import {
|
|
3
|
+
BaseControl,
|
|
4
|
+
ColorPalette,
|
|
3
5
|
PanelBody,
|
|
4
6
|
TextControl,
|
|
5
7
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
@@ -11,6 +13,7 @@ import {__} from '@wordpress/i18n'
|
|
|
11
13
|
import clsx from 'clsx'
|
|
12
14
|
import {ImagePickerBody, ImagePickerControl} from '~/components/ImagePicker'
|
|
13
15
|
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
16
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
14
17
|
import {
|
|
15
18
|
CHIP_POSITIONS,
|
|
16
19
|
DEFAULT_CHIP_VARIANTS,
|
|
@@ -51,6 +54,7 @@ export function createTextAndMediaGroupEdit(options: TextAndMediaGroupOptions) {
|
|
|
51
54
|
}) {
|
|
52
55
|
const {header, mediaPosition, img, ratio, gridStyle, content} = attributes
|
|
53
56
|
const isMediaLeft = mediaPosition === 'left'
|
|
57
|
+
const {paletteColors} = useTenantColorPalette()
|
|
54
58
|
|
|
55
59
|
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
56
60
|
blockClassName: [
|
|
@@ -90,10 +94,11 @@ export function createTextAndMediaGroupEdit(options: TextAndMediaGroupOptions) {
|
|
|
90
94
|
<RichText
|
|
91
95
|
tagName={`h${header.heading.level}` as 'h1' | 'h2' | 'h3' | 'h4'}
|
|
92
96
|
className={clsx('g-text-and-media__heading', `--heading-style-${header.heading.style}`, 'u-text-editable')}
|
|
97
|
+
style={header.heading.color ? {color: header.heading.color} : undefined}
|
|
93
98
|
value={header.heading.title}
|
|
94
99
|
onChange={(value: string) => setAttributes({header: {...header, heading: {...header.heading, title: value}}})}
|
|
95
100
|
placeholder={__('Nadpis...', 'brilo-blocks')}
|
|
96
|
-
allowedFormats={['core/bold', 'core/italic']}
|
|
101
|
+
allowedFormats={['core/bold', 'core/italic', 'core/text-color']}
|
|
97
102
|
/>
|
|
98
103
|
<div {...innerBlocksProps} />
|
|
99
104
|
</div>
|
|
@@ -218,6 +223,13 @@ export function createTextAndMediaGroupEdit(options: TextAndMediaGroupOptions) {
|
|
|
218
223
|
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
219
224
|
))}
|
|
220
225
|
</ToggleGroupControl>
|
|
226
|
+
<BaseControl label={__('Barva nadpisu', 'brilo-blocks')}>
|
|
227
|
+
<ColorPalette
|
|
228
|
+
colors={paletteColors}
|
|
229
|
+
value={header.heading.color || undefined}
|
|
230
|
+
onChange={(value) => setAttributes({header: {...header, heading: {...header.heading, color: value ?? ''}}})}
|
|
231
|
+
/>
|
|
232
|
+
</BaseControl>
|
|
221
233
|
</PanelBody>
|
|
222
234
|
</InspectorControls>
|
|
223
235
|
<div {...blockProps}>
|
|
@@ -55,7 +55,7 @@ export function createTextAndMediaGroupBlock<
|
|
|
55
55
|
header: {
|
|
56
56
|
type: 'object',
|
|
57
57
|
default: {
|
|
58
|
-
heading: {title: '', level: HEADING_LEVELS[1], style: headingStyles[1]?.value ?? headingStyles[0].value},
|
|
58
|
+
heading: {title: '', level: HEADING_LEVELS[1], style: headingStyles[1]?.value ?? headingStyles[0].value, color: ''},
|
|
59
59
|
overline: {title: ''},
|
|
60
60
|
},
|
|
61
61
|
},
|
|
@@ -28,7 +28,7 @@ export interface TextAndMediaGroupAttributes<
|
|
|
28
28
|
TChipVariant extends string = ChipVariants,
|
|
29
29
|
> extends Record<string, unknown> {
|
|
30
30
|
header: {
|
|
31
|
-
heading: {title: string; level: HeadingLevels; style: THeadingStyle}
|
|
31
|
+
heading: {title: string; level: HeadingLevels; style: THeadingStyle; color?: string}
|
|
32
32
|
overline: {title: string}
|
|
33
33
|
}
|
|
34
34
|
mediaPosition: TMediaPosition
|