@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,52 @@
|
|
|
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 {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
9
|
+
import {DEFAULT_ALIGNMENTS} from './constants'
|
|
10
|
+
import type {ButtonGroupAlignment, ButtonGroupAttributes, ButtonGroupOptions} from './types'
|
|
11
|
+
|
|
12
|
+
export function createButtonGroupEdit(options: ButtonGroupOptions) {
|
|
13
|
+
const alignments = options.alignments ?? DEFAULT_ALIGNMENTS
|
|
14
|
+
|
|
15
|
+
return function Edit({
|
|
16
|
+
attributes,
|
|
17
|
+
setAttributes,
|
|
18
|
+
}: {
|
|
19
|
+
attributes: ButtonGroupAttributes
|
|
20
|
+
setAttributes: (a: Partial<ButtonGroupAttributes>) => void
|
|
21
|
+
}) {
|
|
22
|
+
const {alignment} = attributes
|
|
23
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
24
|
+
blockClassName: [options.blockClassName ?? 'g-button-group wp-block-section', `--align-${alignment}`],
|
|
25
|
+
containerClassName: options.containerClassName ?? 'flex gap-3 g-button-group__inner',
|
|
26
|
+
allowedBlocks: options.allowedBlocks,
|
|
27
|
+
template: options.template,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<InspectorControls>
|
|
33
|
+
<PanelBody title={__('Skupina tlačítek', 'brilo-blocks')}>
|
|
34
|
+
<ToggleGroupControl
|
|
35
|
+
label={__('Zarovnání', 'brilo-blocks')}
|
|
36
|
+
value={alignment}
|
|
37
|
+
onChange={(v) => setAttributes({alignment: v as ButtonGroupAlignment})}
|
|
38
|
+
isBlock
|
|
39
|
+
>
|
|
40
|
+
{alignments.map((a) => (
|
|
41
|
+
<ToggleGroupControlOption key={a.value} value={a.value} label={a.label} />
|
|
42
|
+
))}
|
|
43
|
+
</ToggleGroupControl>
|
|
44
|
+
</PanelBody>
|
|
45
|
+
</InspectorControls>
|
|
46
|
+
<div {...blockProps}>
|
|
47
|
+
<div {...innerBlocksProps} />
|
|
48
|
+
</div>
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.g-button-group {
|
|
3
|
+
padding: 8px;
|
|
4
|
+
min-height: 44px;
|
|
5
|
+
|
|
6
|
+
&.--align-left {
|
|
7
|
+
--justify: flex-start;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&.--align-center {
|
|
11
|
+
--justify: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.--align-right {
|
|
15
|
+
--justify: flex-end;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.g-button-group__inner {
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
justify-content: var(--justify, flex-start);
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import type {OptionArray} from '~/types'
|
|
5
|
+
import {DEFAULT_ALIGNMENTS} from './constants'
|
|
6
|
+
import {createButtonGroupEdit} from './edit'
|
|
7
|
+
import type {ButtonGroupAttributes, ButtonGroupOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export type {ButtonGroupAttributes, ButtonGroupOptions}
|
|
10
|
+
|
|
11
|
+
export function createButtonGroupBlock<TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS>(
|
|
12
|
+
options: ButtonGroupOptions<TAlignments>,
|
|
13
|
+
): BlockConfiguration<ButtonGroupAttributes<TAlignments[number]['value']>> {
|
|
14
|
+
const alignments = options.alignments ?? DEFAULT_ALIGNMENTS
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
name: options.name,
|
|
18
|
+
title: options.title ?? __('Skupina tlačítek', 'brilo-blocks'),
|
|
19
|
+
description: options.description,
|
|
20
|
+
category: options.category ?? 'layout',
|
|
21
|
+
...(options.parent && {parent: options.parent}),
|
|
22
|
+
icon: options.icon ?? 'button',
|
|
23
|
+
supports: {html: false, customClassName: false},
|
|
24
|
+
attributes: {
|
|
25
|
+
alignment: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
default: alignments[1]?.value ?? alignments[0].value,
|
|
28
|
+
enum: alignments.map((a) => a.value),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
edit: createButtonGroupEdit(options as unknown as ButtonGroupOptions),
|
|
32
|
+
save: () => <InnerBlocks.Content />,
|
|
33
|
+
} as unknown as BlockConfiguration<ButtonGroupAttributes<TAlignments[number]['value']>>
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type {ButtonGroupAttributes, ButtonGroupOptions} from './types'
|
|
2
|
+
export {createButtonGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {ButtonGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const buttonGroupDefaults: ButtonGroupOptions = {
|
|
7
|
+
name: 'brilo/button-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
allowedBlocks: ['brilo/basic-button'],
|
|
10
|
+
template: [['brilo/basic-button', {}]],
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {OptionArray, BriloBlockType} from '~/types'
|
|
2
|
+
import type {DEFAULT_ALIGNMENTS} from './constants'
|
|
3
|
+
|
|
4
|
+
export type ButtonGroupAlignment = (typeof DEFAULT_ALIGNMENTS)[number]['value']
|
|
5
|
+
|
|
6
|
+
export interface ButtonGroupAttributes<TAlignment extends string = ButtonGroupAlignment> extends Record<string, unknown> {
|
|
7
|
+
alignment: TAlignment
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ButtonGroupOptions<TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS> extends BriloBlockType {
|
|
11
|
+
alignments?: TAlignments
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export {CONTENT_SIZES as DEFAULT_CONTENT_SIZES, HEADING_LEVELS} from '~/constants'
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_RATIOS = [
|
|
6
|
+
{value: '3:2', label: '3:2'},
|
|
7
|
+
{value: '4:3', label: '4:3'},
|
|
8
|
+
{value: '16:9', label: '16:9'},
|
|
9
|
+
{value: '1:1', label: '1:1'},
|
|
10
|
+
{value: '2:1', label: '2:1'},
|
|
11
|
+
{value: '3:4', label: '3:4'},
|
|
12
|
+
{value: 'auto', label: 'Auto'},
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export const CHIP_POSITIONS = [
|
|
16
|
+
{value: 'top-left', label: __('Vlevo nahoře', 'brilo-blocks')},
|
|
17
|
+
{value: 'top-right', label: __('Vpravo nahoře', 'brilo-blocks')},
|
|
18
|
+
{value: 'bottom-left', label: __('Vlevo dole', 'brilo-blocks')},
|
|
19
|
+
{value: 'bottom-right', label: __('Vpravo dole', 'brilo-blocks')},
|
|
20
|
+
] as const
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_CHIP_VARIANTS = [
|
|
23
|
+
{value: 'primary', label: __('Primární', 'brilo-blocks')},
|
|
24
|
+
{value: 'secondary', label: __('Sekundární', 'brilo-blocks')},
|
|
25
|
+
{value: 'neutral', label: __('Neutrální', 'brilo-blocks')},
|
|
26
|
+
] as const
|
|
27
|
+
|
|
28
|
+
export const DEFAULT_MEDIA_POSITIONS = [
|
|
29
|
+
{value: 'left', label: __('Vlevo', 'brilo-blocks')},
|
|
30
|
+
{value: 'right', label: __('Vpravo', 'brilo-blocks')},
|
|
31
|
+
] as const
|
|
32
|
+
|
|
33
|
+
export const DEFAULT_HEADING_STYLES = [
|
|
34
|
+
{value: 'h1', label: 'H1 styl'},
|
|
35
|
+
{value: 'h2', label: 'H2 styl'},
|
|
36
|
+
{value: 'h3', label: 'H3 styl'},
|
|
37
|
+
{value: 'h4', label: 'H4 styl'},
|
|
38
|
+
] as const
|
|
39
|
+
|
|
40
|
+
export const DEFAULT_GRID_STYLES = [
|
|
41
|
+
{value: '1-1', label: __('Půl na půl', 'brilo-blocks')},
|
|
42
|
+
{value: '2-1', label: __('2/3 + 1/3', 'brilo-blocks')},
|
|
43
|
+
] as const
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {BlockControls, InspectorControls, RichText} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
TextControl,
|
|
5
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
6
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
|
+
ToolbarButton,
|
|
8
|
+
ToolbarGroup,
|
|
9
|
+
} from '@wordpress/components'
|
|
10
|
+
import {__} from '@wordpress/i18n'
|
|
11
|
+
import clsx from 'clsx'
|
|
12
|
+
import {ImagePickerBody, ImagePickerControl} from '~/components/ImagePicker'
|
|
13
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
14
|
+
import {
|
|
15
|
+
CHIP_POSITIONS,
|
|
16
|
+
DEFAULT_CHIP_VARIANTS,
|
|
17
|
+
DEFAULT_CONTENT_SIZES,
|
|
18
|
+
DEFAULT_GRID_STYLES,
|
|
19
|
+
DEFAULT_HEADING_STYLES,
|
|
20
|
+
DEFAULT_MEDIA_POSITIONS,
|
|
21
|
+
DEFAULT_RATIOS,
|
|
22
|
+
HEADING_LEVELS,
|
|
23
|
+
} from './constants'
|
|
24
|
+
import type {
|
|
25
|
+
ChipPositions,
|
|
26
|
+
ChipVariants,
|
|
27
|
+
ContentSizes,
|
|
28
|
+
GridStyles,
|
|
29
|
+
HeadingLevels,
|
|
30
|
+
HeadingStyles,
|
|
31
|
+
MediaPositions,
|
|
32
|
+
Ratios,
|
|
33
|
+
TextAndMediaGroupAttributes,
|
|
34
|
+
TextAndMediaGroupOptions,
|
|
35
|
+
} from './types'
|
|
36
|
+
|
|
37
|
+
export function createTextAndMediaGroupEdit(options: TextAndMediaGroupOptions) {
|
|
38
|
+
const RATIOS = options.ratios ?? DEFAULT_RATIOS
|
|
39
|
+
const MEDIA_POSITIONS = options.mediaPositions ?? DEFAULT_MEDIA_POSITIONS
|
|
40
|
+
const GRID_STYLES = options.gridStyles ?? DEFAULT_GRID_STYLES
|
|
41
|
+
const HEADING_STYLES = options.headingStyles ?? DEFAULT_HEADING_STYLES
|
|
42
|
+
const CONTENT_SIZES = options.contentSizes ?? DEFAULT_CONTENT_SIZES
|
|
43
|
+
const CHIP_VARIANTS = options.chipVariants ?? DEFAULT_CHIP_VARIANTS
|
|
44
|
+
|
|
45
|
+
return function Edit({
|
|
46
|
+
attributes,
|
|
47
|
+
setAttributes,
|
|
48
|
+
}: {
|
|
49
|
+
attributes: TextAndMediaGroupAttributes
|
|
50
|
+
setAttributes: (a: Partial<TextAndMediaGroupAttributes>) => void
|
|
51
|
+
}) {
|
|
52
|
+
const {header, mediaPosition, img, ratio, gridStyle, content} = attributes
|
|
53
|
+
const isMediaLeft = mediaPosition === 'left'
|
|
54
|
+
|
|
55
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
56
|
+
blockClassName: [
|
|
57
|
+
options.blockClassName ?? 'g-text-and-media wp-block-section',
|
|
58
|
+
`--media-${mediaPosition}`,
|
|
59
|
+
ratio && `--ratio-${ratio}`,
|
|
60
|
+
`--content-${content.size}`,
|
|
61
|
+
],
|
|
62
|
+
containerClassName: options.containerClassName ?? 'g-text-and-media__inner-blocks',
|
|
63
|
+
allowedBlocks: options.allowedBlocks,
|
|
64
|
+
template: options.template,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const mediaColumn = (
|
|
68
|
+
<div className="g-text-and-media__media">
|
|
69
|
+
<ImagePickerBody
|
|
70
|
+
value={{id: img.id, alt: img.alt}}
|
|
71
|
+
onChange={(val) => setAttributes({img: {...img, ...val}})}
|
|
72
|
+
placeholder={__('Vybrat obrázek', 'brilo-blocks')}
|
|
73
|
+
/>
|
|
74
|
+
{img.id > 0 && img.chip.title && (
|
|
75
|
+
<span className={clsx('g-text-and-media__chip', `--${img.chip.position}`, `--${img.chip.variant}`)}>{img.chip.title}</span>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
const textColumn = (
|
|
81
|
+
<div className="g-text-and-media__text">
|
|
82
|
+
<RichText
|
|
83
|
+
tagName="span"
|
|
84
|
+
className="g-text-and-media__overline u-text-editable"
|
|
85
|
+
value={header.overline.title}
|
|
86
|
+
onChange={(value: string) => setAttributes({header: {...header, overline: {title: value}}})}
|
|
87
|
+
placeholder={__('Overline...', 'brilo-blocks')}
|
|
88
|
+
allowedFormats={[]}
|
|
89
|
+
/>
|
|
90
|
+
<RichText
|
|
91
|
+
tagName={`h${header.heading.level}` as 'h1' | 'h2' | 'h3' | 'h4'}
|
|
92
|
+
className={clsx('g-text-and-media__heading', `--heading-style-${header.heading.style}`, 'u-text-editable')}
|
|
93
|
+
value={header.heading.title}
|
|
94
|
+
onChange={(value: string) => setAttributes({header: {...header, heading: {...header.heading, title: value}}})}
|
|
95
|
+
placeholder={__('Nadpis...', 'brilo-blocks')}
|
|
96
|
+
allowedFormats={['core/bold', 'core/italic']}
|
|
97
|
+
/>
|
|
98
|
+
<div {...innerBlocksProps} />
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<>
|
|
104
|
+
<BlockControls>
|
|
105
|
+
<ToolbarGroup>
|
|
106
|
+
<ToolbarButton
|
|
107
|
+
icon="align-pull-left"
|
|
108
|
+
label={__('Média vlevo', 'brilo-blocks')}
|
|
109
|
+
isActive={isMediaLeft}
|
|
110
|
+
onClick={() => setAttributes({mediaPosition: 'left'})}
|
|
111
|
+
/>
|
|
112
|
+
<ToolbarButton
|
|
113
|
+
icon="align-pull-right"
|
|
114
|
+
label={__('Média vpravo', 'brilo-blocks')}
|
|
115
|
+
isActive={!isMediaLeft}
|
|
116
|
+
onClick={() => setAttributes({mediaPosition: 'right'})}
|
|
117
|
+
/>
|
|
118
|
+
</ToolbarGroup>
|
|
119
|
+
</BlockControls>
|
|
120
|
+
<InspectorControls>
|
|
121
|
+
<PanelBody title={__('Obrázek', 'brilo-blocks')}>
|
|
122
|
+
<ImagePickerControl value={{id: img.id, alt: img.alt}} onChange={(val) => setAttributes({img: {...img, ...val}})} />
|
|
123
|
+
<ToggleGroupControl
|
|
124
|
+
label={__('Poměr stran', 'brilo-blocks')}
|
|
125
|
+
value={ratio}
|
|
126
|
+
onChange={(value) => setAttributes({ratio: value as Ratios})}
|
|
127
|
+
isBlock
|
|
128
|
+
>
|
|
129
|
+
{RATIOS.map((r) => (
|
|
130
|
+
<ToggleGroupControlOption key={r.value} value={r.value} label={r.label} />
|
|
131
|
+
))}
|
|
132
|
+
</ToggleGroupControl>
|
|
133
|
+
<TextControl
|
|
134
|
+
label={__('URL videa', 'brilo-blocks')}
|
|
135
|
+
value={img.video.src}
|
|
136
|
+
onChange={(value: string) => setAttributes({img: {...img, video: {src: value}}})}
|
|
137
|
+
/>
|
|
138
|
+
</PanelBody>
|
|
139
|
+
<PanelBody title={__('Chip', 'brilo-blocks')} initialOpen={false}>
|
|
140
|
+
<TextControl
|
|
141
|
+
label={__('Text chipu', 'brilo-blocks')}
|
|
142
|
+
value={img.chip.title}
|
|
143
|
+
onChange={(value: string) => setAttributes({img: {...img, chip: {...img.chip, title: value}}})}
|
|
144
|
+
/>
|
|
145
|
+
<ToggleGroupControl
|
|
146
|
+
label={__('Pozice chipu', 'brilo-blocks')}
|
|
147
|
+
value={img.chip.position}
|
|
148
|
+
onChange={(value) => setAttributes({img: {...img, chip: {...img.chip, position: value as ChipPositions}}})}
|
|
149
|
+
isBlock
|
|
150
|
+
>
|
|
151
|
+
{CHIP_POSITIONS.map((p) => (
|
|
152
|
+
<ToggleGroupControlOption key={p.value} value={p.value} label={p.label} />
|
|
153
|
+
))}
|
|
154
|
+
</ToggleGroupControl>
|
|
155
|
+
<ToggleGroupControl
|
|
156
|
+
label={__('Varianta chipu', 'brilo-blocks')}
|
|
157
|
+
value={img.chip.variant}
|
|
158
|
+
onChange={(value) => setAttributes({img: {...img, chip: {...img.chip, variant: value as ChipVariants}}})}
|
|
159
|
+
isBlock
|
|
160
|
+
>
|
|
161
|
+
{CHIP_VARIANTS.map((v) => (
|
|
162
|
+
<ToggleGroupControlOption key={v.value} value={v.value} label={v.label} />
|
|
163
|
+
))}
|
|
164
|
+
</ToggleGroupControl>
|
|
165
|
+
</PanelBody>
|
|
166
|
+
<PanelBody title={__('Rozložení', 'brilo-blocks')}>
|
|
167
|
+
<ToggleGroupControl
|
|
168
|
+
label={__('Pozice médií', 'brilo-blocks')}
|
|
169
|
+
value={mediaPosition}
|
|
170
|
+
onChange={(value) => setAttributes({mediaPosition: value as MediaPositions})}
|
|
171
|
+
isBlock
|
|
172
|
+
>
|
|
173
|
+
{MEDIA_POSITIONS.map((p) => (
|
|
174
|
+
<ToggleGroupControlOption key={p.value} value={p.value} label={p.label} />
|
|
175
|
+
))}
|
|
176
|
+
</ToggleGroupControl>
|
|
177
|
+
<ToggleGroupControl
|
|
178
|
+
label={__('Styl mřížky', 'brilo-blocks')}
|
|
179
|
+
value={gridStyle}
|
|
180
|
+
onChange={(value) => setAttributes({gridStyle: value as GridStyles})}
|
|
181
|
+
isBlock
|
|
182
|
+
>
|
|
183
|
+
{GRID_STYLES.map((s) => (
|
|
184
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
185
|
+
))}
|
|
186
|
+
</ToggleGroupControl>
|
|
187
|
+
<ToggleGroupControl
|
|
188
|
+
label={__('Velikost textu', 'brilo-blocks')}
|
|
189
|
+
value={content.size}
|
|
190
|
+
onChange={(value) => setAttributes({content: {size: value as ContentSizes}})}
|
|
191
|
+
isBlock
|
|
192
|
+
>
|
|
193
|
+
{CONTENT_SIZES.map((s) => (
|
|
194
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
195
|
+
))}
|
|
196
|
+
</ToggleGroupControl>
|
|
197
|
+
</PanelBody>
|
|
198
|
+
<PanelBody title={__('Nadpis', 'brilo-blocks')} initialOpen={false}>
|
|
199
|
+
<ToggleGroupControl
|
|
200
|
+
label={__('Úroveň nadpisu', 'brilo-blocks')}
|
|
201
|
+
value={String(header.heading.level)}
|
|
202
|
+
onChange={(value) =>
|
|
203
|
+
setAttributes({header: {...header, heading: {...header.heading, level: Number(value) as HeadingLevels}}})
|
|
204
|
+
}
|
|
205
|
+
isBlock
|
|
206
|
+
>
|
|
207
|
+
{HEADING_LEVELS.map((l) => (
|
|
208
|
+
<ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
|
|
209
|
+
))}
|
|
210
|
+
</ToggleGroupControl>
|
|
211
|
+
<ToggleGroupControl
|
|
212
|
+
label={__('Styl nadpisu', 'brilo-blocks')}
|
|
213
|
+
value={header.heading.style}
|
|
214
|
+
onChange={(value) => setAttributes({header: {...header, heading: {...header.heading, style: value as HeadingStyles}}})}
|
|
215
|
+
isBlock
|
|
216
|
+
>
|
|
217
|
+
{HEADING_STYLES.map((s) => (
|
|
218
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
219
|
+
))}
|
|
220
|
+
</ToggleGroupControl>
|
|
221
|
+
</PanelBody>
|
|
222
|
+
</InspectorControls>
|
|
223
|
+
<div {...blockProps}>
|
|
224
|
+
<div className={clsx('u-grid-responsive --col-2 g-text-and-media__grid', `--grid-style-${gridStyle}`)}>
|
|
225
|
+
{isMediaLeft ? (
|
|
226
|
+
<>
|
|
227
|
+
{mediaColumn}
|
|
228
|
+
{textColumn}
|
|
229
|
+
</>
|
|
230
|
+
) : (
|
|
231
|
+
<>
|
|
232
|
+
{textColumn}
|
|
233
|
+
{mediaColumn}
|
|
234
|
+
</>
|
|
235
|
+
)}
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
</>
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.g-text-and-media {
|
|
3
|
+
padding: 8px;
|
|
4
|
+
|
|
5
|
+
&.--media-right .g-text-and-media__grid.--grid-style-2-1 {
|
|
6
|
+
grid-template-columns: 2fr 1fr;
|
|
7
|
+
}
|
|
8
|
+
&.--media-left .g-text-and-media__grid.--grid-style-2-1 {
|
|
9
|
+
grid-template-columns: 1fr 2fr;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.--ratio-3\:2 {
|
|
13
|
+
--ratio: 3/2;
|
|
14
|
+
}
|
|
15
|
+
&.--ratio-4\:3 {
|
|
16
|
+
--ratio: 4/3;
|
|
17
|
+
}
|
|
18
|
+
&.--ratio-16\:9 {
|
|
19
|
+
--ratio: 16/9;
|
|
20
|
+
}
|
|
21
|
+
&.--ratio-1\:1 {
|
|
22
|
+
--ratio: 1/1;
|
|
23
|
+
}
|
|
24
|
+
&.--ratio-2\:1 {
|
|
25
|
+
--ratio: 2/1;
|
|
26
|
+
}
|
|
27
|
+
&.--ratio-3\:4 {
|
|
28
|
+
--ratio: 3/4;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.g-text-and-media__grid {
|
|
33
|
+
--grid-gap: 24px;
|
|
34
|
+
--grid-min-col-size: 240px;
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.g-text-and-media__media {
|
|
39
|
+
background: #f5f5f5;
|
|
40
|
+
border-radius: 4px;
|
|
41
|
+
min-height: 200px;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
|
|
47
|
+
.c-image-picker-body {
|
|
48
|
+
width: 100%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.c-image-picker-body__preview img {
|
|
52
|
+
aspect-ratio: var(--ratio);
|
|
53
|
+
object-fit: cover;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.c-image-picker-body__placeholder {
|
|
57
|
+
min-height: 200px;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.g-text-and-media__text {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
gap: 8px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.g-text-and-media__overline {
|
|
68
|
+
display: block;
|
|
69
|
+
font-size: 12px;
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
text-transform: uppercase;
|
|
72
|
+
letter-spacing: 1px;
|
|
73
|
+
color: #888;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.g-text-and-media__heading {
|
|
77
|
+
margin: 0;
|
|
78
|
+
font-weight: 700;
|
|
79
|
+
font-size: var(--heading-size, 24px);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.g-text-and-media__inner-blocks {
|
|
83
|
+
margin-top: 8px;
|
|
84
|
+
min-height: 40px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.g-text-and-media__chip {
|
|
88
|
+
position: absolute;
|
|
89
|
+
padding: 4px 10px;
|
|
90
|
+
border-radius: 20px;
|
|
91
|
+
font-size: 11px;
|
|
92
|
+
font-weight: 600;
|
|
93
|
+
background: #0073aa;
|
|
94
|
+
color: #fff;
|
|
95
|
+
white-space: nowrap;
|
|
96
|
+
pointer-events: none;
|
|
97
|
+
|
|
98
|
+
&.--top-left {
|
|
99
|
+
top: 8px;
|
|
100
|
+
left: 8px;
|
|
101
|
+
}
|
|
102
|
+
&.--top-right {
|
|
103
|
+
top: 8px;
|
|
104
|
+
right: 8px;
|
|
105
|
+
}
|
|
106
|
+
&.--bottom-left {
|
|
107
|
+
bottom: 8px;
|
|
108
|
+
left: 8px;
|
|
109
|
+
}
|
|
110
|
+
&.--bottom-right {
|
|
111
|
+
bottom: 40px;
|
|
112
|
+
right: 8px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&.--secondary {
|
|
116
|
+
background: #555d6e;
|
|
117
|
+
}
|
|
118
|
+
&.--neutral {
|
|
119
|
+
background: #e0e0e0;
|
|
120
|
+
color: #333;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import type {OptionArray} from '~/types'
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_CHIP_VARIANTS,
|
|
7
|
+
DEFAULT_CONTENT_SIZES,
|
|
8
|
+
DEFAULT_GRID_STYLES,
|
|
9
|
+
DEFAULT_HEADING_STYLES,
|
|
10
|
+
DEFAULT_MEDIA_POSITIONS,
|
|
11
|
+
DEFAULT_RATIOS,
|
|
12
|
+
HEADING_LEVELS,
|
|
13
|
+
} from './constants'
|
|
14
|
+
import {createTextAndMediaGroupEdit} from './edit'
|
|
15
|
+
import {icon as defaultIcon} from './icon'
|
|
16
|
+
import type {TextAndMediaGroupAttributes, TextAndMediaGroupOptions} from './types'
|
|
17
|
+
|
|
18
|
+
export type {TextAndMediaGroupAttributes, TextAndMediaGroupOptions}
|
|
19
|
+
|
|
20
|
+
export function createTextAndMediaGroupBlock<
|
|
21
|
+
TRatios extends OptionArray = typeof DEFAULT_RATIOS,
|
|
22
|
+
TMediaPositions extends OptionArray = typeof DEFAULT_MEDIA_POSITIONS,
|
|
23
|
+
TGridStyles extends OptionArray = typeof DEFAULT_GRID_STYLES,
|
|
24
|
+
THeadingStyles extends OptionArray = typeof DEFAULT_HEADING_STYLES,
|
|
25
|
+
TContentSizes extends OptionArray = typeof DEFAULT_CONTENT_SIZES,
|
|
26
|
+
TChipVariants extends OptionArray = typeof DEFAULT_CHIP_VARIANTS,
|
|
27
|
+
>(
|
|
28
|
+
options: TextAndMediaGroupOptions<TRatios, TMediaPositions, TGridStyles, THeadingStyles, TContentSizes, TChipVariants>,
|
|
29
|
+
): BlockConfiguration<
|
|
30
|
+
TextAndMediaGroupAttributes<
|
|
31
|
+
TRatios[number]['value'],
|
|
32
|
+
TMediaPositions[number]['value'],
|
|
33
|
+
TGridStyles[number]['value'],
|
|
34
|
+
THeadingStyles[number]['value'],
|
|
35
|
+
TContentSizes[number]['value'],
|
|
36
|
+
TChipVariants[number]['value']
|
|
37
|
+
>
|
|
38
|
+
> {
|
|
39
|
+
const ratios = options.ratios ?? DEFAULT_RATIOS
|
|
40
|
+
const mediaPositions = options.mediaPositions ?? DEFAULT_MEDIA_POSITIONS
|
|
41
|
+
const gridStyles = options.gridStyles ?? DEFAULT_GRID_STYLES
|
|
42
|
+
const headingStyles = options.headingStyles ?? DEFAULT_HEADING_STYLES
|
|
43
|
+
const contentSizes = options.contentSizes ?? DEFAULT_CONTENT_SIZES
|
|
44
|
+
const chipVariants = options.chipVariants ?? DEFAULT_CHIP_VARIANTS
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
name: options.name,
|
|
48
|
+
title: options.title ?? __('Text a média', 'brilo-blocks'),
|
|
49
|
+
description: options.description,
|
|
50
|
+
category: options.category ?? 'layout',
|
|
51
|
+
...(options.parent && {parent: options.parent}),
|
|
52
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
53
|
+
supports: {html: false, customClassName: false},
|
|
54
|
+
attributes: {
|
|
55
|
+
header: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
default: {
|
|
58
|
+
heading: {title: '', level: HEADING_LEVELS[1], style: headingStyles[1]?.value ?? headingStyles[0].value},
|
|
59
|
+
overline: {title: ''},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
mediaPosition: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
default: mediaPositions[1]?.value ?? mediaPositions[0].value,
|
|
65
|
+
enum: mediaPositions.map((p) => p.value),
|
|
66
|
+
},
|
|
67
|
+
img: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
default: {
|
|
70
|
+
id: 0,
|
|
71
|
+
alt: '',
|
|
72
|
+
video: {src: ''},
|
|
73
|
+
chip: {title: '', position: 'bottom-right', variant: chipVariants[0].value},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
ratio: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
default: ratios[2]?.value ?? ratios[0].value,
|
|
79
|
+
enum: ratios.map((r) => r.value),
|
|
80
|
+
},
|
|
81
|
+
gridStyle: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
default: gridStyles[0].value,
|
|
84
|
+
enum: gridStyles.map((g) => g.value),
|
|
85
|
+
},
|
|
86
|
+
content: {type: 'object', default: {size: contentSizes[1]?.value ?? contentSizes[0].value}},
|
|
87
|
+
},
|
|
88
|
+
edit: createTextAndMediaGroupEdit(options as unknown as TextAndMediaGroupOptions),
|
|
89
|
+
save: () => <InnerBlocks.Content />,
|
|
90
|
+
} as unknown as BlockConfiguration<
|
|
91
|
+
TextAndMediaGroupAttributes<
|
|
92
|
+
TRatios[number]['value'],
|
|
93
|
+
TMediaPositions[number]['value'],
|
|
94
|
+
TGridStyles[number]['value'],
|
|
95
|
+
THeadingStyles[number]['value'],
|
|
96
|
+
TContentSizes[number]['value'],
|
|
97
|
+
TChipVariants[number]['value']
|
|
98
|
+
>
|
|
99
|
+
>
|
|
100
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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>Text and Media Group</title>
|
|
4
|
+
<g clipPath="url(#clip0_24_1038)">
|
|
5
|
+
<rect x="0.5" y="0.5" width="10" height="8" stroke="black" fill="none" />
|
|
6
|
+
<path fillRule="evenodd" clipRule="evenodd" d="M4.5 4L2 7L7 7L4.5 4Z" fill="black" />
|
|
7
|
+
<path d="M9 3C9 3.55228 8.55228 4 8 4C7.44772 4 7 3.55228 7 3C7 2.44772 7.44772 2 8 2C8.55228 2 9 2.44772 9 3Z" fill="black" />
|
|
8
|
+
<path d="M13 1H18V2H13V1Z" fill="black" />
|
|
9
|
+
<path d="M13 3H20V4H13V3Z" fill="black" />
|
|
10
|
+
<path
|
|
11
|
+
fillRule="evenodd"
|
|
12
|
+
clipRule="evenodd"
|
|
13
|
+
d="M14.5 5C13.6716 5 13 5.67157 13 6.5C13 7.32843 13.6716 8 14.5 8H18.5C19.3284 8 20 7.32843 20 6.5C20 5.67157 19.3284 5 18.5 5H14.5ZM18 6H15V7H18V6Z"
|
|
14
|
+
fill="#357AB5"
|
|
15
|
+
/>
|
|
16
|
+
<rect x="9.5" y="11.5" width="10" height="8" stroke="black" fill="none" />
|
|
17
|
+
<path fillRule="evenodd" clipRule="evenodd" d="M13.5 15L11 18L16 18L13.5 15Z" fill="black" />
|
|
18
|
+
<path
|
|
19
|
+
d="M18 14C18 14.5523 17.5523 15 17 15C16.4477 15 16 14.5523 16 14C16 13.4477 16.4477 13 17 13C17.5523 13 18 13.4477 18 14Z"
|
|
20
|
+
fill="black"
|
|
21
|
+
/>
|
|
22
|
+
<path d="M0 12H5V13H0V12Z" fill="black" />
|
|
23
|
+
<path d="M0 14H7V15H0V14Z" fill="black" />
|
|
24
|
+
<path
|
|
25
|
+
fillRule="evenodd"
|
|
26
|
+
clipRule="evenodd"
|
|
27
|
+
d="M1.5 16C0.671573 16 0 16.6716 0 17.5C0 18.3284 0.671573 19 1.5 19H5.5C6.32843 19 7 18.3284 7 17.5C7 16.6716 6.32843 16 5.5 16H1.5ZM5 17H2V18H5V17Z"
|
|
28
|
+
fill="#357AB5"
|
|
29
|
+
/>
|
|
30
|
+
</g>
|
|
31
|
+
<defs>
|
|
32
|
+
<clipPath id="clip0_24_1038">
|
|
33
|
+
<rect width="20" height="20" fill="white" />
|
|
34
|
+
</clipPath>
|
|
35
|
+
</defs>
|
|
36
|
+
</svg>
|
|
37
|
+
)
|