@brilo/base-blocks 0.1.6 → 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.
Files changed (103) hide show
  1. package/build/blocks/groups/content-group/constants.d.ts +2 -0
  2. package/build/blocks/groups/content-group/constants.d.ts.map +1 -0
  3. package/build/blocks/groups/content-group/constants.js +1 -0
  4. package/build/blocks/groups/content-group/edit.d.ts +6 -0
  5. package/build/blocks/groups/content-group/edit.d.ts.map +1 -0
  6. package/build/blocks/groups/content-group/edit.js +20 -0
  7. package/build/blocks/groups/content-group/factory.d.ts +4 -0
  8. package/build/blocks/groups/content-group/factory.d.ts.map +1 -0
  9. package/build/blocks/groups/content-group/factory.js +25 -0
  10. package/build/blocks/groups/content-group/icon.d.ts +2 -0
  11. package/build/blocks/groups/content-group/icon.d.ts.map +1 -0
  12. package/build/blocks/groups/content-group/icon.js +2 -0
  13. package/build/blocks/groups/content-group/index.d.ts +5 -0
  14. package/build/blocks/groups/content-group/index.d.ts.map +1 -0
  15. package/build/blocks/groups/content-group/index.js +21 -0
  16. package/build/blocks/groups/content-group/types.d.ts +9 -0
  17. package/build/blocks/groups/content-group/types.d.ts.map +1 -0
  18. package/build/blocks/groups/content-group/types.js +1 -0
  19. package/build/blocks/link/link-item/constants.d.ts +11 -0
  20. package/build/blocks/link/link-item/constants.d.ts.map +1 -0
  21. package/build/blocks/link/link-item/constants.js +6 -0
  22. package/build/blocks/link/link-item/edit.d.ts +6 -0
  23. package/build/blocks/link/link-item/edit.d.ts.map +1 -0
  24. package/build/blocks/link/link-item/edit.js +25 -0
  25. package/build/blocks/link/link-item/factory.d.ts +4 -0
  26. package/build/blocks/link/link-item/factory.d.ts.map +1 -0
  27. package/build/blocks/link/link-item/factory.js +27 -0
  28. package/build/blocks/link/link-item/icon.d.ts +2 -0
  29. package/build/blocks/link/link-item/icon.d.ts.map +1 -0
  30. package/build/blocks/link/link-item/icon.js +2 -0
  31. package/build/blocks/link/link-item/index.d.ts +5 -0
  32. package/build/blocks/link/link-item/index.d.ts.map +1 -0
  33. package/build/blocks/link/link-item/index.js +6 -0
  34. package/build/blocks/link/link-item/types.d.ts +25 -0
  35. package/build/blocks/link/link-item/types.d.ts.map +1 -0
  36. package/build/blocks/link/link-item/types.js +1 -0
  37. package/build/blocks/map/map-group/constants.d.ts +1 -0
  38. package/build/blocks/map/map-group/constants.d.ts.map +1 -1
  39. package/build/blocks/map/map-group/constants.js +2 -0
  40. package/build/blocks/map/map-group/edit.d.ts.map +1 -1
  41. package/build/blocks/map/map-group/edit.js +19 -11
  42. package/build/blocks/map/map-group/factory.d.ts +3 -1
  43. package/build/blocks/map/map-group/factory.d.ts.map +1 -1
  44. package/build/blocks/map/map-group/factory.js +24 -5
  45. package/build/blocks/map/map-group/index.d.ts.map +1 -1
  46. package/build/blocks/map/map-group/index.js +1 -0
  47. package/build/blocks/map/map-group/types.d.ts +18 -4
  48. package/build/blocks/map/map-group/types.d.ts.map +1 -1
  49. package/build/blocks/sections/base-section/attributes.d.ts +5 -1
  50. package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
  51. package/build/blocks/sections/base-section/attributes.js +5 -1
  52. package/build/blocks/sections/base-section/constants.d.ts +0 -16
  53. package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
  54. package/build/blocks/sections/base-section/constants.js +0 -7
  55. package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
  56. package/build/blocks/sections/base-section/controls.js +6 -3
  57. package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
  58. package/build/blocks/sections/base-section/edit.js +8 -1
  59. package/build/blocks/sections/base-section/factory.d.ts.map +1 -1
  60. package/build/blocks/sections/base-section/factory.js +3 -8
  61. package/build/blocks/sections/base-section/index.d.ts +1 -1
  62. package/build/blocks/sections/base-section/index.d.ts.map +1 -1
  63. package/build/blocks/sections/base-section/index.js +1 -1
  64. package/build/blocks/sections/base-section/types.d.ts +1 -0
  65. package/build/blocks/sections/base-section/types.d.ts.map +1 -1
  66. package/build/hooks/useTenantColorPalette.d.ts +9 -0
  67. package/build/hooks/useTenantColorPalette.d.ts.map +1 -0
  68. package/build/hooks/useTenantColorPalette.js +12 -0
  69. package/build/index.d.ts +5 -1
  70. package/build/index.d.ts.map +1 -1
  71. package/build/index.js +3 -1
  72. package/package.json +2 -1
  73. package/src/blocks/groups/content-group/constants.ts +1 -0
  74. package/src/blocks/groups/content-group/edit.tsx +51 -0
  75. package/src/blocks/groups/content-group/editor.scss +10 -0
  76. package/src/blocks/groups/content-group/factory.tsx +26 -0
  77. package/src/blocks/groups/content-group/icon.tsx +23 -0
  78. package/src/blocks/groups/content-group/index.ts +25 -0
  79. package/src/blocks/groups/content-group/types.ts +10 -0
  80. package/src/blocks/link/link-item/constants.ts +7 -0
  81. package/src/blocks/link/link-item/edit.tsx +116 -0
  82. package/src/blocks/link/link-item/editor.scss +11 -0
  83. package/src/blocks/link/link-item/factory.tsx +29 -0
  84. package/src/blocks/link/link-item/icon.tsx +6 -0
  85. package/src/blocks/link/link-item/index.ts +10 -0
  86. package/src/blocks/link/link-item/types.ts +24 -0
  87. package/src/blocks/map/map-group/constants.ts +3 -0
  88. package/src/blocks/map/map-group/edit.tsx +74 -8
  89. package/src/blocks/map/map-group/editor.scss +7 -0
  90. package/src/blocks/map/map-group/factory.tsx +26 -4
  91. package/src/blocks/map/map-group/index.ts +1 -0
  92. package/src/blocks/map/map-group/types.ts +18 -4
  93. package/src/blocks/responsive-grid/responsive-grid-item/editor.scss +9 -0
  94. package/src/blocks/sections/base-section/attributes.ts +5 -1
  95. package/src/blocks/sections/base-section/constants.ts +0 -8
  96. package/src/blocks/sections/base-section/controls.tsx +18 -8
  97. package/src/blocks/sections/base-section/edit.tsx +8 -1
  98. package/src/blocks/sections/base-section/factory.tsx +3 -7
  99. package/src/blocks/sections/base-section/index.ts +1 -1
  100. package/src/blocks/sections/base-section/types.ts +1 -0
  101. package/src/editor.scss +2 -0
  102. package/src/hooks/useTenantColorPalette.ts +21 -0
  103. package/src/index.ts +4 -1
