@brilo/base-blocks 0.1.0

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 (254) hide show
  1. package/.editorconfig +12 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +59 -0
  4. package/USAGE.md +263 -0
  5. package/biome.json +38 -0
  6. package/bun.lock +1392 -0
  7. package/docs/block-anatomy.md +73 -0
  8. package/docs/conventions.md +204 -0
  9. package/docs/new-block.md +179 -0
  10. package/package.json +41 -0
  11. package/src/blocks/column/column-group/edit.tsx +56 -0
  12. package/src/blocks/column/column-group/editor.scss +7 -0
  13. package/src/blocks/column/column-group/factory.tsx +29 -0
  14. package/src/blocks/column/column-group/index.ts +14 -0
  15. package/src/blocks/column/column-group/types.ts +8 -0
  16. package/src/blocks/column/column-item/constants.ts +1 -0
  17. package/src/blocks/column/column-item/edit.tsx +48 -0
  18. package/src/blocks/column/column-item/editor.scss +34 -0
  19. package/src/blocks/column/column-item/factory.tsx +25 -0
  20. package/src/blocks/column/column-item/index.ts +10 -0
  21. package/src/blocks/column/column-item/types.ts +7 -0
  22. package/src/blocks/compare/compare-group/constants.ts +1 -0
  23. package/src/blocks/compare/compare-group/edit.tsx +52 -0
  24. package/src/blocks/compare/compare-group/factory.tsx +29 -0
  25. package/src/blocks/compare/compare-group/icon.tsx +7 -0
  26. package/src/blocks/compare/compare-group/index.ts +13 -0
  27. package/src/blocks/compare/compare-group/types.ts +12 -0
  28. package/src/blocks/compare/compare-item/edit.tsx +38 -0
  29. package/src/blocks/compare/compare-item/editor.scss +15 -0
  30. package/src/blocks/compare/compare-item/factory.tsx +28 -0
  31. package/src/blocks/compare/compare-item/icon.tsx +9 -0
  32. package/src/blocks/compare/compare-item/index.ts +13 -0
  33. package/src/blocks/compare/compare-item/types.ts +9 -0
  34. package/src/blocks/compare/compare-option/constants.ts +7 -0
  35. package/src/blocks/compare/compare-option/edit.tsx +64 -0
  36. package/src/blocks/compare/compare-option/editor.scss +26 -0
  37. package/src/blocks/compare/compare-option/factory.tsx +35 -0
  38. package/src/blocks/compare/compare-option/icon.tsx +7 -0
  39. package/src/blocks/compare/compare-option/index.ts +8 -0
  40. package/src/blocks/compare/compare-option/types.ts +12 -0
  41. package/src/blocks/contact/contact-group/constants.ts +3 -0
  42. package/src/blocks/contact/contact-group/edit.tsx +57 -0
  43. package/src/blocks/contact/contact-group/editor.scss +20 -0
  44. package/src/blocks/contact/contact-group/factory.tsx +35 -0
  45. package/src/blocks/contact/contact-group/index.ts +12 -0
  46. package/src/blocks/contact/contact-group/types.ts +12 -0
  47. package/src/blocks/contact/contact-item/constants.ts +17 -0
  48. package/src/blocks/contact/contact-item/edit.tsx +93 -0
  49. package/src/blocks/contact/contact-item/editor.scss +38 -0
  50. package/src/blocks/contact/contact-item/factory.tsx +35 -0
  51. package/src/blocks/contact/contact-item/index.ts +23 -0
  52. package/src/blocks/contact/contact-item/types.ts +21 -0
  53. package/src/blocks/core/basic-button/constants.ts +17 -0
  54. package/src/blocks/core/basic-button/edit.tsx +107 -0
  55. package/src/blocks/core/basic-button/editor.scss +80 -0
  56. package/src/blocks/core/basic-button/factory.tsx +54 -0
  57. package/src/blocks/core/basic-button/index.ts +8 -0
  58. package/src/blocks/core/basic-button/types.ts +29 -0
  59. package/src/blocks/core/basic-heading/constants.ts +1 -0
  60. package/src/blocks/core/basic-heading/edit.tsx +76 -0
  61. package/src/blocks/core/basic-heading/editor.scss +8 -0
  62. package/src/blocks/core/basic-heading/factory.tsx +40 -0
  63. package/src/blocks/core/basic-heading/index.ts +8 -0
  64. package/src/blocks/core/basic-heading/types.ts +20 -0
  65. package/src/blocks/core/basic-overline/edit.tsx +28 -0
  66. package/src/blocks/core/basic-overline/editor.scss +14 -0
  67. package/src/blocks/core/basic-overline/factory.tsx +22 -0
  68. package/src/blocks/core/basic-overline/index.ts +8 -0
  69. package/src/blocks/core/basic-overline/types.ts +7 -0
  70. package/src/blocks/faq/faq-group/constants.ts +11 -0
  71. package/src/blocks/faq/faq-group/edit.tsx +55 -0
  72. package/src/blocks/faq/faq-group/editor.scss +11 -0
  73. package/src/blocks/faq/faq-group/factory.tsx +39 -0
  74. package/src/blocks/faq/faq-group/index.ts +11 -0
  75. package/src/blocks/faq/faq-group/types.ts +14 -0
  76. package/src/blocks/faq/faq-item/edit.tsx +50 -0
  77. package/src/blocks/faq/faq-item/editor.scss +57 -0
  78. package/src/blocks/faq/faq-item/factory.tsx +24 -0
  79. package/src/blocks/faq/faq-item/index.ts +9 -0
  80. package/src/blocks/faq/faq-item/types.ts +7 -0
  81. package/src/blocks/form/form-field/constants.ts +14 -0
  82. package/src/blocks/form/form-field/edit.tsx +178 -0
  83. package/src/blocks/form/form-field/editor.scss +71 -0
  84. package/src/blocks/form/form-field/factory.tsx +32 -0
  85. package/src/blocks/form/form-field/index.ts +10 -0
  86. package/src/blocks/form/form-field/types.ts +18 -0
  87. package/src/blocks/form/form-group/constants.ts +16 -0
  88. package/src/blocks/form/form-group/edit.tsx +190 -0
  89. package/src/blocks/form/form-group/editor.scss +41 -0
  90. package/src/blocks/form/form-group/factory.tsx +35 -0
  91. package/src/blocks/form/form-group/index.ts +18 -0
  92. package/src/blocks/form/form-group/types.ts +22 -0
  93. package/src/blocks/groups/banner-group/constants.ts +15 -0
  94. package/src/blocks/groups/banner-group/edit.tsx +122 -0
  95. package/src/blocks/groups/banner-group/editor.scss +18 -0
  96. package/src/blocks/groups/banner-group/factory.tsx +64 -0
  97. package/src/blocks/groups/banner-group/icon.tsx +13 -0
  98. package/src/blocks/groups/banner-group/index.ts +11 -0
  99. package/src/blocks/groups/banner-group/types.ts +30 -0
  100. package/src/blocks/groups/basic-header-group/constants.ts +9 -0
  101. package/src/blocks/groups/basic-header-group/edit.tsx +99 -0
  102. package/src/blocks/groups/basic-header-group/editor.scss +35 -0
  103. package/src/blocks/groups/basic-header-group/factory.tsx +46 -0
  104. package/src/blocks/groups/basic-header-group/icon.tsx +17 -0
  105. package/src/blocks/groups/basic-header-group/index.ts +9 -0
  106. package/src/blocks/groups/basic-header-group/types.ts +27 -0
  107. package/src/blocks/groups/button-group/constants.ts +7 -0
  108. package/src/blocks/groups/button-group/edit.tsx +52 -0
  109. package/src/blocks/groups/button-group/editor.scss +23 -0
  110. package/src/blocks/groups/button-group/factory.tsx +34 -0
  111. package/src/blocks/groups/button-group/index.ts +11 -0
  112. package/src/blocks/groups/button-group/types.ts +12 -0
  113. package/src/blocks/groups/text-and-media-group/constants.ts +43 -0
  114. package/src/blocks/groups/text-and-media-group/edit.tsx +241 -0
  115. package/src/blocks/groups/text-and-media-group/editor.scss +123 -0
  116. package/src/blocks/groups/text-and-media-group/factory.tsx +100 -0
  117. package/src/blocks/groups/text-and-media-group/icon.tsx +37 -0
  118. package/src/blocks/groups/text-and-media-group/index.ts +18 -0
  119. package/src/blocks/groups/text-and-media-group/types.ts +60 -0
  120. package/src/blocks/hero/hero-group/constants.ts +23 -0
  121. package/src/blocks/hero/hero-group/edit.tsx +85 -0
  122. package/src/blocks/hero/hero-group/editor.scss +0 -0
  123. package/src/blocks/hero/hero-group/factory.tsx +45 -0
  124. package/src/blocks/hero/hero-group/icon.tsx +28 -0
  125. package/src/blocks/hero/hero-group/index.ts +11 -0
  126. package/src/blocks/hero/hero-group/types.ts +22 -0
  127. package/src/blocks/hero/hero-item/constants.ts +15 -0
  128. package/src/blocks/hero/hero-item/edit.tsx +107 -0
  129. package/src/blocks/hero/hero-item/editor.scss +87 -0
  130. package/src/blocks/hero/hero-item/factory.tsx +49 -0
  131. package/src/blocks/hero/hero-item/index.ts +10 -0
  132. package/src/blocks/hero/hero-item/types.ts +38 -0
  133. package/src/blocks/map/map-group/constants.ts +20 -0
  134. package/src/blocks/map/map-group/edit.tsx +108 -0
  135. package/src/blocks/map/map-group/editor.scss +24 -0
  136. package/src/blocks/map/map-group/factory.tsx +51 -0
  137. package/src/blocks/map/map-group/index.ts +9 -0
  138. package/src/blocks/map/map-group/types.ts +16 -0
  139. package/src/blocks/newsletter/newsletter-form/constants.ts +5 -0
  140. package/src/blocks/newsletter/newsletter-form/edit.tsx +194 -0
  141. package/src/blocks/newsletter/newsletter-form/editor.scss +68 -0
  142. package/src/blocks/newsletter/newsletter-form/factory.tsx +59 -0
  143. package/src/blocks/newsletter/newsletter-form/index.ts +11 -0
  144. package/src/blocks/newsletter/newsletter-form/types.ts +45 -0
  145. package/src/blocks/post/post-slider-group/constants.ts +3 -0
  146. package/src/blocks/post/post-slider-group/edit.tsx +76 -0
  147. package/src/blocks/post/post-slider-group/factory.tsx +43 -0
  148. package/src/blocks/post/post-slider-group/icon.tsx +13 -0
  149. package/src/blocks/post/post-slider-group/index.ts +9 -0
  150. package/src/blocks/post/post-slider-group/types.ts +20 -0
  151. package/src/blocks/responsive-grid/responsive-grid-group/edit.tsx +95 -0
  152. package/src/blocks/responsive-grid/responsive-grid-group/factory.tsx +33 -0
  153. package/src/blocks/responsive-grid/responsive-grid-group/index.ts +13 -0
  154. package/src/blocks/responsive-grid/responsive-grid-group/types.ts +9 -0
  155. package/src/blocks/responsive-grid/responsive-grid-item/edit.tsx +19 -0
  156. package/src/blocks/responsive-grid/responsive-grid-item/factory.tsx +20 -0
  157. package/src/blocks/responsive-grid/responsive-grid-item/index.ts +9 -0
  158. package/src/blocks/responsive-grid/responsive-grid-item/types.ts +5 -0
  159. package/src/blocks/sections/base-section/attributes.ts +17 -0
  160. package/src/blocks/sections/base-section/constants.ts +18 -0
  161. package/src/blocks/sections/base-section/controls.tsx +70 -0
  162. package/src/blocks/sections/base-section/edit.tsx +34 -0
  163. package/src/blocks/sections/base-section/editor.scss +24 -0
  164. package/src/blocks/sections/base-section/factory.tsx +47 -0
  165. package/src/blocks/sections/base-section/icon.tsx +6 -0
  166. package/src/blocks/sections/base-section/index.ts +14 -0
  167. package/src/blocks/sections/base-section/types.ts +26 -0
  168. package/src/blocks/signpost/signpost-group/constants.ts +3 -0
  169. package/src/blocks/signpost/signpost-group/edit.tsx +75 -0
  170. package/src/blocks/signpost/signpost-group/editor.scss +0 -0
  171. package/src/blocks/signpost/signpost-group/factory.tsx +40 -0
  172. package/src/blocks/signpost/signpost-group/icon.tsx +19 -0
  173. package/src/blocks/signpost/signpost-group/index.ts +15 -0
  174. package/src/blocks/signpost/signpost-group/types.ts +9 -0
  175. package/src/blocks/signpost/signpost-item/constants.ts +4 -0
  176. package/src/blocks/signpost/signpost-item/edit.tsx +90 -0
  177. package/src/blocks/signpost/signpost-item/editor.scss +25 -0
  178. package/src/blocks/signpost/signpost-item/factory.tsx +29 -0
  179. package/src/blocks/signpost/signpost-item/icon.tsx +7 -0
  180. package/src/blocks/signpost/signpost-item/index.ts +10 -0
  181. package/src/blocks/signpost/signpost-item/types.ts +12 -0
  182. package/src/blocks/step/step-group/constants.ts +6 -0
  183. package/src/blocks/step/step-group/edit.tsx +64 -0
  184. package/src/blocks/step/step-group/editor.scss +19 -0
  185. package/src/blocks/step/step-group/factory.tsx +36 -0
  186. package/src/blocks/step/step-group/icon.tsx +27 -0
  187. package/src/blocks/step/step-group/index.ts +15 -0
  188. package/src/blocks/step/step-group/types.ts +13 -0
  189. package/src/blocks/step/step-item/constants.ts +6 -0
  190. package/src/blocks/step/step-item/edit.tsx +60 -0
  191. package/src/blocks/step/step-item/editor.scss +18 -0
  192. package/src/blocks/step/step-item/factory.tsx +27 -0
  193. package/src/blocks/step/step-item/index.ts +11 -0
  194. package/src/blocks/step/step-item/types.ts +12 -0
  195. package/src/blocks/testimonial/testimonial-group/constants.ts +27 -0
  196. package/src/blocks/testimonial/testimonial-group/edit.tsx +74 -0
  197. package/src/blocks/testimonial/testimonial-group/editor.scss +38 -0
  198. package/src/blocks/testimonial/testimonial-group/factory.tsx +44 -0
  199. package/src/blocks/testimonial/testimonial-group/icon.tsx +33 -0
  200. package/src/blocks/testimonial/testimonial-group/index.ts +15 -0
  201. package/src/blocks/testimonial/testimonial-group/types.ts +19 -0
  202. package/src/blocks/testimonial/testimonial-item/edit.tsx +48 -0
  203. package/src/blocks/testimonial/testimonial-item/editor.scss +20 -0
  204. package/src/blocks/testimonial/testimonial-item/factory.tsx +35 -0
  205. package/src/blocks/testimonial/testimonial-item/index.ts +9 -0
  206. package/src/blocks/testimonial/testimonial-item/types.ts +9 -0
  207. package/src/blocks/text-and-form/text-and-form-group/constants.ts +6 -0
  208. package/src/blocks/text-and-form/text-and-form-group/edit.tsx +59 -0
  209. package/src/blocks/text-and-form/text-and-form-group/editor.scss +21 -0
  210. package/src/blocks/text-and-form/text-and-form-group/factory.tsx +38 -0
  211. package/src/blocks/text-and-form/text-and-form-group/icon.tsx +23 -0
  212. package/src/blocks/text-and-form/text-and-form-group/index.ts +9 -0
  213. package/src/blocks/text-and-form/text-and-form-group/types.ts +23 -0
  214. package/src/blocks/text-and-form/text-and-form-text-column/constants.ts +10 -0
  215. package/src/blocks/text-and-form/text-and-form-text-column/edit.tsx +94 -0
  216. package/src/blocks/text-and-form/text-and-form-text-column/editor.scss +29 -0
  217. package/src/blocks/text-and-form/text-and-form-text-column/factory.tsx +41 -0
  218. package/src/blocks/text-and-form/text-and-form-text-column/index.ts +18 -0
  219. package/src/blocks/text-and-form/text-and-form-text-column/types.ts +23 -0
  220. package/src/blocks/usp/usp-group/constants.ts +54 -0
  221. package/src/blocks/usp/usp-group/edit.tsx +197 -0
  222. package/src/blocks/usp/usp-group/editor.scss +24 -0
  223. package/src/blocks/usp/usp-group/factory.tsx +113 -0
  224. package/src/blocks/usp/usp-group/icon.tsx +18 -0
  225. package/src/blocks/usp/usp-group/index.ts +15 -0
  226. package/src/blocks/usp/usp-group/types.ts +70 -0
  227. package/src/blocks/usp/usp-item/constants.ts +7 -0
  228. package/src/blocks/usp/usp-item/edit.tsx +65 -0
  229. package/src/blocks/usp/usp-item/editor.scss +17 -0
  230. package/src/blocks/usp/usp-item/factory.tsx +30 -0
  231. package/src/blocks/usp/usp-item/index.ts +11 -0
  232. package/src/blocks/usp/usp-item/types.ts +17 -0
  233. package/src/components/IconControl/IconControl.tsx +55 -0
  234. package/src/components/IconControl/editor.scss +53 -0
  235. package/src/components/IconControl/index.ts +2 -0
  236. package/src/components/IconControl/index.tsx +1 -0
  237. package/src/components/ImagePicker/ImagePicker.tsx +124 -0
  238. package/src/components/ImagePicker/editor.scss +79 -0
  239. package/src/components/ImagePicker/index.ts +2 -0
  240. package/src/components/ImagePicker/index.tsx +1 -0
  241. package/src/components/ItemIconControl/ItemIconControl.tsx +72 -0
  242. package/src/components/ItemIconControl/ItemIconModal.tsx +12 -0
  243. package/src/components/ItemIconControl/ItemIconPreview.tsx +93 -0
  244. package/src/components/ItemIconControl/editor.scss +52 -0
  245. package/src/components/ItemIconControl/index.ts +2 -0
  246. package/src/components/ItemIconControl/types.d.ts +30 -0
  247. package/src/constants.ts +20 -0
  248. package/src/editor.scss +34 -0
  249. package/src/globals.scss +237 -0
  250. package/src/hooks/useGroupBlock.ts +53 -0
  251. package/src/index.ts +122 -0
  252. package/src/types.ts +33 -0
  253. package/src/utils/createEditAdapter.ts +11 -0
  254. package/tsconfig.json +21 -0
