@brilo/base-blocks 0.1.1 → 0.1.3

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 (250) hide show
  1. package/build/blocks/form/form-group/edit.d.ts.map +1 -1
  2. package/build/blocks/form/form-group/edit.js +17 -3
  3. package/build/blocks/form/form-group/factory.d.ts.map +1 -1
  4. package/build/blocks/form/form-group/factory.js +1 -0
  5. package/build/blocks/form/form-group/types.d.ts +1 -0
  6. package/build/blocks/form/form-group/types.d.ts.map +1 -1
  7. package/package.json +3 -2
  8. package/src/blocks/column/column-group/edit.tsx +56 -0
  9. package/src/blocks/column/column-group/editor.scss +7 -0
  10. package/src/blocks/column/column-group/factory.tsx +29 -0
  11. package/src/blocks/column/column-group/index.ts +14 -0
  12. package/src/blocks/column/column-group/types.ts +8 -0
  13. package/src/blocks/column/column-item/constants.ts +1 -0
  14. package/src/blocks/column/column-item/edit.tsx +48 -0
  15. package/src/blocks/column/column-item/editor.scss +34 -0
  16. package/src/blocks/column/column-item/factory.tsx +25 -0
  17. package/src/blocks/column/column-item/index.ts +10 -0
  18. package/src/blocks/column/column-item/types.ts +7 -0
  19. package/src/blocks/compare/compare-group/constants.ts +1 -0
  20. package/src/blocks/compare/compare-group/edit.tsx +52 -0
  21. package/src/blocks/compare/compare-group/factory.tsx +29 -0
  22. package/src/blocks/compare/compare-group/icon.tsx +7 -0
  23. package/src/blocks/compare/compare-group/index.ts +13 -0
  24. package/src/blocks/compare/compare-group/types.ts +12 -0
  25. package/src/blocks/compare/compare-item/edit.tsx +38 -0
  26. package/src/blocks/compare/compare-item/editor.scss +15 -0
  27. package/src/blocks/compare/compare-item/factory.tsx +28 -0
  28. package/src/blocks/compare/compare-item/icon.tsx +9 -0
  29. package/src/blocks/compare/compare-item/index.ts +13 -0
  30. package/src/blocks/compare/compare-item/types.ts +9 -0
  31. package/src/blocks/compare/compare-option/constants.ts +7 -0
  32. package/src/blocks/compare/compare-option/edit.tsx +64 -0
  33. package/src/blocks/compare/compare-option/editor.scss +26 -0
  34. package/src/blocks/compare/compare-option/factory.tsx +35 -0
  35. package/src/blocks/compare/compare-option/icon.tsx +7 -0
  36. package/src/blocks/compare/compare-option/index.ts +8 -0
  37. package/src/blocks/compare/compare-option/types.ts +12 -0
  38. package/src/blocks/contact/contact-group/constants.ts +3 -0
  39. package/src/blocks/contact/contact-group/edit.tsx +57 -0
  40. package/src/blocks/contact/contact-group/editor.scss +20 -0
  41. package/src/blocks/contact/contact-group/factory.tsx +35 -0
  42. package/src/blocks/contact/contact-group/index.ts +12 -0
  43. package/src/blocks/contact/contact-group/types.ts +12 -0
  44. package/src/blocks/contact/contact-item/constants.ts +17 -0
  45. package/src/blocks/contact/contact-item/edit.tsx +93 -0
  46. package/src/blocks/contact/contact-item/editor.scss +38 -0
  47. package/src/blocks/contact/contact-item/factory.tsx +35 -0
  48. package/src/blocks/contact/contact-item/index.ts +23 -0
  49. package/src/blocks/contact/contact-item/types.ts +21 -0
  50. package/src/blocks/core/basic-button/constants.ts +17 -0
  51. package/src/blocks/core/basic-button/edit.tsx +107 -0
  52. package/src/blocks/core/basic-button/editor.scss +80 -0
  53. package/src/blocks/core/basic-button/factory.tsx +54 -0
  54. package/src/blocks/core/basic-button/index.ts +8 -0
  55. package/src/blocks/core/basic-button/types.ts +29 -0
  56. package/src/blocks/core/basic-heading/constants.ts +1 -0
  57. package/src/blocks/core/basic-heading/edit.tsx +76 -0
  58. package/src/blocks/core/basic-heading/editor.scss +8 -0
  59. package/src/blocks/core/basic-heading/factory.tsx +40 -0
  60. package/src/blocks/core/basic-heading/index.ts +8 -0
  61. package/src/blocks/core/basic-heading/types.ts +20 -0
  62. package/src/blocks/core/basic-overline/edit.tsx +28 -0
  63. package/src/blocks/core/basic-overline/editor.scss +14 -0
  64. package/src/blocks/core/basic-overline/factory.tsx +22 -0
  65. package/src/blocks/core/basic-overline/index.ts +8 -0
  66. package/src/blocks/core/basic-overline/types.ts +7 -0
  67. package/src/blocks/faq/faq-group/constants.ts +11 -0
  68. package/src/blocks/faq/faq-group/edit.tsx +55 -0
  69. package/src/blocks/faq/faq-group/editor.scss +11 -0
  70. package/src/blocks/faq/faq-group/factory.tsx +39 -0
  71. package/src/blocks/faq/faq-group/index.ts +11 -0
  72. package/src/blocks/faq/faq-group/types.ts +14 -0
  73. package/src/blocks/faq/faq-item/edit.tsx +50 -0
  74. package/src/blocks/faq/faq-item/editor.scss +57 -0
  75. package/src/blocks/faq/faq-item/factory.tsx +24 -0
  76. package/src/blocks/faq/faq-item/index.ts +9 -0
  77. package/src/blocks/faq/faq-item/types.ts +7 -0
  78. package/src/blocks/form/form-field/constants.ts +14 -0
  79. package/src/blocks/form/form-field/edit.tsx +178 -0
  80. package/src/blocks/form/form-field/editor.scss +71 -0
  81. package/src/blocks/form/form-field/factory.tsx +32 -0
  82. package/src/blocks/form/form-field/index.ts +10 -0
  83. package/src/blocks/form/form-field/types.ts +18 -0
  84. package/src/blocks/form/form-group/constants.ts +16 -0
  85. package/src/blocks/form/form-group/edit.tsx +214 -0
  86. package/src/blocks/form/form-group/editor.scss +41 -0
  87. package/src/blocks/form/form-group/factory.tsx +36 -0
  88. package/src/blocks/form/form-group/index.ts +18 -0
  89. package/src/blocks/form/form-group/types.ts +23 -0
  90. package/src/blocks/groups/banner-group/constants.ts +15 -0
  91. package/src/blocks/groups/banner-group/edit.tsx +122 -0
  92. package/src/blocks/groups/banner-group/editor.scss +18 -0
  93. package/src/blocks/groups/banner-group/factory.tsx +64 -0
  94. package/src/blocks/groups/banner-group/icon.tsx +13 -0
  95. package/src/blocks/groups/banner-group/index.ts +11 -0
  96. package/src/blocks/groups/banner-group/types.ts +30 -0
  97. package/src/blocks/groups/basic-header-group/constants.ts +9 -0
  98. package/src/blocks/groups/basic-header-group/edit.tsx +99 -0
  99. package/src/blocks/groups/basic-header-group/editor.scss +35 -0
  100. package/src/blocks/groups/basic-header-group/factory.tsx +46 -0
  101. package/src/blocks/groups/basic-header-group/icon.tsx +17 -0
  102. package/src/blocks/groups/basic-header-group/index.ts +9 -0
  103. package/src/blocks/groups/basic-header-group/types.ts +27 -0
  104. package/src/blocks/groups/button-group/constants.ts +7 -0
  105. package/src/blocks/groups/button-group/edit.tsx +52 -0
  106. package/src/blocks/groups/button-group/editor.scss +23 -0
  107. package/src/blocks/groups/button-group/factory.tsx +34 -0
  108. package/src/blocks/groups/button-group/index.ts +11 -0
  109. package/src/blocks/groups/button-group/types.ts +12 -0
  110. package/src/blocks/groups/text-and-media-group/constants.ts +43 -0
  111. package/src/blocks/groups/text-and-media-group/edit.tsx +241 -0
  112. package/src/blocks/groups/text-and-media-group/editor.scss +123 -0
  113. package/src/blocks/groups/text-and-media-group/factory.tsx +100 -0
  114. package/src/blocks/groups/text-and-media-group/icon.tsx +37 -0
  115. package/src/blocks/groups/text-and-media-group/index.ts +18 -0
  116. package/src/blocks/groups/text-and-media-group/types.ts +60 -0
  117. package/src/blocks/hero/hero-group/constants.ts +23 -0
  118. package/src/blocks/hero/hero-group/edit.tsx +85 -0
  119. package/src/blocks/hero/hero-group/editor.scss +0 -0
  120. package/src/blocks/hero/hero-group/factory.tsx +45 -0
  121. package/src/blocks/hero/hero-group/icon.tsx +28 -0
  122. package/src/blocks/hero/hero-group/index.ts +11 -0
  123. package/src/blocks/hero/hero-group/types.ts +22 -0
  124. package/src/blocks/hero/hero-item/constants.ts +15 -0
  125. package/src/blocks/hero/hero-item/edit.tsx +107 -0
  126. package/src/blocks/hero/hero-item/editor.scss +87 -0
  127. package/src/blocks/hero/hero-item/factory.tsx +49 -0
  128. package/src/blocks/hero/hero-item/index.ts +10 -0
  129. package/src/blocks/hero/hero-item/types.ts +38 -0
  130. package/src/blocks/map/map-group/constants.ts +20 -0
  131. package/src/blocks/map/map-group/edit.tsx +108 -0
  132. package/src/blocks/map/map-group/editor.scss +24 -0
  133. package/src/blocks/map/map-group/factory.tsx +51 -0
  134. package/src/blocks/map/map-group/index.ts +9 -0
  135. package/src/blocks/map/map-group/types.ts +16 -0
  136. package/src/blocks/newsletter/newsletter-form/constants.ts +5 -0
  137. package/src/blocks/newsletter/newsletter-form/edit.tsx +194 -0
  138. package/src/blocks/newsletter/newsletter-form/editor.scss +68 -0
  139. package/src/blocks/newsletter/newsletter-form/factory.tsx +59 -0
  140. package/src/blocks/newsletter/newsletter-form/index.ts +11 -0
  141. package/src/blocks/newsletter/newsletter-form/types.ts +45 -0
  142. package/src/blocks/post/post-slider-group/constants.ts +3 -0
  143. package/src/blocks/post/post-slider-group/edit.tsx +76 -0
  144. package/src/blocks/post/post-slider-group/factory.tsx +43 -0
  145. package/src/blocks/post/post-slider-group/icon.tsx +13 -0
  146. package/src/blocks/post/post-slider-group/index.ts +9 -0
  147. package/src/blocks/post/post-slider-group/types.ts +20 -0
  148. package/src/blocks/responsive-grid/responsive-grid-group/edit.tsx +95 -0
  149. package/src/blocks/responsive-grid/responsive-grid-group/factory.tsx +33 -0
  150. package/src/blocks/responsive-grid/responsive-grid-group/index.ts +13 -0
  151. package/src/blocks/responsive-grid/responsive-grid-group/types.ts +9 -0
  152. package/src/blocks/responsive-grid/responsive-grid-item/edit.tsx +19 -0
  153. package/src/blocks/responsive-grid/responsive-grid-item/factory.tsx +20 -0
  154. package/src/blocks/responsive-grid/responsive-grid-item/index.ts +9 -0
  155. package/src/blocks/responsive-grid/responsive-grid-item/types.ts +5 -0
  156. package/src/blocks/sections/base-section/attributes.ts +17 -0
  157. package/src/blocks/sections/base-section/constants.ts +18 -0
  158. package/src/blocks/sections/base-section/controls.tsx +70 -0
  159. package/src/blocks/sections/base-section/edit.tsx +34 -0
  160. package/src/blocks/sections/base-section/editor.scss +24 -0
  161. package/src/blocks/sections/base-section/factory.tsx +47 -0
  162. package/src/blocks/sections/base-section/icon.tsx +6 -0
  163. package/src/blocks/sections/base-section/index.ts +14 -0
  164. package/src/blocks/sections/base-section/types.ts +26 -0
  165. package/src/blocks/signpost/signpost-group/constants.ts +3 -0
  166. package/src/blocks/signpost/signpost-group/edit.tsx +75 -0
  167. package/src/blocks/signpost/signpost-group/editor.scss +0 -0
  168. package/src/blocks/signpost/signpost-group/factory.tsx +40 -0
  169. package/src/blocks/signpost/signpost-group/icon.tsx +19 -0
  170. package/src/blocks/signpost/signpost-group/index.ts +15 -0
  171. package/src/blocks/signpost/signpost-group/types.ts +9 -0
  172. package/src/blocks/signpost/signpost-item/constants.ts +4 -0
  173. package/src/blocks/signpost/signpost-item/edit.tsx +90 -0
  174. package/src/blocks/signpost/signpost-item/editor.scss +25 -0
  175. package/src/blocks/signpost/signpost-item/factory.tsx +29 -0
  176. package/src/blocks/signpost/signpost-item/icon.tsx +7 -0
  177. package/src/blocks/signpost/signpost-item/index.ts +10 -0
  178. package/src/blocks/signpost/signpost-item/types.ts +12 -0
  179. package/src/blocks/step/step-group/constants.ts +6 -0
  180. package/src/blocks/step/step-group/edit.tsx +64 -0
  181. package/src/blocks/step/step-group/editor.scss +19 -0
  182. package/src/blocks/step/step-group/factory.tsx +36 -0
  183. package/src/blocks/step/step-group/icon.tsx +27 -0
  184. package/src/blocks/step/step-group/index.ts +15 -0
  185. package/src/blocks/step/step-group/types.ts +13 -0
  186. package/src/blocks/step/step-item/constants.ts +6 -0
  187. package/src/blocks/step/step-item/edit.tsx +60 -0
  188. package/src/blocks/step/step-item/editor.scss +18 -0
  189. package/src/blocks/step/step-item/factory.tsx +27 -0
  190. package/src/blocks/step/step-item/index.ts +11 -0
  191. package/src/blocks/step/step-item/types.ts +12 -0
  192. package/src/blocks/testimonial/testimonial-group/constants.ts +27 -0
  193. package/src/blocks/testimonial/testimonial-group/edit.tsx +74 -0
  194. package/src/blocks/testimonial/testimonial-group/editor.scss +38 -0
  195. package/src/blocks/testimonial/testimonial-group/factory.tsx +44 -0
  196. package/src/blocks/testimonial/testimonial-group/icon.tsx +33 -0
  197. package/src/blocks/testimonial/testimonial-group/index.ts +15 -0
  198. package/src/blocks/testimonial/testimonial-group/types.ts +19 -0
  199. package/src/blocks/testimonial/testimonial-item/edit.tsx +48 -0
  200. package/src/blocks/testimonial/testimonial-item/editor.scss +20 -0
  201. package/src/blocks/testimonial/testimonial-item/factory.tsx +35 -0
  202. package/src/blocks/testimonial/testimonial-item/index.ts +9 -0
  203. package/src/blocks/testimonial/testimonial-item/types.ts +9 -0
  204. package/src/blocks/text-and-form/text-and-form-group/constants.ts +6 -0
  205. package/src/blocks/text-and-form/text-and-form-group/edit.tsx +59 -0
  206. package/src/blocks/text-and-form/text-and-form-group/editor.scss +21 -0
  207. package/src/blocks/text-and-form/text-and-form-group/factory.tsx +38 -0
  208. package/src/blocks/text-and-form/text-and-form-group/icon.tsx +23 -0
  209. package/src/blocks/text-and-form/text-and-form-group/index.ts +9 -0
  210. package/src/blocks/text-and-form/text-and-form-group/types.ts +23 -0
  211. package/src/blocks/text-and-form/text-and-form-text-column/constants.ts +10 -0
  212. package/src/blocks/text-and-form/text-and-form-text-column/edit.tsx +94 -0
  213. package/src/blocks/text-and-form/text-and-form-text-column/editor.scss +29 -0
  214. package/src/blocks/text-and-form/text-and-form-text-column/factory.tsx +41 -0
  215. package/src/blocks/text-and-form/text-and-form-text-column/index.ts +18 -0
  216. package/src/blocks/text-and-form/text-and-form-text-column/types.ts +23 -0
  217. package/src/blocks/usp/usp-group/constants.ts +54 -0
  218. package/src/blocks/usp/usp-group/edit.tsx +197 -0
  219. package/src/blocks/usp/usp-group/editor.scss +24 -0
  220. package/src/blocks/usp/usp-group/factory.tsx +113 -0
  221. package/src/blocks/usp/usp-group/icon.tsx +18 -0
  222. package/src/blocks/usp/usp-group/index.ts +15 -0
  223. package/src/blocks/usp/usp-group/types.ts +70 -0
  224. package/src/blocks/usp/usp-item/constants.ts +7 -0
  225. package/src/blocks/usp/usp-item/edit.tsx +65 -0
  226. package/src/blocks/usp/usp-item/editor.scss +17 -0
  227. package/src/blocks/usp/usp-item/factory.tsx +30 -0
  228. package/src/blocks/usp/usp-item/index.ts +11 -0
  229. package/src/blocks/usp/usp-item/types.ts +17 -0
  230. package/src/components/IconControl/IconControl.tsx +55 -0
  231. package/src/components/IconControl/editor.scss +53 -0
  232. package/src/components/IconControl/index.ts +2 -0
  233. package/src/components/IconControl/index.tsx +1 -0
  234. package/src/components/ImagePicker/ImagePicker.tsx +124 -0
  235. package/src/components/ImagePicker/editor.scss +79 -0
  236. package/src/components/ImagePicker/index.ts +2 -0
  237. package/src/components/ImagePicker/index.tsx +1 -0
  238. package/src/components/ItemIconControl/ItemIconControl.tsx +72 -0
  239. package/src/components/ItemIconControl/ItemIconModal.tsx +12 -0
  240. package/src/components/ItemIconControl/ItemIconPreview.tsx +93 -0
  241. package/src/components/ItemIconControl/editor.scss +52 -0
  242. package/src/components/ItemIconControl/index.ts +2 -0
  243. package/src/components/ItemIconControl/types.d.ts +30 -0
  244. package/src/constants.ts +20 -0
  245. package/src/editor.scss +34 -0
  246. package/src/globals.scss +237 -0
  247. package/src/hooks/useGroupBlock.ts +53 -0
  248. package/src/index.ts +122 -0
  249. package/src/types.ts +33 -0
  250. package/src/utils/createEditAdapter.ts +11 -0
