@brilo/base-blocks 0.1.7 → 0.1.9

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 (213) hide show
  1. package/build/blocks/column/column-item/constants.d.ts +13 -0
  2. package/build/blocks/column/column-item/constants.d.ts.map +1 -1
  3. package/build/blocks/column/column-item/constants.js +19 -0
  4. package/build/blocks/column/column-item/edit.d.ts.map +1 -1
  5. package/build/blocks/column/column-item/edit.js +6 -6
  6. package/build/blocks/column/column-item/factory.d.ts.map +1 -1
  7. package/build/blocks/column/column-item/factory.js +5 -0
  8. package/build/blocks/column/column-item/index.d.ts.map +1 -1
  9. package/build/blocks/column/column-item/index.js +11 -1
  10. package/build/blocks/column/column-item/types.d.ts +1 -0
  11. package/build/blocks/column/column-item/types.d.ts.map +1 -1
  12. package/build/blocks/contact/contact-item/factory.d.ts +7 -2
  13. package/build/blocks/contact/contact-item/factory.d.ts.map +1 -1
  14. package/build/blocks/contact/contact-item/factory.js +2 -2
  15. package/build/blocks/core/basic-button/edit.d.ts.map +1 -1
  16. package/build/blocks/core/basic-button/edit.js +12 -5
  17. package/build/blocks/core/basic-button/factory.d.ts.map +1 -1
  18. package/build/blocks/core/basic-button/factory.js +4 -0
  19. package/build/blocks/core/basic-button/index.d.ts.map +1 -1
  20. package/build/blocks/core/basic-button/index.js +2 -0
  21. package/build/blocks/core/basic-button/types.d.ts +12 -1
  22. package/build/blocks/core/basic-button/types.d.ts.map +1 -1
  23. package/build/blocks/gallery/gallery-group/constants.d.ts +21 -0
  24. package/build/blocks/gallery/gallery-group/constants.d.ts.map +1 -0
  25. package/build/blocks/gallery/gallery-group/constants.js +9 -0
  26. package/build/blocks/gallery/gallery-group/edit.d.ts +7 -0
  27. package/build/blocks/gallery/gallery-group/edit.d.ts.map +1 -0
  28. package/build/blocks/gallery/gallery-group/edit.js +46 -0
  29. package/build/blocks/gallery/gallery-group/factory.d.ts +5 -0
  30. package/build/blocks/gallery/gallery-group/factory.d.ts.map +1 -0
  31. package/build/blocks/gallery/gallery-group/factory.js +33 -0
  32. package/build/blocks/gallery/gallery-group/index.d.ts +5 -0
  33. package/build/blocks/gallery/gallery-group/index.d.ts.map +1 -0
  34. package/build/blocks/gallery/gallery-group/index.js +7 -0
  35. package/build/blocks/gallery/gallery-group/types.d.ts +15 -0
  36. package/build/blocks/gallery/gallery-group/types.d.ts.map +1 -0
  37. package/build/blocks/gallery/gallery-group/types.js +1 -0
  38. package/build/blocks/gallery/gallery-item/edit.d.ts +6 -0
  39. package/build/blocks/gallery/gallery-item/edit.d.ts.map +1 -0
  40. package/build/blocks/gallery/gallery-item/edit.js +13 -0
  41. package/build/blocks/gallery/gallery-item/factory.d.ts +5 -0
  42. package/build/blocks/gallery/gallery-item/factory.d.ts.map +1 -0
  43. package/build/blocks/gallery/gallery-item/factory.js +22 -0
  44. package/build/blocks/gallery/gallery-item/index.d.ts +5 -0
  45. package/build/blocks/gallery/gallery-item/index.d.ts.map +1 -0
  46. package/build/blocks/gallery/gallery-item/index.js +6 -0
  47. package/build/blocks/gallery/gallery-item/types.d.ts +7 -0
  48. package/build/blocks/gallery/gallery-item/types.d.ts.map +1 -0
  49. package/build/blocks/gallery/gallery-item/types.js +1 -0
  50. package/build/blocks/groups/content-group/factory.d.ts +2 -2
  51. package/build/blocks/groups/content-group/factory.d.ts.map +1 -1
  52. package/build/blocks/groups/content-group/factory.js +8 -8
  53. package/build/blocks/groups/content-group/icon.d.ts.map +1 -1
  54. package/build/blocks/link/link-item/constants.d.ts +11 -0
  55. package/build/blocks/link/link-item/constants.d.ts.map +1 -0
  56. package/build/blocks/link/link-item/constants.js +6 -0
  57. package/build/blocks/link/link-item/edit.d.ts +6 -0
  58. package/build/blocks/link/link-item/edit.d.ts.map +1 -0
  59. package/build/blocks/link/link-item/edit.js +25 -0
  60. package/build/blocks/link/link-item/factory.d.ts +4 -0
  61. package/build/blocks/link/link-item/factory.d.ts.map +1 -0
  62. package/build/blocks/link/link-item/factory.js +28 -0
  63. package/build/blocks/link/link-item/icon.d.ts +2 -0
  64. package/build/blocks/link/link-item/icon.d.ts.map +1 -0
  65. package/build/blocks/link/link-item/icon.js +2 -0
  66. package/build/blocks/link/link-item/index.d.ts +5 -0
  67. package/build/blocks/link/link-item/index.d.ts.map +1 -0
  68. package/build/blocks/link/link-item/index.js +6 -0
  69. package/build/blocks/link/link-item/types.d.ts +26 -0
  70. package/build/blocks/link/link-item/types.d.ts.map +1 -0
  71. package/build/blocks/link/link-item/types.js +1 -0
  72. package/build/blocks/map/map-group/constants.d.ts +1 -0
  73. package/build/blocks/map/map-group/constants.d.ts.map +1 -1
  74. package/build/blocks/map/map-group/constants.js +2 -0
  75. package/build/blocks/map/map-group/edit.d.ts.map +1 -1
  76. package/build/blocks/map/map-group/edit.js +19 -11
  77. package/build/blocks/map/map-group/factory.d.ts +3 -1
  78. package/build/blocks/map/map-group/factory.d.ts.map +1 -1
  79. package/build/blocks/map/map-group/factory.js +24 -5
  80. package/build/blocks/map/map-group/index.d.ts.map +1 -1
  81. package/build/blocks/map/map-group/index.js +1 -0
  82. package/build/blocks/map/map-group/types.d.ts +18 -4
  83. package/build/blocks/map/map-group/types.d.ts.map +1 -1
  84. package/build/blocks/person/person-group/constants.d.ts +3 -0
  85. package/build/blocks/person/person-group/constants.d.ts.map +1 -0
  86. package/build/blocks/person/person-group/constants.js +2 -0
  87. package/build/blocks/person/person-group/edit.d.ts +6 -0
  88. package/build/blocks/person/person-group/edit.d.ts.map +1 -0
  89. package/build/blocks/person/person-group/edit.js +23 -0
  90. package/build/blocks/person/person-group/factory.d.ts +5 -0
  91. package/build/blocks/person/person-group/factory.d.ts.map +1 -0
  92. package/build/blocks/person/person-group/factory.js +32 -0
  93. package/build/blocks/person/person-group/icon.d.ts +2 -0
  94. package/build/blocks/person/person-group/icon.d.ts.map +1 -0
  95. package/build/blocks/person/person-group/icon.js +2 -0
  96. package/build/blocks/person/person-group/index.d.ts +5 -0
  97. package/build/blocks/person/person-group/index.d.ts.map +1 -0
  98. package/build/blocks/person/person-group/index.js +11 -0
  99. package/build/blocks/person/person-group/types.d.ts +8 -0
  100. package/build/blocks/person/person-group/types.d.ts.map +1 -0
  101. package/build/blocks/person/person-group/types.js +1 -0
  102. package/build/blocks/person/person-item/constants.d.ts +2 -0
  103. package/build/blocks/person/person-item/constants.d.ts.map +1 -0
  104. package/build/blocks/person/person-item/constants.js +1 -0
  105. package/build/blocks/person/person-item/edit.d.ts +6 -0
  106. package/build/blocks/person/person-item/edit.d.ts.map +1 -0
  107. package/build/blocks/person/person-item/edit.js +23 -0
  108. package/build/blocks/person/person-item/factory.d.ts +5 -0
  109. package/build/blocks/person/person-item/factory.d.ts.map +1 -0
  110. package/build/blocks/person/person-item/factory.js +26 -0
  111. package/build/blocks/person/person-item/icon.d.ts +2 -0
  112. package/build/blocks/person/person-item/icon.d.ts.map +1 -0
  113. package/build/blocks/person/person-item/icon.js +3 -0
  114. package/build/blocks/person/person-item/index.d.ts +5 -0
  115. package/build/blocks/person/person-item/index.d.ts.map +1 -0
  116. package/build/blocks/person/person-item/index.js +6 -0
  117. package/build/blocks/person/person-item/types.d.ts +12 -0
  118. package/build/blocks/person/person-item/types.d.ts.map +1 -0
  119. package/build/blocks/person/person-item/types.js +1 -0
  120. package/build/blocks/sections/base-section/attributes.d.ts +5 -1
  121. package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
  122. package/build/blocks/sections/base-section/attributes.js +5 -1
  123. package/build/blocks/sections/base-section/constants.d.ts +0 -16
  124. package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
  125. package/build/blocks/sections/base-section/constants.js +0 -7
  126. package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
  127. package/build/blocks/sections/base-section/controls.js +6 -3
  128. package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
  129. package/build/blocks/sections/base-section/edit.js +8 -1
  130. package/build/blocks/sections/base-section/factory.d.ts.map +1 -1
  131. package/build/blocks/sections/base-section/factory.js +3 -8
  132. package/build/blocks/sections/base-section/index.d.ts +1 -1
  133. package/build/blocks/sections/base-section/index.d.ts.map +1 -1
  134. package/build/blocks/sections/base-section/index.js +1 -1
  135. package/build/blocks/sections/base-section/types.d.ts +1 -0
  136. package/build/blocks/sections/base-section/types.d.ts.map +1 -1
  137. package/build/components/ImagePicker/ImagePicker.d.ts +5 -0
  138. package/build/components/ImagePicker/ImagePicker.d.ts.map +1 -1
  139. package/build/components/ImagePicker/ImagePicker.js +18 -11
  140. package/build/hooks/useTenantColorPalette.d.ts +9 -0
  141. package/build/hooks/useTenantColorPalette.d.ts.map +1 -0
  142. package/build/hooks/useTenantColorPalette.js +12 -0
  143. package/build/index.d.ts +11 -1
  144. package/build/index.d.ts.map +1 -1
  145. package/build/index.js +6 -1
  146. package/build/types.d.ts +2 -0
  147. package/build/types.d.ts.map +1 -1
  148. package/package.json +2 -1
  149. package/src/blocks/column/column-item/constants.ts +20 -0
  150. package/src/blocks/column/column-item/edit.tsx +20 -4
  151. package/src/blocks/column/column-item/factory.tsx +5 -0
  152. package/src/blocks/column/column-item/index.ts +11 -1
  153. package/src/blocks/column/column-item/types.ts +1 -0
  154. package/src/blocks/contact/contact-item/editor.scss +4 -0
  155. package/src/blocks/contact/contact-item/factory.tsx +13 -5
  156. package/src/blocks/core/basic-button/edit.tsx +50 -1
  157. package/src/blocks/core/basic-button/factory.tsx +4 -0
  158. package/src/blocks/core/basic-button/index.ts +2 -0
  159. package/src/blocks/core/basic-button/types.ts +13 -1
  160. package/src/blocks/gallery/gallery-group/constants.ts +10 -0
  161. package/src/blocks/gallery/gallery-group/edit.tsx +117 -0
  162. package/src/blocks/gallery/gallery-group/editor.scss +18 -0
  163. package/src/blocks/gallery/gallery-group/factory.tsx +36 -0
  164. package/src/blocks/gallery/gallery-group/index.ts +11 -0
  165. package/src/blocks/gallery/gallery-group/types.ts +21 -0
  166. package/src/blocks/gallery/gallery-item/edit.tsx +46 -0
  167. package/src/blocks/gallery/gallery-item/editor.scss +8 -0
  168. package/src/blocks/gallery/gallery-item/factory.tsx +26 -0
  169. package/src/blocks/gallery/gallery-item/index.ts +10 -0
  170. package/src/blocks/gallery/gallery-item/types.ts +7 -0
  171. package/src/blocks/groups/content-group/factory.tsx +11 -11
  172. package/src/blocks/groups/content-group/icon.tsx +1 -1
  173. package/src/blocks/link/link-item/constants.ts +7 -0
  174. package/src/blocks/link/link-item/edit.tsx +124 -0
  175. package/src/blocks/link/link-item/editor.scss +11 -0
  176. package/src/blocks/link/link-item/factory.tsx +30 -0
  177. package/src/blocks/link/link-item/icon.tsx +6 -0
  178. package/src/blocks/link/link-item/index.ts +10 -0
  179. package/src/blocks/link/link-item/types.ts +25 -0
  180. package/src/blocks/map/map-group/constants.ts +3 -0
  181. package/src/blocks/map/map-group/edit.tsx +75 -5
  182. package/src/blocks/map/map-group/editor.scss +7 -0
  183. package/src/blocks/map/map-group/factory.tsx +26 -4
  184. package/src/blocks/map/map-group/index.ts +1 -0
  185. package/src/blocks/map/map-group/types.ts +16 -4
  186. package/src/blocks/person/person-group/constants.ts +2 -0
  187. package/src/blocks/person/person-group/edit.tsx +65 -0
  188. package/src/blocks/person/person-group/editor.scss +0 -0
  189. package/src/blocks/person/person-group/factory.tsx +35 -0
  190. package/src/blocks/person/person-group/icon.tsx +14 -0
  191. package/src/blocks/person/person-group/index.ts +15 -0
  192. package/src/blocks/person/person-group/types.ts +8 -0
  193. package/src/blocks/person/person-item/constants.ts +4 -0
  194. package/src/blocks/person/person-item/edit.tsx +103 -0
  195. package/src/blocks/person/person-item/editor.scss +35 -0
  196. package/src/blocks/person/person-item/factory.tsx +29 -0
  197. package/src/blocks/person/person-item/icon.tsx +7 -0
  198. package/src/blocks/person/person-item/index.ts +10 -0
  199. package/src/blocks/person/person-item/types.ts +12 -0
  200. package/src/blocks/responsive-grid/responsive-grid-item/editor.scss +9 -0
  201. package/src/blocks/sections/base-section/attributes.ts +5 -1
  202. package/src/blocks/sections/base-section/constants.ts +0 -8
  203. package/src/blocks/sections/base-section/controls.tsx +18 -8
  204. package/src/blocks/sections/base-section/edit.tsx +8 -1
  205. package/src/blocks/sections/base-section/factory.tsx +3 -7
  206. package/src/blocks/sections/base-section/index.ts +1 -1
  207. package/src/blocks/sections/base-section/types.ts +1 -0
  208. package/src/components/ImagePicker/ImagePicker.tsx +22 -10
  209. package/src/components/ImagePicker/editor.scss +2 -2
  210. package/src/editor.scss +6 -0
  211. package/src/hooks/useTenantColorPalette.ts +21 -0
  212. package/src/index.ts +10 -1
  213. package/src/types.ts +3 -0
