@brilo/base-blocks 0.1.48 → 0.1.50
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/contact/contact-group/edit.d.ts.map +1 -1
- package/build/blocks/contact/contact-group/edit.js +22 -2
- package/build/blocks/person/person-group/constants.d.ts +17 -0
- package/build/blocks/person/person-group/constants.d.ts.map +1 -1
- package/build/blocks/person/person-group/constants.js +10 -0
- package/build/blocks/person/person-group/edit.d.ts.map +1 -1
- package/build/blocks/person/person-group/edit.js +6 -4
- package/build/blocks/person/person-group/factory.d.ts.map +1 -1
- package/build/blocks/person/person-group/factory.js +12 -1
- package/build/blocks/person/person-group/types.d.ts +11 -0
- package/build/blocks/person/person-group/types.d.ts.map +1 -1
- package/build/blocks/step/step-group/constants.d.ts +55 -0
- package/build/blocks/step/step-group/constants.d.ts.map +1 -1
- package/build/blocks/step/step-group/constants.js +29 -0
- package/build/blocks/step/step-group/edit.d.ts.map +1 -1
- package/build/blocks/step/step-group/edit.js +28 -3
- package/build/blocks/step/step-group/factory.d.ts.map +1 -1
- package/build/blocks/step/step-group/factory.js +16 -1
- package/build/blocks/step/step-group/types.d.ts +17 -1
- package/build/blocks/step/step-group/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blocks/contact/contact-group/edit.tsx +24 -1
- package/src/blocks/person/person-group/constants.ts +13 -0
- package/src/blocks/person/person-group/edit.tsx +63 -3
- package/src/blocks/person/person-group/factory.tsx +12 -1
- package/src/blocks/person/person-group/types.ts +13 -0
- package/src/blocks/step/step-group/constants.ts +35 -0
- package/src/blocks/step/step-group/edit.tsx +163 -5
- package/src/blocks/step/step-group/factory.tsx +16 -1
- package/src/blocks/step/step-group/types.ts +20 -1
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import type {BriloBlockType} from '~/types'
|
|
2
|
+
import type {DEFAULT_SHADOWS, TEXT_ALIGNS} from './constants'
|
|
3
|
+
|
|
4
|
+
export type PersonShadow = (typeof DEFAULT_SHADOWS)[number]['value']
|
|
5
|
+
|
|
6
|
+
export type PersonTextAlign = (typeof TEXT_ALIGNS)[number]['value']
|
|
2
7
|
|
|
3
8
|
export interface PersonGroupAttributes extends Record<string, unknown> {
|
|
4
9
|
columns: number
|
|
5
10
|
headingLevel: number
|
|
11
|
+
style: {
|
|
12
|
+
shadow: PersonShadow
|
|
13
|
+
borderColor: string
|
|
14
|
+
backgroundColor: string
|
|
15
|
+
textColor: string
|
|
16
|
+
headingColor: string
|
|
17
|
+
textAlign: PersonTextAlign
|
|
18
|
+
}
|
|
6
19
|
}
|
|
7
20
|
|
|
8
21
|
export interface PersonGroupOptions extends BriloBlockType {}
|
|
@@ -4,3 +4,38 @@ export const DEFAULT_VARIANTS = [
|
|
|
4
4
|
{value: 'horizontal', label: __('Horizontální', 'brilo-blocks')},
|
|
5
5
|
{value: 'vertical', label: __('Vertikální', 'brilo-blocks')},
|
|
6
6
|
] as const
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_SHADOWS = [
|
|
9
|
+
{value: 'none', label: __('Žádný', 'brilo-blocks')},
|
|
10
|
+
{value: 'sm', label: __('Malý', 'brilo-blocks')},
|
|
11
|
+
{value: 'md', label: __('Střední', 'brilo-blocks')},
|
|
12
|
+
] as const
|
|
13
|
+
|
|
14
|
+
export const TEXT_ALIGNS = [
|
|
15
|
+
{value: 'left', label: __('Vlevo', 'brilo-blocks')},
|
|
16
|
+
{value: 'center', label: __('Na střed', 'brilo-blocks')},
|
|
17
|
+
] as const
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_ICON_SIZE = 48
|
|
20
|
+
export const ICON_SIZE_MIN = 16
|
|
21
|
+
export const ICON_SIZE_MAX = 96
|
|
22
|
+
|
|
23
|
+
export const DEFAULT_ICON_SIZE_PRESETS = [
|
|
24
|
+
{value: 24, label: __('SM', 'brilo-blocks')},
|
|
25
|
+
{value: 32, label: __('MD', 'brilo-blocks')},
|
|
26
|
+
{value: 48, label: __('Výchozí', 'brilo-blocks')},
|
|
27
|
+
{value: 64, label: __('LG', 'brilo-blocks')},
|
|
28
|
+
{value: 80, label: __('XL', 'brilo-blocks')},
|
|
29
|
+
] as const
|
|
30
|
+
|
|
31
|
+
export const DEFAULT_ICON_BACKGROUND_SIZE = 144
|
|
32
|
+
export const ICON_BACKGROUND_SIZE_MIN = 56
|
|
33
|
+
export const ICON_BACKGROUND_SIZE_MAX = 200
|
|
34
|
+
|
|
35
|
+
export const DEFAULT_ICON_BACKGROUND_SIZE_PRESETS = [
|
|
36
|
+
{value: 88, label: __('SM', 'brilo-blocks')},
|
|
37
|
+
{value: 112, label: __('MD', 'brilo-blocks')},
|
|
38
|
+
{value: 144, label: __('Výchozí', 'brilo-blocks')},
|
|
39
|
+
{value: 168, label: __('LG', 'brilo-blocks')},
|
|
40
|
+
{value: 200, label: __('XL', 'brilo-blocks')},
|
|
41
|
+
] as const
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
2
|
import {
|
|
3
|
+
BaseControl,
|
|
4
|
+
Button,
|
|
5
|
+
ColorPalette,
|
|
3
6
|
PanelBody,
|
|
7
|
+
RangeControl,
|
|
4
8
|
ToggleControl,
|
|
5
9
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
6
10
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
@@ -9,21 +13,87 @@ import {__} from '@wordpress/i18n'
|
|
|
9
13
|
import clsx from 'clsx'
|
|
10
14
|
import {ItemSpacingPanel, itemSpacingStyle} from '~/components/ItemSpacingControl'
|
|
11
15
|
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
16
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
12
17
|
import type {OptionArray} from '~/types'
|
|
13
|
-
import type {StepGroupAttributes, StepGroupOptions,
|
|
14
|
-
import {
|
|
18
|
+
import type {StepGroupAttributes, StepGroupOptions, StepShadow, StepTextAlign} from './types'
|
|
19
|
+
import {
|
|
20
|
+
DEFAULT_ICON_BACKGROUND_SIZE,
|
|
21
|
+
DEFAULT_ICON_BACKGROUND_SIZE_PRESETS,
|
|
22
|
+
DEFAULT_ICON_SIZE,
|
|
23
|
+
DEFAULT_ICON_SIZE_PRESETS,
|
|
24
|
+
DEFAULT_SHADOWS,
|
|
25
|
+
DEFAULT_VARIANTS,
|
|
26
|
+
ICON_BACKGROUND_SIZE_MAX,
|
|
27
|
+
ICON_BACKGROUND_SIZE_MIN,
|
|
28
|
+
ICON_SIZE_MAX,
|
|
29
|
+
ICON_SIZE_MIN,
|
|
30
|
+
TEXT_ALIGNS,
|
|
31
|
+
} from './constants'
|
|
32
|
+
|
|
33
|
+
// Older step-group blocks were saved before `style` / `style.icon` existed. WordPress does
|
|
34
|
+
// not deep-merge object-attribute defaults, so normalise here to stay backward compatible.
|
|
35
|
+
function normaliseStyle(saved: Partial<StepGroupAttributes['style']> | undefined): StepGroupAttributes['style'] {
|
|
36
|
+
return {
|
|
37
|
+
shadow: 'none',
|
|
38
|
+
borderColor: '',
|
|
39
|
+
backgroundColor: '',
|
|
40
|
+
textColor: '',
|
|
41
|
+
headingColor: '',
|
|
42
|
+
textAlign: 'left',
|
|
43
|
+
...saved,
|
|
44
|
+
icon: {
|
|
45
|
+
size: DEFAULT_ICON_SIZE,
|
|
46
|
+
background: '',
|
|
47
|
+
backgroundSize: DEFAULT_ICON_BACKGROUND_SIZE,
|
|
48
|
+
...saved?.icon,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function PresetSizeControl({
|
|
54
|
+
label,
|
|
55
|
+
id,
|
|
56
|
+
value,
|
|
57
|
+
presets,
|
|
58
|
+
min,
|
|
59
|
+
max,
|
|
60
|
+
onChange,
|
|
61
|
+
}: {
|
|
62
|
+
label: string
|
|
63
|
+
id: string
|
|
64
|
+
value: number
|
|
65
|
+
presets: readonly {value: number; label: string}[]
|
|
66
|
+
min: number
|
|
67
|
+
max: number
|
|
68
|
+
onChange: (v: number) => void
|
|
69
|
+
}) {
|
|
70
|
+
return (
|
|
71
|
+
<BaseControl label={label} id={id}>
|
|
72
|
+
<div style={{display: 'flex', gap: 4, marginBottom: 8, flexWrap: 'wrap'}}>
|
|
73
|
+
{presets.map((p) => (
|
|
74
|
+
<Button key={p.label} variant={value === p.value ? 'primary' : 'secondary'} size="small" onClick={() => onChange(p.value)}>
|
|
75
|
+
{p.label}
|
|
76
|
+
</Button>
|
|
77
|
+
))}
|
|
78
|
+
</div>
|
|
79
|
+
<RangeControl value={value} onChange={(v) => onChange(v ?? min)} min={min} max={max} step={1} withInputField />
|
|
80
|
+
</BaseControl>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
15
83
|
|
|
16
84
|
export function createStepGroupEdit<TVariants extends OptionArray = typeof DEFAULT_VARIANTS>(options: StepGroupOptions<TVariants>) {
|
|
17
85
|
const VARIANTS = options.variants ?? DEFAULT_VARIANTS
|
|
18
86
|
|
|
19
87
|
return function Edit({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
88
|
+
attributes,
|
|
89
|
+
setAttributes,
|
|
90
|
+
}: {
|
|
23
91
|
attributes: StepGroupAttributes
|
|
24
92
|
setAttributes: (a: Partial<StepGroupAttributes>) => void
|
|
25
93
|
}) {
|
|
26
94
|
const {variant, disableIcon, spacing} = attributes
|
|
95
|
+
const style = normaliseStyle(attributes.style as Partial<StepGroupAttributes['style']> | undefined)
|
|
96
|
+
const {paletteColors} = useTenantColorPalette()
|
|
27
97
|
|
|
28
98
|
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
29
99
|
blockClassName: clsx(options.blockClassName ?? 'g-step wp-block-section', `--variant-${variant}`, disableIcon && '--disable-icon'),
|
|
@@ -55,6 +125,94 @@ export function createStepGroupEdit<TVariants extends OptionArray = typeof DEFAU
|
|
|
55
125
|
onChange={(v) => setAttributes({disableIcon: v})}
|
|
56
126
|
/>
|
|
57
127
|
</PanelBody>
|
|
128
|
+
{style && (
|
|
129
|
+
<PanelBody title={__('Styl', 'brilo-blocks')}>
|
|
130
|
+
<ToggleGroupControl
|
|
131
|
+
isBlock
|
|
132
|
+
label={__('Stín', 'brilo-blocks')}
|
|
133
|
+
value={style.shadow}
|
|
134
|
+
onChange={(v) => setAttributes({style: {...style, shadow: v as StepShadow}})}
|
|
135
|
+
>
|
|
136
|
+
{DEFAULT_SHADOWS.map((s) => (
|
|
137
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
138
|
+
))}
|
|
139
|
+
</ToggleGroupControl>
|
|
140
|
+
<BaseControl
|
|
141
|
+
label={__('Barva okraje', 'brilo-blocks')}
|
|
142
|
+
help={__('Bez vybrané barvy se okraj nevykreslí.', 'brilo-blocks')}
|
|
143
|
+
id="step-group-border-color"
|
|
144
|
+
>
|
|
145
|
+
<ColorPalette
|
|
146
|
+
colors={paletteColors}
|
|
147
|
+
value={style.borderColor || undefined}
|
|
148
|
+
onChange={(value) => setAttributes({style: {...style, borderColor: value ?? ''}})}
|
|
149
|
+
/>
|
|
150
|
+
</BaseControl>
|
|
151
|
+
<BaseControl label={__('Barva pozadí', 'brilo-blocks')} id="step-group-background-color">
|
|
152
|
+
<ColorPalette
|
|
153
|
+
colors={paletteColors}
|
|
154
|
+
value={style.backgroundColor || undefined}
|
|
155
|
+
onChange={(value) => setAttributes({style: {...style, backgroundColor: value ?? ''}})}
|
|
156
|
+
/>
|
|
157
|
+
</BaseControl>
|
|
158
|
+
<BaseControl label={__('Barva textu', 'brilo-blocks')} id="step-group-text-color">
|
|
159
|
+
<ColorPalette
|
|
160
|
+
colors={paletteColors}
|
|
161
|
+
value={style.textColor || undefined}
|
|
162
|
+
onChange={(value) => setAttributes({style: {...style, textColor: value ?? ''}})}
|
|
163
|
+
/>
|
|
164
|
+
</BaseControl>
|
|
165
|
+
<BaseControl label={__('Barva nadpisu', 'brilo-blocks')} id="step-group-heading-color">
|
|
166
|
+
<ColorPalette
|
|
167
|
+
colors={paletteColors}
|
|
168
|
+
value={style.headingColor || undefined}
|
|
169
|
+
onChange={(value) => setAttributes({style: {...style, headingColor: value ?? ''}})}
|
|
170
|
+
/>
|
|
171
|
+
</BaseControl>
|
|
172
|
+
<ToggleGroupControl
|
|
173
|
+
isBlock
|
|
174
|
+
label={__('Zarovnání textu', 'brilo-blocks')}
|
|
175
|
+
value={style.textAlign}
|
|
176
|
+
onChange={(v) => setAttributes({style: {...style, textAlign: v as StepTextAlign}})}
|
|
177
|
+
>
|
|
178
|
+
{TEXT_ALIGNS.map((a) => (
|
|
179
|
+
<ToggleGroupControlOption key={a.value} value={a.value} label={a.label} />
|
|
180
|
+
))}
|
|
181
|
+
</ToggleGroupControl>
|
|
182
|
+
</PanelBody>
|
|
183
|
+
)}
|
|
184
|
+
|
|
185
|
+
<PanelBody title={__('Ikona', 'brilo-blocks')} initialOpen={false}>
|
|
186
|
+
<PresetSizeControl
|
|
187
|
+
label={__('Velikost', 'brilo-blocks')}
|
|
188
|
+
id="step-group-icon-size"
|
|
189
|
+
value={style.icon.size}
|
|
190
|
+
presets={DEFAULT_ICON_SIZE_PRESETS}
|
|
191
|
+
min={ICON_SIZE_MIN}
|
|
192
|
+
max={ICON_SIZE_MAX}
|
|
193
|
+
onChange={(v) => setAttributes({style: {...style, icon: {...style.icon, size: v}}})}
|
|
194
|
+
/>
|
|
195
|
+
<BaseControl
|
|
196
|
+
label={__('Barva pozadí', 'brilo-blocks')}
|
|
197
|
+
help={__('Ovládá i barvu spojnice mezi kroky.', 'brilo-blocks')}
|
|
198
|
+
id="step-group-icon-background"
|
|
199
|
+
>
|
|
200
|
+
<ColorPalette
|
|
201
|
+
colors={paletteColors}
|
|
202
|
+
value={style.icon.background || undefined}
|
|
203
|
+
onChange={(value) => setAttributes({style: {...style, icon: {...style.icon, background: value ?? ''}}})}
|
|
204
|
+
/>
|
|
205
|
+
</BaseControl>
|
|
206
|
+
<PresetSizeControl
|
|
207
|
+
label={__('Velikost pozadí', 'brilo-blocks')}
|
|
208
|
+
id="step-group-icon-background-size"
|
|
209
|
+
value={style.icon.backgroundSize}
|
|
210
|
+
presets={DEFAULT_ICON_BACKGROUND_SIZE_PRESETS}
|
|
211
|
+
min={ICON_BACKGROUND_SIZE_MIN}
|
|
212
|
+
max={ICON_BACKGROUND_SIZE_MAX}
|
|
213
|
+
onChange={(v) => setAttributes({style: {...style, icon: {...style.icon, backgroundSize: v}}})}
|
|
214
|
+
/>
|
|
215
|
+
</PanelBody>
|
|
58
216
|
<ItemSpacingPanel spacing={spacing} onChange={(v) => setAttributes({spacing: v})} />
|
|
59
217
|
</InspectorControls>
|
|
60
218
|
<div {...blockProps}>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
2
|
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
3
|
import {__} from '@wordpress/i18n'
|
|
4
|
-
import {DEFAULT_VARIANTS} from './constants'
|
|
4
|
+
import {DEFAULT_ICON_BACKGROUND_SIZE, DEFAULT_ICON_SIZE, DEFAULT_SHADOWS, DEFAULT_VARIANTS, TEXT_ALIGNS} from './constants'
|
|
5
5
|
import {createStepGroupEdit} from './edit'
|
|
6
6
|
import type {StepGroupAttributes, StepGroupOptions} from './types'
|
|
7
7
|
import {icon} from '~/blocks/step/step-group/icon'
|
|
@@ -30,6 +30,21 @@ export function createStepGroupBlock<TVariants extends OptionArray = typeof DEFA
|
|
|
30
30
|
type: 'boolean',
|
|
31
31
|
default: false,
|
|
32
32
|
},
|
|
33
|
+
style: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
default: {
|
|
36
|
+
shadow: DEFAULT_SHADOWS[0].value,
|
|
37
|
+
borderColor: '',
|
|
38
|
+
backgroundColor: '',
|
|
39
|
+
textColor: '',
|
|
40
|
+
headingColor: '',
|
|
41
|
+
textAlign: TEXT_ALIGNS[0].value,
|
|
42
|
+
icon: {
|
|
43
|
+
background: '',
|
|
44
|
+
backgroundSize: DEFAULT_ICON_BACKGROUND_SIZE,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
33
48
|
...ITEM_SPACING_ATTRIBUTE,
|
|
34
49
|
},
|
|
35
50
|
edit: createStepGroupEdit(options as unknown as StepGroupOptions),
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import type {BriloBlockType, OptionArray} from '~/types'
|
|
2
|
-
import type {DEFAULT_VARIANTS} from './constants'
|
|
2
|
+
import type {DEFAULT_SHADOWS, DEFAULT_VARIANTS, TEXT_ALIGNS} from './constants'
|
|
3
3
|
|
|
4
4
|
export type StepVariant = (typeof DEFAULT_VARIANTS)[number]['value']
|
|
5
5
|
|
|
6
|
+
export type StepShadow = (typeof DEFAULT_SHADOWS)[number]['value']
|
|
7
|
+
|
|
8
|
+
export type StepTextAlign = (typeof TEXT_ALIGNS)[number]['value']
|
|
9
|
+
|
|
10
|
+
export interface StepIconStyle {
|
|
11
|
+
size: number
|
|
12
|
+
background: string
|
|
13
|
+
backgroundSize: number
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
export interface StepGroupAttributes<TVariant extends string = StepVariant> extends Record<string, unknown> {
|
|
7
17
|
variant: TVariant
|
|
8
18
|
disableIcon: boolean
|
|
19
|
+
style: {
|
|
20
|
+
shadow: StepShadow
|
|
21
|
+
borderColor: string
|
|
22
|
+
backgroundColor: string
|
|
23
|
+
textColor: string
|
|
24
|
+
headingColor: string
|
|
25
|
+
textAlign: StepTextAlign
|
|
26
|
+
icon: StepIconStyle
|
|
27
|
+
}
|
|
9
28
|
spacing?: number
|
|
10
29
|
}
|
|
11
30
|
|