@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,103 @@
|
|
|
1
|
+
import {InspectorControls, RichText} from '@wordpress/block-editor'
|
|
2
|
+
import {PanelBody, TextControl} from '@wordpress/components'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {ImagePickerControl} from '~/components/ImagePicker'
|
|
5
|
+
import type {PersonItemAttributes, PersonItemOptions} from './types'
|
|
6
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
7
|
+
import clsx from 'clsx'
|
|
8
|
+
import {Icon, mobile, envelope} from '@wordpress/icons'
|
|
9
|
+
|
|
10
|
+
export function createPersonItemEdit(options: PersonItemOptions) {
|
|
11
|
+
return function Edit({
|
|
12
|
+
attributes,
|
|
13
|
+
setAttributes,
|
|
14
|
+
}: {
|
|
15
|
+
attributes: PersonItemAttributes
|
|
16
|
+
setAttributes: (a: Partial<PersonItemAttributes>) => void
|
|
17
|
+
}) {
|
|
18
|
+
const {title, description, img, email, phone} = attributes
|
|
19
|
+
|
|
20
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
21
|
+
blockClassName: clsx(options.blockClassName ?? 'i-person'),
|
|
22
|
+
containerClassName: [options.containerClassName ?? 'i-person__content wp-block-inner-content'],
|
|
23
|
+
allowedBlocks: options.allowedBlocks,
|
|
24
|
+
orientation: 'vertical',
|
|
25
|
+
template: options.template,
|
|
26
|
+
layout: {type: 'default'},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<InspectorControls>
|
|
32
|
+
<PanelBody title={__('Obrázek', 'brilo-blocks')}>
|
|
33
|
+
<ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
|
|
34
|
+
</PanelBody>
|
|
35
|
+
<PanelBody title={__('Kontakty', 'brilo-blocks')}>
|
|
36
|
+
<TextControl label={__('Email', 'brilo-blocks')} value={email} onChange={(v) => setAttributes({email: v})} />
|
|
37
|
+
<TextControl label={__('Telefon', 'brilo-blocks')} value={phone} onChange={(v) => setAttributes({phone: v})} />
|
|
38
|
+
</PanelBody>
|
|
39
|
+
</InspectorControls>
|
|
40
|
+
|
|
41
|
+
<div {...blockProps}>
|
|
42
|
+
<div className="i-person__inner">
|
|
43
|
+
<div className="i-person__image-wrapper">
|
|
44
|
+
{img.id ? (
|
|
45
|
+
<ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} size={[96, 96]} />
|
|
46
|
+
) : (
|
|
47
|
+
<div className="i-person__image-placeholder">
|
|
48
|
+
<ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<div className="i-person__body">
|
|
54
|
+
<RichText
|
|
55
|
+
tagName="h3"
|
|
56
|
+
className="i-person__title u-text-editable"
|
|
57
|
+
value={title}
|
|
58
|
+
onChange={(v) => setAttributes({title: v})}
|
|
59
|
+
placeholder={__('Nadpis...', 'brilo-blocks')}
|
|
60
|
+
allowedFormats={['core/bold', 'core/italic']}
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<RichText
|
|
64
|
+
tagName="p"
|
|
65
|
+
className="i-person__description u-text-editable"
|
|
66
|
+
value={description}
|
|
67
|
+
onChange={(v) => setAttributes({description: v})}
|
|
68
|
+
placeholder={__('Popis...', 'brilo-blocks')}
|
|
69
|
+
allowedFormats={['core/bold', 'core/italic']}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<div {...innerBlocksProps} />
|
|
73
|
+
|
|
74
|
+
<div className="i-person__contact">
|
|
75
|
+
<Icon icon={envelope} />
|
|
76
|
+
<RichText
|
|
77
|
+
tagName="p"
|
|
78
|
+
className="i-person__email u-text-editable"
|
|
79
|
+
value={email}
|
|
80
|
+
onChange={(v) => setAttributes({email: v})}
|
|
81
|
+
placeholder={__('Email...', 'brilo-blocks')}
|
|
82
|
+
allowedFormats={[]}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div className="i-person__contact">
|
|
87
|
+
<Icon icon={mobile} />
|
|
88
|
+
<RichText
|
|
89
|
+
tagName="p"
|
|
90
|
+
className="i-person__phone u-text-editable"
|
|
91
|
+
value={phone}
|
|
92
|
+
onChange={(v) => setAttributes({phone: v})}
|
|
93
|
+
placeholder={__('Telefon...', 'brilo-blocks')}
|
|
94
|
+
allowedFormats={[]}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.i-person {
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.i-person__inner {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: 8px;
|
|
10
|
+
padding: 12px;
|
|
11
|
+
border: 1px solid #eee;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.i-person__image-placeholder {
|
|
16
|
+
border: 1px dashed #0073aa;
|
|
17
|
+
padding: 16px 8px 8px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.i-person__image-wrapper {
|
|
21
|
+
.c-image-picker-control__row {
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.i-person__contact {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
|
|
31
|
+
.u-text-editable {
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createPersonItemEdit} from './edit'
|
|
4
|
+
import {icon as defaultIcon} from './icon'
|
|
5
|
+
import type {PersonItemAttributes, PersonItemOptions} from './types'
|
|
6
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
7
|
+
|
|
8
|
+
export type {PersonItemAttributes, PersonItemOptions}
|
|
9
|
+
|
|
10
|
+
export function createPersonItemBlock(options: PersonItemOptions): BlockConfiguration<PersonItemAttributes> {
|
|
11
|
+
return {
|
|
12
|
+
name: options.name,
|
|
13
|
+
title: options.title ?? __('Položka osoby', 'brilo-blocks'),
|
|
14
|
+
description: options.description,
|
|
15
|
+
category: options.category ?? 'layout',
|
|
16
|
+
...(options.parent && {parent: options.parent}),
|
|
17
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
18
|
+
supports: {html: false, customClassName: false},
|
|
19
|
+
attributes: {
|
|
20
|
+
title: {type: 'string', default: ''},
|
|
21
|
+
description: {type: 'string', default: ''},
|
|
22
|
+
img: {type: 'object', default: {id: 0, alt: ''}},
|
|
23
|
+
email: {type: 'string', default: ''},
|
|
24
|
+
phone: {type: 'string', default: ''},
|
|
25
|
+
},
|
|
26
|
+
edit: createPersonItemEdit(options),
|
|
27
|
+
save: () => <InnerBlocks.Content />,
|
|
28
|
+
} as unknown as BlockConfiguration<PersonItemAttributes>
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {Path, SVG} from '@wordpress/components'
|
|
2
|
+
|
|
3
|
+
export const icon = (
|
|
4
|
+
<SVG width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
5
|
+
<Path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" />
|
|
6
|
+
</SVG>
|
|
7
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {PersonItemAttributes, PersonItemOptions} from './types'
|
|
2
|
+
export {createPersonItemBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {PersonItemOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const personItemDefaults: PersonItemOptions = {
|
|
7
|
+
name: 'brilo/person-item',
|
|
8
|
+
parent: ['brilo/person-group'],
|
|
9
|
+
allowedBlocks: ['core/paragraph', 'core/list', 'core/heading'],
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {BriloBlockType} from '~/types'
|
|
2
|
+
import {ImageValue} from '~/components/ImagePicker/ImagePicker'
|
|
3
|
+
|
|
4
|
+
export interface PersonItemAttributes extends Record<string, unknown> {
|
|
5
|
+
title: string
|
|
6
|
+
description: string
|
|
7
|
+
img: ImageValue
|
|
8
|
+
email: string
|
|
9
|
+
phone: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface PersonItemOptions extends BriloBlockType {}
|
|
@@ -8,11 +8,3 @@ export const SPACING_POSITIONS = [
|
|
|
8
8
|
] as const
|
|
9
9
|
|
|
10
10
|
export const SPACING_SIZES = ['default', 'sm', 'xs'] as const
|
|
11
|
-
|
|
12
|
-
export const BACKGROUNDS = [
|
|
13
|
-
{value: 'none', label: __('Žádné', 'brilo-blocks')},
|
|
14
|
-
{value: 'primary', label: __('Primární', 'brilo-blocks')},
|
|
15
|
-
{value: 'secondary', label: __('Sekundární', 'brilo-blocks')},
|
|
16
|
-
{value: 'conversion', label: __('Konverzní', 'brilo-blocks')},
|
|
17
|
-
{value: 'neutral', label: __('Neutrální', 'brilo-blocks')},
|
|
18
|
-
] as const
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {ColorPalette, ContrastChecker} from '@wordpress/block-editor'
|
|
1
2
|
import {
|
|
2
3
|
PanelBody,
|
|
3
4
|
SelectControl,
|
|
@@ -6,8 +7,9 @@ import {
|
|
|
6
7
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
8
|
} from '@wordpress/components'
|
|
8
9
|
import {__} from '@wordpress/i18n'
|
|
10
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
9
11
|
import type {BaseBlockAttributes, ExcludableBaseAttr} from './types'
|
|
10
|
-
import {
|
|
12
|
+
import {SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
11
13
|
|
|
12
14
|
type SpacingPosition = BaseBlockAttributes['spacing']['position']
|
|
13
15
|
type SpacingSize = BaseBlockAttributes['spacing']['size']
|
|
@@ -19,7 +21,8 @@ interface BaseControlsProps {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export function BaseControls({attributes, setAttributes, exclude}: BaseControlsProps) {
|
|
22
|
-
const {id, spacing, background} = attributes
|
|
24
|
+
const {id, spacing, background, textColor} = attributes
|
|
25
|
+
const {paletteColors, resolveHex} = useTenantColorPalette()
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<>
|
|
@@ -45,13 +48,20 @@ export function BaseControls({attributes, setAttributes, exclude}: BaseControlsP
|
|
|
45
48
|
)}
|
|
46
49
|
|
|
47
50
|
{!exclude.includes('background') && (
|
|
48
|
-
<PanelBody title={__('
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onChange={(value) => setAttributes({background: value})}
|
|
51
|
+
<PanelBody title={__('Barvy', 'brilo-blocks')}>
|
|
52
|
+
<p>{__('Pozadí', 'brilo-blocks')}</p>
|
|
53
|
+
<ColorPalette
|
|
54
|
+
colors={paletteColors}
|
|
55
|
+
value={background || undefined}
|
|
56
|
+
onChange={(value) => setAttributes({background: value ?? ''})}
|
|
57
|
+
/>
|
|
58
|
+
<p>{__('Barva textu', 'brilo-blocks')}</p>
|
|
59
|
+
<ColorPalette
|
|
60
|
+
colors={paletteColors}
|
|
61
|
+
value={textColor || undefined}
|
|
62
|
+
onChange={(value) => setAttributes({textColor: value ?? ''})}
|
|
54
63
|
/>
|
|
64
|
+
{!!background && !!textColor && <ContrastChecker backgroundColor={resolveHex(background)} textColor={resolveHex(textColor)} />}
|
|
55
65
|
</PanelBody>
|
|
56
66
|
)}
|
|
57
67
|
|
|
@@ -8,7 +8,14 @@ export function createBaseSectionEdit<TExtra extends Record<string, unknown> = R
|
|
|
8
8
|
|
|
9
9
|
return function Edit(props: BlockEditProps<BaseBlockAttributes & TExtra>) {
|
|
10
10
|
const {attributes, setAttributes} = props
|
|
11
|
-
const
|
|
11
|
+
const {background, textColor} = attributes as BaseBlockAttributes
|
|
12
|
+
const blockProps = useBlockProps({
|
|
13
|
+
className: options.blockClassName,
|
|
14
|
+
style: {
|
|
15
|
+
...(background ? {backgroundColor: background, padding: '16px'} : {}),
|
|
16
|
+
...(textColor ? {color: textColor} : {}),
|
|
17
|
+
},
|
|
18
|
+
})
|
|
12
19
|
const innerBlocksProps = useInnerBlocksProps({className: options.containerClassName}, {
|
|
13
20
|
allowedBlocks: options.allowedBlocks,
|
|
14
21
|
orientation: 'vertical',
|
|
@@ -2,7 +2,6 @@ import {InnerBlocks} from '@wordpress/block-editor'
|
|
|
2
2
|
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
3
|
import {__} from '@wordpress/i18n'
|
|
4
4
|
import {baseAttributes} from './attributes'
|
|
5
|
-
import {BACKGROUNDS} from './constants'
|
|
6
5
|
import {createBaseSectionEdit} from './edit'
|
|
7
6
|
import {icon as defaultIcon} from './icon'
|
|
8
7
|
import type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './types'
|
|
@@ -16,12 +15,9 @@ export function createBaseSectionBlock<TExtra extends Record<string, unknown> =
|
|
|
16
15
|
|
|
17
16
|
const attributes: Record<string, unknown> = {}
|
|
18
17
|
for (const [key, value] of Object.entries(baseAttributes)) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
attributes[key] = value
|
|
24
|
-
}
|
|
18
|
+
const excludeKey: ExcludableBaseAttr = key === 'textColor' ? 'background' : (key as ExcludableBaseAttr)
|
|
19
|
+
if (!exclude.includes(excludeKey)) {
|
|
20
|
+
attributes[key] = value
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './types'
|
|
2
2
|
export {baseAttributes} from './attributes'
|
|
3
|
-
export {
|
|
3
|
+
export {SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
4
4
|
export {createBaseSectionEdit} from './edit'
|
|
5
5
|
export {createBaseSectionBlock} from './factory'
|
|
6
6
|
|
|
@@ -7,6 +7,7 @@ import {CSSProperties} from 'react'
|
|
|
7
7
|
export interface ImageValue {
|
|
8
8
|
id: number
|
|
9
9
|
alt: string
|
|
10
|
+
mimeType?: string
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export interface ImageLabels {
|
|
@@ -24,30 +25,38 @@ interface ImagePickerProps {
|
|
|
24
25
|
size?: [number, number]
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export function
|
|
28
|
+
export function useMediaData(id: number): {url?: string; mimeType?: string} {
|
|
28
29
|
return useSelect(
|
|
29
30
|
(select) => {
|
|
30
|
-
if (!id) return
|
|
31
|
+
if (!id) return {}
|
|
31
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
33
|
const media = (select('core') as any).getMedia(id)
|
|
33
|
-
return
|
|
34
|
+
return {
|
|
35
|
+
url: media?.source_url as string | undefined,
|
|
36
|
+
mimeType: media?.mime_type as string | undefined,
|
|
37
|
+
}
|
|
34
38
|
},
|
|
35
39
|
[id],
|
|
36
40
|
)
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
export function useMediaUrl(id: number): string | undefined {
|
|
44
|
+
return useMediaData(id).url
|
|
45
|
+
}
|
|
46
|
+
|
|
39
47
|
function useImagePicker(value: ImageValue, onChange: (v: ImageValue) => void, labels?: ImageLabels) {
|
|
40
|
-
const mediaUrl =
|
|
48
|
+
const {url: mediaUrl, mimeType} = useMediaData(value.id)
|
|
41
49
|
const selectLabel = labels?.select ?? __('Vybrat obrázek', 'brilo-blocks')
|
|
42
50
|
const changeLabel = labels?.change ?? __('Změnit', 'brilo-blocks')
|
|
43
51
|
const removeLabel = labels?.remove ?? __('Odebrat', 'brilo-blocks')
|
|
44
|
-
const handleSelect = (media: {id: number; alt: string
|
|
52
|
+
const handleSelect = (media: {id: number; alt: string; mime?: string; type?: string}) =>
|
|
53
|
+
onChange({id: media.id, alt: media.alt ?? '', mimeType: media.mime ?? (media.type === 'video' ? 'video' : undefined)})
|
|
45
54
|
const handleRemove = () => onChange({id: 0, alt: ''})
|
|
46
|
-
return {mediaUrl, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove}
|
|
55
|
+
return {mediaUrl, mimeType: value.mimeType ?? mimeType, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove}
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
export function ImagePickerBody({value, onChange, allowedTypes = ['image'], placeholder, labels}: ImagePickerProps) {
|
|
50
|
-
const {mediaUrl, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
|
|
59
|
+
const {mediaUrl, mimeType, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
|
|
51
60
|
|
|
52
61
|
return (
|
|
53
62
|
<MediaUploadCheck>
|
|
@@ -58,7 +67,10 @@ export function ImagePickerBody({value, onChange, allowedTypes = ['image'], plac
|
|
|
58
67
|
render={({open}: {open: () => void}) =>
|
|
59
68
|
value.id ? (
|
|
60
69
|
<div className="c-image-picker-body">
|
|
61
|
-
<div className="c-image-picker-body__preview">
|
|
70
|
+
<div className="c-image-picker-body__preview">
|
|
71
|
+
{mediaUrl &&
|
|
72
|
+
(mimeType?.startsWith('video') ? <video src={mediaUrl} autoPlay muted loop /> : <img src={mediaUrl} alt={value.alt} />)}
|
|
73
|
+
</div>
|
|
62
74
|
<div className="c-image-picker-body__actions">
|
|
63
75
|
<Button onClick={open} variant="secondary">
|
|
64
76
|
{changeLabel}
|
|
@@ -80,7 +92,7 @@ export function ImagePickerBody({value, onChange, allowedTypes = ['image'], plac
|
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
export function ImagePickerControl({value, onChange, allowedTypes = ['image'], placeholder, labels, size = [48, 48]}: ImagePickerProps) {
|
|
83
|
-
const {mediaUrl, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
|
|
95
|
+
const {mediaUrl, mimeType, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
|
|
84
96
|
|
|
85
97
|
return (
|
|
86
98
|
<div
|
|
@@ -101,7 +113,7 @@ export function ImagePickerControl({value, onChange, allowedTypes = ['image'], p
|
|
|
101
113
|
<div className="c-image-picker-control__row">
|
|
102
114
|
{!!value.id && !!mediaUrl && (
|
|
103
115
|
<div className="c-image-picker-control__thumb">
|
|
104
|
-
<img src={mediaUrl} alt={value.alt} />
|
|
116
|
+
{mimeType?.startsWith('video') ? <video src={mediaUrl} autoPlay muted loop /> : <img src={mediaUrl} alt={value.alt} />}
|
|
105
117
|
</div>
|
|
106
118
|
)}
|
|
107
119
|
<div className="c-image-picker-control__btns">
|
package/src/editor.scss
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@forward "./globals";
|
|
2
2
|
@forward "./blocks/column/column-group/editor";
|
|
3
|
+
@forward "./blocks/link/link-item/editor";
|
|
3
4
|
@forward "./blocks/column/column-item/editor";
|
|
4
5
|
@forward "./blocks/compare/compare-item/editor";
|
|
5
6
|
@forward "./blocks/compare/compare-option/editor";
|
|
@@ -12,6 +13,8 @@
|
|
|
12
13
|
@forward "./blocks/faq/faq-item/editor";
|
|
13
14
|
@forward "./blocks/form/form-field/editor";
|
|
14
15
|
@forward "./blocks/form/form-group/editor";
|
|
16
|
+
@forward "./blocks/gallery/gallery-group/editor";
|
|
17
|
+
@forward "./blocks/gallery/gallery-item/editor";
|
|
15
18
|
@forward "./blocks/groups/banner-group/editor";
|
|
16
19
|
@forward "./blocks/groups/basic-header-group/editor";
|
|
17
20
|
@forward "./blocks/groups/button-group/editor";
|
|
@@ -29,6 +32,9 @@
|
|
|
29
32
|
@forward "./blocks/text-and-form/text-and-form-text-column/editor";
|
|
30
33
|
@forward "./blocks/usp/usp-group/editor";
|
|
31
34
|
@forward "./blocks/usp/usp-item/editor";
|
|
35
|
+
@forward "./blocks/person/person-group/editor";
|
|
36
|
+
@forward "./blocks/person/person-item/editor";
|
|
37
|
+
@forward "./blocks/responsive-grid/responsive-grid-item/editor";
|
|
32
38
|
@forward "./components/IconControl/editor";
|
|
33
39
|
@forward "./components/ImagePicker/editor";
|
|
34
40
|
@forward "./components/ItemIconControl/editor";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {useSettings} from '@wordpress/block-editor'
|
|
2
|
+
import {useMemo} from '@wordpress/element'
|
|
3
|
+
|
|
4
|
+
interface PaletteColor {
|
|
5
|
+
name: string
|
|
6
|
+
slug: string
|
|
7
|
+
color: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useTenantColorPalette() {
|
|
11
|
+
const [rawColors] = useSettings('color.palette')
|
|
12
|
+
const colors = (rawColors ?? []) as PaletteColor[]
|
|
13
|
+
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
const paletteColors = colors.map((c) => ({...c, color: `var(--${c.slug})`}))
|
|
16
|
+
const hexByValue = new Map(colors.map((c) => [`var(--${c.slug})`, c.color]))
|
|
17
|
+
const resolveHex = (value: string) => hexByValue.get(value) ?? value
|
|
18
|
+
|
|
19
|
+
return {paletteColors, resolveHex}
|
|
20
|
+
}, [colors])
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,14 @@ export type {UspGroupAttributes, UspGroupOptions} from './blocks/usp/usp-group'
|
|
|
56
56
|
export {createUspGroupBlock, uspGroupDefaults} from './blocks/usp/usp-group'
|
|
57
57
|
export type {UspItemAttributes, UspItemOptions} from './blocks/usp/usp-item'
|
|
58
58
|
export {createUspItemBlock, uspItemDefaults} from './blocks/usp/usp-item'
|
|
59
|
+
export type {GalleryGroupAttributes, GalleryGroupOptions} from './blocks/gallery/gallery-group'
|
|
60
|
+
export {createGalleryGroupBlock, galleryGroupDefaults} from './blocks/gallery/gallery-group'
|
|
61
|
+
export type {GalleryItemAttributes, GalleryItemOptions} from './blocks/gallery/gallery-item'
|
|
62
|
+
export {createGalleryItemBlock, galleryItemDefaults} from './blocks/gallery/gallery-item'
|
|
63
|
+
export type {PersonGroupAttributes, PersonGroupOptions} from './blocks/person/person-group'
|
|
64
|
+
export {createPersonGroupBlock, personGroupDefaults} from './blocks/person/person-group'
|
|
65
|
+
export type {PersonItemAttributes, PersonItemOptions} from './blocks/person/person-item'
|
|
66
|
+
export {createPersonItemBlock, personItemDefaults} from './blocks/person/person-item'
|
|
59
67
|
export type {TestimonialGroupAttributes} from './blocks/testimonial/testimonial-group'
|
|
60
68
|
export {createTestimonialGroupBlock, testimonialGroupDefaults} from './blocks/testimonial/testimonial-group'
|
|
61
69
|
export type {TestimonialItemAttributes} from './blocks/testimonial/testimonial-item'
|
|
@@ -82,7 +90,6 @@ export type {ColumnItemAttributes, ColumnItemOptions} from './blocks/column/colu
|
|
|
82
90
|
export {createColumnItemBlock, columnItemDefaults} from './blocks/column/column-item'
|
|
83
91
|
export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './blocks/sections/base-section'
|
|
84
92
|
export {
|
|
85
|
-
BACKGROUNDS,
|
|
86
93
|
baseAttributes,
|
|
87
94
|
baseSectionDefaults,
|
|
88
95
|
createBaseSectionBlock,
|
|
@@ -122,3 +129,5 @@ export type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './bl
|
|
|
122
129
|
export {createResponsiveGridItemBlock, responsiveGridItemDefaults} from './blocks/responsive-grid/responsive-grid-item'
|
|
123
130
|
export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './blocks/post/post-slider-group'
|
|
124
131
|
export {createPostSliderGroupBlock, postSliderGroupDefaults} from './blocks/post/post-slider-group'
|
|
132
|
+
export type {LinkItemAttributes, LinkItemIcon, LinkItemOptions} from './blocks/link/link-item'
|
|
133
|
+
export {createLinkItemBlock, linkItemDefaults} from './blocks/link/link-item'
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {BlockTypeIconDescriptor} from '@wordpress/blocks'
|
|
2
|
+
|
|
2
3
|
export interface SelectOption {
|
|
3
4
|
value: string
|
|
4
5
|
label: string
|
|
@@ -7,6 +8,7 @@ export interface SelectOption {
|
|
|
7
8
|
export interface Media {
|
|
8
9
|
id: number
|
|
9
10
|
alt: string
|
|
11
|
+
mimeType?: string
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export interface Icon {
|
|
@@ -26,6 +28,7 @@ export interface BriloBlockType {
|
|
|
26
28
|
category?: string
|
|
27
29
|
allowedBlocks?: string[]
|
|
28
30
|
template?: [string, Record<string, unknown>][]
|
|
31
|
+
attributes?: Record<string, unknown>
|
|
29
32
|
blockClassName?: string
|
|
30
33
|
containerClassName?: string
|
|
31
34
|
icon?: BlockTypeIconDescriptor
|