@brilo/base-blocks 0.1.43 → 0.1.45
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/compare/compare-group/constants.d.ts +27 -0
- package/build/blocks/compare/compare-group/constants.d.ts.map +1 -1
- package/build/blocks/compare/compare-group/constants.js +23 -0
- package/build/blocks/compare/compare-group/edit.d.ts.map +1 -1
- package/build/blocks/compare/compare-group/edit.js +12 -7
- package/build/blocks/compare/compare-group/factory.d.ts.map +1 -1
- package/build/blocks/compare/compare-group/factory.js +10 -1
- package/build/blocks/compare/compare-group/index.d.ts +1 -1
- package/build/blocks/compare/compare-group/index.d.ts.map +1 -1
- package/build/blocks/compare/compare-group/types.d.ts +7 -1
- package/build/blocks/compare/compare-group/types.d.ts.map +1 -1
- package/build/blocks/compare/compare-item/edit.d.ts.map +1 -1
- package/build/blocks/compare/compare-item/edit.js +6 -4
- package/build/blocks/compare/compare-item/factory.d.ts.map +1 -1
- package/build/blocks/compare/compare-item/factory.js +4 -0
- package/build/blocks/compare/compare-item/index.js +1 -1
- package/build/blocks/compare/compare-item/types.d.ts +2 -0
- package/build/blocks/compare/compare-item/types.d.ts.map +1 -1
- package/build/blocks/core/basic-icon/buildPreviewStyle.d.ts +8 -0
- package/build/blocks/core/basic-icon/buildPreviewStyle.d.ts.map +1 -0
- package/build/blocks/core/basic-icon/buildPreviewStyle.js +22 -0
- package/build/blocks/core/basic-icon/constants.d.ts +84 -0
- package/build/blocks/core/basic-icon/constants.d.ts.map +1 -0
- package/build/blocks/core/basic-icon/constants.js +41 -0
- package/build/blocks/core/basic-icon/edit.d.ts +6 -0
- package/build/blocks/core/basic-icon/edit.d.ts.map +1 -0
- package/build/blocks/core/basic-icon/edit.js +22 -0
- package/build/blocks/core/basic-icon/factory.d.ts +5 -0
- package/build/blocks/core/basic-icon/factory.d.ts.map +1 -0
- package/build/blocks/core/basic-icon/factory.js +38 -0
- package/build/blocks/core/basic-icon/index.d.ts +5 -0
- package/build/blocks/core/basic-icon/index.d.ts.map +1 -0
- package/build/blocks/core/basic-icon/index.js +7 -0
- package/build/blocks/core/basic-icon/types.d.ts +30 -0
- package/build/blocks/core/basic-icon/types.d.ts.map +1 -0
- package/build/blocks/core/basic-icon/types.js +1 -0
- package/build/blocks/faq/faq-group/constants.d.ts +29 -0
- package/build/blocks/faq/faq-group/constants.d.ts.map +1 -1
- package/build/blocks/faq/faq-group/constants.js +15 -0
- package/build/blocks/faq/faq-group/edit.d.ts.map +1 -1
- package/build/blocks/faq/faq-group/edit.js +14 -5
- package/build/blocks/faq/faq-group/factory.d.ts.map +1 -1
- package/build/blocks/faq/faq-group/factory.js +37 -17
- package/build/blocks/faq/faq-group/index.d.ts +1 -1
- package/build/blocks/faq/faq-group/index.d.ts.map +1 -1
- package/build/blocks/faq/faq-group/types.d.ts +21 -1
- package/build/blocks/faq/faq-group/types.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-group/edit.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-group/edit.js +4 -2
- package/build/blocks/gallery/gallery-group/factory.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-group/factory.js +2 -0
- package/build/blocks/gallery/gallery-group/types.d.ts +1 -0
- package/build/blocks/gallery/gallery-group/types.d.ts.map +1 -1
- package/build/blocks/groups/text-and-media-group/index.d.ts.map +1 -1
- package/build/blocks/groups/text-and-media-group/index.js +1 -0
- package/build/blocks/list/list-group/constants.d.ts +21 -0
- package/build/blocks/list/list-group/constants.d.ts.map +1 -0
- package/build/blocks/list/list-group/constants.js +12 -0
- package/build/blocks/list/list-group/edit.d.ts +6 -0
- package/build/blocks/list/list-group/edit.d.ts.map +1 -0
- package/build/blocks/list/list-group/edit.js +30 -0
- package/build/blocks/list/list-group/factory.d.ts +7 -0
- package/build/blocks/list/list-group/factory.d.ts.map +1 -0
- package/build/blocks/list/list-group/factory.js +29 -0
- package/build/blocks/list/list-group/icon.d.ts +2 -0
- package/build/blocks/list/list-group/icon.d.ts.map +1 -0
- package/build/blocks/list/list-group/icon.js +2 -0
- package/build/blocks/list/list-group/index.d.ts +5 -0
- package/build/blocks/list/list-group/index.d.ts.map +1 -0
- package/build/blocks/list/list-group/index.js +11 -0
- package/build/blocks/list/list-group/types.d.ts +22 -0
- package/build/blocks/list/list-group/types.d.ts.map +1 -0
- package/build/blocks/list/list-group/types.js +1 -0
- package/build/blocks/list/list-item/buildPreviewStyle.d.ts +20 -0
- package/build/blocks/list/list-item/buildPreviewStyle.d.ts.map +1 -0
- package/build/blocks/list/list-item/buildPreviewStyle.js +18 -0
- package/build/blocks/list/list-item/constants.d.ts +36 -0
- package/build/blocks/list/list-item/constants.d.ts.map +1 -0
- package/build/blocks/list/list-item/constants.js +16 -0
- package/build/blocks/list/list-item/edit.d.ts +11 -0
- package/build/blocks/list/list-item/edit.d.ts.map +1 -0
- package/build/blocks/list/list-item/edit.js +18 -0
- package/build/blocks/list/list-item/factory.d.ts +5 -0
- package/build/blocks/list/list-item/factory.d.ts.map +1 -0
- package/build/blocks/list/list-item/factory.js +29 -0
- package/build/blocks/list/list-item/index.d.ts +5 -0
- package/build/blocks/list/list-item/index.d.ts.map +1 -0
- package/build/blocks/list/list-item/index.js +7 -0
- package/build/blocks/list/list-item/types.d.ts +21 -0
- package/build/blocks/list/list-item/types.d.ts.map +1 -0
- package/build/blocks/list/list-item/types.js +1 -0
- package/build/blocks/priceplan/priceplan-group/edit.d.ts +5 -2
- package/build/blocks/priceplan/priceplan-group/edit.d.ts.map +1 -1
- package/build/blocks/priceplan/priceplan-group/edit.js +7 -3
- package/build/blocks/priceplan/priceplan-group/factory.d.ts.map +1 -1
- package/build/blocks/priceplan/priceplan-group/factory.js +2 -1
- package/build/blocks/priceplan/priceplan-group/types.d.ts +1 -0
- package/build/blocks/priceplan/priceplan-group/types.d.ts.map +1 -1
- package/build/blocks/review/review-group/constants.d.ts +10 -0
- package/build/blocks/review/review-group/constants.d.ts.map +1 -1
- package/build/blocks/review/review-group/constants.js +5 -0
- package/build/blocks/review/review-group/edit.d.ts.map +1 -1
- package/build/blocks/review/review-group/edit.js +10 -6
- package/build/blocks/review/review-group/factory.d.ts.map +1 -1
- package/build/blocks/review/review-group/factory.js +36 -21
- package/build/blocks/review/review-group/index.d.ts +1 -1
- package/build/blocks/review/review-group/index.d.ts.map +1 -1
- package/build/blocks/review/review-group/types.d.ts +11 -1
- package/build/blocks/review/review-group/types.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.d.ts +35 -0
- package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.js +10 -0
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/controls.js +26 -12
- package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
- package/build/blocks/sections/base-section/edit.js +12 -4
- package/build/blocks/sections/base-section/types.d.ts +9 -1
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/build/blocks/signpost/signpost-group/edit.d.ts.map +1 -1
- package/build/blocks/signpost/signpost-group/edit.js +4 -2
- package/build/blocks/signpost/signpost-group/factory.d.ts.map +1 -1
- package/build/blocks/signpost/signpost-group/factory.js +2 -0
- package/build/blocks/signpost/signpost-group/types.d.ts +1 -0
- package/build/blocks/signpost/signpost-group/types.d.ts.map +1 -1
- package/build/blocks/step/step-group/edit.d.ts.map +1 -1
- package/build/blocks/step/step-group/edit.js +4 -3
- package/build/blocks/step/step-group/factory.d.ts.map +1 -1
- package/build/blocks/step/step-group/factory.js +2 -0
- package/build/blocks/step/step-group/types.d.ts +1 -0
- package/build/blocks/step/step-group/types.d.ts.map +1 -1
- package/build/blocks/text-and-form/text-and-form-text-column/index.d.ts.map +1 -1
- package/build/blocks/text-and-form/text-and-form-text-column/index.js +1 -0
- package/build/blocks/usp/usp-group/edit.d.ts.map +1 -1
- package/build/blocks/usp/usp-group/edit.js +4 -3
- package/build/blocks/usp/usp-group/factory.d.ts.map +1 -1
- package/build/blocks/usp/usp-group/factory.js +2 -0
- package/build/blocks/usp/usp-group/types.d.ts +1 -0
- package/build/blocks/usp/usp-group/types.d.ts.map +1 -1
- package/build/blocks/video/video-group/constants.d.ts +1 -0
- package/build/blocks/video/video-group/constants.d.ts.map +1 -1
- package/build/blocks/video/video-group/constants.js +1 -0
- package/build/blocks/video/video-group/edit.d.ts.map +1 -1
- package/build/blocks/video/video-group/edit.js +7 -5
- package/build/blocks/video/video-group/factory.d.ts.map +1 -1
- package/build/blocks/video/video-group/factory.js +9 -1
- package/build/blocks/video/video-group/types.d.ts +2 -0
- package/build/blocks/video/video-group/types.d.ts.map +1 -1
- package/build/components/ItemSpacingControl/index.d.ts +23 -0
- package/build/components/ItemSpacingControl/index.d.ts.map +1 -0
- package/build/components/ItemSpacingControl/index.js +32 -0
- package/build/index.d.ts +6 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -0
- package/package.json +1 -1
- package/src/blocks/compare/compare-group/constants.ts +27 -0
- package/src/blocks/compare/compare-group/edit.tsx +27 -4
- package/src/blocks/compare/compare-group/factory.tsx +10 -1
- package/src/blocks/compare/compare-group/index.ts +7 -1
- package/src/blocks/compare/compare-group/types.ts +5 -1
- package/src/blocks/compare/compare-item/edit.tsx +32 -13
- package/src/blocks/compare/compare-item/editor.scss +16 -0
- package/src/blocks/compare/compare-item/factory.tsx +4 -0
- package/src/blocks/compare/compare-item/index.ts +1 -1
- package/src/blocks/compare/compare-item/types.ts +2 -0
- package/src/blocks/core/basic-icon/buildPreviewStyle.ts +40 -0
- package/src/blocks/core/basic-icon/constants.ts +48 -0
- package/src/blocks/core/basic-icon/edit.tsx +170 -0
- package/src/blocks/core/basic-icon/editor.scss +119 -0
- package/src/blocks/core/basic-icon/factory.tsx +42 -0
- package/src/blocks/core/basic-icon/index.ts +17 -0
- package/src/blocks/core/basic-icon/types.ts +34 -0
- package/src/blocks/faq/faq-group/constants.ts +18 -0
- package/src/blocks/faq/faq-group/edit.tsx +121 -4
- package/src/blocks/faq/faq-group/factory.tsx +35 -13
- package/src/blocks/faq/faq-group/index.ts +9 -1
- package/src/blocks/faq/faq-group/types.ts +23 -1
- package/src/blocks/gallery/gallery-group/edit.tsx +4 -1
- package/src/blocks/gallery/gallery-group/factory.tsx +2 -0
- package/src/blocks/gallery/gallery-group/types.ts +1 -0
- package/src/blocks/groups/text-and-media-group/index.ts +1 -0
- package/src/blocks/list/list-group/constants.ts +15 -0
- package/src/blocks/list/list-group/edit.tsx +102 -0
- package/src/blocks/list/list-group/editor.scss +14 -0
- package/src/blocks/list/list-group/factory.tsx +35 -0
- package/src/blocks/list/list-group/icon.tsx +11 -0
- package/src/blocks/list/list-group/index.ts +15 -0
- package/src/blocks/list/list-group/types.ts +21 -0
- package/src/blocks/list/list-item/buildPreviewStyle.ts +52 -0
- package/src/blocks/list/list-item/constants.ts +18 -0
- package/src/blocks/list/list-item/edit.tsx +108 -0
- package/src/blocks/list/list-item/editor.scss +108 -0
- package/src/blocks/list/list-item/factory.tsx +33 -0
- package/src/blocks/list/list-item/index.ts +11 -0
- package/src/blocks/list/list-item/types.ts +23 -0
- package/src/blocks/priceplan/priceplan-group/edit.tsx +21 -5
- package/src/blocks/priceplan/priceplan-group/factory.tsx +2 -1
- package/src/blocks/priceplan/priceplan-group/types.ts +3 -1
- package/src/blocks/review/review-group/constants.ts +6 -0
- package/src/blocks/review/review-group/edit.tsx +50 -4
- package/src/blocks/review/review-group/factory.tsx +33 -16
- package/src/blocks/review/review-group/index.ts +10 -1
- package/src/blocks/review/review-group/types.ts +12 -1
- package/src/blocks/sections/base-section/constants.ts +14 -0
- package/src/blocks/sections/base-section/controls.tsx +93 -9
- package/src/blocks/sections/base-section/edit.tsx +10 -2
- package/src/blocks/sections/base-section/types.ts +14 -1
- package/src/blocks/signpost/signpost-group/edit.tsx +4 -1
- package/src/blocks/signpost/signpost-group/factory.tsx +2 -0
- package/src/blocks/signpost/signpost-group/types.ts +1 -0
- package/src/blocks/step/step-group/edit.tsx +4 -2
- package/src/blocks/step/step-group/factory.tsx +2 -0
- package/src/blocks/step/step-group/types.ts +1 -0
- package/src/blocks/text-and-form/text-and-form-text-column/index.ts +1 -0
- package/src/blocks/usp/usp-group/edit.tsx +4 -2
- package/src/blocks/usp/usp-group/factory.tsx +2 -0
- package/src/blocks/usp/usp-group/types.ts +1 -0
- package/src/blocks/video/video-group/constants.ts +2 -0
- package/src/blocks/video/video-group/edit.tsx +33 -2
- package/src/blocks/video/video-group/editor.scss +6 -1
- package/src/blocks/video/video-group/factory.tsx +9 -1
- package/src/blocks/video/video-group/types.ts +2 -0
- package/src/components/ItemSpacingControl/index.tsx +59 -0
- package/src/editor.scss +3 -0
- package/src/index.ts +11 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
BaseControl,
|
|
4
|
+
Button,
|
|
5
|
+
ColorPalette,
|
|
6
|
+
PanelBody,
|
|
7
|
+
RangeControl,
|
|
8
|
+
SelectControl,
|
|
9
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
10
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
11
|
+
} from '@wordpress/components'
|
|
12
|
+
import {__} from '@wordpress/i18n'
|
|
13
|
+
import clsx from 'clsx'
|
|
14
|
+
import {ItemIconControl, ItemIconPreview} from '~/components/ItemIconControl'
|
|
15
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
16
|
+
import {buildBasicIconPreviewStyle} from './buildPreviewStyle'
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_ALIGNMENTS,
|
|
19
|
+
DEFAULT_ICON_BACKGROUND_SHAPES,
|
|
20
|
+
DEFAULT_ICON_BACKGROUND_SIZE_PRESETS,
|
|
21
|
+
DEFAULT_ICON_SIZE_PRESETS,
|
|
22
|
+
ICON_BACKGROUND_SIZE_MAX,
|
|
23
|
+
ICON_BACKGROUND_SIZE_MIN,
|
|
24
|
+
ICON_SIZE_MAX,
|
|
25
|
+
ICON_SIZE_MIN,
|
|
26
|
+
ICON_TYPES,
|
|
27
|
+
} from './constants'
|
|
28
|
+
import type {BasicIconAlignment, BasicIconAttributes, BasicIconBackgroundShape, BasicIconOptions, BasicIconSizePreset} from './types'
|
|
29
|
+
|
|
30
|
+
function PresetSizeControl({
|
|
31
|
+
label,
|
|
32
|
+
value,
|
|
33
|
+
presets,
|
|
34
|
+
min,
|
|
35
|
+
max,
|
|
36
|
+
onChange,
|
|
37
|
+
}: {
|
|
38
|
+
label: string
|
|
39
|
+
value: number
|
|
40
|
+
presets: readonly BasicIconSizePreset[]
|
|
41
|
+
min: number
|
|
42
|
+
max: number
|
|
43
|
+
onChange: (v: number) => void
|
|
44
|
+
}) {
|
|
45
|
+
return (
|
|
46
|
+
<BaseControl label={label} id={`basic-icon-size-${label}`}>
|
|
47
|
+
<div style={{display: 'flex', gap: 4, marginBottom: 8, flexWrap: 'wrap'}}>
|
|
48
|
+
{presets.map((p) => (
|
|
49
|
+
<Button key={p.label} variant={value === p.value ? 'primary' : 'secondary'} size="small" onClick={() => onChange(p.value)}>
|
|
50
|
+
{p.label}
|
|
51
|
+
</Button>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
<RangeControl value={value} onChange={(v) => onChange(v ?? min)} min={min} max={max} step={1} withInputField />
|
|
55
|
+
</BaseControl>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function createBasicIconEdit(options: BasicIconOptions) {
|
|
60
|
+
return function Edit({
|
|
61
|
+
attributes,
|
|
62
|
+
setAttributes,
|
|
63
|
+
}: {
|
|
64
|
+
attributes: BasicIconAttributes
|
|
65
|
+
setAttributes: (a: Partial<BasicIconAttributes>) => void
|
|
66
|
+
}) {
|
|
67
|
+
const {icon, style} = attributes
|
|
68
|
+
const {paletteColors, resolveHex} = useTenantColorPalette()
|
|
69
|
+
const {rootClassName, iconClassName, cssVars} = buildBasicIconPreviewStyle(style, resolveHex)
|
|
70
|
+
|
|
71
|
+
const blockProps = useBlockProps({className: clsx('i-basic-icon', rootClassName)})
|
|
72
|
+
|
|
73
|
+
const setIcon = (patch: Partial<BasicIconAttributes['style']['icon']>) =>
|
|
74
|
+
setAttributes({style: {...style, icon: {...style.icon, ...patch}}})
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<InspectorControls>
|
|
79
|
+
<PanelBody title={__('Ikona', 'brilo-blocks')}>
|
|
80
|
+
<ItemIconControl icon={icon} setAttributes={setAttributes} iconTypes={ICON_TYPES} options={options} />
|
|
81
|
+
</PanelBody>
|
|
82
|
+
<PanelBody title={__('Zarovnání', 'brilo-blocks')}>
|
|
83
|
+
<ToggleGroupControl
|
|
84
|
+
isBlock
|
|
85
|
+
label={__('Zarovnání', 'brilo-blocks')}
|
|
86
|
+
value={style.align}
|
|
87
|
+
onChange={(v) => setAttributes({style: {...style, align: v as BasicIconAlignment}})}
|
|
88
|
+
>
|
|
89
|
+
{DEFAULT_ALIGNMENTS.map((a) => (
|
|
90
|
+
<ToggleGroupControlOption key={a.value} value={a.value} label={a.label} />
|
|
91
|
+
))}
|
|
92
|
+
</ToggleGroupControl>
|
|
93
|
+
</PanelBody>
|
|
94
|
+
<PanelBody title={__('Styl ikony', 'brilo-blocks')} initialOpen={false}>
|
|
95
|
+
<PresetSizeControl
|
|
96
|
+
label={__('Velikost', 'brilo-blocks')}
|
|
97
|
+
value={style.icon.size}
|
|
98
|
+
presets={DEFAULT_ICON_SIZE_PRESETS}
|
|
99
|
+
min={ICON_SIZE_MIN}
|
|
100
|
+
max={ICON_SIZE_MAX}
|
|
101
|
+
onChange={(v) => setIcon({size: v})}
|
|
102
|
+
/>
|
|
103
|
+
<BaseControl label={__('Barva', 'brilo-blocks')} id="basic-icon-color">
|
|
104
|
+
<ColorPalette
|
|
105
|
+
colors={paletteColors}
|
|
106
|
+
value={style.icon.color || undefined}
|
|
107
|
+
onChange={(value) => setIcon({color: value ?? ''})}
|
|
108
|
+
/>
|
|
109
|
+
</BaseControl>
|
|
110
|
+
<BaseControl label={__('Pozadí', 'brilo-blocks')} id="basic-icon-background-color">
|
|
111
|
+
<ColorPalette
|
|
112
|
+
colors={paletteColors}
|
|
113
|
+
value={style.icon.background || undefined}
|
|
114
|
+
onChange={(value) => setIcon({background: value ?? ''})}
|
|
115
|
+
/>
|
|
116
|
+
</BaseControl>
|
|
117
|
+
<PresetSizeControl
|
|
118
|
+
label={__('Velikost pozadí', 'brilo-blocks')}
|
|
119
|
+
value={style.icon.backgroundSize}
|
|
120
|
+
presets={DEFAULT_ICON_BACKGROUND_SIZE_PRESETS}
|
|
121
|
+
min={ICON_BACKGROUND_SIZE_MIN}
|
|
122
|
+
max={ICON_BACKGROUND_SIZE_MAX}
|
|
123
|
+
onChange={(v) => setIcon({backgroundSize: v})}
|
|
124
|
+
/>
|
|
125
|
+
{style.icon.background && (
|
|
126
|
+
<SelectControl<string>
|
|
127
|
+
label={__('Tvar pozadí', 'brilo-blocks')}
|
|
128
|
+
value={style.icon.backgroundShape}
|
|
129
|
+
options={[...DEFAULT_ICON_BACKGROUND_SHAPES]}
|
|
130
|
+
onChange={(v) => setIcon({backgroundShape: v as BasicIconBackgroundShape})}
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
133
|
+
<BaseControl
|
|
134
|
+
label={__('Barva ohraničení', 'brilo-blocks')}
|
|
135
|
+
help={__('Bez vybrané barvy se okraj nevykreslí.', 'brilo-blocks')}
|
|
136
|
+
id="basic-icon-border-color"
|
|
137
|
+
>
|
|
138
|
+
<ColorPalette
|
|
139
|
+
colors={paletteColors}
|
|
140
|
+
value={style.icon.borderColor || undefined}
|
|
141
|
+
onChange={(value) => setIcon({borderColor: value ?? ''})}
|
|
142
|
+
/>
|
|
143
|
+
</BaseControl>
|
|
144
|
+
{style.icon.borderColor && (
|
|
145
|
+
<RangeControl
|
|
146
|
+
label={__('Šířka ohraničení (px)', 'brilo-blocks')}
|
|
147
|
+
value={style.icon.borderWidth}
|
|
148
|
+
onChange={(v) => setIcon({borderWidth: v ?? 0})}
|
|
149
|
+
min={0}
|
|
150
|
+
max={10}
|
|
151
|
+
step={1}
|
|
152
|
+
/>
|
|
153
|
+
)}
|
|
154
|
+
</PanelBody>
|
|
155
|
+
</InspectorControls>
|
|
156
|
+
|
|
157
|
+
<div {...blockProps}>
|
|
158
|
+
<ItemIconPreview
|
|
159
|
+
icon={icon}
|
|
160
|
+
className="i-basic-icon__icon"
|
|
161
|
+
modifierClassName={iconClassName}
|
|
162
|
+
style={cssVars}
|
|
163
|
+
setAttributes={setAttributes}
|
|
164
|
+
options={options}
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
</>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.i-basic-icon {
|
|
2
|
+
display: flex;
|
|
3
|
+
--icon-background-size: 0px;
|
|
4
|
+
|
|
5
|
+
// Background size only reserves space when a background or outline is actually selected.
|
|
6
|
+
&.--icon-background,
|
|
7
|
+
&.--icon-bordered {
|
|
8
|
+
--icon-background-size: 88px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&.--align-left {
|
|
12
|
+
justify-content: flex-start;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.--align-center {
|
|
16
|
+
justify-content: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.--align-right {
|
|
20
|
+
justify-content: flex-end;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.i-basic-icon__icon {
|
|
25
|
+
--icon-box-size: max(var(--icon-background-size, 0px), var(--icon-size, 88px));
|
|
26
|
+
|
|
27
|
+
width: var(--icon-box-size);
|
|
28
|
+
height: var(--icon-box-size);
|
|
29
|
+
flex: 0 0 var(--icon-box-size);
|
|
30
|
+
display: grid;
|
|
31
|
+
grid-template-areas: "pile";
|
|
32
|
+
place-items: center;
|
|
33
|
+
isolation: isolate;
|
|
34
|
+
|
|
35
|
+
&::before,
|
|
36
|
+
&::after {
|
|
37
|
+
content: "";
|
|
38
|
+
grid-area: pile;
|
|
39
|
+
width: var(--icon-background-size, 0px);
|
|
40
|
+
height: var(--icon-background-size, 0px);
|
|
41
|
+
border-radius: inherit;
|
|
42
|
+
clip-path: var(--icon-background-shape, none);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&::before {
|
|
46
|
+
z-index: 0;
|
|
47
|
+
background-color: var(--icon-outline-color, transparent);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&::after {
|
|
51
|
+
z-index: 1;
|
|
52
|
+
width: calc(var(--icon-background-size, 0px) - var(--icon-outline-width, 0px) * 2);
|
|
53
|
+
height: calc(var(--icon-background-size, 0px) - var(--icon-outline-width, 0px) * 2);
|
|
54
|
+
background-color: var(--icon-background-color, transparent);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
img,
|
|
58
|
+
svg,
|
|
59
|
+
span {
|
|
60
|
+
grid-area: pile;
|
|
61
|
+
position: relative;
|
|
62
|
+
z-index: 2;
|
|
63
|
+
width: var(--icon-size, 88px);
|
|
64
|
+
height: var(--icon-size, 88px);
|
|
65
|
+
object-fit: contain;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
svg path {
|
|
69
|
+
fill: var(--icon-color, currentcolor);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
span {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
color: var(--icon-color, currentcolor);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&.--background-shape-circle {
|
|
80
|
+
--icon-background-shape: circle(50% at 50% 50%);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&.--background-shape-triangle {
|
|
84
|
+
--icon-background-shape: polygon(50% 0%, 0% 100%, 100% 100%);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&.--background-shape-rhombus {
|
|
88
|
+
--icon-background-shape: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&.--background-shape-octagon {
|
|
92
|
+
--icon-background-shape: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&.--background-shape-bevel {
|
|
96
|
+
--icon-background-shape: polygon(20% 0%, 80% 0%, 100% 20%, 100% 80%, 80% 100%, 20% 100%, 0% 80%, 0% 20%);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&.--background-shape-rabbet {
|
|
100
|
+
--icon-background-shape: polygon(
|
|
101
|
+
0% 15%,
|
|
102
|
+
15% 15%,
|
|
103
|
+
15% 0%,
|
|
104
|
+
85% 0%,
|
|
105
|
+
85% 15%,
|
|
106
|
+
100% 15%,
|
|
107
|
+
100% 85%,
|
|
108
|
+
85% 85%,
|
|
109
|
+
85% 100%,
|
|
110
|
+
15% 100%,
|
|
111
|
+
15% 85%,
|
|
112
|
+
0% 85%
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&.--background-shape-parallelogram {
|
|
117
|
+
--icon-background-shape: polygon(25% 0%, 100% 0%, 75% 100%, 0% 100%);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {DEFAULT_ALIGNMENTS, DEFAULT_ICON_BACKGROUND_SHAPES, DEFAULT_ICON_BACKGROUND_SIZE, DEFAULT_ICON_SIZE, ICON_TYPES} from './constants'
|
|
4
|
+
import {createBasicIconEdit} from './edit'
|
|
5
|
+
import type {BasicIconAttributes, BasicIconOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export type {BasicIconAttributes, BasicIconOptions}
|
|
8
|
+
|
|
9
|
+
export function createBasicIconBlock(options: BasicIconOptions): BlockConfiguration<BasicIconAttributes> {
|
|
10
|
+
return {
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: options.title ?? __('Ikona', 'brilo-blocks'),
|
|
13
|
+
description: options.description,
|
|
14
|
+
category: options.category ?? 'layout',
|
|
15
|
+
...(options.parent && {parent: options.parent}),
|
|
16
|
+
icon: options.icon ?? 'star-filled',
|
|
17
|
+
supports: {html: false, customClassName: false},
|
|
18
|
+
attributes: {
|
|
19
|
+
icon: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
default: {type: ICON_TYPES[0].value, src: '', media: {id: 0, alt: ''}},
|
|
22
|
+
},
|
|
23
|
+
style: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
default: {
|
|
26
|
+
align: DEFAULT_ALIGNMENTS[0].value,
|
|
27
|
+
icon: {
|
|
28
|
+
size: DEFAULT_ICON_SIZE,
|
|
29
|
+
color: '',
|
|
30
|
+
background: '',
|
|
31
|
+
backgroundSize: DEFAULT_ICON_BACKGROUND_SIZE,
|
|
32
|
+
backgroundShape: DEFAULT_ICON_BACKGROUND_SHAPES[0].value,
|
|
33
|
+
borderColor: '',
|
|
34
|
+
borderWidth: 1,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
edit: createBasicIconEdit(options),
|
|
40
|
+
save: () => null,
|
|
41
|
+
} as unknown as BlockConfiguration<BasicIconAttributes>
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
BasicIconAlignment,
|
|
3
|
+
BasicIconAttributes,
|
|
4
|
+
BasicIconBackgroundShape,
|
|
5
|
+
BasicIconOptions,
|
|
6
|
+
BasicIconStyle,
|
|
7
|
+
} from './types'
|
|
8
|
+
export {createBasicIconBlock} from './factory'
|
|
9
|
+
|
|
10
|
+
import type {BasicIconOptions} from './types'
|
|
11
|
+
|
|
12
|
+
export const basicIconDefaults: BasicIconOptions = {
|
|
13
|
+
name: 'brilo/basic-icon',
|
|
14
|
+
parent: ['brilo/base-section'],
|
|
15
|
+
icons: [],
|
|
16
|
+
iconsSrc: '',
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {IconType} from '~/components/IconControl'
|
|
2
|
+
import type {BriloBlockType, Icon} from '~/types'
|
|
3
|
+
import type {DEFAULT_ALIGNMENTS, DEFAULT_ICON_BACKGROUND_SHAPES} from './constants'
|
|
4
|
+
|
|
5
|
+
export type BasicIconAlignment = (typeof DEFAULT_ALIGNMENTS)[number]['value']
|
|
6
|
+
export type BasicIconBackgroundShape = (typeof DEFAULT_ICON_BACKGROUND_SHAPES)[number]['value']
|
|
7
|
+
|
|
8
|
+
export interface BasicIconSizePreset {
|
|
9
|
+
value: number
|
|
10
|
+
label: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BasicIconStyle {
|
|
14
|
+
align: BasicIconAlignment
|
|
15
|
+
icon: {
|
|
16
|
+
size: number
|
|
17
|
+
color: string
|
|
18
|
+
background: string
|
|
19
|
+
backgroundSize: number
|
|
20
|
+
backgroundShape: BasicIconBackgroundShape
|
|
21
|
+
borderColor: string
|
|
22
|
+
borderWidth: number
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface BasicIconAttributes extends Record<string, unknown> {
|
|
27
|
+
icon: Icon
|
|
28
|
+
style: BasicIconStyle
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface BasicIconOptions extends BriloBlockType {
|
|
32
|
+
icons: IconType[]
|
|
33
|
+
iconsSrc: string
|
|
34
|
+
}
|
|
@@ -9,3 +9,21 @@ export const DEFAULT_ICON_VARIANTS = [
|
|
|
9
9
|
{value: 'info', label: __('Informace', 'brilo-blocks')},
|
|
10
10
|
{value: 'message', label: __('Zpráva', 'brilo-blocks')},
|
|
11
11
|
] as const
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_SHADOWS = [
|
|
14
|
+
{value: 'none', label: __('Žádný', 'brilo-blocks')},
|
|
15
|
+
{value: 'sm', label: __('Malý', 'brilo-blocks')},
|
|
16
|
+
{value: 'md', label: __('Střední', 'brilo-blocks')},
|
|
17
|
+
] as const
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_ICON_SIZE = 24
|
|
20
|
+
export const ICON_SIZE_MIN = 12
|
|
21
|
+
export const ICON_SIZE_MAX = 64
|
|
22
|
+
|
|
23
|
+
export const DEFAULT_ICON_SIZE_PRESETS = [
|
|
24
|
+
{value: 16, label: __('XS', 'brilo-blocks')},
|
|
25
|
+
{value: 20, label: __('SM', 'brilo-blocks')},
|
|
26
|
+
{value: 24, label: __('MD', 'brilo-blocks')},
|
|
27
|
+
{value: 32, label: __('LG', 'brilo-blocks')},
|
|
28
|
+
{value: 40, label: __('XL', 'brilo-blocks')},
|
|
29
|
+
] as const
|
|
@@ -1,12 +1,61 @@
|
|
|
1
1
|
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BaseControl,
|
|
4
|
+
Button,
|
|
5
|
+
ColorPalette,
|
|
6
|
+
PanelBody,
|
|
7
|
+
RangeControl,
|
|
8
|
+
SelectControl,
|
|
9
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
10
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
11
|
+
} from '@wordpress/components'
|
|
3
12
|
import {__} from '@wordpress/i18n'
|
|
13
|
+
import {ItemSpacingPanel, itemSpacingStyle} from '~/components/ItemSpacingControl'
|
|
4
14
|
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
15
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_ICON_SIZE_PRESETS,
|
|
18
|
+
DEFAULT_ICON_VARIANTS,
|
|
19
|
+
DEFAULT_SHADOWS,
|
|
20
|
+
FAQ_HEADING_LEVELS,
|
|
21
|
+
ICON_SIZE_MAX,
|
|
22
|
+
ICON_SIZE_MIN,
|
|
23
|
+
} from './constants'
|
|
24
|
+
import type {FaqGroupAttributes, FaqGroupOptions, FaqHeadingLevel, FaqIconVariant, FaqShadow, FaqSizePreset} from './types'
|
|
25
|
+
|
|
26
|
+
function PresetSizeControl({
|
|
27
|
+
label,
|
|
28
|
+
value,
|
|
29
|
+
presets,
|
|
30
|
+
min,
|
|
31
|
+
max,
|
|
32
|
+
onChange,
|
|
33
|
+
}: {
|
|
34
|
+
label: string
|
|
35
|
+
value: number
|
|
36
|
+
presets: readonly FaqSizePreset[]
|
|
37
|
+
min: number
|
|
38
|
+
max: number
|
|
39
|
+
onChange: (v: number) => void
|
|
40
|
+
}) {
|
|
41
|
+
return (
|
|
42
|
+
<BaseControl label={label} id={`faq-group-size-${label}`}>
|
|
43
|
+
<div style={{display: 'flex', gap: 4, marginBottom: 8, flexWrap: 'wrap'}}>
|
|
44
|
+
{presets.map((p) => (
|
|
45
|
+
<Button key={p.label} variant={value === p.value ? 'primary' : 'secondary'} size="small" onClick={() => onChange(p.value)}>
|
|
46
|
+
{p.label}
|
|
47
|
+
</Button>
|
|
48
|
+
))}
|
|
49
|
+
</div>
|
|
50
|
+
<RangeControl value={value} onChange={(v) => onChange(v ?? min)} min={min} max={max} step={1} withInputField />
|
|
51
|
+
</BaseControl>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
7
54
|
|
|
8
55
|
export function createFaqGroupEdit(options: FaqGroupOptions) {
|
|
9
56
|
const ICON_VARIANTS = options.iconVariants ?? DEFAULT_ICON_VARIANTS
|
|
57
|
+
const ICON_SIZE_PRESETS = options.iconSizePresets ?? DEFAULT_ICON_SIZE_PRESETS
|
|
58
|
+
const exclude = options.exclude ?? []
|
|
10
59
|
|
|
11
60
|
return function Edit({
|
|
12
61
|
attributes,
|
|
@@ -15,11 +64,13 @@ export function createFaqGroupEdit(options: FaqGroupOptions) {
|
|
|
15
64
|
attributes: FaqGroupAttributes
|
|
16
65
|
setAttributes: (a: Partial<FaqGroupAttributes>) => void
|
|
17
66
|
}) {
|
|
18
|
-
const {headingLevel, iconVariant} = attributes
|
|
67
|
+
const {headingLevel, iconVariant, style, spacing} = attributes
|
|
68
|
+
const {paletteColors} = useTenantColorPalette()
|
|
19
69
|
|
|
20
70
|
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
21
71
|
blockClassName: options.blockClassName ?? 'g-faq wp-block-section',
|
|
22
72
|
containerClassName: options.containerClassName ?? 'g-faq__items',
|
|
73
|
+
containerStyle: itemSpacingStyle(spacing),
|
|
23
74
|
allowedBlocks: options.allowedBlocks,
|
|
24
75
|
template: options.template,
|
|
25
76
|
orientation: 'vertical',
|
|
@@ -44,7 +95,73 @@ export function createFaqGroupEdit(options: FaqGroupOptions) {
|
|
|
44
95
|
options={ICON_VARIANTS.map((v) => ({value: v.value, label: v.label}))}
|
|
45
96
|
onChange={(value) => setAttributes({iconVariant: value as FaqIconVariant})}
|
|
46
97
|
/>
|
|
98
|
+
{!exclude.includes('colors') && style && (
|
|
99
|
+
<>
|
|
100
|
+
<PresetSizeControl
|
|
101
|
+
label={__('Velikost', 'brilo-blocks')}
|
|
102
|
+
value={style.icon.size}
|
|
103
|
+
presets={ICON_SIZE_PRESETS}
|
|
104
|
+
min={ICON_SIZE_MIN}
|
|
105
|
+
max={ICON_SIZE_MAX}
|
|
106
|
+
onChange={(v) => setAttributes({style: {...style, icon: {...style.icon, size: v}}})}
|
|
107
|
+
/>
|
|
108
|
+
<BaseControl label={__('Barva', 'brilo-blocks')} id="faq-group-icon-color">
|
|
109
|
+
<ColorPalette
|
|
110
|
+
colors={paletteColors}
|
|
111
|
+
value={style.icon.color || undefined}
|
|
112
|
+
onChange={(value) => setAttributes({style: {...style, icon: {...style.icon, color: value ?? ''}}})}
|
|
113
|
+
/>
|
|
114
|
+
</BaseControl>
|
|
115
|
+
<BaseControl label={__('Pozadí', 'brilo-blocks')} id="faq-group-icon-background-color">
|
|
116
|
+
<ColorPalette
|
|
117
|
+
colors={paletteColors}
|
|
118
|
+
value={style.icon.background || undefined}
|
|
119
|
+
onChange={(value) => setAttributes({style: {...style, icon: {...style.icon, background: value ?? ''}}})}
|
|
120
|
+
/>
|
|
121
|
+
</BaseControl>
|
|
122
|
+
</>
|
|
123
|
+
)}
|
|
47
124
|
</PanelBody>
|
|
125
|
+
{!exclude.includes('colors') && style && (
|
|
126
|
+
<PanelBody title={__('Styl', 'brilo-blocks')}>
|
|
127
|
+
<ToggleGroupControl
|
|
128
|
+
isBlock
|
|
129
|
+
label={__('Stín', 'brilo-blocks')}
|
|
130
|
+
value={style.shadow}
|
|
131
|
+
onChange={(v) => setAttributes({style: {...style, shadow: v as FaqShadow}})}
|
|
132
|
+
>
|
|
133
|
+
{DEFAULT_SHADOWS.map((s) => (
|
|
134
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
135
|
+
))}
|
|
136
|
+
</ToggleGroupControl>
|
|
137
|
+
<BaseControl
|
|
138
|
+
label={__('Barva okraje', 'brilo-blocks')}
|
|
139
|
+
help={__('Bez vybrané barvy se okraj nevykreslí.', 'brilo-blocks')}
|
|
140
|
+
id="faq-group-border-color"
|
|
141
|
+
>
|
|
142
|
+
<ColorPalette
|
|
143
|
+
colors={paletteColors}
|
|
144
|
+
value={style.borderColor || undefined}
|
|
145
|
+
onChange={(value) => setAttributes({style: {...style, borderColor: value ?? ''}})}
|
|
146
|
+
/>
|
|
147
|
+
</BaseControl>
|
|
148
|
+
<BaseControl label={__('Barva pozadí', 'brilo-blocks')} id="faq-group-background-color">
|
|
149
|
+
<ColorPalette
|
|
150
|
+
colors={paletteColors}
|
|
151
|
+
value={style.backgroundColor || undefined}
|
|
152
|
+
onChange={(value) => setAttributes({style: {...style, backgroundColor: value ?? ''}})}
|
|
153
|
+
/>
|
|
154
|
+
</BaseControl>
|
|
155
|
+
<BaseControl label={__('Barva textu', 'brilo-blocks')} id="faq-group-text-color">
|
|
156
|
+
<ColorPalette
|
|
157
|
+
colors={paletteColors}
|
|
158
|
+
value={style.textColor || undefined}
|
|
159
|
+
onChange={(value) => setAttributes({style: {...style, textColor: value ?? ''}})}
|
|
160
|
+
/>
|
|
161
|
+
</BaseControl>
|
|
162
|
+
</PanelBody>
|
|
163
|
+
)}
|
|
164
|
+
<ItemSpacingPanel spacing={spacing} onChange={(v) => setAttributes({spacing: v})} />
|
|
48
165
|
</InspectorControls>
|
|
49
166
|
<div {...blockProps}>
|
|
50
167
|
<div {...innerBlocksProps} />
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
2
|
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
3
|
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {ITEM_SPACING_ATTRIBUTE} from '~/components/ItemSpacingControl'
|
|
4
5
|
import type {OptionArray} from '~/types'
|
|
5
|
-
import {DEFAULT_ICON_VARIANTS, FAQ_HEADING_LEVELS} from './constants'
|
|
6
|
+
import {DEFAULT_ICON_SIZE, DEFAULT_ICON_VARIANTS, DEFAULT_SHADOWS, FAQ_HEADING_LEVELS} from './constants'
|
|
6
7
|
import {createFaqGroupEdit} from './edit'
|
|
7
8
|
import type {FaqGroupAttributes, FaqGroupOptions} from './types'
|
|
8
9
|
|
|
@@ -12,6 +13,38 @@ export function createFaqGroupBlock<TIconVariants extends OptionArray = typeof D
|
|
|
12
13
|
options: FaqGroupOptions<TIconVariants>,
|
|
13
14
|
): BlockConfiguration<FaqGroupAttributes<TIconVariants[number]['value']>> {
|
|
14
15
|
const iconVariants = options.iconVariants ?? DEFAULT_ICON_VARIANTS
|
|
16
|
+
const exclude = options.exclude ?? []
|
|
17
|
+
|
|
18
|
+
const attributes: Record<string, unknown> = {
|
|
19
|
+
headingLevel: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
default: FAQ_HEADING_LEVELS[1],
|
|
22
|
+
enum: [...FAQ_HEADING_LEVELS],
|
|
23
|
+
},
|
|
24
|
+
iconVariant: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
default: iconVariants[1]?.value ?? iconVariants[0].value,
|
|
27
|
+
enum: iconVariants.map((v) => v.value),
|
|
28
|
+
},
|
|
29
|
+
...ITEM_SPACING_ATTRIBUTE,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!exclude.includes('colors')) {
|
|
33
|
+
attributes.style = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
default: {
|
|
36
|
+
shadow: DEFAULT_SHADOWS[0].value,
|
|
37
|
+
borderColor: '',
|
|
38
|
+
backgroundColor: '',
|
|
39
|
+
textColor: '',
|
|
40
|
+
icon: {
|
|
41
|
+
color: '',
|
|
42
|
+
background: '',
|
|
43
|
+
size: DEFAULT_ICON_SIZE,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
}
|
|
15
48
|
|
|
16
49
|
return {
|
|
17
50
|
name: options.name,
|
|
@@ -21,18 +54,7 @@ export function createFaqGroupBlock<TIconVariants extends OptionArray = typeof D
|
|
|
21
54
|
...(options.parent && {parent: options.parent}),
|
|
22
55
|
icon: options.icon ?? 'editor-help',
|
|
23
56
|
supports: {html: false, customClassName: false},
|
|
24
|
-
attributes
|
|
25
|
-
headingLevel: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
default: FAQ_HEADING_LEVELS[1],
|
|
28
|
-
enum: [...FAQ_HEADING_LEVELS],
|
|
29
|
-
},
|
|
30
|
-
iconVariant: {
|
|
31
|
-
type: 'string',
|
|
32
|
-
default: iconVariants[1]?.value ?? iconVariants[0].value,
|
|
33
|
-
enum: iconVariants.map((v) => v.value),
|
|
34
|
-
},
|
|
35
|
-
},
|
|
57
|
+
attributes,
|
|
36
58
|
edit: createFaqGroupEdit(options as unknown as FaqGroupOptions),
|
|
37
59
|
save: () => <InnerBlocks.Content />,
|
|
38
60
|
} as unknown as BlockConfiguration<FaqGroupAttributes<TIconVariants[number]['value']>>
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type {
|
|
2
|
+
ExcludableFaqAttr,
|
|
3
|
+
FaqGroupAttributes,
|
|
4
|
+
FaqGroupOptions,
|
|
5
|
+
FaqHeadingLevel,
|
|
6
|
+
FaqIconVariant,
|
|
7
|
+
FaqShadow,
|
|
8
|
+
FaqSizePreset,
|
|
9
|
+
} from './types'
|
|
2
10
|
export {createFaqGroupBlock} from './factory'
|
|
3
11
|
|
|
4
12
|
import type {FaqGroupOptions} from './types'
|
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
import type {BriloBlockType, OptionArray} from '~/types'
|
|
2
|
-
import type {DEFAULT_ICON_VARIANTS, FAQ_HEADING_LEVELS} from './constants'
|
|
2
|
+
import type {DEFAULT_ICON_VARIANTS, DEFAULT_SHADOWS, FAQ_HEADING_LEVELS} from './constants'
|
|
3
3
|
|
|
4
4
|
export type FaqHeadingLevel = (typeof FAQ_HEADING_LEVELS)[number]
|
|
5
5
|
export type FaqIconVariant = (typeof DEFAULT_ICON_VARIANTS)[number]['value']
|
|
6
|
+
export type FaqShadow = (typeof DEFAULT_SHADOWS)[number]['value']
|
|
7
|
+
|
|
8
|
+
export type ExcludableFaqAttr = 'colors'
|
|
9
|
+
|
|
10
|
+
export interface FaqSizePreset {
|
|
11
|
+
value: number
|
|
12
|
+
label: string
|
|
13
|
+
}
|
|
6
14
|
|
|
7
15
|
export interface FaqGroupAttributes<TIconVariant extends string = FaqIconVariant> extends Record<string, unknown> {
|
|
8
16
|
headingLevel: FaqHeadingLevel
|
|
9
17
|
iconVariant: TIconVariant
|
|
18
|
+
style: {
|
|
19
|
+
shadow: FaqShadow
|
|
20
|
+
borderColor: string
|
|
21
|
+
backgroundColor: string
|
|
22
|
+
textColor: string
|
|
23
|
+
icon: {
|
|
24
|
+
color: string
|
|
25
|
+
background: string
|
|
26
|
+
size: number
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
spacing?: number
|
|
10
30
|
}
|
|
11
31
|
|
|
12
32
|
export interface FaqGroupOptions<TIconVariants extends OptionArray = typeof DEFAULT_ICON_VARIANTS> extends BriloBlockType {
|
|
13
33
|
iconVariants?: TIconVariants
|
|
34
|
+
iconSizePresets?: readonly FaqSizePreset[]
|
|
35
|
+
exclude?: ExcludableFaqAttr[]
|
|
14
36
|
}
|