@@ -0,0 +1,40 @@
1
+ import {InnerBlocks} from '@wordpress/block-editor'
2
+ import type {BlockConfiguration} from '@wordpress/blocks'
3
+ import {__} from '@wordpress/i18n'
4
+ import {COLUMNS, HEADING_LEVELS, RATIOS} from './constants'
5
+ import {createSignpostGroupEdit} from './edit'
6
+ import {icon as defaultIcon} from './icon'
7
+ import type {SignpostGroupAttributes, SignpostGroupOptions} from './types'
8
+
9
+ export type {SignpostGroupAttributes, SignpostGroupOptions}
10
+
11
+ export function createSignpostGroupBlock(options: SignpostGroupOptions): BlockConfiguration<SignpostGroupAttributes> {
12
+ return {
13
+ name: options.name,
14
+ title: options.title ?? __('Rozcestník', 'brilo-blocks'),
15
+ description: options.description,
16
+ category: options.category ?? 'layout',
17
+ ...(options.parent && {parent: options.parent}),
18
+ icon: options.icon ?? {src: defaultIcon},
19
+ supports: {html: false, customClassName: false},
20
+ attributes: {
21
+ columns: {
22
+ type: 'number',
23
+ default: COLUMNS[1],
24
+ enum: [...COLUMNS],
25
+ },
26
+ ratio: {
27
+ type: 'string',
28
+ default: RATIOS[0],
29
+ enum: [...RATIOS],
30
+ },
31
+ headingLevel: {
32
+ type: 'number',
33
+ default: HEADING_LEVELS[0],
34
+ enum: [...HEADING_LEVELS],
35
+ },
36
+ },
37
+ edit: createSignpostGroupEdit(options),
38
+ save: () => <InnerBlocks.Content />,
39
+ } as unknown as BlockConfiguration<SignpostGroupAttributes>
40
+ }
@@ -0,0 +1,19 @@
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="0.5" y="7.5" width="8" height="11" stroke="black" fill="none" />
4
+ <rect x="2.5" y="9.5" width="4" height="3" stroke="black" fill="none" />
5
+ <path d="M2 14H6V15H2V14Z" fill="black" />
6
+ <path d="M2 16H7V17H2V16Z" fill="black" />
7
+ <rect x="11.5" y="7.5" width="8" height="11" stroke="black" fill="none" />
8
+ <rect x="13.5" y="9.5" width="4" height="3" stroke="black" fill="none" />
9
+ <path d="M13 14H17V15H13V14Z" fill="black" />
10
+ <path d="M13 16H18V17H13V16Z" fill="black" />
11
+ <path d="M4 4H9V5H4V4Z" fill="black" />
12
+ <path d="M10 4H16V5H10V4Z" fill="black" />
13
+ <path
14
+ d="M12 2C12 1.44772 12.4477 1 13 1H14C14.5523 1 15 1.44772 15 2C15 2.55228 14.5523 3 14 3H13C12.4477 3 12 2.55228 12 2Z"
15
+ fill="black"
16
+ />
17
+ <path d="M5 2C5 1.44772 5.44772 1 6 1H10C10.5523 1 11 1.44772 11 2C11 2.55228 10.5523 3 10 3H6C5.44772 3 5 2.55228 5 2Z" fill="black" />
18
+ </svg>
19
+ )
@@ -0,0 +1,15 @@
1
+ export type {SignpostGroupAttributes, SignpostGroupOptions} from './types'
2
+ export {createSignpostGroupBlock} from './factory'
3
+
4
+ import type {SignpostGroupOptions} from './types'
5
+
6
+ export const signpostGroupDefaults: SignpostGroupOptions = {
7
+ name: 'brilo/signpost-group',
8
+ parent: ['brilo/base-section'],
9
+ allowedBlocks: ['brilo/signpost-item'],
10
+ template: [
11
+ ['brilo/signpost-item', {}],
12
+ ['brilo/signpost-item', {}],
13
+ ['brilo/signpost-item', {}],
14
+ ],
15
+ }
@@ -0,0 +1,9 @@
1
+ import {BriloBlockType} from '~/types'
2
+
3
+ export interface SignpostGroupAttributes extends Record<string, unknown> {
4
+ columns: number
5
+ headingLevel: number
6
+ ratio: string
7
+ }
8
+
9
+ export interface SignpostGroupOptions extends BriloBlockType {}
@@ -0,0 +1,4 @@
1
+ import {__} from '@wordpress/i18n'
2
+
3
+ // No item-specific constants yet, but file is required by anatomy
4
+ export {}
@@ -0,0 +1,90 @@
1
+ import {InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
2
+ import {Button, PanelBody, TextControl, ToggleControl} from '@wordpress/components'
3
+ import {__} from '@wordpress/i18n'
4
+ import {ImagePickerControl} from '~/components/ImagePicker'
5
+ import type {SignpostItemAttributes, SignpostItemOptions} from './types'
6
+ import {useGroupBlock} from '~/hooks/useGroupBlock'
7
+ import clsx from 'clsx'
8
+
9
+ export function createSignpostItemEdit(options: SignpostItemOptions) {
10
+ return function Edit({
11
+ attributes,
12
+ setAttributes,
13
+ }: {
14
+ attributes: SignpostItemAttributes
15
+ setAttributes: (a: Partial<SignpostItemAttributes>) => void
16
+ }) {
17
+ const {title, img, button, url} = attributes
18
+
19
+ const {blockProps, innerBlocksProps} = useGroupBlock({
20
+ blockClassName: clsx(options.blockClassName ?? 'i-signpost'),
21
+ containerClassName: [options.containerClassName ?? 'i-signpost__content wp-block-inner-content'],
22
+ allowedBlocks: options.allowedBlocks,
23
+ orientation: 'vertical',
24
+ template: options.template,
25
+ layout: {type: 'default'},
26
+ })
27
+
28
+ return (
29
+ <>
30
+ <InspectorControls>
31
+ <PanelBody title={__('Obrázek', 'brilo-blocks')}>
32
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
33
+ </PanelBody>
34
+ <PanelBody title={__('Tlačítko', 'brilo-blocks')}>
35
+ <TextControl
36
+ label={__('Text tlačítka', 'brilo-blocks')}
37
+ value={button.text}
38
+ onChange={(v) => setAttributes({button: {...button, text: v}})}
39
+ />
40
+ </PanelBody>
41
+ <PanelBody title={__('Odkaz', 'brilo-blocks')} initialOpen={false}>
42
+ <TextControl label={__('URL', 'brilo-blocks')} value={url.src} onChange={(v) => setAttributes({url: {...url, src: v}})} />
43
+ <ToggleControl
44
+ label={__('Otevřít v nové záložce', 'brilo-blocks')}
45
+ checked={url.blank}
46
+ onChange={(v) => setAttributes({url: {...url, blank: v}})}
47
+ />
48
+ </PanelBody>
49
+ </InspectorControls>
50
+
51
+ <div {...blockProps}>
52
+ <div className="i-signpost__inner">
53
+ <div className="i-signpost__image-wrapper">
54
+ {img.id ? (
55
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} size={[128, 128]} />
56
+ ) : (
57
+ <div className="i-signpost__image-placeholder">
58
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
59
+ </div>
60
+ )}
61
+ </div>
62
+
63
+ <div className="i-signpost__body">
64
+ <RichText
65
+ tagName="h3"
66
+ className="i-signpost__title u-text-editable"
67
+ value={title}
68
+ onChange={(v) => setAttributes({title: v})}
69
+ placeholder={__('Nadpis...', 'brilo-blocks')}
70
+ allowedFormats={['core/bold', 'core/italic']}
71
+ />
72
+
73
+ <div {...innerBlocksProps} />
74
+
75
+ <Button variant={'primary'} className="i-signpost__button">
76
+ <RichText
77
+ tagName="span"
78
+ className="i-signpost__button-text"
79
+ value={button.text}
80
+ onChange={(v) => setAttributes({button: {...button, text: v}})}
81
+ placeholder={__('Text tlačítka...', 'brilo-blocks')}
82
+ />
83
+ </Button>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </>
88
+ )
89
+ }
90
+ }
@@ -0,0 +1,25 @@
1
+ @layer base {
2
+ .i-signpost {
3
+ width: 100%;
4
+ }
5
+
6
+ .i-signpost__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-signpost__image-placeholder {
16
+ border: 1px dashed #0073aa;
17
+ padding: 16px 8px 8px;
18
+ }
19
+
20
+ .i-signpost__image-wrapper {
21
+ .c-image-picker-control__row {
22
+ flex-direction: column;
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,29 @@
1
+ import type {BlockConfiguration} from '@wordpress/blocks'
2
+ import {__} from '@wordpress/i18n'
3
+ import {createSignpostItemEdit} from './edit'
4
+ import {icon as defaultIcon} from './icon'
5
+ import type {SignpostItemAttributes, SignpostItemOptions} from './types'
6
+ import {InnerBlocks} from '@wordpress/block-editor'
7
+
8
+ export type {SignpostItemAttributes, SignpostItemOptions}
9
+
10
+ export function createSignpostItemBlock(options: SignpostItemOptions): BlockConfiguration<SignpostItemAttributes> {
11
+ return {
12
+ name: options.name,
13
+ title: options.title ?? __('Signpost položka', '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
+ img: {type: 'object', default: {id: 0, alt: ''}},
22
+ button: {type: 'object', default: {text: ''}},
23
+ url: {type: 'string', default: ''},
24
+ blank: {type: 'boolean', default: false},
25
+ },
26
+ edit: createSignpostItemEdit(options),
27
+ save: () => <InnerBlocks.Content />,
28
+ } as unknown as BlockConfiguration<SignpostItemAttributes>
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 {SignpostItemAttributes, SignpostItemOptions} from './types'
2
+ export {createSignpostItemBlock} from './factory'
3
+
4
+ import type {SignpostItemOptions} from './types'
5
+
6
+ export const signpostItemDefaults: SignpostItemOptions = {
7
+ name: 'brilo/signpost-item',
8
+ parent: ['brilo/signpost-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 SignpostItemAttributes extends Record<string, unknown> {
5
+ title: string
6
+ img: ImageValue
7
+ button: {text: string}
8
+ url: {src: string; blank: boolean}
9
+ blank: boolean
10
+ }
11
+
12
+ export interface SignpostItemOptions extends BriloBlockType {}
@@ -0,0 +1,6 @@
1
+ import {__} from '@wordpress/i18n'
2
+
3
+ export const DEFAULT_VARIANTS = [
4
+ {value: 'horizontal', label: __('Horizontální', 'brilo-blocks')},
5
+ {value: 'vertical', label: __('Vertikální', 'brilo-blocks')},
6
+ ] as const
@@ -0,0 +1,64 @@
1
+ import {InspectorControls} from '@wordpress/block-editor'
2
+ import {
3
+ PanelBody,
4
+ ToggleControl,
5
+ __experimentalToggleGroupControl as ToggleGroupControl,
6
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
7
+ } from '@wordpress/components'
8
+ import {__} from '@wordpress/i18n'
9
+ import clsx from 'clsx'
10
+ import {useGroupBlock} from '~/hooks/useGroupBlock'
11
+ import {OptionArray} from '~/types'
12
+ import type {StepGroupAttributes, StepGroupOptions, StepVariant} from './types'
13
+ import {DEFAULT_VARIANTS} from './constants'
14
+
15
+ export function createStepGroupEdit<TVariants extends OptionArray = typeof DEFAULT_VARIANTS>(options: StepGroupOptions<TVariants>) {
16
+ const VARIANTS = options.variants ?? DEFAULT_VARIANTS
17
+
18
+ return function Edit({
19
+ attributes,
20
+ setAttributes,
21
+ }: {
22
+ attributes: StepGroupAttributes
23
+ setAttributes: (a: Partial<StepGroupAttributes>) => void
24
+ }) {
25
+ const {variant, disableIcon} = attributes
26
+
27
+ const {blockProps, innerBlocksProps} = useGroupBlock({
28
+ blockClassName: clsx(options.blockClassName ?? 'g-step wp-block-section', `--variant-${variant}`, disableIcon && '--disable-icon'),
29
+ containerClassName: [options.containerClassName ?? 'g-step__container', 'u-grid-responsive', '--cols-3'],
30
+ containerStyle: {'--grid-max-col-count': 3},
31
+ allowedBlocks: options.allowedBlocks,
32
+ orientation: 'horizontal',
33
+ template: options.template,
34
+ layout: {type: 'default'},
35
+ })
36
+
37
+ return (
38
+ <>
39
+ <InspectorControls>
40
+ <PanelBody title={__('Nastavení', 'brilo-blocks')}>
41
+ <ToggleGroupControl
42
+ isBlock
43
+ label={__('Varianta', 'brilo-blocks')}
44
+ value={variant}
45
+ onChange={(v) => setAttributes({variant: v as StepGroupAttributes['variant']})}
46
+ >
47
+ {VARIANTS.map((v) => (
48
+ <ToggleGroupControlOption key={v.value} value={v.value} label={v.label} />
49
+ ))}
50
+ </ToggleGroupControl>
51
+ <ToggleControl
52
+ label={__('Vypnout ikonu', 'brilo-blocks')}
53
+ checked={disableIcon}
54
+ onChange={(v) => setAttributes({disableIcon: v})}
55
+ />
56
+ </PanelBody>
57
+ </InspectorControls>
58
+ <div {...blockProps}>
59
+ <div {...innerBlocksProps} />
60
+ </div>
61
+ </>
62
+ )
63
+ }
64
+ }
@@ -0,0 +1,19 @@
1
+ @layer base {
2
+ .g-step {
3
+ counter-reset: step-counter;
4
+
5
+ &.--variant-vertical {
6
+ .g-step__container {
7
+ display: flex;
8
+ flex-direction: column;
9
+ gap: 24px;
10
+ }
11
+ }
12
+
13
+ &.--disable-icon {
14
+ .i-step__icon-container {
15
+ display: none;
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,36 @@
1
+ import {InnerBlocks} from '@wordpress/block-editor'
2
+ import type {BlockConfiguration} from '@wordpress/blocks'
3
+ import {__} from '@wordpress/i18n'
4
+ import {DEFAULT_VARIANTS} from './constants'
5
+ import {createStepGroupEdit} from './edit'
6
+ import type {StepGroupAttributes, StepGroupOptions} from './types'
7
+ import {icon} from '~/blocks/step/step-group/icon'
8
+ import {OptionArray} from '~/types'
9
+
10
+ export function createStepGroupBlock<TVariants extends OptionArray = typeof DEFAULT_VARIANTS>(
11
+ options: StepGroupOptions<TVariants>,
12
+ ): BlockConfiguration<StepGroupAttributes<TVariants[number]['value']>> {
13
+ const variants = options.variants ?? DEFAULT_VARIANTS
14
+
15
+ return {
16
+ name: options.name,
17
+ title: options.title ?? __('Krok skupina', 'brilo-blocks'),
18
+ description: options.description,
19
+ category: options.category ?? 'layout',
20
+ ...(options.parent && {parent: options.parent}),
21
+ icon: options.icon ?? icon,
22
+ supports: {html: false, customClassName: false},
23
+ attributes: {
24
+ variant: {
25
+ type: 'string',
26
+ default: variants[0].value,
27
+ },
28
+ disableIcon: {
29
+ type: 'boolean',
30
+ default: false,
31
+ },
32
+ },
33
+ edit: createStepGroupEdit(options as unknown as StepGroupOptions),
34
+ save: () => <InnerBlocks.Content />,
35
+ } as unknown as BlockConfiguration<StepGroupAttributes<TVariants[number]['value']>>
36
+ }
@@ -0,0 +1,27 @@
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
+ <path d="M4 6H7V7H4V6Z" fill="black" />
4
+ <path d="M12 6H15V7H12V6Z" fill="black" />
5
+ <path
6
+ d="M0 6.5C0 5.67157 0.671573 5 1.5 5C2.32843 5 3 5.67157 3 6.5C3 7.32843 2.32843 8 1.5 8C0.671573 8 0 7.32843 0 6.5Z"
7
+ fill="#357AB5"
8
+ />
9
+ <path
10
+ d="M8 6.5C8 5.67157 8.67157 5 9.5 5C10.3284 5 11 5.67157 11 6.5C11 7.32843 10.3284 8 9.5 8C8.67157 8 8 7.32843 8 6.5Z"
11
+ fill="#357AB5"
12
+ />
13
+ <path
14
+ d="M16 6.5C16 5.67157 16.6716 5 17.5 5C18.3284 5 19 5.67157 19 6.5C19 7.32843 18.3284 8 17.5 8C16.6716 8 16 7.32843 16 6.5Z"
15
+ fill="#357AB5"
16
+ />
17
+ <path d="M8 13H11V14H8V13Z" fill="black" />
18
+ <path
19
+ d="M4 13.5C4 12.6716 4.67157 12 5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5Z"
20
+ fill="#357AB5"
21
+ />
22
+ <path
23
+ d="M12 13.5C12 12.6716 12.6716 12 13.5 12C14.3284 12 15 12.6716 15 13.5C15 14.3284 14.3284 15 13.5 15C12.6716 15 12 14.3284 12 13.5Z"
24
+ fill="#357AB5"
25
+ />
26
+ </svg>
27
+ )
@@ -0,0 +1,15 @@
1
+ export type {StepGroupAttributes, StepGroupOptions} from './types'
2
+ export {createStepGroupBlock} from './factory'
3
+
4
+ import type {StepGroupOptions} from './types'
5
+
6
+ export const stepGroupDefaults: StepGroupOptions = {
7
+ name: 'brilo/step-group',
8
+ parent: ['brilo/base-section'],
9
+ allowedBlocks: ['brilo/step-item'],
10
+ template: [
11
+ ['brilo/step-item', {}],
12
+ ['brilo/step-item', {}],
13
+ ['brilo/step-item', {}],
14
+ ],
15
+ }
@@ -0,0 +1,13 @@
1
+ import {BriloBlockType, OptionArray} from '~/types'
2
+ import {DEFAULT_VARIANTS} from './constants'
3
+
4
+ export type StepVariant = (typeof DEFAULT_VARIANTS)[number]['value']
5
+
6
+ export interface StepGroupAttributes<TVariant extends string = StepVariant> extends Record<string, unknown> {
7
+ variant: TVariant
8
+ disableIcon: boolean
9
+ }
10
+
11
+ export interface StepGroupOptions<TVariants extends OptionArray = typeof DEFAULT_VARIANTS> extends BriloBlockType {
12
+ variants?: TVariants
13
+ }
@@ -0,0 +1,6 @@
1
+ import {__} from '@wordpress/i18n'
2
+
3
+ export const ICON_TYPES = [
4
+ {value: 'preselected', label: __('Předdefinovaná', 'brilo-blocks')},
5
+ {value: 'media', label: __('Z médií', 'brilo-blocks')},
6
+ ] as const
@@ -0,0 +1,60 @@
1
+ import {InspectorControls, RichText} from '@wordpress/block-editor'
2
+ import {PanelBody} from '@wordpress/components'
3
+ import {__} from '@wordpress/i18n'
4
+ import clsx from 'clsx'
5
+ import {ItemIconControl, ItemIconPreview} from '~/components/ItemIconControl'
6
+ import {ICON_TYPES} from './constants'
7
+ import type {StepItemAttributes, StepItemOptions} from './types'
8
+ import {useGroupBlock} from '~/hooks/useGroupBlock'
9
+
10
+ export function createStepItemEdit(options: StepItemOptions) {
11
+ return function Edit({
12
+ attributes,
13
+ setAttributes,
14
+ }: {
15
+ attributes: StepItemAttributes
16
+ setAttributes: (a: Partial<StepItemAttributes>) => void
17
+ }) {
18
+ const {title, icon} = attributes
19
+
20
+ const {blockProps, innerBlocksProps} = useGroupBlock({
21
+ blockClassName: clsx(options.blockClassName ?? 'i-step'),
22
+ containerClassName: [options.containerClassName ?? 'i-step__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={__('Ikona', 'brilo-blocks')}>
33
+ <ItemIconControl icon={icon} setAttributes={setAttributes} iconTypes={ICON_TYPES} options={options} />
34
+ </PanelBody>
35
+ </InspectorControls>
36
+
37
+ <div {...blockProps}>
38
+ <div className="i-step__inner wp-block-inner">
39
+ <div className="i-step__icon-container">
40
+ <ItemIconPreview icon={icon} className="i-step__icon" setAttributes={setAttributes} options={options} />
41
+ </div>
42
+
43
+ <div className={clsx('i-step__body', 'grow')}>
44
+ <RichText
45
+ tagName="h3"
46
+ className="i-step__title u-text-editable"
47
+ value={title}
48
+ onChange={(v) => setAttributes({title: v})}
49
+ placeholder={__('Nadpis kroku...', 'brilo-blocks')}
50
+ allowedFormats={['core/bold', 'core/italic']}
51
+ />
52
+
53
+ <div {...innerBlocksProps} />
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </>
58
+ )
59
+ }
60
+ }
@@ -0,0 +1,18 @@
1
+ @layer base {
2
+ .i-step {
3
+ width: min(480px, 100%);
4
+ counter-increment: step-counter;
5
+ }
6
+
7
+ .i-step__icon-container {
8
+ flex-shrink: 0;
9
+ }
10
+
11
+ .i-step__inner {
12
+ &::before {
13
+ content: counter(step-counter) ".";
14
+ font-size: 18px;
15
+ font-weight: 700;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,27 @@
1
+ import type {BlockConfiguration} from '@wordpress/blocks'
2
+ import {__} from '@wordpress/i18n'
3
+ import {ICON_TYPES} from './constants'
4
+ import {createStepItemEdit} from './edit'
5
+ import type {StepItemAttributes, StepItemOptions} from './types'
6
+ import {InnerBlocks} from '@wordpress/block-editor'
7
+
8
+ export function createStepItemBlock(options: StepItemOptions): BlockConfiguration<StepItemAttributes> {
9
+ return {
10
+ name: options.name,
11
+ title: options.title ?? __('Krok položka', 'brilo-blocks'),
12
+ description: options.description,
13
+ category: options.category ?? 'layout',
14
+ ...(options.parent && {parent: options.parent}),
15
+ icon: options.icon ?? 'editor-ol',
16
+ supports: {html: false, customClassName: false},
17
+ attributes: {
18
+ title: {type: 'string', default: ''},
19
+ icon: {
20
+ type: 'object',
21
+ default: {type: ICON_TYPES[0].value, src: '', media: {id: 0, alt: ''}},
22
+ },
23
+ },
24
+ edit: createStepItemEdit(options),
25
+ save: () => <InnerBlocks.Content />,
26
+ } as unknown as BlockConfiguration<StepItemAttributes>
27
+ }
@@ -0,0 +1,11 @@
1
+ export type {StepItemAttributes, StepItemOptions} from './types'
2
+ export {createStepItemBlock} from './factory'
3
+
4
+ import type {StepItemOptions} from './types'
5
+
6
+ export const stepItemDefaults: StepItemOptions = {
7
+ name: 'brilo/step-item',
8
+ parent: ['brilo/step-group'],
9
+ icons: [],
10
+ iconsSrc: '',
11
+ }
@@ -0,0 +1,12 @@
1
+ import {BriloBlockType, Icon} from '~/types'
2
+ import type {IconType} from '~/components/IconControl'
3
+
4
+ export interface StepItemAttributes extends Record<string, unknown> {
5
+ title: string
6
+ icon: Icon
7
+ }
8
+
9
+ export interface StepItemOptions extends BriloBlockType {
10
+ icons: IconType[]
11
+ iconsSrc: string
12
+ }
@@ -0,0 +1,27 @@
1
+ import {__} from '@wordpress/i18n'
2
+
3
+ export const VARIANTS = [
4
+ {
5
+ value: 'default',
6
+ label: __('Výchozí', 'brilo-blocks'),
7
+ },
8
+ {
9
+ value: 'slider',
10
+ label: __('Slider', 'brilo-blocks'),
11
+ },
12
+ ] as const
13
+
14
+ export const SIZES = [
15
+ {
16
+ value: 'sm',
17
+ label: __('Malé', 'brilo-blocks'),
18
+ },
19
+ {
20
+ value: 'md',
21
+ label: __('Střední', 'brilo-blocks'),
22
+ },
23
+ {
24
+ value: 'lg',
25
+ label: __('Velká', 'brilo-blocks'),
26
+ },
27
+ ] as const