@brilo/base-blocks 0.1.21 → 0.1.23
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/.tsbuildinfo +1 -1
- package/build/blocks/form/form-field/SelectOptionsRepeater.d.ts +10 -0
- package/build/blocks/form/form-field/SelectOptionsRepeater.d.ts.map +1 -0
- package/build/blocks/form/form-field/SelectOptionsRepeater.js +20 -0
- package/build/blocks/form/form-field/constants.d.ts +8 -0
- package/build/blocks/form/form-field/constants.d.ts.map +1 -1
- package/build/blocks/form/form-field/constants.js +5 -0
- package/build/blocks/form/form-field/edit.d.ts.map +1 -1
- package/build/blocks/form/form-field/edit.js +20 -11
- package/build/blocks/form/form-field/factory.d.ts.map +1 -1
- package/build/blocks/form/form-field/factory.js +1 -0
- package/build/blocks/form/form-field/normalizeOptions.d.ts +18 -0
- package/build/blocks/form/form-field/normalizeOptions.d.ts.map +1 -0
- package/build/blocks/form/form-field/normalizeOptions.js +39 -0
- package/build/blocks/form/form-field/types.d.ts +9 -2
- package/build/blocks/form/form-field/types.d.ts.map +1 -1
- package/build/blocks/layout/layout-aside/constants.d.ts +2 -0
- package/build/blocks/layout/layout-aside/constants.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/constants.js +1 -0
- package/build/blocks/layout/layout-aside/edit.d.ts +4 -0
- package/build/blocks/layout/layout-aside/edit.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/edit.js +13 -0
- package/build/blocks/layout/layout-aside/factory.d.ts +4 -0
- package/build/blocks/layout/layout-aside/factory.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/factory.js +20 -0
- package/build/blocks/layout/layout-aside/icon.d.ts +3 -0
- package/build/blocks/layout/layout-aside/icon.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/icon.js +2 -0
- package/build/blocks/layout/layout-aside/index.d.ts +5 -0
- package/build/blocks/layout/layout-aside/index.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/index.js +5 -0
- package/build/blocks/layout/layout-aside/types.d.ts +6 -0
- package/build/blocks/layout/layout-aside/types.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/types.js +1 -0
- package/build/blocks/layout/layout-content/constants.d.ts +2 -0
- package/build/blocks/layout/layout-content/constants.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/constants.js +1 -0
- package/build/blocks/layout/layout-content/edit.d.ts +4 -0
- package/build/blocks/layout/layout-content/edit.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/edit.js +13 -0
- package/build/blocks/layout/layout-content/factory.d.ts +4 -0
- package/build/blocks/layout/layout-content/factory.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/factory.js +20 -0
- package/build/blocks/layout/layout-content/icon.d.ts +3 -0
- package/build/blocks/layout/layout-content/icon.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/icon.js +2 -0
- package/build/blocks/layout/layout-content/index.d.ts +5 -0
- package/build/blocks/layout/layout-content/index.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/index.js +5 -0
- package/build/blocks/layout/layout-content/types.d.ts +6 -0
- package/build/blocks/layout/layout-content/types.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/types.js +1 -0
- package/build/blocks/layout/layout-content-w-aside/constants.d.ts +11 -0
- package/build/blocks/layout/layout-content-w-aside/constants.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/constants.js +6 -0
- package/build/blocks/layout/layout-content-w-aside/edit.d.ts +7 -0
- package/build/blocks/layout/layout-content-w-aside/edit.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/edit.js +22 -0
- package/build/blocks/layout/layout-content-w-aside/factory.d.ts +6 -0
- package/build/blocks/layout/layout-content-w-aside/factory.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/factory.js +26 -0
- package/build/blocks/layout/layout-content-w-aside/icon.d.ts +3 -0
- package/build/blocks/layout/layout-content-w-aside/icon.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/icon.js +2 -0
- package/build/blocks/layout/layout-content-w-aside/index.d.ts +5 -0
- package/build/blocks/layout/layout-content-w-aside/index.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/index.js +9 -0
- package/build/blocks/layout/layout-content-w-aside/types.d.ts +10 -0
- package/build/blocks/layout/layout-content-w-aside/types.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/types.js +1 -0
- package/build/blocks/post/posts-grid/constants.d.ts +4 -0
- package/build/blocks/post/posts-grid/constants.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/constants.js +3 -0
- package/build/blocks/post/posts-grid/edit.d.ts +6 -0
- package/build/blocks/post/posts-grid/edit.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/edit.js +21 -0
- package/build/blocks/post/posts-grid/factory.d.ts +5 -0
- package/build/blocks/post/posts-grid/factory.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/factory.js +59 -0
- package/build/blocks/post/posts-grid/icon.d.ts +2 -0
- package/build/blocks/post/posts-grid/icon.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/icon.js +2 -0
- package/build/blocks/post/posts-grid/index.d.ts +5 -0
- package/build/blocks/post/posts-grid/index.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/index.js +5 -0
- package/build/blocks/post/posts-grid/types.d.ts +22 -0
- package/build/blocks/post/posts-grid/types.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/types.js +1 -0
- package/build/blocks/sections/base-section/attributes.d.ts +4 -0
- package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
- package/build/blocks/sections/base-section/attributes.js +4 -0
- package/build/blocks/sections/base-section/constants.d.ts +7 -0
- package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.js +7 -0
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/controls.js +23 -5
- package/build/blocks/sections/base-section/types.d.ts +18 -1
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/build/blocks/signpost/signpost-group/constants.d.ts +1 -1
- package/build/blocks/signpost/signpost-group/constants.d.ts.map +1 -1
- package/build/blocks/signpost/signpost-group/constants.js +1 -1
- package/build/index.d.ts +8 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/package.json +5 -2
- package/src/blocks/form/form-field/SelectOptionsRepeater.tsx +111 -0
- package/src/blocks/form/form-field/constants.ts +7 -0
- package/src/blocks/form/form-field/edit.tsx +42 -16
- package/src/blocks/form/form-field/editor.scss +28 -0
- package/src/blocks/form/form-field/factory.tsx +1 -0
- package/src/blocks/form/form-field/normalizeOptions.ts +58 -0
- package/src/blocks/form/form-field/types.ts +6 -2
- package/src/blocks/layout/layout-aside/constants.ts +1 -0
- package/src/blocks/layout/layout-aside/edit.tsx +20 -0
- package/src/blocks/layout/layout-aside/editor.scss +9 -0
- package/src/blocks/layout/layout-aside/factory.tsx +24 -0
- package/src/blocks/layout/layout-aside/icon.tsx +12 -0
- package/src/blocks/layout/layout-aside/index.ts +9 -0
- package/src/blocks/layout/layout-aside/types.ts +5 -0
- package/src/blocks/layout/layout-content/constants.ts +1 -0
- package/src/blocks/layout/layout-content/edit.tsx +20 -0
- package/src/blocks/layout/layout-content/editor.scss +9 -0
- package/src/blocks/layout/layout-content/factory.tsx +24 -0
- package/src/blocks/layout/layout-content/icon.tsx +12 -0
- package/src/blocks/layout/layout-content/index.ts +9 -0
- package/src/blocks/layout/layout-content/types.ts +5 -0
- package/src/blocks/layout/layout-content-w-aside/constants.ts +7 -0
- package/src/blocks/layout/layout-content-w-aside/edit.tsx +52 -0
- package/src/blocks/layout/layout-content-w-aside/editor.scss +35 -0
- package/src/blocks/layout/layout-content-w-aside/factory.tsx +34 -0
- package/src/blocks/layout/layout-content-w-aside/icon.tsx +12 -0
- package/src/blocks/layout/layout-content-w-aside/index.ts +13 -0
- package/src/blocks/layout/layout-content-w-aside/types.ts +12 -0
- package/src/blocks/post/posts-grid/constants.ts +3 -0
- package/src/blocks/post/posts-grid/edit.tsx +105 -0
- package/src/blocks/post/posts-grid/factory.tsx +63 -0
- package/src/blocks/post/posts-grid/icon.tsx +8 -0
- package/src/blocks/post/posts-grid/index.ts +9 -0
- package/src/blocks/post/posts-grid/types.ts +25 -0
- package/src/blocks/sections/base-section/attributes.ts +4 -0
- package/src/blocks/sections/base-section/constants.ts +10 -0
- package/src/blocks/sections/base-section/controls.tsx +83 -4
- package/src/blocks/sections/base-section/types.ts +20 -1
- package/src/blocks/signpost/signpost-group/constants.ts +1 -1
- package/src/editor.scss +3 -0
- package/src/index.ts +8 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
RangeControl,
|
|
5
|
+
ToggleControl,
|
|
6
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
7
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
8
|
+
} from '@wordpress/components'
|
|
9
|
+
import {__} from '@wordpress/i18n'
|
|
10
|
+
import {POSTS_PER_PAGE_DEFAULT, POSTS_PER_PAGE_MAX, POSTS_PER_PAGE_MIN} from './constants'
|
|
11
|
+
import type {PostsGridAttributes, PostsGridOptions} from './types'
|
|
12
|
+
|
|
13
|
+
export function createPostsGridEdit(options: PostsGridOptions) {
|
|
14
|
+
return function Edit({
|
|
15
|
+
attributes,
|
|
16
|
+
setAttributes,
|
|
17
|
+
}: {
|
|
18
|
+
attributes: PostsGridAttributes
|
|
19
|
+
setAttributes: (a: Partial<PostsGridAttributes>) => void
|
|
20
|
+
}) {
|
|
21
|
+
const {mode, postsPerPage, selectedPosts, selectedCategories, showImage, showCategory, showDate, showExcerpt, showAuthor} = attributes
|
|
22
|
+
|
|
23
|
+
const blockProps = useBlockProps({className: 'wp-block-section'})
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<InspectorControls>
|
|
28
|
+
<PanelBody title={__('Nastavení výpisu', 'brilo-blocks')} initialOpen>
|
|
29
|
+
<ToggleGroupControl
|
|
30
|
+
label={__('Režim výběru', 'brilo-blocks')}
|
|
31
|
+
value={mode}
|
|
32
|
+
onChange={(value) => setAttributes({mode: value as PostsGridAttributes['mode']})}
|
|
33
|
+
isBlock
|
|
34
|
+
>
|
|
35
|
+
<ToggleGroupControlOption value="manual" label={__('Ruční výběr', 'brilo-blocks')} />
|
|
36
|
+
<ToggleGroupControlOption value="category" label={__('Dle kategorie', 'brilo-blocks')} />
|
|
37
|
+
<ToggleGroupControlOption value="latest" label={__('Nejnovější', 'brilo-blocks')} />
|
|
38
|
+
</ToggleGroupControl>
|
|
39
|
+
|
|
40
|
+
{mode !== 'manual' && (
|
|
41
|
+
<RangeControl
|
|
42
|
+
label={__('Počet příspěvků na stránku', 'brilo-blocks')}
|
|
43
|
+
value={postsPerPage}
|
|
44
|
+
onChange={(value) => setAttributes({postsPerPage: value ?? POSTS_PER_PAGE_DEFAULT})}
|
|
45
|
+
min={POSTS_PER_PAGE_MIN}
|
|
46
|
+
max={POSTS_PER_PAGE_MAX}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
</PanelBody>
|
|
50
|
+
|
|
51
|
+
<PanelBody title={__('Zobrazené údaje', 'brilo-blocks')} initialOpen={false}>
|
|
52
|
+
<ToggleControl
|
|
53
|
+
label={__('Zobrazit obrázek', 'brilo-blocks')}
|
|
54
|
+
checked={showImage}
|
|
55
|
+
onChange={(value) => setAttributes({showImage: value})}
|
|
56
|
+
/>
|
|
57
|
+
<ToggleControl
|
|
58
|
+
label={__('Zobrazit kategorii', 'brilo-blocks')}
|
|
59
|
+
checked={showCategory}
|
|
60
|
+
onChange={(value) => setAttributes({showCategory: value})}
|
|
61
|
+
/>
|
|
62
|
+
<ToggleControl
|
|
63
|
+
label={__('Zobrazit datum', 'brilo-blocks')}
|
|
64
|
+
checked={showDate}
|
|
65
|
+
onChange={(value) => setAttributes({showDate: value})}
|
|
66
|
+
/>
|
|
67
|
+
<ToggleControl
|
|
68
|
+
label={__('Zobrazit perex', 'brilo-blocks')}
|
|
69
|
+
checked={showExcerpt}
|
|
70
|
+
onChange={(value) => setAttributes({showExcerpt: value})}
|
|
71
|
+
/>
|
|
72
|
+
<ToggleControl
|
|
73
|
+
label={__('Zobrazit autora', 'brilo-blocks')}
|
|
74
|
+
checked={showAuthor}
|
|
75
|
+
onChange={(value) => setAttributes({showAuthor: value})}
|
|
76
|
+
/>
|
|
77
|
+
</PanelBody>
|
|
78
|
+
</InspectorControls>
|
|
79
|
+
|
|
80
|
+
<div {...blockProps}>
|
|
81
|
+
{mode === 'category' &&
|
|
82
|
+
options.renderCategoryControl?.({
|
|
83
|
+
selectedItems: selectedCategories,
|
|
84
|
+
onChange: (ids: number[]) => setAttributes({selectedCategories: ids}),
|
|
85
|
+
})}
|
|
86
|
+
|
|
87
|
+
{mode === 'manual' &&
|
|
88
|
+
options.renderPostsControl?.({
|
|
89
|
+
selectedItems: selectedPosts,
|
|
90
|
+
onChange: (ids: number[]) => setAttributes({selectedPosts: ids}),
|
|
91
|
+
})}
|
|
92
|
+
|
|
93
|
+
{mode === 'latest' && (
|
|
94
|
+
<div className="components-placeholder">
|
|
95
|
+
<div className="components-placeholder__label">{__('Posts Grid', 'brilo-blocks')}</div>
|
|
96
|
+
<div className="components-placeholder__instructions">
|
|
97
|
+
{`${__('Zobrazí', 'brilo-blocks')} ${postsPerPage} ${__('nejnovějších příspěvků.', 'brilo-blocks')}`}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {POSTS_PER_PAGE_DEFAULT} from './constants'
|
|
4
|
+
import {createPostsGridEdit} from './edit'
|
|
5
|
+
import {icon as defaultIcon} from './icon'
|
|
6
|
+
import type {PostsGridAttributes, PostsGridOptions} from './types'
|
|
7
|
+
|
|
8
|
+
export type {PostsGridAttributes, PostsGridOptions}
|
|
9
|
+
|
|
10
|
+
export function createPostsGridBlock(options: PostsGridOptions): BlockConfiguration<PostsGridAttributes> {
|
|
11
|
+
return {
|
|
12
|
+
name: options.name,
|
|
13
|
+
title: options.title ?? __('Posts Grid', '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: 'latest',
|
|
23
|
+
enum: ['manual', 'category', 'latest'],
|
|
24
|
+
},
|
|
25
|
+
postsPerPage: {
|
|
26
|
+
type: 'number',
|
|
27
|
+
default: POSTS_PER_PAGE_DEFAULT,
|
|
28
|
+
},
|
|
29
|
+
selectedPosts: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
default: [],
|
|
32
|
+
items: {type: 'number'},
|
|
33
|
+
},
|
|
34
|
+
selectedCategories: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
default: [],
|
|
37
|
+
items: {type: 'number'},
|
|
38
|
+
},
|
|
39
|
+
showImage: {
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
default: true,
|
|
42
|
+
},
|
|
43
|
+
showCategory: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
default: true,
|
|
46
|
+
},
|
|
47
|
+
showDate: {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
default: true,
|
|
50
|
+
},
|
|
51
|
+
showExcerpt: {
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
default: true,
|
|
54
|
+
},
|
|
55
|
+
showAuthor: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
default: true,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
edit: createPostsGridEdit(options),
|
|
61
|
+
save: () => null,
|
|
62
|
+
} as unknown as BlockConfiguration<PostsGridAttributes>
|
|
63
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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="1" width="8" height="8" stroke="black" fill="none" />
|
|
4
|
+
<rect x="11" y="1" width="8" height="8" stroke="black" fill="none" />
|
|
5
|
+
<rect x="1" y="11" width="8" height="8" stroke="black" fill="none" />
|
|
6
|
+
<rect x="11" y="11" width="8" height="8" stroke="black" fill="none" />
|
|
7
|
+
</svg>
|
|
8
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {PostsGridAttributes, PostsGridOptions} from './types'
|
|
2
|
+
export {createPostsGridBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {PostsGridOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const postsGridDefaults: PostsGridOptions = {
|
|
7
|
+
name: 'brilo/posts-grid-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {BriloBlockType} from '~/types'
|
|
2
|
+
|
|
3
|
+
export type PostsGridMode = 'manual' | 'category' | 'latest'
|
|
4
|
+
|
|
5
|
+
export interface PostsGridAttributes extends Record<string, unknown> {
|
|
6
|
+
mode: PostsGridMode
|
|
7
|
+
postsPerPage: number
|
|
8
|
+
selectedPosts: number[]
|
|
9
|
+
selectedCategories: number[]
|
|
10
|
+
showImage: boolean
|
|
11
|
+
showCategory: boolean
|
|
12
|
+
showDate: boolean
|
|
13
|
+
showExcerpt: boolean
|
|
14
|
+
showAuthor: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SelectControlProps {
|
|
18
|
+
selectedItems: number[]
|
|
19
|
+
onChange: (ids: number[]) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PostsGridOptions extends BriloBlockType {
|
|
23
|
+
renderCategoryControl?: (props: SelectControlProps) => JSX.Element
|
|
24
|
+
renderPostsControl?: (props: SelectControlProps) => JSX.Element
|
|
25
|
+
}
|
|
@@ -8,3 +8,13 @@ export const SPACING_POSITIONS = [
|
|
|
8
8
|
] as const
|
|
9
9
|
|
|
10
10
|
export const SPACING_SIZES = ['default', 'sm', 'xs'] as const
|
|
11
|
+
|
|
12
|
+
export const FLUID_DECORATION_HEIGHT_PRESETS = [32, 56, 88, 128] as const
|
|
13
|
+
|
|
14
|
+
export const FLUID_DECORATION_DEFAULT_HEIGHT = '56px'
|
|
15
|
+
|
|
16
|
+
export const FLUID_DECORATION_UNITS = [
|
|
17
|
+
{value: 'px', label: 'px', default: 56},
|
|
18
|
+
{value: 'rem', label: 'rem', default: 3.5},
|
|
19
|
+
{value: '%', label: '%', default: 10},
|
|
20
|
+
]
|
|
@@ -1,15 +1,81 @@
|
|
|
1
|
-
import {ColorPalette, ContrastChecker} from '@wordpress/block-editor'
|
|
1
|
+
import {ColorPalette, ContrastChecker, MediaUpload, MediaUploadCheck} from '@wordpress/block-editor'
|
|
2
2
|
import {
|
|
3
|
+
BaseControl,
|
|
4
|
+
Button,
|
|
5
|
+
ButtonGroup,
|
|
3
6
|
PanelBody,
|
|
7
|
+
PanelRow,
|
|
4
8
|
SelectControl,
|
|
5
9
|
TextControl,
|
|
6
10
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
7
11
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
12
|
+
__experimentalUnitControl as UnitControl,
|
|
8
13
|
} from '@wordpress/components'
|
|
9
14
|
import {__} from '@wordpress/i18n'
|
|
10
15
|
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
11
|
-
import type {BaseBlockAttributes, ExcludableBaseAttr} from './types'
|
|
12
|
-
import {SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
16
|
+
import type {BaseBlockAttributes, ExcludableBaseAttr, FluidDecoration, FluidDecorationImage} from './types'
|
|
17
|
+
import {FLUID_DECORATION_DEFAULT_HEIGHT, FLUID_DECORATION_HEIGHT_PRESETS, FLUID_DECORATION_UNITS, SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
18
|
+
|
|
19
|
+
interface FluidDecorationControlProps {
|
|
20
|
+
label: string
|
|
21
|
+
value?: FluidDecoration
|
|
22
|
+
onChange: (value: FluidDecoration | undefined) => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function FluidDecorationControl({label, value, onChange}: FluidDecorationControlProps) {
|
|
26
|
+
const img = value?.img
|
|
27
|
+
const height = value?.height ?? FLUID_DECORATION_DEFAULT_HEIGHT
|
|
28
|
+
|
|
29
|
+
const handleSelect = (media: {id: number; url: string; alt: string; width?: number; height?: number}) => {
|
|
30
|
+
const nextImg: FluidDecorationImage = {id: media.id, src: media.url, alt: media.alt ?? '', width: media.width, height: media.height}
|
|
31
|
+
onChange({img: nextImg, height})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const handleRemove = () => onChange(undefined)
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<BaseControl label={label} __nextHasNoMarginBottom>
|
|
38
|
+
<MediaUploadCheck>
|
|
39
|
+
<MediaUpload
|
|
40
|
+
onSelect={handleSelect}
|
|
41
|
+
allowedTypes={['image']}
|
|
42
|
+
value={img?.id || 0}
|
|
43
|
+
render={({open}: {open: () => void}) => (
|
|
44
|
+
<PanelRow>
|
|
45
|
+
{img?.src && <img src={img.src} alt={img.alt} style={{maxWidth: 48, maxHeight: 48, objectFit: 'contain'}} />}
|
|
46
|
+
<Button onClick={open} variant="secondary" size="small">
|
|
47
|
+
{img?.src ? __('Změnit', 'brilo-blocks') : __('Vybrat obrázek', 'brilo-blocks')}
|
|
48
|
+
</Button>
|
|
49
|
+
{!!img?.src && (
|
|
50
|
+
<Button onClick={handleRemove} variant="tertiary" size="small" isDestructive>
|
|
51
|
+
{__('Odebrat', 'brilo-blocks')}
|
|
52
|
+
</Button>
|
|
53
|
+
)}
|
|
54
|
+
</PanelRow>
|
|
55
|
+
)}
|
|
56
|
+
/>
|
|
57
|
+
</MediaUploadCheck>
|
|
58
|
+
|
|
59
|
+
{!!img?.src && (
|
|
60
|
+
<>
|
|
61
|
+
<UnitControl
|
|
62
|
+
label={__('Výška', 'brilo-blocks')}
|
|
63
|
+
value={height}
|
|
64
|
+
units={FLUID_DECORATION_UNITS}
|
|
65
|
+
onChange={(next) => onChange({img, height: (next as string) ?? FLUID_DECORATION_DEFAULT_HEIGHT})}
|
|
66
|
+
/>
|
|
67
|
+
<ButtonGroup>
|
|
68
|
+
{FLUID_DECORATION_HEIGHT_PRESETS.map((preset) => (
|
|
69
|
+
<Button key={preset} variant="secondary" size="small" onClick={() => onChange({img, height: `${preset}px`})}>
|
|
70
|
+
{preset}
|
|
71
|
+
</Button>
|
|
72
|
+
))}
|
|
73
|
+
</ButtonGroup>
|
|
74
|
+
</>
|
|
75
|
+
)}
|
|
76
|
+
</BaseControl>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
13
79
|
|
|
14
80
|
type SpacingPosition = BaseBlockAttributes['spacing']['position']
|
|
15
81
|
type SpacingSize = BaseBlockAttributes['spacing']['size']
|
|
@@ -21,8 +87,14 @@ interface BaseControlsProps {
|
|
|
21
87
|
}
|
|
22
88
|
|
|
23
89
|
export function BaseControls({attributes, setAttributes, exclude}: BaseControlsProps) {
|
|
24
|
-
const {id, spacing, background, textColor} = attributes
|
|
90
|
+
const {id, spacing, background, textColor, decorations} = attributes
|
|
25
91
|
const {paletteColors, resolveHex} = useTenantColorPalette()
|
|
92
|
+
const fluid = decorations?.fluid ?? {}
|
|
93
|
+
|
|
94
|
+
const setFluid = (position: 'top' | 'bottom', value: FluidDecoration | undefined) => {
|
|
95
|
+
const nextFluid = {...fluid, [position]: value}
|
|
96
|
+
setAttributes({decorations: {...decorations, fluid: nextFluid}})
|
|
97
|
+
}
|
|
26
98
|
|
|
27
99
|
return (
|
|
28
100
|
<>
|
|
@@ -65,6 +137,13 @@ export function BaseControls({attributes, setAttributes, exclude}: BaseControlsP
|
|
|
65
137
|
</PanelBody>
|
|
66
138
|
)}
|
|
67
139
|
|
|
140
|
+
{!exclude.includes('decorations') && (
|
|
141
|
+
<PanelBody title={__('Fluidní dekorace', 'brilo-blocks')} initialOpen={false}>
|
|
142
|
+
<FluidDecorationControl label={__('Nahoře', 'brilo-blocks')} value={fluid.top} onChange={(value) => setFluid('top', value)} />
|
|
143
|
+
<FluidDecorationControl label={__('Dole', 'brilo-blocks')} value={fluid.bottom} onChange={(value) => setFluid('bottom', value)} />
|
|
144
|
+
</PanelBody>
|
|
145
|
+
)}
|
|
146
|
+
|
|
68
147
|
{!exclude.includes('id') && (
|
|
69
148
|
<PanelBody title={__('Kotva', 'brilo-blocks')} initialOpen={false}>
|
|
70
149
|
<TextControl
|
|
@@ -2,6 +2,19 @@ import type {BlockConfiguration, BlockEditProps} from '@wordpress/blocks'
|
|
|
2
2
|
import type {ReactNode} from 'react'
|
|
3
3
|
import type {BriloBlockType} from '~/types'
|
|
4
4
|
|
|
5
|
+
export interface FluidDecorationImage {
|
|
6
|
+
id: number
|
|
7
|
+
src: string
|
|
8
|
+
alt: string
|
|
9
|
+
width?: number
|
|
10
|
+
height?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FluidDecoration {
|
|
14
|
+
img?: FluidDecorationImage
|
|
15
|
+
height: string
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
6
19
|
id: string
|
|
7
20
|
spacing: {
|
|
@@ -10,9 +23,15 @@ export interface BaseBlockAttributes extends Record<string, unknown> {
|
|
|
10
23
|
}
|
|
11
24
|
background: string
|
|
12
25
|
textColor: string
|
|
26
|
+
decorations: {
|
|
27
|
+
fluid?: {
|
|
28
|
+
top?: FluidDecoration
|
|
29
|
+
bottom?: FluidDecoration
|
|
30
|
+
}
|
|
31
|
+
}
|
|
13
32
|
}
|
|
14
33
|
|
|
15
|
-
export type ExcludableBaseAttr = 'spacing' | 'background' | 'id'
|
|
34
|
+
export type ExcludableBaseAttr = 'spacing' | 'background' | 'id' | 'decorations'
|
|
16
35
|
|
|
17
36
|
export interface BaseSectionOptions<TExtra extends Record<string, unknown> = Record<string, never>> extends BriloBlockType {
|
|
18
37
|
supports?: BlockConfiguration['supports']
|
package/src/editor.scss
CHANGED
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
@forward "./blocks/person/person-group/editor";
|
|
36
36
|
@forward "./blocks/person/person-item/editor";
|
|
37
37
|
@forward "./blocks/responsive-grid/responsive-grid-item/editor";
|
|
38
|
+
@forward "./blocks/layout/layout-aside/editor";
|
|
39
|
+
@forward "./blocks/layout/layout-content/editor";
|
|
40
|
+
@forward "./blocks/layout/layout-content-w-aside/editor";
|
|
38
41
|
@forward "./components/IconControl/editor";
|
|
39
42
|
@forward "./components/ImagePicker/editor";
|
|
40
43
|
@forward "./components/ItemIconControl/editor";
|
package/src/index.ts
CHANGED
|
@@ -132,5 +132,13 @@ export type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './bl
|
|
|
132
132
|
export {createResponsiveGridItemBlock, responsiveGridItemDefaults} from './blocks/responsive-grid/responsive-grid-item'
|
|
133
133
|
export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './blocks/post/post-slider-group'
|
|
134
134
|
export {createPostSliderGroupBlock, postSliderGroupDefaults} from './blocks/post/post-slider-group'
|
|
135
|
+
export type {PostsGridAttributes, PostsGridOptions} from './blocks/post/posts-grid'
|
|
136
|
+
export {createPostsGridBlock, postsGridDefaults} from './blocks/post/posts-grid'
|
|
135
137
|
export type {LinkItemAttributes, LinkItemIcon, LinkItemOptions} from './blocks/link/link-item'
|
|
136
138
|
export {createLinkItemBlock, linkItemDefaults} from './blocks/link/link-item'
|
|
139
|
+
export type {ContentWithAsideAttributes, ContentWithAsideOptions} from './blocks/layout/layout-content-w-aside'
|
|
140
|
+
export {createContentWithAsideBlock, contentWithAsideDefaults} from './blocks/layout/layout-content-w-aside'
|
|
141
|
+
export type {ContentAttributes, ContentOptions} from './blocks/layout/layout-content'
|
|
142
|
+
export {createContentBlock, contentDefaults} from './blocks/layout/layout-content'
|
|
143
|
+
export type {AsideAttributes, AsideOptions} from './blocks/layout/layout-aside'
|
|
144
|
+
export {createAsideBlock, asideDefaults} from './blocks/layout/layout-aside'
|