@@ -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
@@ -0,0 +1,74 @@
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 {VARIANTS, SIZES} from './constants'
12
+ import type {Variant, Size, TestimonialGroupAttributes, TestimonialGroupOptions} from './types'
13
+
14
+ export function createTestimonialGroupEdit(options: TestimonialGroupOptions) {
15
+ return function Edit({
16
+ attributes,
17
+ setAttributes,
18
+ }: {
19
+ attributes: TestimonialGroupAttributes
20
+ setAttributes: (a: Partial<TestimonialGroupAttributes>) => void
21
+ }) {
22
+ const {size, isBlackAndWhite, variant} = attributes
23
+
24
+ const {blockProps, innerBlocksProps} = useGroupBlock({
25
+ blockClassName: clsx(
26
+ options.blockClassName ?? 'g-testimonial wp-block-section',
27
+ `--variant-${variant}`,
28
+ isBlackAndWhite && '--is-bw',
29
+ ),
30
+ containerClassName:
31
+ options.containerClassName ?? clsx(options.blockClassName ?? 'g-testimonial__inner-blocks u-grid-responsive', `--size-${size}`),
32
+ allowedBlocks: options.allowedBlocks,
33
+ orientation: 'horizontal',
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 Variant})}
46
+ >
47
+ {VARIANTS.map((v) => (
48
+ <ToggleGroupControlOption key={v.value} value={v.value} label={v.label} />
49
+ ))}
50
+ </ToggleGroupControl>
51
+ <ToggleGroupControl
52
+ isBlock
53
+ label={__('Velikost', 'brilo-blocks')}
54
+ value={size}
55
+ onChange={(v) => setAttributes({size: v as Size})}
56
+ >
57
+ {SIZES.map((s) => (
58
+ <ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
59
+ ))}
60
+ </ToggleGroupControl>
61
+ <ToggleControl
62
+ label={__('Zobrazovat loga černobíle', 'brilo-blocks')}
63
+ checked={isBlackAndWhite}
64
+ onChange={(v) => setAttributes({isBlackAndWhite: v})}
65
+ />
66
+ </PanelBody>
67
+ </InspectorControls>
68
+ <div {...blockProps}>
69
+ <div {...innerBlocksProps} />
70
+ </div>
71
+ </>
72
+ )
73
+ }
74
+ }
@@ -0,0 +1,38 @@
1
+ @layer base {
2
+ .g-testimonial {
3
+ &.--is-bw {
4
+ .i-testimonial__image-wrap {
5
+ filter: grayscale(100%);
6
+ opacity: 0.7;
7
+ transition:
8
+ filter 0.3s ease,
9
+ opacity 0.3s ease;
10
+
11
+ &:hover {
12
+ filter: grayscale(0%);
13
+ opacity: 1;
14
+ }
15
+ }
16
+ }
17
+ }
18
+
19
+ .g-testimonial__inner-blocks {
20
+ &.--size-sm {
21
+ --grid-min-col-size: 100px;
22
+ --grid-gap: 16px;
23
+ --grid-max-col-count: 5;
24
+ }
25
+
26
+ &.--size-md {
27
+ --grid-min-col-size: 150px;
28
+ --grid-gap: 24px;
29
+ --grid-max-col-count: 4;
30
+ }
31
+
32
+ &.--size-lg {
33
+ --grid-min-col-size: 200px;
34
+ --grid-gap: 32px;
35
+ --grid-max-col-count: 3;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,44 @@
1
+ import {InnerBlocks} from '@wordpress/block-editor'
2
+ import type {BlockConfiguration} from '@wordpress/blocks'
3
+ import {__} from '@wordpress/i18n'
4
+ import type {OptionArray} from '~/types'
5
+ import {VARIANTS, SIZES} from './constants'
6
+ import {createTestimonialGroupEdit} from './edit'
7
+ import type {TestimonialGroupAttributes, TestimonialGroupOptions} from './types'
8
+ import {icon} from './icon'
9
+
10
+ export type {TestimonialGroupAttributes, TestimonialGroupOptions}
11
+
12
+ export function createTestimonialGroupBlock<TVariants extends OptionArray = typeof VARIANTS, TSizes extends OptionArray = typeof SIZES>(
13
+ options: TestimonialGroupOptions<TVariants, TSizes>,
14
+ ): BlockConfiguration<TestimonialGroupAttributes<TVariants[number]['value'], TSizes[number]['value']>> {
15
+ const variants = options.variants ?? VARIANTS
16
+ const sizes = options.sizes ?? SIZES
17
+
18
+ return {
19
+ name: options.name,
20
+ title: options.title ?? __('Reference - loga', 'brilo-blocks'),
21
+ category: options.category ?? 'layout',
22
+ ...(options.parent && {parent: options.parent}),
23
+ supports: {html: false, customClassName: false},
24
+ icon: options.icon ?? icon,
25
+ attributes: {
26
+ variant: {
27
+ type: 'string',
28
+ default: variants[0].value,
29
+ enum: variants.map((v) => v.value),
30
+ },
31
+ size: {
32
+ type: 'string',
33
+ default: sizes[1].value,
34
+ enum: sizes.map((s) => s.value),
35
+ },
36
+ isBlackAndWhite: {
37
+ type: 'boolean',
38
+ default: true,
39
+ },
40
+ },
41
+ edit: createTestimonialGroupEdit(options as unknown as TestimonialGroupOptions),
42
+ save: () => <InnerBlocks.Content />,
43
+ } as unknown as BlockConfiguration<TestimonialGroupAttributes<TVariants[number]['value'], TSizes[number]['value']>>
44
+ }
@@ -0,0 +1,33 @@
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 4H9V5H4V4Z" fill="black" />
4
+ <path d="M10 4H16V5H10V4Z" fill="black" />
5
+ <path
6
+ 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"
7
+ fill="black"
8
+ />
9
+ <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" />
10
+ <path d="M1 9C1 8.44772 1.44772 8 2 8H3C3.55228 8 4 8.44772 4 9C4 9.55228 3.55228 10 3 10H2C1.44772 10 1 9.55228 1 9Z" fill="#357AB5" />
11
+ <path d="M6 9C6 8.44772 6.44772 8 7 8H8C8.55228 8 9 8.44772 9 9C9 9.55228 8.55228 10 8 10H7C6.44772 10 6 9.55228 6 9Z" fill="#357AB5" />
12
+ <path
13
+ d="M11 9C11 8.44772 11.4477 8 12 8H13C13.5523 8 14 8.44772 14 9C14 9.55228 13.5523 10 13 10H12C11.4477 10 11 9.55228 11 9Z"
14
+ fill="#357AB5"
15
+ />
16
+ <path
17
+ d="M16 9C16 8.44772 16.4477 8 17 8H18C18.5523 8 19 8.44772 19 9C19 9.55228 18.5523 10 18 10H17C16.4477 10 16 9.55228 16 9Z"
18
+ fill="#357AB5"
19
+ />
20
+ <path
21
+ d="M3 13C3 12.4477 3.44772 12 4 12H5C5.55228 12 6 12.4477 6 13C6 13.5523 5.55228 14 5 14H4C3.44772 14 3 13.5523 3 13Z"
22
+ fill="#357AB5"
23
+ />
24
+ <path
25
+ d="M8 13C8 12.4477 8.44772 12 9 12H11C11.5523 12 12 12.4477 12 13C12 13.5523 11.5523 14 11 14H9C8.44772 14 8 13.5523 8 13Z"
26
+ fill="#357AB5"
27
+ />
28
+ <path
29
+ d="M14 13C14 12.4477 14.4477 12 15 12H16C16.5523 12 17 12.4477 17 13C17 13.5523 16.5523 14 16 14H15C14.4477 14 14 13.5523 14 13Z"
30
+ fill="#357AB5"
31
+ />
32
+ </svg>
33
+ )
@@ -0,0 +1,15 @@
1
+ export type {TestimonialGroupAttributes} from './types'
2
+ export {createTestimonialGroupBlock} from './factory'
3
+
4
+ import {TestimonialGroupOptions} from './types'
5
+
6
+ export const testimonialGroupDefaults: TestimonialGroupOptions = {
7
+ name: 'brilo/testimonial-group',
8
+ parent: ['brilo/base-section'],
9
+ allowedBlocks: ['brilo/testimonial-item'],
10
+ template: [
11
+ ['brilo/testimonial-item', {}],
12
+ ['brilo/testimonial-item', {}],
13
+ ['brilo/testimonial-item', {}],
14
+ ],
15
+ }
@@ -0,0 +1,19 @@
1
+ import type {BriloBlockType, OptionArray} from '~/types'
2
+ import {VARIANTS, SIZES} from './constants'
3
+
4
+ export type Variant = (typeof VARIANTS)[number]['value']
5
+ export type Size = (typeof SIZES)[number]['value']
6
+
7
+ export interface TestimonialGroupAttributes<TVariant extends string = Variant, TSize extends string = Size>
8
+ extends Record<string, unknown> {
9
+ size: TSize
10
+ isBlackAndWhite: boolean
11
+ variant: TVariant
12
+ }
13
+
14
+ export interface TestimonialGroupOptions<TVariants extends OptionArray = typeof VARIANTS, TSizes extends OptionArray = typeof SIZES>
15
+ extends BriloBlockType {
16
+ allowedBlocks: string[]
17
+ variants?: TVariants
18
+ sizes?: TSizes
19
+ }