@@ -1,28 +1,66 @@
1
- import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
2
- import {PanelBody, BaseControl, TextControl, SelectControl, TextareaControl} from '@wordpress/components'
1
+ import {InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
2
+ import {
3
+ PanelBody, BaseControl, TextControl, SelectControl, TextareaControl,
4
+ __experimentalToggleGroupControl as ToggleGroupControl,
5
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption
6
+ } from '@wordpress/components'
3
7
  import {__} from '@wordpress/i18n'
4
8
  import {ImagePickerControl} from '~/components/ImagePicker'
5
9
  import {MAP_TYPES} from './constants'
6
10
  import type {MapGroupAttributes, MapGroupOptions} from './types'
7
11
  import {Icon, mapMarker} from '@wordpress/icons'
12
+ import {useGroupBlock} from "~/hooks/useGroupBlock";
13
+ import clsx from "clsx";
14
+ import type {HeadingLevels, HeadingStyles} from "~/blocks/groups/banner-group/types";
15
+ import {HEADING_LEVELS, HEADING_STYLES} from "~/constants";
8
16
 
9
17
  export function createMapGroupEdit(options: MapGroupOptions) {
10
18
  return function Edit({
11
- attributes,
12
- setAttributes,
13
- }: {
19
+ attributes,
20
+ setAttributes,
21
+ }: {
14
22
  attributes: MapGroupAttributes
15
23
  setAttributes: (a: Partial<MapGroupAttributes>) => void
16
24
  }) {
17
- const {mapType, iframeSrc, iframeElement, img, url, lat, long} = attributes
25
+ const {mapType, iframeSrc, iframeElement, img, url, address, lat, long, description, header} = attributes
18
26
 
19
- const blockProps = useBlockProps({
20
- className: options.blockClassName ?? 'g-map wp-block-section',
27
+ const {blockProps, innerBlocksProps} = useGroupBlock({
28
+ blockClassName: clsx(options.blockClassName ?? 'g-map wp-block-section'),
29
+ containerClassName: [options.containerClassName ?? 'g-map__button-wraper wp-block-inner-content'],
30
+ allowedBlocks: options.allowedBlocks,
31
+ orientation: 'vertical',
32
+ template: options.template,
33
+ layout: {type: 'default'},
21
34
  })
22
35
 
23
36
  return (
24
37
  <>
25
38
  <InspectorControls>
39
+ <PanelBody title={__('Nadpis', 'brilo-blocks')} initialOpen={false}>
40
+ <ToggleGroupControl
41
+ label={__('Úroveň nadpisu', 'brilo-blocks')}
42
+ value={String(header.heading.level)}
43
+ onChange={(value) =>
44
+ setAttributes({header: {...header, heading: {...header.heading, level: Number(value) as HeadingLevels}}})
45
+ }
46
+ isBlock
47
+ >
48
+ {HEADING_LEVELS.map((l) => (
49
+ <ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
50
+ ))}
51
+ </ToggleGroupControl>
52
+ <ToggleGroupControl
53
+ label={__('Styl nadpisu', 'brilo-blocks')}
54
+ value={header.heading.style}
55
+ onChange={(value) => setAttributes({header: {...header, heading: {...header.heading, style: value as HeadingStyles}}})}
56
+ isBlock
57
+ >
58
+ {HEADING_STYLES.map((s) => (
59
+ <ToggleGroupControlOption key={s} value={s} label={s} />
60
+ ))}
61
+ </ToggleGroupControl>
62
+ </PanelBody>
63
+
26
64
  <PanelBody title={__('Nastavení mapy', 'brilo-blocks')}>
27
65
  <SelectControl
28
66
  label={__('Typ mapy', 'brilo-blocks')}
@@ -74,12 +112,40 @@ export function createMapGroupEdit(options: MapGroupOptions) {
74
112
  value={url || ''}
75
113
  onChange={(value: string) => setAttributes({url: value})}
76
114
  />
115
+
116
+ <TextControl
117
+ label={__('Adresa:', 'brilo-blocks')}
118
+ value={address || ''}
119
+ onChange={(value: string) => setAttributes({address: value})}
120
+ />
77
121
  </>
78
122
  )}
79
123
  </PanelBody>
80
124
  </InspectorControls>
81
125
 
82
126
  <div {...blockProps}>
127
+ <div className="g-map__banner">
128
+ <div className="g-map__content">
129
+ <RichText
130
+ tagName={`h${header.heading.level}` as HeadingStyles}
131
+ className={clsx('g-map__heading', `--heading-style-${header.heading.style}`, 'u-text-editable')}
132
+ value={header.heading.title}
133
+ onChange={(value: string) => setAttributes({header: {...header, heading: {...header.heading, title: value}}})}
134
+ placeholder={__('Nadpis...', 'brilo-blocks')}
135
+ allowedFormats={['core/bold', 'core/italic']}
136
+ />
137
+ <RichText
138
+ tagName="div"
139
+ className="g-map__description u-text-editable"
140
+ value={description}
141
+ onChange={(value: string) => setAttributes({description: value})}
142
+ placeholder={__('Popis...', 'brilo-blocks')}
143
+ />
144
+ </div>
145
+
146
+ <div {...innerBlocksProps} />
147
+ </div>
148
+
83
149
  <div className="g-map__map">
84
150
  {mapType === 'gps' && (lat || long) && (
85
151
  <div>
@@ -1,4 +1,11 @@
1
1
  @layer base {
2
+ .g-map__banner {
3
+ display: grid;
4
+ grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
5
+ gap: 16px;
6
+ margin-bottom: 16px;
7
+ }
8
+
2
9
  .g-map__map {
3
10
  min-height: 200px;
4
11
  padding: 16px;
@@ -3,10 +3,18 @@ import {__} from '@wordpress/i18n'
3
3
  import {createMapGroupEdit} from './edit'
4
4
  import type {MapGroupAttributes, MapGroupOptions} from './types'
5
5
  import {MAP_TYPES} from './constants'
6
+ import type {StringArray} from "~/types";
7
+ import {DEFAULT_HEADING_STYLES, DEFAULT_VARIANTS} from "~/blocks/groups/banner-group/constants";
8
+ import {InnerBlocks} from "@wordpress/block-editor";
9
+ import {HEADING_LEVELS} from "~/constants";
6
10
 
7
11
  export type {MapGroupAttributes, MapGroupOptions}
8
12
 
9
- export function createMapGroupBlock(options: MapGroupOptions): BlockConfiguration<MapGroupAttributes> {
13
+ export function createMapGroupBlock<THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES>(
14
+ options: MapGroupOptions<THeadingStyles>
15
+ ): BlockConfiguration<MapGroupAttributes<THeadingStyles[number]>> {
16
+ const headingStyles = options.headingStyles ?? DEFAULT_HEADING_STYLES
17
+
10
18
  return {
11
19
  name: options.name,
12
20
  title: options.title ?? __('Mapa', 'brilo-blocks'),
@@ -16,6 +24,16 @@ export function createMapGroupBlock(options: MapGroupOptions): BlockConfiguratio
16
24
  icon: options.icon ?? 'location-alt',
17
25
  supports: {html: false, customClassName: false},
18
26
  attributes: {
27
+ header: {
28
+ type: 'object',
29
+ default: {
30
+ heading: {title: '', level: HEADING_LEVELS[1], style: headingStyles[1] ?? headingStyles[0]},
31
+ },
32
+ },
33
+ description: {
34
+ type: 'string',
35
+ default: '',
36
+ },
19
37
  mapType: {
20
38
  type: 'string',
21
39
  default: MAP_TYPES[0].value,
@@ -32,6 +50,10 @@ export function createMapGroupBlock(options: MapGroupOptions): BlockConfiguratio
32
50
  type: 'object',
33
51
  default: {id: 0, url: '', alt: ''},
34
52
  },
53
+ address: {
54
+ type: 'string',
55
+ default: '',
56
+ },
35
57
  url: {
36
58
  type: 'string',
37
59
  default: '',
@@ -45,7 +67,7 @@ export function createMapGroupBlock(options: MapGroupOptions): BlockConfiguratio
45
67
  default: '',
46
68
  },
47
69
  },
48
- edit: createMapGroupEdit(options),
49
- save: () => null,
50
- } as unknown as BlockConfiguration<MapGroupAttributes>
70
+ edit: createMapGroupEdit(options as unknown as MapGroupOptions),
71
+ save: () => <InnerBlocks.Content />,
72
+ } as unknown as BlockConfiguration<MapGroupAttributes<THeadingStyles[number]>>
51
73
  }
@@ -6,4 +6,5 @@ import type {MapGroupOptions} from './types'
6
6
  export const mapGroupDefaults: MapGroupOptions = {
7
7
  name: 'brilo/map-group',
8
8
  parent: ['brilo/base-section'],
9
+ allowedBlocks: ['brilo/button-group', 'brilo/basic-button']
9
10
  }
@@ -1,16 +1,30 @@
1
- import {BriloBlockType, Media} from '~/types'
2
- import {MAP_TYPES} from './constants'
1
+ import {BriloBlockType, Media, type OptionArray, type StringArray} from '~/types'
2
+ import {DEFAULT_HEADING_STYLES, MAP_TYPES} from './constants'
3
+ import {HEADING_LEVELS} from "~/constants";
3
4
 
4
5
  export type MapType = (typeof MAP_TYPES)[number]['value']
5
6
 
6
- export interface MapGroupAttributes extends Record<string, unknown> {
7
+ export type HeadingLevels = (typeof HEADING_LEVELS)[number]
8
+ export type HeadingStyles = (typeof DEFAULT_HEADING_STYLES)[number]
9
+
10
+ export interface MapGroupAttributes<THeadingStyle extends string = HeadingStyles> extends Record<string, unknown> {
11
+ header: {
12
+ heading: {title: string; level: HeadingLevels; style: THeadingStyle}
13
+ }
14
+ description: string
7
15
  mapType: MapType
8
16
  iframeSrc: string
9
17
  iframeElement: string
10
18
  img: Media
19
+ address: string
11
20
  url: string
12
21
  lat: string
13
22
  long: string
14
23
  }
15
24
 
16
- export interface MapGroupOptions extends BriloBlockType {}
25
+ export interface MapGroupOptions<
26
+ THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES,
27
+ > extends BriloBlockType {
28
+ headingStyles?: THeadingStyles
29
+ headingLevels?: HeadingLevels
30
+ }
@@ -0,0 +1,9 @@
1
+ .wp-block-brilo-responsive-grid-item {
2
+ width: 100%;
3
+ margin-block: 0;
4
+ }
5
+
6
+ .u-grid-responsive__item-inner {
7
+ padding: 8px;
8
+ outline: 1px solid var(--border-color);
9
+ }
@@ -12,6 +12,10 @@ export const baseAttributes = {
12
12
  },
13
13
  background: {
14
14
  type: 'string',
15
- default: 'none',
15
+ default: '',
16
+ },
17
+ textColor: {
18
+ type: 'string',
19
+ default: '',
16
20
  },
17
21
  } as const
@@ -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 {BACKGROUNDS, SPACING_POSITIONS, SPACING_SIZES} from './constants'
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={__('Pozadí', 'brilo-blocks')}>
49
- <SelectControl<string>
50
- label={__('Pozadí', 'brilo-blocks')}
51
- value={background}
52
- options={[...BACKGROUNDS]}
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 blockProps = useBlockProps({className: options.blockClassName})
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
- 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
- }
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 {BACKGROUNDS, SPACING_POSITIONS, SPACING_SIZES} from './constants'
3
+ export {SPACING_POSITIONS, SPACING_SIZES} from './constants'
4
4
  export {createBaseSectionEdit} from './edit'
5
5
  export {createBaseSectionBlock} from './factory'
6
6
 
@@ -9,6 +9,7 @@ export interface BaseBlockAttributes extends Record<string, unknown> {
9
9
  size: string
10
10
  }
11
11
  background: string
12
+ textColor: string
12
13
  }
13
14
 
14
15
  export type ExcludableBaseAttr = 'spacing' | 'background' | 'id'
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
@@ -44,6 +44,8 @@ export type {ButtonGroupAttributes, ButtonGroupOptions} from './blocks/groups/bu
44
44
  export {buttonGroupDefaults, createButtonGroupBlock} from './blocks/groups/button-group'
45
45
  export type {BannerGroupAttributes, BannerGroupOptions} from './blocks/groups/banner-group'
46
46
  export {createBannerGroupBlock, bannerGroupDefaults} from './blocks/groups/banner-group'
47
+ export type {ContentGroupAttributes, ContentGroupOptions, ContentGroupSize} from './blocks/groups/content-group'
48
+ export {createContentGroupBlock, contentGroupDefaults} from './blocks/groups/content-group'
47
49
  export type {TextAndMediaGroupAttributes, TextAndMediaGroupOptions} from './blocks/groups/text-and-media-group'
48
50
  export {createTextAndMediaGroupBlock, textAndMediaGroupDefaults} from './blocks/groups/text-and-media-group'
49
51
  export type {TextAndFormGroupAttributes, TextAndFormGroupOptions} from './blocks/text-and-form/text-and-form-group'
@@ -80,7 +82,6 @@ export type {ColumnItemAttributes, ColumnItemOptions} from './blocks/column/colu
80
82
  export {createColumnItemBlock, columnItemDefaults} from './blocks/column/column-item'
81
83
  export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './blocks/sections/base-section'
82
84
  export {
83
- BACKGROUNDS,
84
85
  baseAttributes,
85
86
  baseSectionDefaults,
86
87
  createBaseSectionBlock,
@@ -120,3 +121,5 @@ export type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './bl
120
121
  export {createResponsiveGridItemBlock, responsiveGridItemDefaults} from './blocks/responsive-grid/responsive-grid-item'
121
122
  export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './blocks/post/post-slider-group'
122
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'