@@ -0,0 +1,103 @@
1
+ import {InspectorControls, RichText} from '@wordpress/block-editor'
2
+ import {PanelBody, TextControl} from '@wordpress/components'
3
+ import {__} from '@wordpress/i18n'
4
+ import {ImagePickerControl} from '~/components/ImagePicker'
5
+ import type {PersonItemAttributes, PersonItemOptions} from './types'
6
+ import {useGroupBlock} from '~/hooks/useGroupBlock'
7
+ import clsx from 'clsx'
8
+ import {Icon, mobile, envelope} from '@wordpress/icons'
9
+
10
+ export function createPersonItemEdit(options: PersonItemOptions) {
11
+ return function Edit({
12
+ attributes,
13
+ setAttributes,
14
+ }: {
15
+ attributes: PersonItemAttributes
16
+ setAttributes: (a: Partial<PersonItemAttributes>) => void
17
+ }) {
18
+ const {title, description, img, email, phone} = attributes
19
+
20
+ const {blockProps, innerBlocksProps} = useGroupBlock({
21
+ blockClassName: clsx(options.blockClassName ?? 'i-person'),
22
+ containerClassName: [options.containerClassName ?? 'i-person__content wp-block-inner-content'],
23
+ allowedBlocks: options.allowedBlocks,
24
+ orientation: 'vertical',
25
+ template: options.template,
26
+ layout: {type: 'default'},
27
+ })
28
+
29
+ return (
30
+ <>
31
+ <InspectorControls>
32
+ <PanelBody title={__('Obrázek', 'brilo-blocks')}>
33
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
34
+ </PanelBody>
35
+ <PanelBody title={__('Kontakty', 'brilo-blocks')}>
36
+ <TextControl label={__('Email', 'brilo-blocks')} value={email} onChange={(v) => setAttributes({email: v})} />
37
+ <TextControl label={__('Telefon', 'brilo-blocks')} value={phone} onChange={(v) => setAttributes({phone: v})} />
38
+ </PanelBody>
39
+ </InspectorControls>
40
+
41
+ <div {...blockProps}>
42
+ <div className="i-person__inner">
43
+ <div className="i-person__image-wrapper">
44
+ {img.id ? (
45
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} size={[96, 96]} />
46
+ ) : (
47
+ <div className="i-person__image-placeholder">
48
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
49
+ </div>
50
+ )}
51
+ </div>
52
+
53
+ <div className="i-person__body">
54
+ <RichText
55
+ tagName="h3"
56
+ className="i-person__title u-text-editable"
57
+ value={title}
58
+ onChange={(v) => setAttributes({title: v})}
59
+ placeholder={__('Nadpis...', 'brilo-blocks')}
60
+ allowedFormats={['core/bold', 'core/italic']}
61
+ />
62
+
63
+ <RichText
64
+ tagName="p"
65
+ className="i-person__description u-text-editable"
66
+ value={description}
67
+ onChange={(v) => setAttributes({description: v})}
68
+ placeholder={__('Popis...', 'brilo-blocks')}
69
+ allowedFormats={['core/bold', 'core/italic']}
70
+ />
71
+
72
+ <div {...innerBlocksProps} />
73
+
74
+ <div className="i-person__contact">
75
+ <Icon icon={envelope} />
76
+ <RichText
77
+ tagName="p"
78
+ className="i-person__email u-text-editable"
79
+ value={email}
80
+ onChange={(v) => setAttributes({email: v})}
81
+ placeholder={__('Email...', 'brilo-blocks')}
82
+ allowedFormats={[]}
83
+ />
84
+ </div>
85
+
86
+ <div className="i-person__contact">
87
+ <Icon icon={mobile} />
88
+ <RichText
89
+ tagName="p"
90
+ className="i-person__phone u-text-editable"
91
+ value={phone}
92
+ onChange={(v) => setAttributes({phone: v})}
93
+ placeholder={__('Telefon...', 'brilo-blocks')}
94
+ allowedFormats={[]}
95
+ />
96
+ </div>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ </>
101
+ )
102
+ }
103
+ }
@@ -0,0 +1,35 @@
1
+ @layer base {
2
+ .i-person {
3
+ width: 100%;
4
+ }
5
+
6
+ .i-person__inner {
7
+ display: flex;
8
+ flex-direction: column;
9
+ gap: 8px;
10
+ padding: 12px;
11
+ border: 1px solid #eee;
12
+ border-radius: 4px;
13
+ }
14
+
15
+ .i-person__image-placeholder {
16
+ border: 1px dashed #0073aa;
17
+ padding: 16px 8px 8px;
18
+ }
19
+
20
+ .i-person__image-wrapper {
21
+ .c-image-picker-control__row {
22
+ flex-direction: column;
23
+ }
24
+ }
25
+
26
+ .i-person__contact {
27
+ display: flex;
28
+ align-items: center;
29
+ gap: 8px;
30
+
31
+ .u-text-editable {
32
+ width: 100%;
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,29 @@
1
+ import type {BlockConfiguration} from '@wordpress/blocks'
2
+ import {__} from '@wordpress/i18n'
3
+ import {createPersonItemEdit} from './edit'
4
+ import {icon as defaultIcon} from './icon'
5
+ import type {PersonItemAttributes, PersonItemOptions} from './types'
6
+ import {InnerBlocks} from '@wordpress/block-editor'
7
+
8
+ export type {PersonItemAttributes, PersonItemOptions}
9
+
10
+ export function createPersonItemBlock(options: PersonItemOptions): BlockConfiguration<PersonItemAttributes> {
11
+ return {
12
+ name: options.name,
13
+ title: options.title ?? __('Položka osoby', 'brilo-blocks'),
14
+ description: options.description,
15
+ category: options.category ?? 'layout',
16
+ ...(options.parent && {parent: options.parent}),
17
+ icon: options.icon ?? {src: defaultIcon},
18
+ supports: {html: false, customClassName: false},
19
+ attributes: {
20
+ title: {type: 'string', default: ''},
21
+ description: {type: 'string', default: ''},
22
+ img: {type: 'object', default: {id: 0, alt: ''}},
23
+ email: {type: 'string', default: ''},
24
+ phone: {type: 'string', default: ''},
25
+ },
26
+ edit: createPersonItemEdit(options),
27
+ save: () => <InnerBlocks.Content />,
28
+ } as unknown as BlockConfiguration<PersonItemAttributes>
29
+ }
@@ -0,0 +1,7 @@
1
+ import {Path, SVG} from '@wordpress/components'
2
+
3
+ export const icon = (
4
+ <SVG width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
5
+ <Path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" />
6
+ </SVG>
7
+ )
@@ -0,0 +1,10 @@
1
+ export type {PersonItemAttributes, PersonItemOptions} from './types'
2
+ export {createPersonItemBlock} from './factory'
3
+
4
+ import type {PersonItemOptions} from './types'
5
+
6
+ export const personItemDefaults: PersonItemOptions = {
7
+ name: 'brilo/person-item',
8
+ parent: ['brilo/person-group'],
9
+ allowedBlocks: ['core/paragraph', 'core/list', 'core/heading'],
10
+ }
@@ -0,0 +1,12 @@
1
+ import {BriloBlockType} from '~/types'
2
+ import {ImageValue} from '~/components/ImagePicker/ImagePicker'
3
+
4
+ export interface PersonItemAttributes extends Record<string, unknown> {
5
+ title: string
6
+ description: string
7
+ img: ImageValue
8
+ email: string
9
+ phone: string
10
+ }
11
+
12
+ export interface PersonItemOptions extends BriloBlockType {}
@@ -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'
@@ -7,6 +7,7 @@ import {CSSProperties} from 'react'
7
7
  export interface ImageValue {
8
8
  id: number
9
9
  alt: string
10
+ mimeType?: string
10
11
  }
11
12
 
12
13
  export interface ImageLabels {
@@ -24,30 +25,38 @@ interface ImagePickerProps {
24
25
  size?: [number, number]
25
26
  }
26
27
 
27
- export function useMediaUrl(id: number): string | undefined {
28
+ export function useMediaData(id: number): {url?: string; mimeType?: string} {
28
29
  return useSelect(
29
30
  (select) => {
30
- if (!id) return undefined
31
+ if (!id) return {}
31
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
33
  const media = (select('core') as any).getMedia(id)
33
- return media?.source_url as string | undefined
34
+ return {
35
+ url: media?.source_url as string | undefined,
36
+ mimeType: media?.mime_type as string | undefined,
37
+ }
34
38
  },
35
39
  [id],
36
40
  )
37
41
  }
38
42
 
43
+ export function useMediaUrl(id: number): string | undefined {
44
+ return useMediaData(id).url
45
+ }
46
+
39
47
  function useImagePicker(value: ImageValue, onChange: (v: ImageValue) => void, labels?: ImageLabels) {
40
- const mediaUrl = useMediaUrl(value.id)
48
+ const {url: mediaUrl, mimeType} = useMediaData(value.id)
41
49
  const selectLabel = labels?.select ?? __('Vybrat obrázek', 'brilo-blocks')
42
50
  const changeLabel = labels?.change ?? __('Změnit', 'brilo-blocks')
43
51
  const removeLabel = labels?.remove ?? __('Odebrat', 'brilo-blocks')
44
- const handleSelect = (media: {id: number; alt: string}) => onChange({id: media.id, alt: media.alt ?? ''})
52
+ const handleSelect = (media: {id: number; alt: string; mime?: string; type?: string}) =>
53
+ onChange({id: media.id, alt: media.alt ?? '', mimeType: media.mime ?? (media.type === 'video' ? 'video' : undefined)})
45
54
  const handleRemove = () => onChange({id: 0, alt: ''})
46
- return {mediaUrl, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove}
55
+ return {mediaUrl, mimeType: value.mimeType ?? mimeType, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove}
47
56
  }
48
57
 
49
58
  export function ImagePickerBody({value, onChange, allowedTypes = ['image'], placeholder, labels}: ImagePickerProps) {
50
- const {mediaUrl, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
59
+ const {mediaUrl, mimeType, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
51
60
 
52
61
  return (
53
62
  <MediaUploadCheck>
@@ -58,7 +67,10 @@ export function ImagePickerBody({value, onChange, allowedTypes = ['image'], plac
58
67
  render={({open}: {open: () => void}) =>
59
68
  value.id ? (
60
69
  <div className="c-image-picker-body">
61
- <div className="c-image-picker-body__preview">{mediaUrl && <img src={mediaUrl} alt={value.alt} />}</div>
70
+ <div className="c-image-picker-body__preview">
71
+ {mediaUrl &&
72
+ (mimeType?.startsWith('video') ? <video src={mediaUrl} autoPlay muted loop /> : <img src={mediaUrl} alt={value.alt} />)}
73
+ </div>
62
74
  <div className="c-image-picker-body__actions">
63
75
  <Button onClick={open} variant="secondary">
64
76
  {changeLabel}
@@ -80,7 +92,7 @@ export function ImagePickerBody({value, onChange, allowedTypes = ['image'], plac
80
92
  }
81
93
 
82
94
  export function ImagePickerControl({value, onChange, allowedTypes = ['image'], placeholder, labels, size = [48, 48]}: ImagePickerProps) {
83
- const {mediaUrl, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
95
+ const {mediaUrl, mimeType, selectLabel, changeLabel, removeLabel, handleSelect, handleRemove} = useImagePicker(value, onChange, labels)
84
96
 
85
97
  return (
86
98
  <div
@@ -101,7 +113,7 @@ export function ImagePickerControl({value, onChange, allowedTypes = ['image'], p
101
113
  <div className="c-image-picker-control__row">
102
114
  {!!value.id && !!mediaUrl && (
103
115
  <div className="c-image-picker-control__thumb">
104
- <img src={mediaUrl} alt={value.alt} />
116
+ {mimeType?.startsWith('video') ? <video src={mediaUrl} autoPlay muted loop /> : <img src={mediaUrl} alt={value.alt} />}
105
117
  </div>
106
118
  )}
107
119
  <div className="c-image-picker-control__btns">
@@ -64,8 +64,8 @@
64
64
 
65
65
  img {
66
66
  width: 100%;
67
- height: 100%;
68
- object-fit: cover;
67
+ max-height: 100%;
68
+ object-fit: contain;
69
69
  display: block;
70
70
  }
71
71
  }
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";
@@ -12,6 +13,8 @@
12
13
  @forward "./blocks/faq/faq-item/editor";
13
14
  @forward "./blocks/form/form-field/editor";
14
15
  @forward "./blocks/form/form-group/editor";
16
+ @forward "./blocks/gallery/gallery-group/editor";
17
+ @forward "./blocks/gallery/gallery-item/editor";
15
18
  @forward "./blocks/groups/banner-group/editor";
16
19
  @forward "./blocks/groups/basic-header-group/editor";
17
20
  @forward "./blocks/groups/button-group/editor";
@@ -29,6 +32,9 @@
29
32
  @forward "./blocks/text-and-form/text-and-form-text-column/editor";
30
33
  @forward "./blocks/usp/usp-group/editor";
31
34
  @forward "./blocks/usp/usp-item/editor";
35
+ @forward "./blocks/person/person-group/editor";
36
+ @forward "./blocks/person/person-item/editor";
37
+ @forward "./blocks/responsive-grid/responsive-grid-item/editor";
32
38
  @forward "./components/IconControl/editor";
33
39
  @forward "./components/ImagePicker/editor";
34
40
  @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
@@ -56,6 +56,14 @@ export type {UspGroupAttributes, UspGroupOptions} from './blocks/usp/usp-group'
56
56
  export {createUspGroupBlock, uspGroupDefaults} from './blocks/usp/usp-group'
57
57
  export type {UspItemAttributes, UspItemOptions} from './blocks/usp/usp-item'
58
58
  export {createUspItemBlock, uspItemDefaults} from './blocks/usp/usp-item'
59
+ export type {GalleryGroupAttributes, GalleryGroupOptions} from './blocks/gallery/gallery-group'
60
+ export {createGalleryGroupBlock, galleryGroupDefaults} from './blocks/gallery/gallery-group'
61
+ export type {GalleryItemAttributes, GalleryItemOptions} from './blocks/gallery/gallery-item'
62
+ export {createGalleryItemBlock, galleryItemDefaults} from './blocks/gallery/gallery-item'
63
+ export type {PersonGroupAttributes, PersonGroupOptions} from './blocks/person/person-group'
64
+ export {createPersonGroupBlock, personGroupDefaults} from './blocks/person/person-group'
65
+ export type {PersonItemAttributes, PersonItemOptions} from './blocks/person/person-item'
66
+ export {createPersonItemBlock, personItemDefaults} from './blocks/person/person-item'
59
67
  export type {TestimonialGroupAttributes} from './blocks/testimonial/testimonial-group'
60
68
  export {createTestimonialGroupBlock, testimonialGroupDefaults} from './blocks/testimonial/testimonial-group'
61
69
  export type {TestimonialItemAttributes} from './blocks/testimonial/testimonial-item'
@@ -82,7 +90,6 @@ export type {ColumnItemAttributes, ColumnItemOptions} from './blocks/column/colu
82
90
  export {createColumnItemBlock, columnItemDefaults} from './blocks/column/column-item'
83
91
  export type {BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr} from './blocks/sections/base-section'
84
92
  export {
85
- BACKGROUNDS,
86
93
  baseAttributes,
87
94
  baseSectionDefaults,
88
95
  createBaseSectionBlock,
@@ -122,3 +129,5 @@ export type {ResponsiveGridItemAttributes, ResponsiveGridItemOptions} from './bl
122
129
  export {createResponsiveGridItemBlock, responsiveGridItemDefaults} from './blocks/responsive-grid/responsive-grid-item'
123
130
  export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './blocks/post/post-slider-group'
124
131
  export {createPostSliderGroupBlock, postSliderGroupDefaults} from './blocks/post/post-slider-group'
132
+ export type {LinkItemAttributes, LinkItemIcon, LinkItemOptions} from './blocks/link/link-item'
133
+ export {createLinkItemBlock, linkItemDefaults} from './blocks/link/link-item'
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {BlockTypeIconDescriptor} from '@wordpress/blocks'
2
+
2
3
  export interface SelectOption {
3
4
  value: string
4
5
  label: string
@@ -7,6 +8,7 @@ export interface SelectOption {
7
8
  export interface Media {
8
9
  id: number
9
10
  alt: string
11
+ mimeType?: string
10
12
  }
11
13
 
12
14
  export interface Icon {
@@ -26,6 +28,7 @@ export interface BriloBlockType {
26
28
  category?: string
27
29
  allowedBlocks?: string[]
28
30
  template?: [string, Record<string, unknown>][]
31
+ attributes?: Record<string, unknown>
29
32
  blockClassName?: string
30
33
  containerClassName?: string
31
34
  icon?: BlockTypeIconDescriptor