@brilo/base-blocks 0.1.7 → 0.1.8
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/groups/content-group/factory.d.ts +2 -2
- package/build/blocks/groups/content-group/factory.d.ts.map +1 -1
- package/build/blocks/groups/content-group/factory.js +8 -8
- package/build/blocks/groups/content-group/icon.d.ts.map +1 -1
- package/build/blocks/link/link-item/constants.d.ts +11 -0
- package/build/blocks/link/link-item/constants.d.ts.map +1 -0
- package/build/blocks/link/link-item/constants.js +6 -0
- package/build/blocks/link/link-item/edit.d.ts +6 -0
- package/build/blocks/link/link-item/edit.d.ts.map +1 -0
- package/build/blocks/link/link-item/edit.js +25 -0
- package/build/blocks/link/link-item/factory.d.ts +4 -0
- package/build/blocks/link/link-item/factory.d.ts.map +1 -0
- package/build/blocks/link/link-item/factory.js +27 -0
- package/build/blocks/link/link-item/icon.d.ts +2 -0
- package/build/blocks/link/link-item/icon.d.ts.map +1 -0
- package/build/blocks/link/link-item/icon.js +2 -0
- package/build/blocks/link/link-item/index.d.ts +5 -0
- package/build/blocks/link/link-item/index.d.ts.map +1 -0
- package/build/blocks/link/link-item/index.js +6 -0
- package/build/blocks/link/link-item/types.d.ts +25 -0
- package/build/blocks/link/link-item/types.d.ts.map +1 -0
- package/build/blocks/link/link-item/types.js +1 -0
- package/build/blocks/map/map-group/constants.d.ts +1 -0
- package/build/blocks/map/map-group/constants.d.ts.map +1 -1
- package/build/blocks/map/map-group/constants.js +2 -0
- package/build/blocks/map/map-group/edit.d.ts.map +1 -1
- package/build/blocks/map/map-group/edit.js +19 -11
- package/build/blocks/map/map-group/factory.d.ts +3 -1
- package/build/blocks/map/map-group/factory.d.ts.map +1 -1
- package/build/blocks/map/map-group/factory.js +24 -5
- package/build/blocks/map/map-group/index.d.ts.map +1 -1
- package/build/blocks/map/map-group/index.js +1 -0
- package/build/blocks/map/map-group/types.d.ts +18 -4
- package/build/blocks/map/map-group/types.d.ts.map +1 -1
- package/build/blocks/sections/base-section/attributes.d.ts +5 -1
- package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
- package/build/blocks/sections/base-section/attributes.js +5 -1
- package/build/blocks/sections/base-section/constants.d.ts +0 -16
- package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.js +0 -7
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/controls.js +6 -3
- package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
- package/build/blocks/sections/base-section/edit.js +8 -1
- package/build/blocks/sections/base-section/factory.d.ts.map +1 -1
- package/build/blocks/sections/base-section/factory.js +3 -8
- package/build/blocks/sections/base-section/index.d.ts +1 -1
- package/build/blocks/sections/base-section/index.d.ts.map +1 -1
- package/build/blocks/sections/base-section/index.js +1 -1
- package/build/blocks/sections/base-section/types.d.ts +1 -0
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/build/hooks/useTenantColorPalette.d.ts +9 -0
- package/build/hooks/useTenantColorPalette.d.ts.map +1 -0
- package/build/hooks/useTenantColorPalette.js +12 -0
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/package.json +2 -1
- package/src/blocks/groups/content-group/factory.tsx +11 -11
- package/src/blocks/groups/content-group/icon.tsx +1 -1
- package/src/blocks/link/link-item/constants.ts +7 -0
- package/src/blocks/link/link-item/edit.tsx +116 -0
- package/src/blocks/link/link-item/editor.scss +11 -0
- package/src/blocks/link/link-item/factory.tsx +29 -0
- package/src/blocks/link/link-item/icon.tsx +6 -0
- package/src/blocks/link/link-item/index.ts +10 -0
- package/src/blocks/link/link-item/types.ts +24 -0
- package/src/blocks/map/map-group/constants.ts +3 -0
- package/src/blocks/map/map-group/edit.tsx +74 -8
- package/src/blocks/map/map-group/editor.scss +7 -0
- package/src/blocks/map/map-group/factory.tsx +26 -4
- package/src/blocks/map/map-group/index.ts +1 -0
- package/src/blocks/map/map-group/types.ts +18 -4
- package/src/blocks/responsive-grid/responsive-grid-item/editor.scss +9 -0
- package/src/blocks/sections/base-section/attributes.ts +5 -1
- package/src/blocks/sections/base-section/constants.ts +0 -8
- package/src/blocks/sections/base-section/controls.tsx +18 -8
- package/src/blocks/sections/base-section/edit.tsx +8 -1
- package/src/blocks/sections/base-section/factory.tsx +3 -7
- package/src/blocks/sections/base-section/index.ts +1 -1
- package/src/blocks/sections/base-section/types.ts +1 -0
- package/src/editor.scss +2 -0
- package/src/hooks/useTenantColorPalette.ts +21 -0
- package/src/index.ts +2 -1
|
@@ -8,11 +8,3 @@ 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 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
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {ColorPalette, ContrastChecker} from '@wordpress/block-editor'
|
|
1
2
|
import {
|
|
2
3
|
PanelBody,
|
|
3
4
|
SelectControl,
|
|
@@ -6,8 +7,9 @@ import {
|
|
|
6
7
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
8
|
} from '@wordpress/components'
|
|
8
9
|
import {__} from '@wordpress/i18n'
|
|
10
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
9
11
|
import type {BaseBlockAttributes, ExcludableBaseAttr} from './types'
|
|
10
|
-
import {
|
|
12
|
+
import {SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
11
13
|
|
|
12
14
|
type SpacingPosition = BaseBlockAttributes['spacing']['position']
|
|
13
15
|
type SpacingSize = BaseBlockAttributes['spacing']['size']
|
|
@@ -19,7 +21,8 @@ interface BaseControlsProps {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export function BaseControls({attributes, setAttributes, exclude}: BaseControlsProps) {
|
|
22
|
-
const {id, spacing, background} = attributes
|
|
24
|
+
const {id, spacing, background, textColor} = attributes
|
|
25
|
+
const {paletteColors, resolveHex} = useTenantColorPalette()
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<>
|
|
@@ -45,13 +48,20 @@ export function BaseControls({attributes, setAttributes, exclude}: BaseControlsP
|
|
|
45
48
|
)}
|
|
46
49
|
|
|
47
50
|
{!exclude.includes('background') && (
|
|
48
|
-
<PanelBody title={__('
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onChange={(value) => setAttributes({background: value})}
|
|
51
|
+
<PanelBody title={__('Barvy', 'brilo-blocks')}>
|
|
52
|
+
<p>{__('Pozadí', 'brilo-blocks')}</p>
|
|
53
|
+
<ColorPalette
|
|
54
|
+
colors={paletteColors}
|
|
55
|
+
value={background || undefined}
|
|
56
|
+
onChange={(value) => setAttributes({background: value ?? ''})}
|
|
57
|
+
/>
|
|
58
|
+
<p>{__('Barva textu', 'brilo-blocks')}</p>
|
|
59
|
+
<ColorPalette
|
|
60
|
+
colors={paletteColors}
|
|
61
|
+
value={textColor || undefined}
|
|
62
|
+
onChange={(value) => setAttributes({textColor: value ?? ''})}
|
|
54
63
|
/>
|
|
64
|
+
{!!background && !!textColor && <ContrastChecker backgroundColor={resolveHex(background)} textColor={resolveHex(textColor)} />}
|
|
55
65
|
</PanelBody>
|
|
56
66
|
)}
|
|
57
67
|
|
|
@@ -8,7 +8,14 @@ export function createBaseSectionEdit<TExtra extends Record<string, unknown> = R
|
|
|
8
8
|
|
|
9
9
|
return function Edit(props: BlockEditProps<BaseBlockAttributes & TExtra>) {
|
|
10
10
|
const {attributes, setAttributes} = props
|
|
11
|
-
const
|
|
11
|
+
const {background, textColor} = attributes as BaseBlockAttributes
|
|
12
|
+
const blockProps = useBlockProps({
|
|
13
|
+
className: options.blockClassName,
|
|
14
|
+
style: {
|
|
15
|
+
...(background ? {backgroundColor: background, padding: '16px'} : {}),
|
|
16
|
+
...(textColor ? {color: textColor} : {}),
|
|
17
|
+
},
|
|
18
|
+
})
|
|
12
19
|
const innerBlocksProps = useInnerBlocksProps({className: options.containerClassName}, {
|
|
13
20
|
allowedBlocks: options.allowedBlocks,
|
|
14
21
|
orientation: 'vertical',
|
|
@@ -2,7 +2,6 @@ import {InnerBlocks} from '@wordpress/block-editor'
|
|
|
2
2
|
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
3
|
import {__} from '@wordpress/i18n'
|
|
4
4
|
import {baseAttributes} from './attributes'
|
|
5
|
-
import {BACKGROUNDS} from './constants'
|
|
6
5
|
import {createBaseSectionEdit} from './edit'
|
|
7
6
|
import {icon as defaultIcon} from './icon'
|
|
8
7
|
import type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './types'
|
|
@@ -16,12 +15,9 @@ export function createBaseSectionBlock<TExtra extends Record<string, unknown> =
|
|
|
16
15
|
|
|
17
16
|
const attributes: Record<string, unknown> = {}
|
|
18
17
|
for (const [key, value] of Object.entries(baseAttributes)) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
attributes[key] = value
|
|
24
|
-
}
|
|
18
|
+
const excludeKey: ExcludableBaseAttr = key === 'textColor' ? 'background' : (key as ExcludableBaseAttr)
|
|
19
|
+
if (!exclude.includes(excludeKey)) {
|
|
20
|
+
attributes[key] = value
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './types'
|
|
2
2
|
export {baseAttributes} from './attributes'
|
|
3
|
-
export {
|
|
3
|
+
export {SPACING_POSITIONS, SPACING_SIZES} from './constants'
|
|
4
4
|
export {createBaseSectionEdit} from './edit'
|
|
5
5
|
export {createBaseSectionBlock} from './factory'
|
|
6
6
|
|
package/src/editor.scss
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@forward "./globals";
|
|
2
2
|
@forward "./blocks/column/column-group/editor";
|
|
3
|
+
@forward "./blocks/link/link-item/editor";
|
|
3
4
|
@forward "./blocks/column/column-item/editor";
|
|
4
5
|
@forward "./blocks/compare/compare-item/editor";
|
|
5
6
|
@forward "./blocks/compare/compare-option/editor";
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
@forward "./blocks/text-and-form/text-and-form-text-column/editor";
|
|
30
31
|
@forward "./blocks/usp/usp-group/editor";
|
|
31
32
|
@forward "./blocks/usp/usp-item/editor";
|
|
33
|
+
@forward "./blocks/responsive-grid/responsive-grid-item/editor";
|
|
32
34
|
@forward "./components/IconControl/editor";
|
|
33
35
|
@forward "./components/ImagePicker/editor";
|
|
34
36
|
@forward "./components/ItemIconControl/editor";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {useSettings} from '@wordpress/block-editor'
|
|
2
|
+
import {useMemo} from '@wordpress/element'
|
|
3
|
+
|
|
4
|
+
interface PaletteColor {
|
|
5
|
+
name: string
|
|
6
|
+
slug: string
|
|
7
|
+
color: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useTenantColorPalette() {
|
|
11
|
+
const [rawColors] = useSettings('color.palette')
|
|
12
|
+
const colors = (rawColors ?? []) as PaletteColor[]
|
|
13
|
+
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
const paletteColors = colors.map((c) => ({...c, color: `var(--${c.slug})`}))
|
|
16
|
+
const hexByValue = new Map(colors.map((c) => [`var(--${c.slug})`, c.color]))
|
|
17
|
+
const resolveHex = (value: string) => hexByValue.get(value) ?? value
|
|
18
|
+
|
|
19
|
+
return {paletteColors, resolveHex}
|
|
20
|
+
}, [colors])
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -82,7 +82,6 @@ export type {ColumnItemAttributes, ColumnItemOptions} from './blocks/column/colu
|
|
|
82
82
|
export {createColumnItemBlock, columnItemDefaults} from './blocks/column/column-item'
|
|
83
83
|
export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './blocks/sections/base-section'
|
|
84
84
|
export {
|
|
85
|
-
BACKGROUNDS,
|
|
86
85
|
baseAttributes,
|
|
87
86
|
baseSectionDefaults,
|
|
88
87
|
createBaseSectionBlock,
|
|
@@ -122,3 +121,5 @@ export type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './bl
|
|
|
122
121
|
export {createResponsiveGridItemBlock, responsiveGridItemDefaults} from './blocks/responsive-grid/responsive-grid-item'
|
|
123
122
|
export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './blocks/post/post-slider-group'
|
|
124
123
|
export {createPostSliderGroupBlock, postSliderGroupDefaults} from './blocks/post/post-slider-group'
|
|
124
|
+
export type {LinkItemAttributes, LinkItemIcon, LinkItemOptions} from './blocks/link/link-item'
|
|
125
|
+
export {createLinkItemBlock, linkItemDefaults} from './blocks/link/link-item'
|