@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,43 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {MAX_ITEMS_DEFAULT} from './constants'
|
|
4
|
+
import {createPostSliderGroupEdit} from './edit'
|
|
5
|
+
import {icon as defaultIcon} from './icon'
|
|
6
|
+
import type {PostSliderGroupAttributes, PostSliderGroupOptions} from './types'
|
|
7
|
+
|
|
8
|
+
export type {PostSliderGroupAttributes, PostSliderGroupOptions}
|
|
9
|
+
|
|
10
|
+
export function createPostSliderGroupBlock(options: PostSliderGroupOptions): BlockConfiguration<PostSliderGroupAttributes> {
|
|
11
|
+
return {
|
|
12
|
+
name: options.name,
|
|
13
|
+
title: options.title ?? __('Post Slider', 'brilo-blocks'),
|
|
14
|
+
description: options.description,
|
|
15
|
+
category: options.category ?? 'widgets',
|
|
16
|
+
...(options.parent && {parent: options.parent}),
|
|
17
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
18
|
+
supports: {html: false, customClassName: false},
|
|
19
|
+
attributes: {
|
|
20
|
+
mode: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: 'default',
|
|
23
|
+
enum: ['default', 'category', 'selected'],
|
|
24
|
+
},
|
|
25
|
+
maxItems: {
|
|
26
|
+
type: 'number',
|
|
27
|
+
default: MAX_ITEMS_DEFAULT,
|
|
28
|
+
},
|
|
29
|
+
selectedCategories: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
default: [],
|
|
32
|
+
items: {type: 'number'},
|
|
33
|
+
},
|
|
34
|
+
selectedPosts: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
default: [],
|
|
37
|
+
items: {type: 'number'},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
edit: createPostSliderGroupEdit(options),
|
|
41
|
+
save: () => null,
|
|
42
|
+
} as unknown as BlockConfiguration<PostSliderGroupAttributes>
|
|
43
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<rect x="1" y="4" width="18" height="12" rx="1" stroke="black" fill="none" />
|
|
4
|
+
<rect x="3" y="6" width="6" height="5" stroke="black" fill="none" />
|
|
5
|
+
<path d="M3 13H7V14H3V13Z" fill="black" />
|
|
6
|
+
<path d="M3 15H9V16H3V15Z" fill="black" />
|
|
7
|
+
<path d="M11 8H17V9H11V8Z" fill="black" />
|
|
8
|
+
<path d="M11 11H17V12H11V11Z" fill="black" />
|
|
9
|
+
<path d="M11 14H15V15H11V14Z" fill="black" />
|
|
10
|
+
<circle cx="17.5" cy="10" r="1" fill="#357AB5" />
|
|
11
|
+
<circle cx="2.5" cy="10" r="1" fill="#357AB5" />
|
|
12
|
+
</svg>
|
|
13
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './types'
|
|
2
|
+
export {createPostSliderGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {PostSliderGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const postSliderGroupDefaults: PostSliderGroupOptions = {
|
|
7
|
+
name: 'brilo/post-slider-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type {BriloBlockType} from '~/types'
|
|
2
|
+
|
|
3
|
+
export type PostSliderMode = 'default' | 'category' | 'selected'
|
|
4
|
+
|
|
5
|
+
export interface PostSliderGroupAttributes extends Record<string, unknown> {
|
|
6
|
+
mode: PostSliderMode
|
|
7
|
+
maxItems: number
|
|
8
|
+
selectedCategories: number[]
|
|
9
|
+
selectedPosts: number[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SelectControlProps {
|
|
13
|
+
selectedItems: number[]
|
|
14
|
+
onChange: (ids: number[]) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PostSliderGroupOptions extends BriloBlockType {
|
|
18
|
+
renderCategoryControl?: (props: SelectControlProps) => JSX.Element
|
|
19
|
+
renderPostsControl?: (props: SelectControlProps) => JSX.Element
|
|
20
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
__experimentalNumberControl as NumberControl,
|
|
5
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
6
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
|
+
} from '@wordpress/components'
|
|
8
|
+
import {__} from '@wordpress/i18n'
|
|
9
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
10
|
+
import type {ResponsiveGridGroupAttributes, ResponsiveGridGroupOptions} from './types'
|
|
11
|
+
|
|
12
|
+
const COLUMN_OPTIONS = [2, 3, 4, 5, 6]
|
|
13
|
+
const GAP_PRESETS = [8, 16, 24, 32, 48]
|
|
14
|
+
const MIN_COL_PRESETS = [150, 200, 250, 300]
|
|
15
|
+
|
|
16
|
+
export function createResponsiveGridGroupEdit(options: ResponsiveGridGroupOptions) {
|
|
17
|
+
return function Edit({
|
|
18
|
+
attributes,
|
|
19
|
+
setAttributes,
|
|
20
|
+
}: {
|
|
21
|
+
attributes: ResponsiveGridGroupAttributes
|
|
22
|
+
setAttributes: (a: Partial<ResponsiveGridGroupAttributes>) => void
|
|
23
|
+
}) {
|
|
24
|
+
const {columns, gap, minColSize} = attributes
|
|
25
|
+
|
|
26
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
27
|
+
blockClassName: options.blockClassName ?? 'wp-block-section',
|
|
28
|
+
containerClassName: options.containerClassName ?? 'u-grid-responsive',
|
|
29
|
+
containerStyle: {
|
|
30
|
+
'--grid-max-col-count': columns,
|
|
31
|
+
'--grid-min-col-size': `${minColSize}px`,
|
|
32
|
+
'--grid-gap': `${gap}px`,
|
|
33
|
+
},
|
|
34
|
+
allowedBlocks: options.allowedBlocks,
|
|
35
|
+
template: options.template,
|
|
36
|
+
layout: {type: 'default'},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<InspectorControls>
|
|
42
|
+
<PanelBody title={__('Rozložení mřížky', 'brilo-blocks')}>
|
|
43
|
+
<ToggleGroupControl
|
|
44
|
+
isBlock
|
|
45
|
+
label={__('Počet sloupců', 'brilo-blocks')}
|
|
46
|
+
value={String(columns)}
|
|
47
|
+
onChange={(v) => setAttributes({columns: Number(v)})}
|
|
48
|
+
>
|
|
49
|
+
{COLUMN_OPTIONS.map((c) => (
|
|
50
|
+
<ToggleGroupControlOption key={c} value={String(c)} label={String(c)} />
|
|
51
|
+
))}
|
|
52
|
+
</ToggleGroupControl>
|
|
53
|
+
<ToggleGroupControl
|
|
54
|
+
isBlock
|
|
55
|
+
label={__('Mezera (gap)', 'brilo-blocks')}
|
|
56
|
+
value={GAP_PRESETS.includes(gap) ? String(gap) : undefined}
|
|
57
|
+
onChange={(v) => v && setAttributes({gap: Number(v)})}
|
|
58
|
+
>
|
|
59
|
+
{GAP_PRESETS.map((p) => (
|
|
60
|
+
<ToggleGroupControlOption key={p} value={String(p)} label={`${p}px`} />
|
|
61
|
+
))}
|
|
62
|
+
</ToggleGroupControl>
|
|
63
|
+
<NumberControl
|
|
64
|
+
label={__('Vlastní mezera (px)', 'brilo-blocks')}
|
|
65
|
+
value={gap}
|
|
66
|
+
onChange={(v) => setAttributes({gap: Number(v) || 0})}
|
|
67
|
+
min={0}
|
|
68
|
+
step={4}
|
|
69
|
+
/>
|
|
70
|
+
<ToggleGroupControl
|
|
71
|
+
isBlock
|
|
72
|
+
label={__('Minimální šířka sloupce', 'brilo-blocks')}
|
|
73
|
+
value={MIN_COL_PRESETS.includes(minColSize) ? String(minColSize) : undefined}
|
|
74
|
+
onChange={(v) => v && setAttributes({minColSize: Number(v)})}
|
|
75
|
+
>
|
|
76
|
+
{MIN_COL_PRESETS.map((p) => (
|
|
77
|
+
<ToggleGroupControlOption key={p} value={String(p)} label={`${p}px`} />
|
|
78
|
+
))}
|
|
79
|
+
</ToggleGroupControl>
|
|
80
|
+
<NumberControl
|
|
81
|
+
label={__('Vlastní minimum (px)', 'brilo-blocks')}
|
|
82
|
+
value={minColSize}
|
|
83
|
+
onChange={(v) => setAttributes({minColSize: Number(v) || 0})}
|
|
84
|
+
min={0}
|
|
85
|
+
step={10}
|
|
86
|
+
/>
|
|
87
|
+
</PanelBody>
|
|
88
|
+
</InspectorControls>
|
|
89
|
+
<div {...blockProps}>
|
|
90
|
+
<div {...innerBlocksProps} />
|
|
91
|
+
</div>
|
|
92
|
+
</>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createResponsiveGridGroupEdit} from './edit'
|
|
5
|
+
import type {ResponsiveGridGroupAttributes, ResponsiveGridGroupOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export function createResponsiveGridGroupBlock(options: ResponsiveGridGroupOptions): BlockConfiguration<ResponsiveGridGroupAttributes> {
|
|
8
|
+
return {
|
|
9
|
+
name: options.name,
|
|
10
|
+
title: options.title ?? __('Responzivní mřížka', 'brilo-blocks'),
|
|
11
|
+
description: options.description,
|
|
12
|
+
category: options.category ?? 'layout',
|
|
13
|
+
...(options.parent && {parent: options.parent}),
|
|
14
|
+
icon: options.icon ?? 'grid-view',
|
|
15
|
+
supports: {html: false, customClassName: false},
|
|
16
|
+
attributes: {
|
|
17
|
+
columns: {
|
|
18
|
+
type: 'number',
|
|
19
|
+
default: 2,
|
|
20
|
+
},
|
|
21
|
+
gap: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
default: 32,
|
|
24
|
+
},
|
|
25
|
+
minColSize: {
|
|
26
|
+
type: 'number',
|
|
27
|
+
default: 300,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
edit: createResponsiveGridGroupEdit(options),
|
|
31
|
+
save: () => <InnerBlocks.Content />,
|
|
32
|
+
} as BlockConfiguration<ResponsiveGridGroupAttributes>
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {ResponsiveGridGroupAttributes, ResponsiveGridGroupOptions} from './types'
|
|
2
|
+
export {createResponsiveGridGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {ResponsiveGridGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const responsiveGridGroupDefaults: ResponsiveGridGroupOptions = {
|
|
7
|
+
name: 'brilo/responsive-grid-group',
|
|
8
|
+
allowedBlocks: ['brilo/responsive-grid-item'],
|
|
9
|
+
template: [
|
|
10
|
+
['brilo/responsive-grid-item', {}],
|
|
11
|
+
['brilo/responsive-grid-item', {}],
|
|
12
|
+
],
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
2
|
+
import type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './types'
|
|
3
|
+
|
|
4
|
+
export function createResponsiveGridItemEdit(options: ResponsiveGridItemOptions) {
|
|
5
|
+
return function Edit(_: {attributes: ResponsiveGridItemAttributes; setAttributes: (a: Partial<ResponsiveGridItemAttributes>) => void}) {
|
|
6
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
7
|
+
blockClassName: options.blockClassName ?? 'u-grid-responsive__item',
|
|
8
|
+
containerClassName: options.containerClassName ?? 'u-grid-responsive__item-inner entry-content',
|
|
9
|
+
allowedBlocks: options.allowedBlocks,
|
|
10
|
+
template: options.template,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div {...blockProps}>
|
|
15
|
+
<div {...innerBlocksProps} />
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createResponsiveGridItemEdit} from './edit'
|
|
5
|
+
import type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export function createResponsiveGridItemBlock(options: ResponsiveGridItemOptions): BlockConfiguration<ResponsiveGridItemAttributes> {
|
|
8
|
+
return {
|
|
9
|
+
name: options.name,
|
|
10
|
+
title: options.title ?? __('Buňka mřížky', 'brilo-blocks'),
|
|
11
|
+
description: options.description,
|
|
12
|
+
category: options.category ?? 'layout',
|
|
13
|
+
...(options.parent && {parent: options.parent}),
|
|
14
|
+
icon: options.icon ?? 'grid-view',
|
|
15
|
+
supports: {html: false, customClassName: false},
|
|
16
|
+
attributes: {},
|
|
17
|
+
edit: createResponsiveGridItemEdit(options),
|
|
18
|
+
save: () => <InnerBlocks.Content />,
|
|
19
|
+
} as BlockConfiguration<ResponsiveGridItemAttributes>
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './types'
|
|
2
|
+
export {createResponsiveGridItemBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {ResponsiveGridItemOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const responsiveGridItemDefaults: ResponsiveGridItemOptions = {
|
|
7
|
+
name: 'brilo/responsive-grid-item',
|
|
8
|
+
parent: ['brilo/responsive-grid-group'],
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const baseAttributes = {
|
|
2
|
+
id: {
|
|
3
|
+
type: 'string',
|
|
4
|
+
default: '',
|
|
5
|
+
},
|
|
6
|
+
spacing: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
default: {
|
|
9
|
+
position: 'default',
|
|
10
|
+
size: 'default',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
background: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
default: 'none',
|
|
16
|
+
},
|
|
17
|
+
} as const
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const SPACING_POSITIONS = [
|
|
4
|
+
{value: 'default', label: __('Nahoře i dole', 'brilo-blocks')},
|
|
5
|
+
{value: 'none', label: __('Žádná', 'brilo-blocks')},
|
|
6
|
+
{value: 'bottom-0', label: __('Pouze nahoře', 'brilo-blocks')},
|
|
7
|
+
{value: 'top-0', label: __('Pouze dole', 'brilo-blocks')},
|
|
8
|
+
] as const
|
|
9
|
+
|
|
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
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PanelBody,
|
|
3
|
+
SelectControl,
|
|
4
|
+
TextControl,
|
|
5
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
6
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
|
+
} from '@wordpress/components'
|
|
8
|
+
import {__} from '@wordpress/i18n'
|
|
9
|
+
import type {BaseBlockAttributes, ExcludableBaseAttr} from './types'
|
|
10
|
+
import {BACKGROUNDS, SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
11
|
+
|
|
12
|
+
type SpacingPosition = BaseBlockAttributes['spacing']['position']
|
|
13
|
+
type SpacingSize = BaseBlockAttributes['spacing']['size']
|
|
14
|
+
|
|
15
|
+
interface BaseControlsProps {
|
|
16
|
+
attributes: BaseBlockAttributes
|
|
17
|
+
setAttributes: (attrs: Partial<BaseBlockAttributes>) => void
|
|
18
|
+
exclude: ExcludableBaseAttr[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function BaseControls({attributes, setAttributes, exclude}: BaseControlsProps) {
|
|
22
|
+
const {id, spacing, background} = attributes
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
{!exclude.includes('spacing') && (
|
|
27
|
+
<PanelBody title={__('Rozestupy', 'brilo-blocks')}>
|
|
28
|
+
<SelectControl<string>
|
|
29
|
+
label={__('Pozice', 'brilo-blocks')}
|
|
30
|
+
value={spacing.position}
|
|
31
|
+
options={[...SPACING_POSITIONS]}
|
|
32
|
+
onChange={(value) => setAttributes({spacing: {...spacing, position: value as SpacingPosition}})}
|
|
33
|
+
/>
|
|
34
|
+
<ToggleGroupControl
|
|
35
|
+
label={__('Velikost', 'brilo-blocks')}
|
|
36
|
+
value={spacing.size}
|
|
37
|
+
onChange={(value) => setAttributes({spacing: {...spacing, size: value as SpacingSize}})}
|
|
38
|
+
isBlock
|
|
39
|
+
>
|
|
40
|
+
{SPACING_SIZES.map((s) => (
|
|
41
|
+
<ToggleGroupControlOption key={s} value={s} label={s === 'default' ? __('Výchozí', 'brilo-blocks') : s.toUpperCase()} />
|
|
42
|
+
))}
|
|
43
|
+
</ToggleGroupControl>
|
|
44
|
+
</PanelBody>
|
|
45
|
+
)}
|
|
46
|
+
|
|
47
|
+
{!exclude.includes('background') && (
|
|
48
|
+
<PanelBody title={__('Pozadí', 'brilo-blocks')}>
|
|
49
|
+
<SelectControl<string>
|
|
50
|
+
label={__('Pozadí', 'brilo-blocks')}
|
|
51
|
+
value={background}
|
|
52
|
+
options={[...BACKGROUNDS]}
|
|
53
|
+
onChange={(value) => setAttributes({background: value})}
|
|
54
|
+
/>
|
|
55
|
+
</PanelBody>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
{!exclude.includes('id') && (
|
|
59
|
+
<PanelBody title={__('Kotva', 'brilo-blocks')} initialOpen={false}>
|
|
60
|
+
<TextControl
|
|
61
|
+
label={__('ID sekce', 'brilo-blocks')}
|
|
62
|
+
value={id ?? ''}
|
|
63
|
+
onChange={(value) => setAttributes({id: value})}
|
|
64
|
+
help={__('Použije se jako HTML atribut id pro kotevní odkaz.', 'brilo-blocks')}
|
|
65
|
+
/>
|
|
66
|
+
</PanelBody>
|
|
67
|
+
)}
|
|
68
|
+
</>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps, useInnerBlocksProps} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockEditProps} from '@wordpress/blocks'
|
|
3
|
+
import type {BaseBlockAttributes, BaseSectionOptions} from './types'
|
|
4
|
+
import {BaseControls} from './controls'
|
|
5
|
+
|
|
6
|
+
export function createBaseSectionEdit<TExtra extends Record<string, unknown> = Record<string, never>>(options: BaseSectionOptions<TExtra>) {
|
|
7
|
+
const EXCLUDE = options.exclude ?? []
|
|
8
|
+
|
|
9
|
+
return function Edit(props: BlockEditProps<BaseBlockAttributes & TExtra>) {
|
|
10
|
+
const {attributes, setAttributes} = props
|
|
11
|
+
const blockProps = useBlockProps({className: options.blockClassName})
|
|
12
|
+
const innerBlocksProps = useInnerBlocksProps({className: options.containerClassName}, {
|
|
13
|
+
allowedBlocks: options.allowedBlocks,
|
|
14
|
+
orientation: 'vertical',
|
|
15
|
+
layout: {type: 'default'},
|
|
16
|
+
} as Parameters<typeof useInnerBlocksProps>[1])
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<InspectorControls>
|
|
21
|
+
<BaseControls
|
|
22
|
+
attributes={attributes as BaseBlockAttributes}
|
|
23
|
+
setAttributes={setAttributes as (attrs: Partial<BaseBlockAttributes>) => void}
|
|
24
|
+
exclude={EXCLUDE}
|
|
25
|
+
/>
|
|
26
|
+
{options.extraControls?.(props)}
|
|
27
|
+
</InspectorControls>
|
|
28
|
+
<div {...blockProps}>
|
|
29
|
+
<div {...innerBlocksProps} />
|
|
30
|
+
</div>
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.s-base {
|
|
3
|
+
border: 2px dashed #0073aa;
|
|
4
|
+
padding: 16px;
|
|
5
|
+
min-height: 60px;
|
|
6
|
+
position: relative;
|
|
7
|
+
max-width: 1200px;
|
|
8
|
+
|
|
9
|
+
&::before {
|
|
10
|
+
content: "Sekce";
|
|
11
|
+
display: block;
|
|
12
|
+
font-size: 10px;
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
text-transform: uppercase;
|
|
15
|
+
color: #0073aa;
|
|
16
|
+
letter-spacing: 0.5px;
|
|
17
|
+
margin-bottom: 8px;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.s-base__inner {
|
|
22
|
+
min-height: 40px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {baseAttributes} from './attributes'
|
|
5
|
+
import {BACKGROUNDS} from './constants'
|
|
6
|
+
import {createBaseSectionEdit} from './edit'
|
|
7
|
+
import {icon as defaultIcon} from './icon'
|
|
8
|
+
import type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './types'
|
|
9
|
+
|
|
10
|
+
export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr}
|
|
11
|
+
|
|
12
|
+
export function createBaseSectionBlock<TExtra extends Record<string, unknown> = Record<string, never>>(
|
|
13
|
+
options: BaseSectionOptions<TExtra>,
|
|
14
|
+
): BlockConfiguration<BaseBlockAttributes & TExtra> {
|
|
15
|
+
const exclude = options.exclude ?? []
|
|
16
|
+
|
|
17
|
+
const attributes: Record<string, unknown> = {}
|
|
18
|
+
for (const [key, value] of Object.entries(baseAttributes)) {
|
|
19
|
+
if (!exclude.includes(key as keyof typeof baseAttributes)) {
|
|
20
|
+
if (key === 'background') {
|
|
21
|
+
attributes[key] = {...value, enum: BACKGROUNDS.map((b) => b.value)}
|
|
22
|
+
} else {
|
|
23
|
+
attributes[key] = value
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (options.extraAttributes) {
|
|
29
|
+
Object.assign(attributes, options.extraAttributes)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
name: options.name,
|
|
34
|
+
title: options.title ?? __('Sekce', 'brilo-blocks'),
|
|
35
|
+
description: options.description,
|
|
36
|
+
category: options.category ?? 'layout',
|
|
37
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
38
|
+
supports: options.supports ?? {
|
|
39
|
+
html: false,
|
|
40
|
+
customClassName: false,
|
|
41
|
+
align: false,
|
|
42
|
+
},
|
|
43
|
+
attributes,
|
|
44
|
+
edit: createBaseSectionEdit(options),
|
|
45
|
+
save: () => <InnerBlocks.Content />,
|
|
46
|
+
} as unknown as BlockConfiguration<BaseBlockAttributes & TExtra>
|
|
47
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512" fill="black">
|
|
3
|
+
<title>Base Section</title>
|
|
4
|
+
<path d="M.3 89.5C.1 91.6 0 93.8 0 96L0 224 0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-192 0-128c0-35.3-28.7-64-64-64L64 32c-2.2 0-4.4 .1-6.5 .3c-9.2 .9-17.8 3.8-25.5 8.2C21.8 46.5 13.4 55.1 7.7 65.5c-3.9 7.3-6.5 15.4-7.4 24zM48 224l416 0 0 192c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16l0-192z" />
|
|
5
|
+
</svg>
|
|
6
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './types'
|
|
2
|
+
export {baseAttributes} from './attributes'
|
|
3
|
+
export {BACKGROUNDS, SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
4
|
+
export {createBaseSectionEdit} from './edit'
|
|
5
|
+
export {createBaseSectionBlock} from './factory'
|
|
6
|
+
|
|
7
|
+
import type {BaseSectionOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export const baseSectionDefaults: BaseSectionOptions = {
|
|
10
|
+
name: 'brilo/base-section',
|
|
11
|
+
blockClassName: 'wp-block-section',
|
|
12
|
+
containerClassName: 'wp-block-section__inner',
|
|
13
|
+
allowedBlocks: [],
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {BlockConfiguration, BlockEditProps} from '@wordpress/blocks'
|
|
2
|
+
import type {ReactNode} from 'react'
|
|
3
|
+
import type {BriloBlockType} from '~/types'
|
|
4
|
+
|
|
5
|
+
export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
6
|
+
id: string
|
|
7
|
+
spacing: {
|
|
8
|
+
position: string
|
|
9
|
+
size: string
|
|
10
|
+
}
|
|
11
|
+
background: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ExcludableBaseAttr = 'spacing' | 'background' | 'id'
|
|
15
|
+
|
|
16
|
+
export interface BaseSectionOptions<TExtra extends Record<string, unknown> = Record<string, never>> extends BriloBlockType {
|
|
17
|
+
supports?: BlockConfiguration['supports']
|
|
18
|
+
extraAttributes?: {
|
|
19
|
+
[K in keyof TExtra]: {
|
|
20
|
+
type: string
|
|
21
|
+
default: TExtra[K]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
extraControls?: (props: BlockEditProps<BaseBlockAttributes & TExtra>) => ReactNode
|
|
25
|
+
exclude?: ExcludableBaseAttr[]
|
|
26
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
5
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
6
|
+
} from '@wordpress/components'
|
|
7
|
+
import {__} from '@wordpress/i18n'
|
|
8
|
+
import clsx from 'clsx'
|
|
9
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
10
|
+
import {COLUMNS, HEADING_LEVELS, RATIOS} from './constants'
|
|
11
|
+
import type {SignpostGroupAttributes, SignpostGroupOptions} from './types'
|
|
12
|
+
|
|
13
|
+
export function createSignpostGroupEdit(options: SignpostGroupOptions) {
|
|
14
|
+
return function Edit({
|
|
15
|
+
attributes,
|
|
16
|
+
setAttributes,
|
|
17
|
+
}: {
|
|
18
|
+
attributes: SignpostGroupAttributes
|
|
19
|
+
setAttributes: (a: Partial<SignpostGroupAttributes>) => void
|
|
20
|
+
}) {
|
|
21
|
+
const {columns, headingLevel, ratio} = attributes
|
|
22
|
+
|
|
23
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
24
|
+
blockClassName: clsx(options.blockClassName ?? 'g-signpost wp-block-section'),
|
|
25
|
+
containerClassName: [options.containerClassName ?? 'u-grid-responsive', `--cols-${columns}`, `--ratio-${ratio.replace(':', '-')}`],
|
|
26
|
+
containerStyle: {'--grid-max-col-count': columns},
|
|
27
|
+
allowedBlocks: options.allowedBlocks,
|
|
28
|
+
orientation: 'horizontal',
|
|
29
|
+
template: options.template,
|
|
30
|
+
layout: {type: 'default'},
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<InspectorControls>
|
|
36
|
+
<PanelBody title={__('Rozložení', 'brilo-blocks')}>
|
|
37
|
+
<ToggleGroupControl
|
|
38
|
+
isBlock
|
|
39
|
+
label={__('Počet sloupců', 'brilo-blocks')}
|
|
40
|
+
value={String(columns)}
|
|
41
|
+
onChange={(v) => setAttributes({columns: Number(v) as SignpostGroupAttributes['columns']})}
|
|
42
|
+
>
|
|
43
|
+
{COLUMNS.map((c) => (
|
|
44
|
+
<ToggleGroupControlOption key={c} value={String(c)} label={String(c)} />
|
|
45
|
+
))}
|
|
46
|
+
</ToggleGroupControl>
|
|
47
|
+
<ToggleGroupControl
|
|
48
|
+
isBlock
|
|
49
|
+
label={__('Poměr stran', 'brilo-blocks')}
|
|
50
|
+
value={ratio}
|
|
51
|
+
onChange={(v) => setAttributes({ratio: v as string})}
|
|
52
|
+
>
|
|
53
|
+
{RATIOS.map((r) => (
|
|
54
|
+
<ToggleGroupControlOption key={r} value={r} label={r} />
|
|
55
|
+
))}
|
|
56
|
+
</ToggleGroupControl>
|
|
57
|
+
<ToggleGroupControl
|
|
58
|
+
isBlock
|
|
59
|
+
label={__('Úroveň nadpisu položek', 'brilo-blocks')}
|
|
60
|
+
value={String(headingLevel)}
|
|
61
|
+
onChange={(v) => setAttributes({headingLevel: Number(v)})}
|
|
62
|
+
>
|
|
63
|
+
{HEADING_LEVELS.map((l) => (
|
|
64
|
+
<ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
|
|
65
|
+
))}
|
|
66
|
+
</ToggleGroupControl>
|
|
67
|
+
</PanelBody>
|
|
68
|
+
</InspectorControls>
|
|
69
|
+
<div {...blockProps}>
|
|
70
|
+
<div {...innerBlocksProps} />
|
|
71
|
+
</div>
|
|
72
|
+
</>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
File without changes
|