@brilo/base-blocks 0.1.22 → 0.1.24
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/anchor/anchor-group/constants.d.ts +24 -0
- package/build/blocks/anchor/anchor-group/constants.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-group/constants.js +12 -0
- package/build/blocks/anchor/anchor-group/edit.d.ts +6 -0
- package/build/blocks/anchor/anchor-group/edit.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-group/edit.js +28 -0
- package/build/blocks/anchor/anchor-group/factory.d.ts +7 -0
- package/build/blocks/anchor/anchor-group/factory.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-group/factory.js +33 -0
- package/build/blocks/anchor/anchor-group/index.d.ts +6 -0
- package/build/blocks/anchor/anchor-group/index.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-group/index.js +7 -0
- package/build/blocks/anchor/anchor-group/types.d.ts +13 -0
- package/build/blocks/anchor/anchor-group/types.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-group/types.js +1 -0
- package/build/blocks/anchor/anchor-item/constants.d.ts +13 -0
- package/build/blocks/anchor/anchor-item/constants.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-item/constants.js +7 -0
- package/build/blocks/anchor/anchor-item/edit.d.ts +6 -0
- package/build/blocks/anchor/anchor-item/edit.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-item/edit.js +24 -0
- package/build/blocks/anchor/anchor-item/factory.d.ts +5 -0
- package/build/blocks/anchor/anchor-item/factory.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-item/factory.js +25 -0
- package/build/blocks/anchor/anchor-item/index.d.ts +7 -0
- package/build/blocks/anchor/anchor-item/index.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-item/index.js +9 -0
- package/build/blocks/anchor/anchor-item/types.d.ts +18 -0
- package/build/blocks/anchor/anchor-item/types.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-item/types.js +1 -0
- 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/index.d.ts +12 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -0
- package/package.json +1 -1
- package/src/blocks/anchor/anchor-group/constants.ts +14 -0
- package/src/blocks/anchor/anchor-group/edit.tsx +70 -0
- package/src/blocks/anchor/anchor-group/editor.scss +52 -0
- package/src/blocks/anchor/anchor-group/factory.tsx +43 -0
- package/src/blocks/anchor/anchor-group/index.ts +11 -0
- package/src/blocks/anchor/anchor-group/types.ts +19 -0
- package/src/blocks/anchor/anchor-item/constants.ts +10 -0
- package/src/blocks/anchor/anchor-item/edit.tsx +96 -0
- package/src/blocks/anchor/anchor-item/editor.scss +22 -0
- package/src/blocks/anchor/anchor-item/factory.tsx +29 -0
- package/src/blocks/anchor/anchor-item/index.ts +13 -0
- package/src/blocks/anchor/anchor-item/types.ts +16 -0
- 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/editor.scss +5 -0
- package/src/index.ts +19 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.l-content-w-aside {
|
|
3
|
+
padding: 16px;
|
|
4
|
+
border: 2px dashed #0073aa;
|
|
5
|
+
flex-shrink: 0;
|
|
6
|
+
|
|
7
|
+
&__container {
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: 16px;
|
|
10
|
+
|
|
11
|
+
&.--aside-small {
|
|
12
|
+
--aside-width: 15%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.--aside-medium {
|
|
16
|
+
--aside-width: 25%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.--aside-large {
|
|
20
|
+
--aside-width: 35%;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&::before {
|
|
25
|
+
content: "Obsah s postranním panelem";
|
|
26
|
+
display: block;
|
|
27
|
+
font-size: 10px;
|
|
28
|
+
font-weight: 600;
|
|
29
|
+
text-transform: uppercase;
|
|
30
|
+
color: #0073aa;
|
|
31
|
+
letter-spacing: 0.5px;
|
|
32
|
+
margin-bottom: 8px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -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 React from 'react'
|
|
5
|
+
import type {OptionArray} from '~/types'
|
|
6
|
+
import {ASIDE_SIZES} from './constants'
|
|
7
|
+
import {createContentWithAsideEdit} from './edit'
|
|
8
|
+
import {icon as defaultIcon} from './icon'
|
|
9
|
+
import type {ContentWithAsideAttributes, ContentWithAsideOptions} from './types'
|
|
10
|
+
|
|
11
|
+
export function createContentWithAsideBlock<
|
|
12
|
+
TAsideSizes extends OptionArray = typeof ASIDE_SIZES,
|
|
13
|
+
>(
|
|
14
|
+
options: ContentWithAsideOptions<TAsideSizes>,
|
|
15
|
+
): BlockConfiguration<ContentWithAsideAttributes<TAsideSizes[number]['value']>> {
|
|
16
|
+
const asideSizes = options.asideSizes ?? ASIDE_SIZES
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
name: options.name,
|
|
20
|
+
title: options.title ?? __('Obsah s postranním panelem', 'brilo-blocks'),
|
|
21
|
+
description: options.description,
|
|
22
|
+
category: options.category ?? 'layout',
|
|
23
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
24
|
+
supports: {html: false, customClassName: false},
|
|
25
|
+
attributes: {
|
|
26
|
+
asideSize: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
default: asideSizes[1].value, // medium
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
edit: createContentWithAsideEdit(options as unknown as ContentWithAsideOptions),
|
|
32
|
+
save: () => <InnerBlocks.Content />,
|
|
33
|
+
} as unknown as BlockConfiguration<ContentWithAsideAttributes<TAsideSizes[number]['value']>>
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const icon = (
|
|
4
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5
|
+
<path
|
|
6
|
+
fillRule="evenodd"
|
|
7
|
+
clipRule="evenodd"
|
|
8
|
+
d="M4 4H20V20H4V4ZM6 6H13V18H6V6ZM15 6H18V18H15V6Z"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
/>
|
|
11
|
+
</svg>
|
|
12
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {ContentWithAsideAttributes, ContentWithAsideOptions} from './types'
|
|
2
|
+
export {createContentWithAsideBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {ContentWithAsideOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const contentWithAsideDefaults: ContentWithAsideOptions = {
|
|
7
|
+
name: 'brilo/layout-content-w-aside',
|
|
8
|
+
allowedBlocks: ['brilo/layout-content', 'brilo/layout-aside'],
|
|
9
|
+
template: [
|
|
10
|
+
['brilo/layout-content', {}],
|
|
11
|
+
['brilo/layout-aside', {}],
|
|
12
|
+
],
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {BriloBlockType, OptionArray} from '~/types'
|
|
2
|
+
import type {ASIDE_SIZES} from './constants'
|
|
3
|
+
|
|
4
|
+
export type AsideSize = (typeof ASIDE_SIZES)[number]['value']
|
|
5
|
+
|
|
6
|
+
export interface ContentWithAsideAttributes<TAsideSize extends string = AsideSize> extends Record<string, unknown> {
|
|
7
|
+
asideSize: TAsideSize
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ContentWithAsideOptions<TAsideSizes extends OptionArray = typeof ASIDE_SIZES> extends BriloBlockType {
|
|
11
|
+
asideSizes?: TAsideSizes
|
|
12
|
+
}
|
|
@@ -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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
@forward "./globals";
|
|
2
|
+
@forward "./blocks/anchor/anchor-group/editor";
|
|
3
|
+
@forward "./blocks/anchor/anchor-item/editor";
|
|
2
4
|
@forward "./blocks/column/column-group/editor";
|
|
3
5
|
@forward "./blocks/link/link-item/editor";
|
|
4
6
|
@forward "./blocks/column/column-item/editor";
|
|
@@ -35,6 +37,9 @@
|
|
|
35
37
|
@forward "./blocks/person/person-group/editor";
|
|
36
38
|
@forward "./blocks/person/person-item/editor";
|
|
37
39
|
@forward "./blocks/responsive-grid/responsive-grid-item/editor";
|
|
40
|
+
@forward "./blocks/layout/layout-aside/editor";
|
|
41
|
+
@forward "./blocks/layout/layout-content/editor";
|
|
42
|
+
@forward "./blocks/layout/layout-content-w-aside/editor";
|
|
38
43
|
@forward "./components/IconControl/editor";
|
|
39
44
|
@forward "./components/ImagePicker/editor";
|
|
40
45
|
@forward "./components/ItemIconControl/editor";
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export type {AnchorAlignment, AnchorColumns, AnchorGroupAttributes, AnchorGroupOptions} from './blocks/anchor/anchor-group'
|
|
2
|
+
export {ANCHOR_ALIGNMENTS, ANCHOR_COLUMNS, anchorGroupDefaults, createAnchorGroupBlock} from './blocks/anchor/anchor-group'
|
|
3
|
+
export type {AnchorItemAttributes, AnchorItemOptions} from './blocks/anchor/anchor-item'
|
|
4
|
+
export {
|
|
5
|
+
ANCHOR_ICON_SIZE_DEFAULT,
|
|
6
|
+
ANCHOR_ICON_SIZE_RANGE,
|
|
7
|
+
ANCHOR_ICON_TYPES,
|
|
8
|
+
anchorItemDefaults,
|
|
9
|
+
createAnchorItemBlock,
|
|
10
|
+
createAnchorItemEdit,
|
|
11
|
+
} from './blocks/anchor/anchor-item'
|
|
1
12
|
export type {
|
|
2
13
|
ContactColumns,
|
|
3
14
|
ContactGroupAttributes,
|
|
@@ -132,5 +143,13 @@ export type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './bl
|
|
|
132
143
|
export {createResponsiveGridItemBlock, responsiveGridItemDefaults} from './blocks/responsive-grid/responsive-grid-item'
|
|
133
144
|
export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './blocks/post/post-slider-group'
|
|
134
145
|
export {createPostSliderGroupBlock, postSliderGroupDefaults} from './blocks/post/post-slider-group'
|
|
146
|
+
export type {PostsGridAttributes, PostsGridOptions} from './blocks/post/posts-grid'
|
|
147
|
+
export {createPostsGridBlock, postsGridDefaults} from './blocks/post/posts-grid'
|
|
135
148
|
export type {LinkItemAttributes, LinkItemIcon, LinkItemOptions} from './blocks/link/link-item'
|
|
136
149
|
export {createLinkItemBlock, linkItemDefaults} from './blocks/link/link-item'
|
|
150
|
+
export type {ContentWithAsideAttributes, ContentWithAsideOptions} from './blocks/layout/layout-content-w-aside'
|
|
151
|
+
export {createContentWithAsideBlock, contentWithAsideDefaults} from './blocks/layout/layout-content-w-aside'
|
|
152
|
+
export type {ContentAttributes, ContentOptions} from './blocks/layout/layout-content'
|
|
153
|
+
export {createContentBlock, contentDefaults} from './blocks/layout/layout-content'
|
|
154
|
+
export type {AsideAttributes, AsideOptions} from './blocks/layout/layout-aside'
|
|
155
|
+
export {createAsideBlock, asideDefaults} from './blocks/layout/layout-aside'
|