@brilo/base-blocks 0.1.7 → 0.1.9
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/blocks/column/column-item/constants.d.ts +13 -0
- package/build/blocks/column/column-item/constants.d.ts.map +1 -1
- package/build/blocks/column/column-item/constants.js +19 -0
- package/build/blocks/column/column-item/edit.d.ts.map +1 -1
- package/build/blocks/column/column-item/edit.js +6 -6
- package/build/blocks/column/column-item/factory.d.ts.map +1 -1
- package/build/blocks/column/column-item/factory.js +5 -0
- package/build/blocks/column/column-item/index.d.ts.map +1 -1
- package/build/blocks/column/column-item/index.js +11 -1
- package/build/blocks/column/column-item/types.d.ts +1 -0
- package/build/blocks/column/column-item/types.d.ts.map +1 -1
- package/build/blocks/contact/contact-item/factory.d.ts +7 -2
- package/build/blocks/contact/contact-item/factory.d.ts.map +1 -1
- package/build/blocks/contact/contact-item/factory.js +2 -2
- package/build/blocks/core/basic-button/edit.d.ts.map +1 -1
- package/build/blocks/core/basic-button/edit.js +12 -5
- package/build/blocks/core/basic-button/factory.d.ts.map +1 -1
- package/build/blocks/core/basic-button/factory.js +4 -0
- package/build/blocks/core/basic-button/index.d.ts.map +1 -1
- package/build/blocks/core/basic-button/index.js +2 -0
- package/build/blocks/core/basic-button/types.d.ts +12 -1
- package/build/blocks/core/basic-button/types.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-group/constants.d.ts +21 -0
- package/build/blocks/gallery/gallery-group/constants.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-group/constants.js +9 -0
- package/build/blocks/gallery/gallery-group/edit.d.ts +7 -0
- package/build/blocks/gallery/gallery-group/edit.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-group/edit.js +46 -0
- package/build/blocks/gallery/gallery-group/factory.d.ts +5 -0
- package/build/blocks/gallery/gallery-group/factory.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-group/factory.js +33 -0
- package/build/blocks/gallery/gallery-group/index.d.ts +5 -0
- package/build/blocks/gallery/gallery-group/index.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-group/index.js +7 -0
- package/build/blocks/gallery/gallery-group/types.d.ts +15 -0
- package/build/blocks/gallery/gallery-group/types.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-group/types.js +1 -0
- package/build/blocks/gallery/gallery-item/edit.d.ts +6 -0
- package/build/blocks/gallery/gallery-item/edit.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-item/edit.js +13 -0
- package/build/blocks/gallery/gallery-item/factory.d.ts +5 -0
- package/build/blocks/gallery/gallery-item/factory.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-item/factory.js +22 -0
- package/build/blocks/gallery/gallery-item/index.d.ts +5 -0
- package/build/blocks/gallery/gallery-item/index.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-item/index.js +6 -0
- package/build/blocks/gallery/gallery-item/types.d.ts +7 -0
- package/build/blocks/gallery/gallery-item/types.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-item/types.js +1 -0
- package/build/blocks/groups/content-group/factory.d.ts +2 -2
- package/build/blocks/groups/content-group/factory.d.ts.map +1 -1
- package/build/blocks/groups/content-group/factory.js +8 -8
- package/build/blocks/groups/content-group/icon.d.ts.map +1 -1
- package/build/blocks/link/link-item/constants.d.ts +11 -0
- package/build/blocks/link/link-item/constants.d.ts.map +1 -0
- package/build/blocks/link/link-item/constants.js +6 -0
- package/build/blocks/link/link-item/edit.d.ts +6 -0
- package/build/blocks/link/link-item/edit.d.ts.map +1 -0
- package/build/blocks/link/link-item/edit.js +25 -0
- package/build/blocks/link/link-item/factory.d.ts +4 -0
- package/build/blocks/link/link-item/factory.d.ts.map +1 -0
- package/build/blocks/link/link-item/factory.js +28 -0
- package/build/blocks/link/link-item/icon.d.ts +2 -0
- package/build/blocks/link/link-item/icon.d.ts.map +1 -0
- package/build/blocks/link/link-item/icon.js +2 -0
- package/build/blocks/link/link-item/index.d.ts +5 -0
- package/build/blocks/link/link-item/index.d.ts.map +1 -0
- package/build/blocks/link/link-item/index.js +6 -0
- package/build/blocks/link/link-item/types.d.ts +26 -0
- package/build/blocks/link/link-item/types.d.ts.map +1 -0
- package/build/blocks/link/link-item/types.js +1 -0
- package/build/blocks/map/map-group/constants.d.ts +1 -0
- package/build/blocks/map/map-group/constants.d.ts.map +1 -1
- package/build/blocks/map/map-group/constants.js +2 -0
- package/build/blocks/map/map-group/edit.d.ts.map +1 -1
- package/build/blocks/map/map-group/edit.js +19 -11
- package/build/blocks/map/map-group/factory.d.ts +3 -1
- package/build/blocks/map/map-group/factory.d.ts.map +1 -1
- package/build/blocks/map/map-group/factory.js +24 -5
- package/build/blocks/map/map-group/index.d.ts.map +1 -1
- package/build/blocks/map/map-group/index.js +1 -0
- package/build/blocks/map/map-group/types.d.ts +18 -4
- package/build/blocks/map/map-group/types.d.ts.map +1 -1
- package/build/blocks/person/person-group/constants.d.ts +3 -0
- package/build/blocks/person/person-group/constants.d.ts.map +1 -0
- package/build/blocks/person/person-group/constants.js +2 -0
- package/build/blocks/person/person-group/edit.d.ts +6 -0
- package/build/blocks/person/person-group/edit.d.ts.map +1 -0
- package/build/blocks/person/person-group/edit.js +23 -0
- package/build/blocks/person/person-group/factory.d.ts +5 -0
- package/build/blocks/person/person-group/factory.d.ts.map +1 -0
- package/build/blocks/person/person-group/factory.js +32 -0
- package/build/blocks/person/person-group/icon.d.ts +2 -0
- package/build/blocks/person/person-group/icon.d.ts.map +1 -0
- package/build/blocks/person/person-group/icon.js +2 -0
- package/build/blocks/person/person-group/index.d.ts +5 -0
- package/build/blocks/person/person-group/index.d.ts.map +1 -0
- package/build/blocks/person/person-group/index.js +11 -0
- package/build/blocks/person/person-group/types.d.ts +8 -0
- package/build/blocks/person/person-group/types.d.ts.map +1 -0
- package/build/blocks/person/person-group/types.js +1 -0
- package/build/blocks/person/person-item/constants.d.ts +2 -0
- package/build/blocks/person/person-item/constants.d.ts.map +1 -0
- package/build/blocks/person/person-item/constants.js +1 -0
- package/build/blocks/person/person-item/edit.d.ts +6 -0
- package/build/blocks/person/person-item/edit.d.ts.map +1 -0
- package/build/blocks/person/person-item/edit.js +23 -0
- package/build/blocks/person/person-item/factory.d.ts +5 -0
- package/build/blocks/person/person-item/factory.d.ts.map +1 -0
- package/build/blocks/person/person-item/factory.js +26 -0
- package/build/blocks/person/person-item/icon.d.ts +2 -0
- package/build/blocks/person/person-item/icon.d.ts.map +1 -0
- package/build/blocks/person/person-item/icon.js +3 -0
- package/build/blocks/person/person-item/index.d.ts +5 -0
- package/build/blocks/person/person-item/index.d.ts.map +1 -0
- package/build/blocks/person/person-item/index.js +6 -0
- package/build/blocks/person/person-item/types.d.ts +12 -0
- package/build/blocks/person/person-item/types.d.ts.map +1 -0
- package/build/blocks/person/person-item/types.js +1 -0
- package/build/blocks/sections/base-section/attributes.d.ts +5 -1
- package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
- package/build/blocks/sections/base-section/attributes.js +5 -1
- package/build/blocks/sections/base-section/constants.d.ts +0 -16
- package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.js +0 -7
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/controls.js +6 -3
- package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
- package/build/blocks/sections/base-section/edit.js +8 -1
- package/build/blocks/sections/base-section/factory.d.ts.map +1 -1
- package/build/blocks/sections/base-section/factory.js +3 -8
- package/build/blocks/sections/base-section/index.d.ts +1 -1
- package/build/blocks/sections/base-section/index.d.ts.map +1 -1
- package/build/blocks/sections/base-section/index.js +1 -1
- package/build/blocks/sections/base-section/types.d.ts +1 -0
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/build/components/ImagePicker/ImagePicker.d.ts +5 -0
- package/build/components/ImagePicker/ImagePicker.d.ts.map +1 -1
- package/build/components/ImagePicker/ImagePicker.js +18 -11
- package/build/hooks/useTenantColorPalette.d.ts +9 -0
- package/build/hooks/useTenantColorPalette.d.ts.map +1 -0
- package/build/hooks/useTenantColorPalette.js +12 -0
- package/build/index.d.ts +11 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -1
- package/build/types.d.ts +2 -0
- package/build/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/blocks/column/column-item/constants.ts +20 -0
- package/src/blocks/column/column-item/edit.tsx +20 -4
- package/src/blocks/column/column-item/factory.tsx +5 -0
- package/src/blocks/column/column-item/index.ts +11 -1
- package/src/blocks/column/column-item/types.ts +1 -0
- package/src/blocks/contact/contact-item/editor.scss +4 -0
- package/src/blocks/contact/contact-item/factory.tsx +13 -5
- package/src/blocks/core/basic-button/edit.tsx +50 -1
- package/src/blocks/core/basic-button/factory.tsx +4 -0
- package/src/blocks/core/basic-button/index.ts +2 -0
- package/src/blocks/core/basic-button/types.ts +13 -1
- package/src/blocks/gallery/gallery-group/constants.ts +10 -0
- package/src/blocks/gallery/gallery-group/edit.tsx +117 -0
- package/src/blocks/gallery/gallery-group/editor.scss +18 -0
- package/src/blocks/gallery/gallery-group/factory.tsx +36 -0
- package/src/blocks/gallery/gallery-group/index.ts +11 -0
- package/src/blocks/gallery/gallery-group/types.ts +21 -0
- package/src/blocks/gallery/gallery-item/edit.tsx +46 -0
- package/src/blocks/gallery/gallery-item/editor.scss +8 -0
- package/src/blocks/gallery/gallery-item/factory.tsx +26 -0
- package/src/blocks/gallery/gallery-item/index.ts +10 -0
- package/src/blocks/gallery/gallery-item/types.ts +7 -0
- package/src/blocks/groups/content-group/factory.tsx +11 -11
- package/src/blocks/groups/content-group/icon.tsx +1 -1
- package/src/blocks/link/link-item/constants.ts +7 -0
- package/src/blocks/link/link-item/edit.tsx +124 -0
- package/src/blocks/link/link-item/editor.scss +11 -0
- package/src/blocks/link/link-item/factory.tsx +30 -0
- package/src/blocks/link/link-item/icon.tsx +6 -0
- package/src/blocks/link/link-item/index.ts +10 -0
- package/src/blocks/link/link-item/types.ts +25 -0
- package/src/blocks/map/map-group/constants.ts +3 -0
- package/src/blocks/map/map-group/edit.tsx +75 -5
- package/src/blocks/map/map-group/editor.scss +7 -0
- package/src/blocks/map/map-group/factory.tsx +26 -4
- package/src/blocks/map/map-group/index.ts +1 -0
- package/src/blocks/map/map-group/types.ts +16 -4
- package/src/blocks/person/person-group/constants.ts +2 -0
- package/src/blocks/person/person-group/edit.tsx +65 -0
- package/src/blocks/person/person-group/editor.scss +0 -0
- package/src/blocks/person/person-group/factory.tsx +35 -0
- package/src/blocks/person/person-group/icon.tsx +14 -0
- package/src/blocks/person/person-group/index.ts +15 -0
- package/src/blocks/person/person-group/types.ts +8 -0
- package/src/blocks/person/person-item/constants.ts +4 -0
- package/src/blocks/person/person-item/edit.tsx +103 -0
- package/src/blocks/person/person-item/editor.scss +35 -0
- package/src/blocks/person/person-item/factory.tsx +29 -0
- package/src/blocks/person/person-item/icon.tsx +7 -0
- package/src/blocks/person/person-item/index.ts +10 -0
- package/src/blocks/person/person-item/types.ts +12 -0
- package/src/blocks/responsive-grid/responsive-grid-item/editor.scss +9 -0
- package/src/blocks/sections/base-section/attributes.ts +5 -1
- package/src/blocks/sections/base-section/constants.ts +0 -8
- package/src/blocks/sections/base-section/controls.tsx +18 -8
- package/src/blocks/sections/base-section/edit.tsx +8 -1
- package/src/blocks/sections/base-section/factory.tsx +3 -7
- package/src/blocks/sections/base-section/index.ts +1 -1
- package/src/blocks/sections/base-section/types.ts +1 -0
- package/src/components/ImagePicker/ImagePicker.tsx +22 -10
- package/src/components/ImagePicker/editor.scss +2 -2
- package/src/editor.scss +6 -0
- package/src/hooks/useTenantColorPalette.ts +21 -0
- package/src/index.ts +10 -1
- package/src/types.ts +3 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {ColorPalette, InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
RangeControl,
|
|
5
|
+
TextControl,
|
|
6
|
+
ToggleControl,
|
|
7
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
8
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
9
|
+
} from '@wordpress/components'
|
|
10
|
+
import {__} from '@wordpress/i18n'
|
|
11
|
+
import clsx from 'clsx'
|
|
12
|
+
import {ItemIconControl, ItemIconPreview} from '~/components/ItemIconControl'
|
|
13
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
14
|
+
import {ICON_TYPES} from './constants'
|
|
15
|
+
import type {LinkItemAttributes, LinkItemOptions} from './types'
|
|
16
|
+
|
|
17
|
+
export function createLinkItemEdit(options: LinkItemOptions) {
|
|
18
|
+
return function Edit({
|
|
19
|
+
attributes,
|
|
20
|
+
setAttributes,
|
|
21
|
+
}: {
|
|
22
|
+
attributes: LinkItemAttributes
|
|
23
|
+
setAttributes: (a: Partial<LinkItemAttributes>) => void
|
|
24
|
+
}) {
|
|
25
|
+
const {title, url, icon, color, underline_initial, size} = attributes
|
|
26
|
+
const {paletteColors} = useTenantColorPalette()
|
|
27
|
+
const hasIcon = icon.type !== 'none' && (icon.src || icon.media?.id)
|
|
28
|
+
|
|
29
|
+
const setIconBase = (attrs: {icon: import('~/types').Icon}) => {
|
|
30
|
+
setAttributes({icon: {...icon, ...attrs.icon} as typeof icon})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const blockProps = useBlockProps({
|
|
34
|
+
className: clsx('link-item', underline_initial && '--underline-initial'),
|
|
35
|
+
style: color ? {color} : undefined,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const iconPreviewStyle = {maxWidth: icon.size, flex: `0 0 ${icon.size}px`} as React.CSSProperties
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
<InspectorControls>
|
|
43
|
+
<PanelBody title={__('Odkaz', 'brilo-blocks')}>
|
|
44
|
+
<TextControl label={__('URL', 'brilo-blocks')} value={url.src} onChange={(v) => setAttributes({url: {...url, src: v}})} />
|
|
45
|
+
<ToggleControl
|
|
46
|
+
label={__('Otevřít v nové záložce', 'brilo-blocks')}
|
|
47
|
+
checked={url.blank}
|
|
48
|
+
onChange={(v) => setAttributes({url: {...url, blank: v}})}
|
|
49
|
+
/>
|
|
50
|
+
</PanelBody>
|
|
51
|
+
|
|
52
|
+
<PanelBody title={__('Ikona', 'brilo-blocks')} initialOpen={false}>
|
|
53
|
+
<ItemIconControl
|
|
54
|
+
icon={icon as unknown as import('~/types').Icon}
|
|
55
|
+
setAttributes={setIconBase}
|
|
56
|
+
iconTypes={ICON_TYPES}
|
|
57
|
+
options={options}
|
|
58
|
+
/>
|
|
59
|
+
{hasIcon && (
|
|
60
|
+
<>
|
|
61
|
+
<ToggleGroupControl
|
|
62
|
+
isBlock
|
|
63
|
+
label={__('Pozice', 'brilo-blocks')}
|
|
64
|
+
value={icon.position}
|
|
65
|
+
onChange={(v) => setAttributes({icon: {...icon, position: String(v) as 'before' | 'after'}})}
|
|
66
|
+
>
|
|
67
|
+
<ToggleGroupControlOption value="before" label={__('Před', 'brilo-blocks')} />
|
|
68
|
+
<ToggleGroupControlOption value="after" label={__('Za', 'brilo-blocks')} />
|
|
69
|
+
</ToggleGroupControl>
|
|
70
|
+
<RangeControl
|
|
71
|
+
label={__('Velikost (px)', 'brilo-blocks')}
|
|
72
|
+
value={icon.size}
|
|
73
|
+
onChange={(v) => setAttributes({icon: {...icon, size: v ?? 24}})}
|
|
74
|
+
min={8}
|
|
75
|
+
max={80}
|
|
76
|
+
step={1}
|
|
77
|
+
/>
|
|
78
|
+
</>
|
|
79
|
+
)}
|
|
80
|
+
</PanelBody>
|
|
81
|
+
|
|
82
|
+
<PanelBody title={__('Styl', 'brilo-blocks')} initialOpen={false}>
|
|
83
|
+
<p>{__('Barva', 'brilo-blocks')}</p>
|
|
84
|
+
<ColorPalette colors={paletteColors} value={color || undefined} onChange={(v) => setAttributes({color: v ?? ''})} />
|
|
85
|
+
<ToggleControl
|
|
86
|
+
label={__('Podtržení výchozí', 'brilo-blocks')}
|
|
87
|
+
checked={underline_initial}
|
|
88
|
+
onChange={(v) => setAttributes({underline_initial: v})}
|
|
89
|
+
/>
|
|
90
|
+
<RangeControl
|
|
91
|
+
label={__('Velikost textu (px)', 'brilo-blocks')}
|
|
92
|
+
value={size}
|
|
93
|
+
onChange={(v) => setAttributes({size: v ?? 16})}
|
|
94
|
+
min={8}
|
|
95
|
+
max={80}
|
|
96
|
+
step={1}
|
|
97
|
+
/>
|
|
98
|
+
</PanelBody>
|
|
99
|
+
</InspectorControls>
|
|
100
|
+
|
|
101
|
+
<div {...blockProps}>
|
|
102
|
+
{hasIcon && icon.position === 'before' && (
|
|
103
|
+
<span className="link-item__icon" style={iconPreviewStyle}>
|
|
104
|
+
<ItemIconPreview icon={icon as unknown as import('~/types').Icon} setAttributes={setIconBase} options={options} />
|
|
105
|
+
</span>
|
|
106
|
+
)}
|
|
107
|
+
<RichText
|
|
108
|
+
tagName="span"
|
|
109
|
+
className="link-item__title"
|
|
110
|
+
value={title}
|
|
111
|
+
onChange={(v) => setAttributes({title: v})}
|
|
112
|
+
placeholder={__('Text odkazu...', 'brilo-blocks')}
|
|
113
|
+
allowedFormats={['core/bold', 'core/italic']}
|
|
114
|
+
/>
|
|
115
|
+
{hasIcon && icon.position === 'after' && (
|
|
116
|
+
<span className="link-item__icon" style={iconPreviewStyle}>
|
|
117
|
+
<ItemIconPreview icon={icon as unknown as import('~/types').Icon} setAttributes={setIconBase} options={options} />
|
|
118
|
+
</span>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
</>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {type BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createLinkItemEdit} from './edit'
|
|
4
|
+
import {icon as defaultIcon} from './icon'
|
|
5
|
+
import type {LinkItemAttributes, LinkItemOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export function createLinkItemBlock(options: LinkItemOptions): BlockConfiguration<LinkItemAttributes> {
|
|
8
|
+
return {
|
|
9
|
+
name: options.name,
|
|
10
|
+
title: options.title ?? __('Odkaz', 'brilo-blocks'),
|
|
11
|
+
description: options.description,
|
|
12
|
+
category: options.category ?? 'text',
|
|
13
|
+
...(options.parent && {parent: options.parent}),
|
|
14
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
15
|
+
supports: {html: false, customClassName: false},
|
|
16
|
+
attributes: {
|
|
17
|
+
title: {type: 'string', default: ''},
|
|
18
|
+
url: {type: 'object', default: {src: '', blank: false}},
|
|
19
|
+
icon: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
default: {type: 'none', src: '', media: {}, position: 'after', size: 24},
|
|
22
|
+
},
|
|
23
|
+
color: {type: 'string', default: ''},
|
|
24
|
+
size: {type: 'number', default: 16},
|
|
25
|
+
underline_initial: {type: 'boolean', default: false},
|
|
26
|
+
},
|
|
27
|
+
edit: createLinkItemEdit(options),
|
|
28
|
+
save: () => null,
|
|
29
|
+
} as BlockConfiguration<LinkItemAttributes>
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M8 4H4C2.895 4 2 4.895 2 6v10c0 1.105.895 2 2 2h10c1.105 0 2-.895 2-2v-4" stroke="black" strokeWidth="1.5" fill="none" />
|
|
4
|
+
<path d="M12 2h6v6M18 2L10 10" stroke="black" strokeWidth="1.5" strokeLinecap="round" />
|
|
5
|
+
</svg>
|
|
6
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {LinkItemAttributes, LinkItemIcon, LinkItemOptions} from './types'
|
|
2
|
+
export {createLinkItemBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {LinkItemOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const linkItemDefaults: LinkItemOptions = {
|
|
7
|
+
name: 'brilo/link-item',
|
|
8
|
+
icons: [],
|
|
9
|
+
iconsSrc: '',
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {Media} from '~/types'
|
|
2
|
+
import type {BriloBlockType} from '~/types'
|
|
3
|
+
import type {IconType} from '~/components/IconControl'
|
|
4
|
+
|
|
5
|
+
export interface LinkItemIcon {
|
|
6
|
+
type: 'preselected' | 'media' | 'none'
|
|
7
|
+
src: string
|
|
8
|
+
media: Media
|
|
9
|
+
position: 'before' | 'after'
|
|
10
|
+
size: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface LinkItemAttributes extends Record<string, unknown> {
|
|
14
|
+
title: string
|
|
15
|
+
url: {src: string; blank: boolean}
|
|
16
|
+
icon: LinkItemIcon
|
|
17
|
+
color: string
|
|
18
|
+
size: number
|
|
19
|
+
underline_initial: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface LinkItemOptions extends BriloBlockType {
|
|
23
|
+
icons: IconType[]
|
|
24
|
+
iconsSrc: string
|
|
25
|
+
}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
-
import {
|
|
1
|
+
import {InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
BaseControl,
|
|
5
|
+
TextControl,
|
|
6
|
+
SelectControl,
|
|
7
|
+
TextareaControl,
|
|
8
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
9
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
10
|
+
} from '@wordpress/components'
|
|
3
11
|
import {__} from '@wordpress/i18n'
|
|
4
12
|
import {ImagePickerControl} from '~/components/ImagePicker'
|
|
5
13
|
import {MAP_TYPES} from './constants'
|
|
6
14
|
import type {MapGroupAttributes, MapGroupOptions} from './types'
|
|
7
15
|
import {Icon, mapMarker} from '@wordpress/icons'
|
|
16
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
17
|
+
import clsx from 'clsx'
|
|
18
|
+
import type {HeadingLevels, HeadingStyles} from '~/blocks/groups/banner-group/types'
|
|
19
|
+
import {HEADING_LEVELS, HEADING_STYLES} from '~/constants'
|
|
8
20
|
|
|
9
21
|
export function createMapGroupEdit(options: MapGroupOptions) {
|
|
10
22
|
return function Edit({
|
|
@@ -14,15 +26,45 @@ export function createMapGroupEdit(options: MapGroupOptions) {
|
|
|
14
26
|
attributes: MapGroupAttributes
|
|
15
27
|
setAttributes: (a: Partial<MapGroupAttributes>) => void
|
|
16
28
|
}) {
|
|
17
|
-
const {mapType, iframeSrc, iframeElement, img, url, lat, long} = attributes
|
|
29
|
+
const {mapType, iframeSrc, iframeElement, img, url, address, lat, long, description, header} = attributes
|
|
18
30
|
|
|
19
|
-
const blockProps =
|
|
20
|
-
|
|
31
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
32
|
+
blockClassName: clsx(options.blockClassName ?? 'g-map wp-block-section'),
|
|
33
|
+
containerClassName: [options.containerClassName ?? 'g-map__button-wraper wp-block-inner-content'],
|
|
34
|
+
allowedBlocks: options.allowedBlocks,
|
|
35
|
+
orientation: 'vertical',
|
|
36
|
+
template: options.template,
|
|
37
|
+
layout: {type: 'default'},
|
|
21
38
|
})
|
|
22
39
|
|
|
23
40
|
return (
|
|
24
41
|
<>
|
|
25
42
|
<InspectorControls>
|
|
43
|
+
<PanelBody title={__('Nadpis', 'brilo-blocks')} initialOpen={false}>
|
|
44
|
+
<ToggleGroupControl
|
|
45
|
+
label={__('Úroveň nadpisu', 'brilo-blocks')}
|
|
46
|
+
value={String(header.heading.level)}
|
|
47
|
+
onChange={(value) =>
|
|
48
|
+
setAttributes({header: {...header, heading: {...header.heading, level: Number(value) as HeadingLevels}}})
|
|
49
|
+
}
|
|
50
|
+
isBlock
|
|
51
|
+
>
|
|
52
|
+
{HEADING_LEVELS.map((l) => (
|
|
53
|
+
<ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
|
|
54
|
+
))}
|
|
55
|
+
</ToggleGroupControl>
|
|
56
|
+
<ToggleGroupControl
|
|
57
|
+
label={__('Styl nadpisu', 'brilo-blocks')}
|
|
58
|
+
value={header.heading.style}
|
|
59
|
+
onChange={(value) => setAttributes({header: {...header, heading: {...header.heading, style: value as HeadingStyles}}})}
|
|
60
|
+
isBlock
|
|
61
|
+
>
|
|
62
|
+
{HEADING_STYLES.map((s) => (
|
|
63
|
+
<ToggleGroupControlOption key={s} value={s} label={s} />
|
|
64
|
+
))}
|
|
65
|
+
</ToggleGroupControl>
|
|
66
|
+
</PanelBody>
|
|
67
|
+
|
|
26
68
|
<PanelBody title={__('Nastavení mapy', 'brilo-blocks')}>
|
|
27
69
|
<SelectControl
|
|
28
70
|
label={__('Typ mapy', 'brilo-blocks')}
|
|
@@ -74,12 +116,40 @@ export function createMapGroupEdit(options: MapGroupOptions) {
|
|
|
74
116
|
value={url || ''}
|
|
75
117
|
onChange={(value: string) => setAttributes({url: value})}
|
|
76
118
|
/>
|
|
119
|
+
|
|
120
|
+
<TextControl
|
|
121
|
+
label={__('Adresa:', 'brilo-blocks')}
|
|
122
|
+
value={address || ''}
|
|
123
|
+
onChange={(value: string) => setAttributes({address: value})}
|
|
124
|
+
/>
|
|
77
125
|
</>
|
|
78
126
|
)}
|
|
79
127
|
</PanelBody>
|
|
80
128
|
</InspectorControls>
|
|
81
129
|
|
|
82
130
|
<div {...blockProps}>
|
|
131
|
+
<div className="g-map__banner">
|
|
132
|
+
<div className="g-map__content">
|
|
133
|
+
<RichText
|
|
134
|
+
tagName={`h${header.heading.level}` as HeadingStyles}
|
|
135
|
+
className={clsx('g-map__heading', `--heading-style-${header.heading.style}`, 'u-text-editable')}
|
|
136
|
+
value={header.heading.title}
|
|
137
|
+
onChange={(value: string) => setAttributes({header: {...header, heading: {...header.heading, title: value}}})}
|
|
138
|
+
placeholder={__('Nadpis...', 'brilo-blocks')}
|
|
139
|
+
allowedFormats={['core/bold', 'core/italic']}
|
|
140
|
+
/>
|
|
141
|
+
<RichText
|
|
142
|
+
tagName="div"
|
|
143
|
+
className="g-map__description u-text-editable"
|
|
144
|
+
value={description}
|
|
145
|
+
onChange={(value: string) => setAttributes({description: value})}
|
|
146
|
+
placeholder={__('Popis...', 'brilo-blocks')}
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<div {...innerBlocksProps} />
|
|
151
|
+
</div>
|
|
152
|
+
|
|
83
153
|
<div className="g-map__map">
|
|
84
154
|
{mapType === 'gps' && (lat || long) && (
|
|
85
155
|
<div>
|
|
@@ -3,10 +3,18 @@ import {__} from '@wordpress/i18n'
|
|
|
3
3
|
import {createMapGroupEdit} from './edit'
|
|
4
4
|
import type {MapGroupAttributes, MapGroupOptions} from './types'
|
|
5
5
|
import {MAP_TYPES} from './constants'
|
|
6
|
+
import type {StringArray} from '~/types'
|
|
7
|
+
import {DEFAULT_HEADING_STYLES, DEFAULT_VARIANTS} from '~/blocks/groups/banner-group/constants'
|
|
8
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
9
|
+
import {HEADING_LEVELS} from '~/constants'
|
|
6
10
|
|
|
7
11
|
export type {MapGroupAttributes, MapGroupOptions}
|
|
8
12
|
|
|
9
|
-
export function createMapGroupBlock
|
|
13
|
+
export function createMapGroupBlock<THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES>(
|
|
14
|
+
options: MapGroupOptions<THeadingStyles>,
|
|
15
|
+
): BlockConfiguration<MapGroupAttributes<THeadingStyles[number]>> {
|
|
16
|
+
const headingStyles = options.headingStyles ?? DEFAULT_HEADING_STYLES
|
|
17
|
+
|
|
10
18
|
return {
|
|
11
19
|
name: options.name,
|
|
12
20
|
title: options.title ?? __('Mapa', 'brilo-blocks'),
|
|
@@ -16,6 +24,16 @@ export function createMapGroupBlock(options: MapGroupOptions): BlockConfiguratio
|
|
|
16
24
|
icon: options.icon ?? 'location-alt',
|
|
17
25
|
supports: {html: false, customClassName: false},
|
|
18
26
|
attributes: {
|
|
27
|
+
header: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
default: {
|
|
30
|
+
heading: {title: '', level: HEADING_LEVELS[1], style: headingStyles[1] ?? headingStyles[0]},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
description: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: '',
|
|
36
|
+
},
|
|
19
37
|
mapType: {
|
|
20
38
|
type: 'string',
|
|
21
39
|
default: MAP_TYPES[0].value,
|
|
@@ -32,6 +50,10 @@ export function createMapGroupBlock(options: MapGroupOptions): BlockConfiguratio
|
|
|
32
50
|
type: 'object',
|
|
33
51
|
default: {id: 0, url: '', alt: ''},
|
|
34
52
|
},
|
|
53
|
+
address: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
default: '',
|
|
56
|
+
},
|
|
35
57
|
url: {
|
|
36
58
|
type: 'string',
|
|
37
59
|
default: '',
|
|
@@ -45,7 +67,7 @@ export function createMapGroupBlock(options: MapGroupOptions): BlockConfiguratio
|
|
|
45
67
|
default: '',
|
|
46
68
|
},
|
|
47
69
|
},
|
|
48
|
-
edit: createMapGroupEdit(options),
|
|
49
|
-
save: () =>
|
|
50
|
-
} as unknown as BlockConfiguration<MapGroupAttributes
|
|
70
|
+
edit: createMapGroupEdit(options as unknown as MapGroupOptions),
|
|
71
|
+
save: () => <InnerBlocks.Content />,
|
|
72
|
+
} as unknown as BlockConfiguration<MapGroupAttributes<THeadingStyles[number]>>
|
|
51
73
|
}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import {BriloBlockType, Media} from '~/types'
|
|
2
|
-
import {MAP_TYPES} from './constants'
|
|
1
|
+
import {BriloBlockType, Media, type OptionArray, type StringArray} from '~/types'
|
|
2
|
+
import {DEFAULT_HEADING_STYLES, MAP_TYPES} from './constants'
|
|
3
|
+
import {HEADING_LEVELS} from '~/constants'
|
|
3
4
|
|
|
4
5
|
export type MapType = (typeof MAP_TYPES)[number]['value']
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
+
export type HeadingLevels = (typeof HEADING_LEVELS)[number]
|
|
8
|
+
export type HeadingStyles = (typeof DEFAULT_HEADING_STYLES)[number]
|
|
9
|
+
|
|
10
|
+
export interface MapGroupAttributes<THeadingStyle extends string = HeadingStyles> extends Record<string, unknown> {
|
|
11
|
+
header: {
|
|
12
|
+
heading: {title: string; level: HeadingLevels; style: THeadingStyle}
|
|
13
|
+
}
|
|
14
|
+
description: string
|
|
7
15
|
mapType: MapType
|
|
8
16
|
iframeSrc: string
|
|
9
17
|
iframeElement: string
|
|
10
18
|
img: Media
|
|
19
|
+
address: string
|
|
11
20
|
url: string
|
|
12
21
|
lat: string
|
|
13
22
|
long: string
|
|
14
23
|
}
|
|
15
24
|
|
|
16
|
-
export interface MapGroupOptions extends BriloBlockType {
|
|
25
|
+
export interface MapGroupOptions<THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES> extends BriloBlockType {
|
|
26
|
+
headingStyles?: THeadingStyles
|
|
27
|
+
headingLevels?: HeadingLevels
|
|
28
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
5
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
6
|
+
} from '@wordpress/components'
|
|
7
|
+
import {__} from '@wordpress/i18n'
|
|
8
|
+
import clsx from 'clsx'
|
|
9
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
10
|
+
import {COLUMNS, HEADING_LEVELS} from './constants'
|
|
11
|
+
import type {PersonGroupAttributes, PersonGroupOptions} from './types'
|
|
12
|
+
|
|
13
|
+
export function createPersonGroupEdit(options: PersonGroupOptions) {
|
|
14
|
+
return function Edit({
|
|
15
|
+
attributes,
|
|
16
|
+
setAttributes,
|
|
17
|
+
}: {
|
|
18
|
+
attributes: PersonGroupAttributes
|
|
19
|
+
setAttributes: (a: Partial<PersonGroupAttributes>) => void
|
|
20
|
+
}) {
|
|
21
|
+
const {columns, headingLevel} = attributes
|
|
22
|
+
|
|
23
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
24
|
+
blockClassName: clsx(options.blockClassName ?? 'g-person wp-block-section'),
|
|
25
|
+
containerClassName: [options.containerClassName ?? 'u-grid-responsive', `--cols-${columns}`],
|
|
26
|
+
containerStyle: {'--grid-max-col-count': columns},
|
|
27
|
+
allowedBlocks: options.allowedBlocks,
|
|
28
|
+
orientation: 'horizontal',
|
|
29
|
+
template: options.template,
|
|
30
|
+
layout: {type: 'default'},
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<InspectorControls>
|
|
36
|
+
<PanelBody title={__('Rozložení', 'brilo-blocks')}>
|
|
37
|
+
<ToggleGroupControl
|
|
38
|
+
isBlock
|
|
39
|
+
label={__('Počet sloupců', 'brilo-blocks')}
|
|
40
|
+
value={String(columns)}
|
|
41
|
+
onChange={(v) => setAttributes({columns: Number(v) as PersonGroupAttributes['columns']})}
|
|
42
|
+
>
|
|
43
|
+
{COLUMNS.map((c) => (
|
|
44
|
+
<ToggleGroupControlOption key={c} value={String(c)} label={String(c)} />
|
|
45
|
+
))}
|
|
46
|
+
</ToggleGroupControl>
|
|
47
|
+
<ToggleGroupControl
|
|
48
|
+
isBlock
|
|
49
|
+
label={__('Úroveň nadpisu položek', 'brilo-blocks')}
|
|
50
|
+
value={String(headingLevel)}
|
|
51
|
+
onChange={(v) => setAttributes({headingLevel: Number(v)})}
|
|
52
|
+
>
|
|
53
|
+
{HEADING_LEVELS.map((l) => (
|
|
54
|
+
<ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
|
|
55
|
+
))}
|
|
56
|
+
</ToggleGroupControl>
|
|
57
|
+
</PanelBody>
|
|
58
|
+
</InspectorControls>
|
|
59
|
+
<div {...blockProps}>
|
|
60
|
+
<div {...innerBlocksProps} />
|
|
61
|
+
</div>
|
|
62
|
+
</>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {COLUMNS, HEADING_LEVELS} from './constants'
|
|
5
|
+
import {createPersonGroupEdit} from './edit'
|
|
6
|
+
import {icon as defaultIcon} from './icon'
|
|
7
|
+
import type {PersonGroupAttributes, PersonGroupOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export type {PersonGroupAttributes, PersonGroupOptions}
|
|
10
|
+
|
|
11
|
+
export function createPersonGroupBlock(options: PersonGroupOptions): BlockConfiguration<PersonGroupAttributes> {
|
|
12
|
+
return {
|
|
13
|
+
name: options.name,
|
|
14
|
+
title: options.title ?? __('Osoby', 'brilo-blocks'),
|
|
15
|
+
description: options.description,
|
|
16
|
+
category: options.category ?? 'layout',
|
|
17
|
+
...(options.parent && {parent: options.parent}),
|
|
18
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
19
|
+
supports: {html: false, customClassName: false},
|
|
20
|
+
attributes: {
|
|
21
|
+
columns: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
default: COLUMNS[1],
|
|
24
|
+
enum: [...COLUMNS],
|
|
25
|
+
},
|
|
26
|
+
headingLevel: {
|
|
27
|
+
type: 'number',
|
|
28
|
+
default: HEADING_LEVELS[0],
|
|
29
|
+
enum: [...HEADING_LEVELS],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
edit: createPersonGroupEdit(options),
|
|
33
|
+
save: () => <InnerBlocks.Content />,
|
|
34
|
+
} as unknown as BlockConfiguration<PersonGroupAttributes>
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<rect x="2.5" y="1.5" width="15" height="17" stroke="black" fill="none" />
|
|
4
|
+
<path d="M7 13H13V14H7V13Z" fill="black" />
|
|
5
|
+
<path d="M6 15H14V16H6V15Z" fill="black" />
|
|
6
|
+
<path d="M8 6C8 4.89543 8.89543 4 10 4C11.1046 4 12 4.89543 12 6C12 7.10457 11.1046 8 10 8C8.89543 8 8 7.10457 8 6Z" fill="#357AB5" />
|
|
7
|
+
<path
|
|
8
|
+
fill-rule="evenodd"
|
|
9
|
+
clip-rule="evenodd"
|
|
10
|
+
d="M6.99664 11H13.0009C12.9997 9.34295 11.6561 8 9.99875 8C8.34144 8 6.99778 9.34295 6.99664 11Z"
|
|
11
|
+
fill="#357AB5"
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
14
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type {PersonGroupAttributes, PersonGroupOptions} from './types'
|
|
2
|
+
export {createPersonGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {PersonGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const personGroupDefaults: PersonGroupOptions = {
|
|
7
|
+
name: 'brilo/person-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
allowedBlocks: ['brilo/person-item'],
|
|
10
|
+
template: [
|
|
11
|
+
['brilo/person-item', {}],
|
|
12
|
+
['brilo/person-item', {}],
|
|
13
|
+
['brilo/person-item', {}],
|
|
14
|
+
],
|
|
15
|
+
}
|