@brilo/base-blocks 0.1.1 → 0.1.3
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/form/form-group/edit.d.ts.map +1 -1
- package/build/blocks/form/form-group/edit.js +17 -3
- package/build/blocks/form/form-group/factory.d.ts.map +1 -1
- package/build/blocks/form/form-group/factory.js +1 -0
- package/build/blocks/form/form-group/types.d.ts +1 -0
- package/build/blocks/form/form-group/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/blocks/column/column-group/edit.tsx +56 -0
- package/src/blocks/column/column-group/editor.scss +7 -0
- package/src/blocks/column/column-group/factory.tsx +29 -0
- package/src/blocks/column/column-group/index.ts +14 -0
- package/src/blocks/column/column-group/types.ts +8 -0
- package/src/blocks/column/column-item/constants.ts +1 -0
- package/src/blocks/column/column-item/edit.tsx +48 -0
- package/src/blocks/column/column-item/editor.scss +34 -0
- package/src/blocks/column/column-item/factory.tsx +25 -0
- package/src/blocks/column/column-item/index.ts +10 -0
- package/src/blocks/column/column-item/types.ts +7 -0
- package/src/blocks/compare/compare-group/constants.ts +1 -0
- package/src/blocks/compare/compare-group/edit.tsx +52 -0
- package/src/blocks/compare/compare-group/factory.tsx +29 -0
- package/src/blocks/compare/compare-group/icon.tsx +7 -0
- package/src/blocks/compare/compare-group/index.ts +13 -0
- package/src/blocks/compare/compare-group/types.ts +12 -0
- package/src/blocks/compare/compare-item/edit.tsx +38 -0
- package/src/blocks/compare/compare-item/editor.scss +15 -0
- package/src/blocks/compare/compare-item/factory.tsx +28 -0
- package/src/blocks/compare/compare-item/icon.tsx +9 -0
- package/src/blocks/compare/compare-item/index.ts +13 -0
- package/src/blocks/compare/compare-item/types.ts +9 -0
- package/src/blocks/compare/compare-option/constants.ts +7 -0
- package/src/blocks/compare/compare-option/edit.tsx +64 -0
- package/src/blocks/compare/compare-option/editor.scss +26 -0
- package/src/blocks/compare/compare-option/factory.tsx +35 -0
- package/src/blocks/compare/compare-option/icon.tsx +7 -0
- package/src/blocks/compare/compare-option/index.ts +8 -0
- package/src/blocks/compare/compare-option/types.ts +12 -0
- package/src/blocks/contact/contact-group/constants.ts +3 -0
- package/src/blocks/contact/contact-group/edit.tsx +57 -0
- package/src/blocks/contact/contact-group/editor.scss +20 -0
- package/src/blocks/contact/contact-group/factory.tsx +35 -0
- package/src/blocks/contact/contact-group/index.ts +12 -0
- package/src/blocks/contact/contact-group/types.ts +12 -0
- package/src/blocks/contact/contact-item/constants.ts +17 -0
- package/src/blocks/contact/contact-item/edit.tsx +93 -0
- package/src/blocks/contact/contact-item/editor.scss +38 -0
- package/src/blocks/contact/contact-item/factory.tsx +35 -0
- package/src/blocks/contact/contact-item/index.ts +23 -0
- package/src/blocks/contact/contact-item/types.ts +21 -0
- package/src/blocks/core/basic-button/constants.ts +17 -0
- package/src/blocks/core/basic-button/edit.tsx +107 -0
- package/src/blocks/core/basic-button/editor.scss +80 -0
- package/src/blocks/core/basic-button/factory.tsx +54 -0
- package/src/blocks/core/basic-button/index.ts +8 -0
- package/src/blocks/core/basic-button/types.ts +29 -0
- package/src/blocks/core/basic-heading/constants.ts +1 -0
- package/src/blocks/core/basic-heading/edit.tsx +76 -0
- package/src/blocks/core/basic-heading/editor.scss +8 -0
- package/src/blocks/core/basic-heading/factory.tsx +40 -0
- package/src/blocks/core/basic-heading/index.ts +8 -0
- package/src/blocks/core/basic-heading/types.ts +20 -0
- package/src/blocks/core/basic-overline/edit.tsx +28 -0
- package/src/blocks/core/basic-overline/editor.scss +14 -0
- package/src/blocks/core/basic-overline/factory.tsx +22 -0
- package/src/blocks/core/basic-overline/index.ts +8 -0
- package/src/blocks/core/basic-overline/types.ts +7 -0
- package/src/blocks/faq/faq-group/constants.ts +11 -0
- package/src/blocks/faq/faq-group/edit.tsx +55 -0
- package/src/blocks/faq/faq-group/editor.scss +11 -0
- package/src/blocks/faq/faq-group/factory.tsx +39 -0
- package/src/blocks/faq/faq-group/index.ts +11 -0
- package/src/blocks/faq/faq-group/types.ts +14 -0
- package/src/blocks/faq/faq-item/edit.tsx +50 -0
- package/src/blocks/faq/faq-item/editor.scss +57 -0
- package/src/blocks/faq/faq-item/factory.tsx +24 -0
- package/src/blocks/faq/faq-item/index.ts +9 -0
- package/src/blocks/faq/faq-item/types.ts +7 -0
- package/src/blocks/form/form-field/constants.ts +14 -0
- package/src/blocks/form/form-field/edit.tsx +178 -0
- package/src/blocks/form/form-field/editor.scss +71 -0
- package/src/blocks/form/form-field/factory.tsx +32 -0
- package/src/blocks/form/form-field/index.ts +10 -0
- package/src/blocks/form/form-field/types.ts +18 -0
- package/src/blocks/form/form-group/constants.ts +16 -0
- package/src/blocks/form/form-group/edit.tsx +214 -0
- package/src/blocks/form/form-group/editor.scss +41 -0
- package/src/blocks/form/form-group/factory.tsx +36 -0
- package/src/blocks/form/form-group/index.ts +18 -0
- package/src/blocks/form/form-group/types.ts +23 -0
- package/src/blocks/groups/banner-group/constants.ts +15 -0
- package/src/blocks/groups/banner-group/edit.tsx +122 -0
- package/src/blocks/groups/banner-group/editor.scss +18 -0
- package/src/blocks/groups/banner-group/factory.tsx +64 -0
- package/src/blocks/groups/banner-group/icon.tsx +13 -0
- package/src/blocks/groups/banner-group/index.ts +11 -0
- package/src/blocks/groups/banner-group/types.ts +30 -0
- package/src/blocks/groups/basic-header-group/constants.ts +9 -0
- package/src/blocks/groups/basic-header-group/edit.tsx +99 -0
- package/src/blocks/groups/basic-header-group/editor.scss +35 -0
- package/src/blocks/groups/basic-header-group/factory.tsx +46 -0
- package/src/blocks/groups/basic-header-group/icon.tsx +17 -0
- package/src/blocks/groups/basic-header-group/index.ts +9 -0
- package/src/blocks/groups/basic-header-group/types.ts +27 -0
- package/src/blocks/groups/button-group/constants.ts +7 -0
- package/src/blocks/groups/button-group/edit.tsx +52 -0
- package/src/blocks/groups/button-group/editor.scss +23 -0
- package/src/blocks/groups/button-group/factory.tsx +34 -0
- package/src/blocks/groups/button-group/index.ts +11 -0
- package/src/blocks/groups/button-group/types.ts +12 -0
- package/src/blocks/groups/text-and-media-group/constants.ts +43 -0
- package/src/blocks/groups/text-and-media-group/edit.tsx +241 -0
- package/src/blocks/groups/text-and-media-group/editor.scss +123 -0
- package/src/blocks/groups/text-and-media-group/factory.tsx +100 -0
- package/src/blocks/groups/text-and-media-group/icon.tsx +37 -0
- package/src/blocks/groups/text-and-media-group/index.ts +18 -0
- package/src/blocks/groups/text-and-media-group/types.ts +60 -0
- package/src/blocks/hero/hero-group/constants.ts +23 -0
- package/src/blocks/hero/hero-group/edit.tsx +85 -0
- package/src/blocks/hero/hero-group/editor.scss +0 -0
- package/src/blocks/hero/hero-group/factory.tsx +45 -0
- package/src/blocks/hero/hero-group/icon.tsx +28 -0
- package/src/blocks/hero/hero-group/index.ts +11 -0
- package/src/blocks/hero/hero-group/types.ts +22 -0
- package/src/blocks/hero/hero-item/constants.ts +15 -0
- package/src/blocks/hero/hero-item/edit.tsx +107 -0
- package/src/blocks/hero/hero-item/editor.scss +87 -0
- package/src/blocks/hero/hero-item/factory.tsx +49 -0
- package/src/blocks/hero/hero-item/index.ts +10 -0
- package/src/blocks/hero/hero-item/types.ts +38 -0
- package/src/blocks/map/map-group/constants.ts +20 -0
- package/src/blocks/map/map-group/edit.tsx +108 -0
- package/src/blocks/map/map-group/editor.scss +24 -0
- package/src/blocks/map/map-group/factory.tsx +51 -0
- package/src/blocks/map/map-group/index.ts +9 -0
- package/src/blocks/map/map-group/types.ts +16 -0
- package/src/blocks/newsletter/newsletter-form/constants.ts +5 -0
- package/src/blocks/newsletter/newsletter-form/edit.tsx +194 -0
- package/src/blocks/newsletter/newsletter-form/editor.scss +68 -0
- package/src/blocks/newsletter/newsletter-form/factory.tsx +59 -0
- package/src/blocks/newsletter/newsletter-form/index.ts +11 -0
- package/src/blocks/newsletter/newsletter-form/types.ts +45 -0
- package/src/blocks/post/post-slider-group/constants.ts +3 -0
- package/src/blocks/post/post-slider-group/edit.tsx +76 -0
- package/src/blocks/post/post-slider-group/factory.tsx +43 -0
- package/src/blocks/post/post-slider-group/icon.tsx +13 -0
- package/src/blocks/post/post-slider-group/index.ts +9 -0
- package/src/blocks/post/post-slider-group/types.ts +20 -0
- package/src/blocks/responsive-grid/responsive-grid-group/edit.tsx +95 -0
- package/src/blocks/responsive-grid/responsive-grid-group/factory.tsx +33 -0
- package/src/blocks/responsive-grid/responsive-grid-group/index.ts +13 -0
- package/src/blocks/responsive-grid/responsive-grid-group/types.ts +9 -0
- package/src/blocks/responsive-grid/responsive-grid-item/edit.tsx +19 -0
- package/src/blocks/responsive-grid/responsive-grid-item/factory.tsx +20 -0
- package/src/blocks/responsive-grid/responsive-grid-item/index.ts +9 -0
- package/src/blocks/responsive-grid/responsive-grid-item/types.ts +5 -0
- package/src/blocks/sections/base-section/attributes.ts +17 -0
- package/src/blocks/sections/base-section/constants.ts +18 -0
- package/src/blocks/sections/base-section/controls.tsx +70 -0
- package/src/blocks/sections/base-section/edit.tsx +34 -0
- package/src/blocks/sections/base-section/editor.scss +24 -0
- package/src/blocks/sections/base-section/factory.tsx +47 -0
- package/src/blocks/sections/base-section/icon.tsx +6 -0
- package/src/blocks/sections/base-section/index.ts +14 -0
- package/src/blocks/sections/base-section/types.ts +26 -0
- package/src/blocks/signpost/signpost-group/constants.ts +3 -0
- package/src/blocks/signpost/signpost-group/edit.tsx +75 -0
- package/src/blocks/signpost/signpost-group/editor.scss +0 -0
- package/src/blocks/signpost/signpost-group/factory.tsx +40 -0
- package/src/blocks/signpost/signpost-group/icon.tsx +19 -0
- package/src/blocks/signpost/signpost-group/index.ts +15 -0
- package/src/blocks/signpost/signpost-group/types.ts +9 -0
- package/src/blocks/signpost/signpost-item/constants.ts +4 -0
- package/src/blocks/signpost/signpost-item/edit.tsx +90 -0
- package/src/blocks/signpost/signpost-item/editor.scss +25 -0
- package/src/blocks/signpost/signpost-item/factory.tsx +29 -0
- package/src/blocks/signpost/signpost-item/icon.tsx +7 -0
- package/src/blocks/signpost/signpost-item/index.ts +10 -0
- package/src/blocks/signpost/signpost-item/types.ts +12 -0
- package/src/blocks/step/step-group/constants.ts +6 -0
- package/src/blocks/step/step-group/edit.tsx +64 -0
- package/src/blocks/step/step-group/editor.scss +19 -0
- package/src/blocks/step/step-group/factory.tsx +36 -0
- package/src/blocks/step/step-group/icon.tsx +27 -0
- package/src/blocks/step/step-group/index.ts +15 -0
- package/src/blocks/step/step-group/types.ts +13 -0
- package/src/blocks/step/step-item/constants.ts +6 -0
- package/src/blocks/step/step-item/edit.tsx +60 -0
- package/src/blocks/step/step-item/editor.scss +18 -0
- package/src/blocks/step/step-item/factory.tsx +27 -0
- package/src/blocks/step/step-item/index.ts +11 -0
- package/src/blocks/step/step-item/types.ts +12 -0
- package/src/blocks/testimonial/testimonial-group/constants.ts +27 -0
- package/src/blocks/testimonial/testimonial-group/edit.tsx +74 -0
- package/src/blocks/testimonial/testimonial-group/editor.scss +38 -0
- package/src/blocks/testimonial/testimonial-group/factory.tsx +44 -0
- package/src/blocks/testimonial/testimonial-group/icon.tsx +33 -0
- package/src/blocks/testimonial/testimonial-group/index.ts +15 -0
- package/src/blocks/testimonial/testimonial-group/types.ts +19 -0
- package/src/blocks/testimonial/testimonial-item/edit.tsx +48 -0
- package/src/blocks/testimonial/testimonial-item/editor.scss +20 -0
- package/src/blocks/testimonial/testimonial-item/factory.tsx +35 -0
- package/src/blocks/testimonial/testimonial-item/index.ts +9 -0
- package/src/blocks/testimonial/testimonial-item/types.ts +9 -0
- package/src/blocks/text-and-form/text-and-form-group/constants.ts +6 -0
- package/src/blocks/text-and-form/text-and-form-group/edit.tsx +59 -0
- package/src/blocks/text-and-form/text-and-form-group/editor.scss +21 -0
- package/src/blocks/text-and-form/text-and-form-group/factory.tsx +38 -0
- package/src/blocks/text-and-form/text-and-form-group/icon.tsx +23 -0
- package/src/blocks/text-and-form/text-and-form-group/index.ts +9 -0
- package/src/blocks/text-and-form/text-and-form-group/types.ts +23 -0
- package/src/blocks/text-and-form/text-and-form-text-column/constants.ts +10 -0
- package/src/blocks/text-and-form/text-and-form-text-column/edit.tsx +94 -0
- package/src/blocks/text-and-form/text-and-form-text-column/editor.scss +29 -0
- package/src/blocks/text-and-form/text-and-form-text-column/factory.tsx +41 -0
- package/src/blocks/text-and-form/text-and-form-text-column/index.ts +18 -0
- package/src/blocks/text-and-form/text-and-form-text-column/types.ts +23 -0
- package/src/blocks/usp/usp-group/constants.ts +54 -0
- package/src/blocks/usp/usp-group/edit.tsx +197 -0
- package/src/blocks/usp/usp-group/editor.scss +24 -0
- package/src/blocks/usp/usp-group/factory.tsx +113 -0
- package/src/blocks/usp/usp-group/icon.tsx +18 -0
- package/src/blocks/usp/usp-group/index.ts +15 -0
- package/src/blocks/usp/usp-group/types.ts +70 -0
- package/src/blocks/usp/usp-item/constants.ts +7 -0
- package/src/blocks/usp/usp-item/edit.tsx +65 -0
- package/src/blocks/usp/usp-item/editor.scss +17 -0
- package/src/blocks/usp/usp-item/factory.tsx +30 -0
- package/src/blocks/usp/usp-item/index.ts +11 -0
- package/src/blocks/usp/usp-item/types.ts +17 -0
- package/src/components/IconControl/IconControl.tsx +55 -0
- package/src/components/IconControl/editor.scss +53 -0
- package/src/components/IconControl/index.ts +2 -0
- package/src/components/IconControl/index.tsx +1 -0
- package/src/components/ImagePicker/ImagePicker.tsx +124 -0
- package/src/components/ImagePicker/editor.scss +79 -0
- package/src/components/ImagePicker/index.ts +2 -0
- package/src/components/ImagePicker/index.tsx +1 -0
- package/src/components/ItemIconControl/ItemIconControl.tsx +72 -0
- package/src/components/ItemIconControl/ItemIconModal.tsx +12 -0
- package/src/components/ItemIconControl/ItemIconPreview.tsx +93 -0
- package/src/components/ItemIconControl/editor.scss +52 -0
- package/src/components/ItemIconControl/index.ts +2 -0
- package/src/components/ItemIconControl/types.d.ts +30 -0
- package/src/constants.ts +20 -0
- package/src/editor.scss +34 -0
- package/src/globals.scss +237 -0
- package/src/hooks/useGroupBlock.ts +53 -0
- package/src/index.ts +122 -0
- package/src/types.ts +33 -0
- package/src/utils/createEditAdapter.ts +11 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
TextControl,
|
|
5
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
6
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
|
+
} from '@wordpress/components'
|
|
8
|
+
import {__} from '@wordpress/i18n'
|
|
9
|
+
import {VARIANTS} from './constants'
|
|
10
|
+
import type {CompareOptionAttributes, CompareOptionOptions} from './types'
|
|
11
|
+
|
|
12
|
+
export function createCompareOptionEdit(options: CompareOptionOptions) {
|
|
13
|
+
return function Edit({
|
|
14
|
+
attributes,
|
|
15
|
+
setAttributes,
|
|
16
|
+
}: {
|
|
17
|
+
attributes: CompareOptionAttributes
|
|
18
|
+
setAttributes: (a: Partial<CompareOptionAttributes>) => void
|
|
19
|
+
}) {
|
|
20
|
+
const {text, variant, customChar} = attributes
|
|
21
|
+
const blockProps = useBlockProps({className: 'i-compare-option'})
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<InspectorControls>
|
|
26
|
+
<PanelBody title={__('Nastavení', 'brilo-blocks')}>
|
|
27
|
+
<ToggleGroupControl
|
|
28
|
+
isBlock
|
|
29
|
+
label={__('Varianta', 'brilo-blocks')}
|
|
30
|
+
value={variant}
|
|
31
|
+
onChange={(v) => setAttributes({variant: v as CompareOptionAttributes['variant']})}
|
|
32
|
+
>
|
|
33
|
+
{VARIANTS.map((v) => (
|
|
34
|
+
<ToggleGroupControlOption key={v.value} value={v.value} label={v.label} />
|
|
35
|
+
))}
|
|
36
|
+
</ToggleGroupControl>
|
|
37
|
+
{variant === 'custom' && (
|
|
38
|
+
<TextControl
|
|
39
|
+
label={__('Vlastní znak', 'brilo-blocks')}
|
|
40
|
+
value={customChar}
|
|
41
|
+
onChange={(v) => setAttributes({customChar: v.substring(0, 1)})}
|
|
42
|
+
help={__('Zadejte 1 znak', 'brilo-blocks')}
|
|
43
|
+
/>
|
|
44
|
+
)}
|
|
45
|
+
</PanelBody>
|
|
46
|
+
</InspectorControls>
|
|
47
|
+
<div {...blockProps}>
|
|
48
|
+
<div className="i-compare-option__bullet">
|
|
49
|
+
{variant === 'plus' && '+'}
|
|
50
|
+
{variant === 'minus' && '−'}
|
|
51
|
+
{variant === 'custom' && (customChar || '?')}
|
|
52
|
+
</div>
|
|
53
|
+
<RichText
|
|
54
|
+
tagName="span"
|
|
55
|
+
className="i-compare-option__text u-text-editable"
|
|
56
|
+
value={text}
|
|
57
|
+
onChange={(v) => setAttributes({text: v})}
|
|
58
|
+
placeholder={__('Text...', 'brilo-blocks')}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
</>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.i-compare-option__bullet {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
padding: 4px;
|
|
7
|
+
width: 24px;
|
|
8
|
+
height: 24px;
|
|
9
|
+
background-color: #006ba1;
|
|
10
|
+
color: #fff;
|
|
11
|
+
font-weight: 900;
|
|
12
|
+
font-size: 18px;
|
|
13
|
+
flex-shrink: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.i-compare-option__text {
|
|
17
|
+
flex-grow: 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.i-compare-option {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 8px;
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createCompareOptionEdit} from './edit'
|
|
4
|
+
import {icon as defaultIcon} from './icon'
|
|
5
|
+
import type {CompareOptionAttributes, CompareOptionOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export type {CompareOptionAttributes, CompareOptionOptions}
|
|
8
|
+
|
|
9
|
+
export function createCompareOptionBlock(options: CompareOptionOptions): BlockConfiguration<CompareOptionAttributes> {
|
|
10
|
+
return {
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: options.title ?? __('Možnost srovnání', 'brilo-blocks'),
|
|
13
|
+
description: options.description,
|
|
14
|
+
category: options.category ?? 'layout',
|
|
15
|
+
...(options.parent && {parent: options.parent}),
|
|
16
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
17
|
+
supports: {html: false, customClassName: false},
|
|
18
|
+
attributes: {
|
|
19
|
+
text: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
default: '',
|
|
22
|
+
},
|
|
23
|
+
variant: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
default: 'plus',
|
|
26
|
+
},
|
|
27
|
+
customChar: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: '',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
edit: createCompareOptionEdit(options),
|
|
33
|
+
save: () => null,
|
|
34
|
+
} as unknown as BlockConfiguration<CompareOptionAttributes>
|
|
35
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
<title>Compare Option</title>
|
|
4
|
+
<path d="M4 10H16" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
5
|
+
<path d="M10 4V16" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
6
|
+
</svg>
|
|
7
|
+
)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type {CompareOptionAttributes, CompareOptionOptions} from './types'
|
|
2
|
+
export {createCompareOptionBlock} from './factory'
|
|
3
|
+
import type {CompareOptionOptions} from './types'
|
|
4
|
+
|
|
5
|
+
export const compareOptionDefaults: CompareOptionOptions = {
|
|
6
|
+
name: 'brilo/compare-option',
|
|
7
|
+
parent: ['brilo/compare-item'],
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {BriloBlockType} from '~/types'
|
|
2
|
+
import {VARIANTS} from './constants'
|
|
3
|
+
|
|
4
|
+
export type CompareOptionVariant = (typeof VARIANTS)[number]['value']
|
|
5
|
+
|
|
6
|
+
export interface CompareOptionAttributes extends Record<string, unknown> {
|
|
7
|
+
text: string
|
|
8
|
+
variant: CompareOptionVariant
|
|
9
|
+
customChar: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CompareOptionOptions extends BriloBlockType {}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 {CONTACT_COLUMNS} from './constants'
|
|
11
|
+
import type {ContactColumns, ContactGroupAttributes, ContactGroupOptions} from './types'
|
|
12
|
+
|
|
13
|
+
export function createContactGroupEdit(options: ContactGroupOptions) {
|
|
14
|
+
const COLUMNS = options.columns ?? CONTACT_COLUMNS
|
|
15
|
+
|
|
16
|
+
return function Edit({
|
|
17
|
+
attributes,
|
|
18
|
+
setAttributes,
|
|
19
|
+
}: {
|
|
20
|
+
attributes: ContactGroupAttributes
|
|
21
|
+
setAttributes: (a: Partial<ContactGroupAttributes>) => void
|
|
22
|
+
}) {
|
|
23
|
+
const {columns} = attributes
|
|
24
|
+
|
|
25
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
26
|
+
blockClassName: clsx(options.blockClassName ?? 'g-contact wp-block-section'),
|
|
27
|
+
containerClassName: [options.containerClassName ?? 'g-contact__items', `--cols-${columns}`],
|
|
28
|
+
containerStyle: {'--grid-max-col-count': columns},
|
|
29
|
+
allowedBlocks: options.allowedBlocks,
|
|
30
|
+
orientation: 'horizontal',
|
|
31
|
+
template: options.template,
|
|
32
|
+
layout: {type: 'default'},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<InspectorControls>
|
|
38
|
+
<PanelBody title={__('Rozložení', 'brilo-blocks')}>
|
|
39
|
+
<ToggleGroupControl
|
|
40
|
+
isBlock
|
|
41
|
+
label={__('Počet sloupců', 'brilo-blocks')}
|
|
42
|
+
value={String(columns)}
|
|
43
|
+
onChange={(v) => setAttributes({columns: Number(v) as ContactColumns})}
|
|
44
|
+
>
|
|
45
|
+
{COLUMNS.map((c) => (
|
|
46
|
+
<ToggleGroupControlOption key={c} value={String(c)} label={String(c)} />
|
|
47
|
+
))}
|
|
48
|
+
</ToggleGroupControl>
|
|
49
|
+
</PanelBody>
|
|
50
|
+
</InspectorControls>
|
|
51
|
+
<div {...blockProps}>
|
|
52
|
+
<div {...innerBlocksProps} />
|
|
53
|
+
</div>
|
|
54
|
+
</>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.g-contact {
|
|
3
|
+
.g-contact__items {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: repeat(var(--grid-max-col-count, 3), minmax(0, 1fr));
|
|
6
|
+
gap: 16px;
|
|
7
|
+
align-items: start;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// WP core sets `margin-left/right: auto` on `.wp-block` children of containers whose
|
|
13
|
+
// layout type isn't flex/grid (ours is `default`). That rule is UNLAYERED, so a
|
|
14
|
+
// layered override can't beat it regardless of specificity — keep this UNLAYERED and
|
|
15
|
+
// bump above WP's (0,2,0) specificity to win.
|
|
16
|
+
.editor-styles-wrapper .g-contact__items > .wp-block {
|
|
17
|
+
margin-left: 0;
|
|
18
|
+
margin-right: 0;
|
|
19
|
+
max-width: none;
|
|
20
|
+
}
|
|
@@ -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 type {NumberArray} from '~/types'
|
|
5
|
+
import {CONTACT_COLUMNS, CONTACT_COLUMNS_CONTEXT} from './constants'
|
|
6
|
+
import {createContactGroupEdit} from './edit'
|
|
7
|
+
import type {ContactGroupAttributes, ContactGroupOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export type {ContactGroupAttributes, ContactGroupOptions}
|
|
10
|
+
|
|
11
|
+
export function createContactGroupBlock<TColumns extends NumberArray = typeof CONTACT_COLUMNS>(
|
|
12
|
+
options: ContactGroupOptions<TColumns>,
|
|
13
|
+
): BlockConfiguration<ContactGroupAttributes<TColumns[number]>> {
|
|
14
|
+
const columns = options.columns ?? CONTACT_COLUMNS
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
name: options.name,
|
|
18
|
+
title: options.title ?? __('Kontakty', 'brilo-blocks'),
|
|
19
|
+
description: options.description,
|
|
20
|
+
category: options.category ?? 'layout',
|
|
21
|
+
...(options.parent && {parent: options.parent}),
|
|
22
|
+
icon: options.icon ?? 'id-alt',
|
|
23
|
+
supports: {html: false, customClassName: false},
|
|
24
|
+
providesContext: {[CONTACT_COLUMNS_CONTEXT]: 'columns'},
|
|
25
|
+
attributes: {
|
|
26
|
+
columns: {
|
|
27
|
+
type: 'number',
|
|
28
|
+
default: columns[1] ?? columns[0],
|
|
29
|
+
enum: [...columns],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
edit: createContactGroupEdit(options as unknown as ContactGroupOptions),
|
|
33
|
+
save: () => <InnerBlocks.Content />,
|
|
34
|
+
} as unknown as BlockConfiguration<ContactGroupAttributes<TColumns[number]>>
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type {ContactColumns, ContactGroupAttributes, ContactGroupOptions} from './types'
|
|
2
|
+
export {createContactGroupBlock} from './factory'
|
|
3
|
+
export {CONTACT_COLUMNS, CONTACT_COLUMNS_CONTEXT} from './constants'
|
|
4
|
+
|
|
5
|
+
import type {ContactGroupOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export const contactGroupDefaults: ContactGroupOptions = {
|
|
8
|
+
name: 'brilo/contact-group',
|
|
9
|
+
parent: ['brilo/base-section'],
|
|
10
|
+
allowedBlocks: ['brilo/contact-item'],
|
|
11
|
+
template: [['brilo/contact-item', {}]],
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {BriloBlockType, NumberArray} from '~/types'
|
|
2
|
+
import type {CONTACT_COLUMNS} from './constants'
|
|
3
|
+
|
|
4
|
+
export type ContactColumns = (typeof CONTACT_COLUMNS)[number]
|
|
5
|
+
|
|
6
|
+
export interface ContactGroupAttributes<TColumns extends number = ContactColumns> extends Record<string, unknown> {
|
|
7
|
+
columns: TColumns
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ContactGroupOptions<TColumns extends NumberArray = typeof CONTACT_COLUMNS> extends BriloBlockType {
|
|
11
|
+
columns?: TColumns
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const CONTACT_ICON_TYPES = [
|
|
4
|
+
{value: 'preselected', label: __('Předvolená', 'brilo-blocks')},
|
|
5
|
+
{value: 'media', label: __('Obrázek', 'brilo-blocks')},
|
|
6
|
+
] as const
|
|
7
|
+
|
|
8
|
+
export const CONTACT_ICON_SIZES = [
|
|
9
|
+
{value: 'sm', label: __('Malá', 'brilo-blocks'), size: 24},
|
|
10
|
+
{value: 'md', label: __('Střední', 'brilo-blocks'), size: 32},
|
|
11
|
+
{value: 'lg', label: __('Velká', 'brilo-blocks'), size: 48},
|
|
12
|
+
{value: 'custom', label: __('Vlastní', 'brilo-blocks')},
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export const CONTACT_ICON_SIZE_RANGE = {min: 8, max: 100} as const
|
|
16
|
+
|
|
17
|
+
export const CONTACT_ICON_SIZE_DEFAULT = 32
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
RangeControl,
|
|
5
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
6
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
|
+
} from '@wordpress/components'
|
|
8
|
+
import {__} from '@wordpress/i18n'
|
|
9
|
+
import clsx from 'clsx'
|
|
10
|
+
import type {CSSProperties} from 'react'
|
|
11
|
+
import {ItemIconControl, ItemIconPreview} from '~/components/ItemIconControl'
|
|
12
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
13
|
+
import {CONTACT_COLUMNS_CONTEXT} from '../contact-group/constants'
|
|
14
|
+
import {CONTACT_ICON_SIZE_DEFAULT, CONTACT_ICON_SIZE_RANGE, CONTACT_ICON_SIZES, CONTACT_ICON_TYPES} from './constants'
|
|
15
|
+
import type {ContactIconSizeVariant, ContactItemAttributes, ContactItemOptions} from './types'
|
|
16
|
+
|
|
17
|
+
export function createContactItemEdit(options: ContactItemOptions) {
|
|
18
|
+
const iconOptions = {icons: options.icons ?? [], iconsSrc: options.iconsSrc ?? ''}
|
|
19
|
+
|
|
20
|
+
return function Edit({
|
|
21
|
+
attributes,
|
|
22
|
+
setAttributes,
|
|
23
|
+
context,
|
|
24
|
+
}: {
|
|
25
|
+
attributes: ContactItemAttributes
|
|
26
|
+
setAttributes: (a: Partial<ContactItemAttributes>) => void
|
|
27
|
+
context: Record<string, unknown>
|
|
28
|
+
}) {
|
|
29
|
+
const {colSpan, icon, iconSize} = attributes
|
|
30
|
+
const columns = Number(context[CONTACT_COLUMNS_CONTEXT] ?? 3)
|
|
31
|
+
const span = Math.min(colSpan, columns)
|
|
32
|
+
|
|
33
|
+
const sizePreset = CONTACT_ICON_SIZES.find((s) => s.value === iconSize.variant)
|
|
34
|
+
const iconPx =
|
|
35
|
+
iconSize.variant === 'custom' ? iconSize.custom : sizePreset && 'size' in sizePreset ? sizePreset.size : CONTACT_ICON_SIZE_DEFAULT
|
|
36
|
+
|
|
37
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
38
|
+
blockClassName: clsx(options.blockClassName ?? 'i-contact'),
|
|
39
|
+
containerClassName: [options.containerClassName ?? 'i-contact__inner'],
|
|
40
|
+
allowedBlocks: options.allowedBlocks,
|
|
41
|
+
template: options.template,
|
|
42
|
+
orientation: 'vertical',
|
|
43
|
+
layout: {type: 'default'},
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<InspectorControls>
|
|
49
|
+
<PanelBody title={__('Šířka', 'brilo-blocks')}>
|
|
50
|
+
<ToggleGroupControl
|
|
51
|
+
isBlock
|
|
52
|
+
label={__('Počet sloupců', 'brilo-blocks')}
|
|
53
|
+
value={String(span)}
|
|
54
|
+
onChange={(v) => setAttributes({colSpan: Number(v)})}
|
|
55
|
+
>
|
|
56
|
+
{Array.from({length: columns}, (_, i) => i + 1).map((c) => (
|
|
57
|
+
<ToggleGroupControlOption key={c} value={String(c)} label={String(c)} />
|
|
58
|
+
))}
|
|
59
|
+
</ToggleGroupControl>
|
|
60
|
+
</PanelBody>
|
|
61
|
+
<PanelBody title={__('Ikona', 'brilo-blocks')}>
|
|
62
|
+
<ItemIconControl icon={icon} setAttributes={setAttributes} iconTypes={CONTACT_ICON_TYPES} options={iconOptions} />
|
|
63
|
+
<ToggleGroupControl
|
|
64
|
+
isBlock
|
|
65
|
+
label={__('Velikost ikony', 'brilo-blocks')}
|
|
66
|
+
value={iconSize.variant}
|
|
67
|
+
onChange={(v) => setAttributes({iconSize: {...iconSize, variant: v as ContactIconSizeVariant}})}
|
|
68
|
+
>
|
|
69
|
+
{CONTACT_ICON_SIZES.map((s) => (
|
|
70
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
71
|
+
))}
|
|
72
|
+
</ToggleGroupControl>
|
|
73
|
+
{iconSize.variant === 'custom' && (
|
|
74
|
+
<RangeControl
|
|
75
|
+
label={__('Vlastní velikost (px)', 'brilo-blocks')}
|
|
76
|
+
value={iconSize.custom}
|
|
77
|
+
min={CONTACT_ICON_SIZE_RANGE.min}
|
|
78
|
+
max={CONTACT_ICON_SIZE_RANGE.max}
|
|
79
|
+
onChange={(v) => setAttributes({iconSize: {...iconSize, custom: v ?? CONTACT_ICON_SIZE_RANGE.min}})}
|
|
80
|
+
/>
|
|
81
|
+
)}
|
|
82
|
+
</PanelBody>
|
|
83
|
+
</InspectorControls>
|
|
84
|
+
<div {...blockProps} style={{...(blockProps.style as CSSProperties), '--col-span': span} as CSSProperties}>
|
|
85
|
+
<div className="i-contact__icon-wrap" style={{'--icon-size': `${iconPx}px`} as CSSProperties}>
|
|
86
|
+
<ItemIconPreview icon={icon} className="i-contact__icon" setAttributes={setAttributes} options={iconOptions} />
|
|
87
|
+
</div>
|
|
88
|
+
<div {...innerBlocksProps} />
|
|
89
|
+
</div>
|
|
90
|
+
</>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// WP core centers `.wp-block` children (`margin-left/right: auto`) and caps their
|
|
2
|
+
// `max-width` when the parent isn't is-layout-flex/grid. The item content lives in
|
|
3
|
+
// `.i-contact__inner` (plain `display:flex`, no WP layout class), so kill it here.
|
|
4
|
+
// Unlayered + (0,3,0) to beat core's unlayered (0,2,0) rule.
|
|
5
|
+
.editor-styles-wrapper .i-contact__inner > .wp-block {
|
|
6
|
+
margin-left: 0;
|
|
7
|
+
margin-right: 0;
|
|
8
|
+
max-width: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.i-contact {
|
|
12
|
+
grid-column: span var(--col-span, 1);
|
|
13
|
+
margin-inline: 0;
|
|
14
|
+
width: 100%;
|
|
15
|
+
|
|
16
|
+
.i-contact__inner {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
|
|
21
|
+
p,
|
|
22
|
+
h3,
|
|
23
|
+
h2,
|
|
24
|
+
h4 {
|
|
25
|
+
margin-block: 4px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.i-contact__icon-wrap {
|
|
30
|
+
--icon-size: 32px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.i-contact__icon img {
|
|
34
|
+
width: var(--icon-size);
|
|
35
|
+
height: var(--icon-size);
|
|
36
|
+
object-fit: contain;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -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 {CONTACT_COLUMNS_CONTEXT} from '../contact-group/constants'
|
|
5
|
+
import {CONTACT_ICON_SIZE_DEFAULT, CONTACT_ICON_TYPES} from './constants'
|
|
6
|
+
import {createContactItemEdit} from './edit'
|
|
7
|
+
import type {ContactItemAttributes, ContactItemOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export type {ContactItemAttributes, ContactItemOptions}
|
|
10
|
+
|
|
11
|
+
export function createContactItemBlock(options: ContactItemOptions): BlockConfiguration<ContactItemAttributes> {
|
|
12
|
+
return {
|
|
13
|
+
name: options.name,
|
|
14
|
+
title: options.title ?? __('Kontaktní položka', 'brilo-blocks'),
|
|
15
|
+
description: options.description,
|
|
16
|
+
category: options.category ?? 'layout',
|
|
17
|
+
...(options.parent && {parent: options.parent}),
|
|
18
|
+
icon: options.icon ?? 'id-alt',
|
|
19
|
+
supports: {html: false, customClassName: false},
|
|
20
|
+
usesContext: [CONTACT_COLUMNS_CONTEXT],
|
|
21
|
+
attributes: {
|
|
22
|
+
colSpan: {type: 'number', default: 1},
|
|
23
|
+
icon: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
default: {type: CONTACT_ICON_TYPES[0].value, src: '', media: {id: 0, alt: ''}},
|
|
26
|
+
},
|
|
27
|
+
iconSize: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
default: {variant: 'md', custom: CONTACT_ICON_SIZE_DEFAULT},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
edit: createContactItemEdit(options),
|
|
33
|
+
save: () => <InnerBlocks.Content />,
|
|
34
|
+
} as unknown as BlockConfiguration<ContactItemAttributes>
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type {ContactIconSize, ContactIconSizeVariant, ContactItemAttributes, ContactItemOptions} from './types'
|
|
2
|
+
export {createContactItemBlock} from './factory'
|
|
3
|
+
export {CONTACT_ICON_SIZE_RANGE, CONTACT_ICON_SIZES, CONTACT_ICON_TYPES} from './constants'
|
|
4
|
+
|
|
5
|
+
import type {ContactItemOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export const contactItemDefaults: ContactItemOptions = {
|
|
8
|
+
name: 'brilo/contact-item',
|
|
9
|
+
parent: ['brilo/contact-group'],
|
|
10
|
+
allowedBlocks: [
|
|
11
|
+
'core/heading',
|
|
12
|
+
'core/paragraph',
|
|
13
|
+
'core/list',
|
|
14
|
+
'core/image',
|
|
15
|
+
'core/table',
|
|
16
|
+
'brilo/column-group',
|
|
17
|
+
'brilo/responsive-grid-group',
|
|
18
|
+
],
|
|
19
|
+
template: [
|
|
20
|
+
['core/heading', {level: 3}],
|
|
21
|
+
['core/paragraph', {}],
|
|
22
|
+
],
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {BriloBlockType, Icon} from '~/types'
|
|
2
|
+
import type {IconType} from '~/components/IconControl'
|
|
3
|
+
import type {CONTACT_ICON_SIZES} from './constants'
|
|
4
|
+
|
|
5
|
+
export type ContactIconSizeVariant = (typeof CONTACT_ICON_SIZES)[number]['value']
|
|
6
|
+
|
|
7
|
+
export interface ContactIconSize {
|
|
8
|
+
variant: ContactIconSizeVariant
|
|
9
|
+
custom: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ContactItemAttributes extends Record<string, unknown> {
|
|
13
|
+
colSpan: number
|
|
14
|
+
icon: Icon
|
|
15
|
+
iconSize: ContactIconSize
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ContactItemOptions extends BriloBlockType {
|
|
19
|
+
icons?: IconType[]
|
|
20
|
+
iconsSrc?: string
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_VARIANTS = [
|
|
4
|
+
{value: 'primary', label: __('Primární', 'brilo-blocks')},
|
|
5
|
+
{value: 'secondary', label: __('Sekundární', 'brilo-blocks')},
|
|
6
|
+
] as const
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_SIZES = [
|
|
9
|
+
{value: 'default', label: __('Výchozí', 'brilo-blocks')},
|
|
10
|
+
{value: 'sm', label: __('Malá', 'brilo-blocks')},
|
|
11
|
+
] as const
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_FULL_WIDTH_OPTIONS = [
|
|
14
|
+
{value: 'false', label: __('Ne', 'brilo-blocks')},
|
|
15
|
+
{value: 'mobile', label: __('Mobil', 'brilo-blocks')},
|
|
16
|
+
{value: 'true', label: __('Vždy', 'brilo-blocks')},
|
|
17
|
+
] as const
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
TextControl,
|
|
5
|
+
ToggleControl,
|
|
6
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
7
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
8
|
+
} from '@wordpress/components'
|
|
9
|
+
import {__} from '@wordpress/i18n'
|
|
10
|
+
import clsx from 'clsx'
|
|
11
|
+
import {DEFAULT_FULL_WIDTH_OPTIONS, DEFAULT_SIZES, DEFAULT_VARIANTS} from './constants'
|
|
12
|
+
import type {BasicButtonAttributes, BasicButtonOptions, ButtonFullWidth, ButtonSize, ButtonVariant} from './types'
|
|
13
|
+
|
|
14
|
+
export function createBasicButtonEdit(options: BasicButtonOptions) {
|
|
15
|
+
const VARIANTS = options.variants ?? DEFAULT_VARIANTS
|
|
16
|
+
const SIZES = options.sizes ?? DEFAULT_SIZES
|
|
17
|
+
const FULL_WIDTH_OPTIONS = options.fullWidthOptions ?? DEFAULT_FULL_WIDTH_OPTIONS
|
|
18
|
+
|
|
19
|
+
return function Edit({
|
|
20
|
+
attributes,
|
|
21
|
+
setAttributes,
|
|
22
|
+
}: {
|
|
23
|
+
attributes: BasicButtonAttributes
|
|
24
|
+
setAttributes: (a: Partial<BasicButtonAttributes>) => void
|
|
25
|
+
}) {
|
|
26
|
+
const {title, variant, outline, fullWidth, size, url} = attributes
|
|
27
|
+
const blockProps = useBlockProps({
|
|
28
|
+
className: clsx(
|
|
29
|
+
options.blockClassName ?? 'i-button',
|
|
30
|
+
`--variant-${variant}`,
|
|
31
|
+
`--size-${size}`,
|
|
32
|
+
outline && '--outline',
|
|
33
|
+
fullWidth !== 'false' && `--full-width-${fullWidth}`,
|
|
34
|
+
),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<InspectorControls>
|
|
40
|
+
<PanelBody title={__('Tlačítko', 'brilo-blocks')}>
|
|
41
|
+
<TextControl
|
|
42
|
+
label={__('Text tlačítka', 'brilo-blocks')}
|
|
43
|
+
value={title}
|
|
44
|
+
onChange={(value) => setAttributes({title: value})}
|
|
45
|
+
placeholder={__('Text tlačítka...', 'brilo-blocks')}
|
|
46
|
+
/>
|
|
47
|
+
<ToggleGroupControl
|
|
48
|
+
label={__('Varianta', 'brilo-blocks')}
|
|
49
|
+
value={variant}
|
|
50
|
+
onChange={(value) => setAttributes({variant: value as ButtonVariant})}
|
|
51
|
+
isBlock
|
|
52
|
+
>
|
|
53
|
+
{VARIANTS.map((v) => (
|
|
54
|
+
<ToggleGroupControlOption key={v.value} value={v.value} label={v.label} />
|
|
55
|
+
))}
|
|
56
|
+
</ToggleGroupControl>
|
|
57
|
+
<ToggleControl label={__('Outline', 'brilo-blocks')} checked={outline} onChange={(value) => setAttributes({outline: value})} />
|
|
58
|
+
<ToggleGroupControl
|
|
59
|
+
label={__('Velikost', 'brilo-blocks')}
|
|
60
|
+
value={size}
|
|
61
|
+
onChange={(value) => setAttributes({size: value as ButtonSize})}
|
|
62
|
+
isBlock
|
|
63
|
+
>
|
|
64
|
+
{SIZES.map((s) => (
|
|
65
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
66
|
+
))}
|
|
67
|
+
</ToggleGroupControl>
|
|
68
|
+
<ToggleGroupControl
|
|
69
|
+
label={__('Celá šířka', 'brilo-blocks')}
|
|
70
|
+
value={fullWidth}
|
|
71
|
+
onChange={(value) => setAttributes({fullWidth: value as ButtonFullWidth})}
|
|
72
|
+
isBlock
|
|
73
|
+
>
|
|
74
|
+
{FULL_WIDTH_OPTIONS.map((o) => (
|
|
75
|
+
<ToggleGroupControlOption key={o.value} value={o.value} label={o.label} />
|
|
76
|
+
))}
|
|
77
|
+
</ToggleGroupControl>
|
|
78
|
+
</PanelBody>
|
|
79
|
+
<PanelBody title={__('Odkaz', 'brilo-blocks')}>
|
|
80
|
+
<TextControl
|
|
81
|
+
label={__('URL', 'brilo-blocks')}
|
|
82
|
+
value={url.src}
|
|
83
|
+
onChange={(value) => setAttributes({url: {...url, src: value}})}
|
|
84
|
+
/>
|
|
85
|
+
<ToggleControl
|
|
86
|
+
label={__('Otevřít v nové záložce', 'brilo-blocks')}
|
|
87
|
+
checked={url.blank}
|
|
88
|
+
onChange={(value) => setAttributes({url: {...url, blank: value}})}
|
|
89
|
+
/>
|
|
90
|
+
</PanelBody>
|
|
91
|
+
</InspectorControls>
|
|
92
|
+
<div {...blockProps}>
|
|
93
|
+
<div className="i-button__inner">
|
|
94
|
+
<RichText
|
|
95
|
+
tagName="span"
|
|
96
|
+
className="i-button__label"
|
|
97
|
+
value={title}
|
|
98
|
+
onChange={(value) => setAttributes({title: value})}
|
|
99
|
+
placeholder={__('Text tlačítka...', 'brilo-blocks')}
|
|
100
|
+
allowedFormats={[]}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
}
|