@brilo/base-blocks 0.1.8 → 0.1.10

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 (158) 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/link/link-item/edit.d.ts.map +1 -1
  51. package/build/blocks/link/link-item/edit.js +2 -2
  52. package/build/blocks/link/link-item/factory.d.ts.map +1 -1
  53. package/build/blocks/link/link-item/factory.js +1 -0
  54. package/build/blocks/link/link-item/types.d.ts +1 -0
  55. package/build/blocks/link/link-item/types.d.ts.map +1 -1
  56. package/build/blocks/map/map-group/constants.js +1 -1
  57. package/build/blocks/map/map-group/edit.d.ts.map +1 -1
  58. package/build/blocks/map/map-group/edit.js +4 -4
  59. package/build/blocks/map/map-group/factory.d.ts +2 -2
  60. package/build/blocks/map/map-group/factory.d.ts.map +1 -1
  61. package/build/blocks/map/map-group/factory.js +3 -3
  62. package/build/blocks/map/map-group/index.js +1 -1
  63. package/build/blocks/map/map-group/types.d.ts +1 -1
  64. package/build/blocks/map/map-group/types.d.ts.map +1 -1
  65. package/build/blocks/person/person-group/constants.d.ts +3 -0
  66. package/build/blocks/person/person-group/constants.d.ts.map +1 -0
  67. package/build/blocks/person/person-group/constants.js +2 -0
  68. package/build/blocks/person/person-group/edit.d.ts +6 -0
  69. package/build/blocks/person/person-group/edit.d.ts.map +1 -0
  70. package/build/blocks/person/person-group/edit.js +23 -0
  71. package/build/blocks/person/person-group/factory.d.ts +5 -0
  72. package/build/blocks/person/person-group/factory.d.ts.map +1 -0
  73. package/build/blocks/person/person-group/factory.js +32 -0
  74. package/build/blocks/person/person-group/icon.d.ts +2 -0
  75. package/build/blocks/person/person-group/icon.d.ts.map +1 -0
  76. package/build/blocks/person/person-group/icon.js +2 -0
  77. package/build/blocks/person/person-group/index.d.ts +5 -0
  78. package/build/blocks/person/person-group/index.d.ts.map +1 -0
  79. package/build/blocks/person/person-group/index.js +11 -0
  80. package/build/blocks/person/person-group/types.d.ts +8 -0
  81. package/build/blocks/person/person-group/types.d.ts.map +1 -0
  82. package/build/blocks/person/person-group/types.js +1 -0
  83. package/build/blocks/person/person-item/constants.d.ts +2 -0
  84. package/build/blocks/person/person-item/constants.d.ts.map +1 -0
  85. package/build/blocks/person/person-item/constants.js +1 -0
  86. package/build/blocks/person/person-item/edit.d.ts +6 -0
  87. package/build/blocks/person/person-item/edit.d.ts.map +1 -0
  88. package/build/blocks/person/person-item/edit.js +23 -0
  89. package/build/blocks/person/person-item/factory.d.ts +5 -0
  90. package/build/blocks/person/person-item/factory.d.ts.map +1 -0
  91. package/build/blocks/person/person-item/factory.js +26 -0
  92. package/build/blocks/person/person-item/icon.d.ts +2 -0
  93. package/build/blocks/person/person-item/icon.d.ts.map +1 -0
  94. package/build/blocks/person/person-item/icon.js +3 -0
  95. package/build/blocks/person/person-item/index.d.ts +5 -0
  96. package/build/blocks/person/person-item/index.d.ts.map +1 -0
  97. package/build/blocks/person/person-item/index.js +6 -0
  98. package/build/blocks/person/person-item/types.d.ts +12 -0
  99. package/build/blocks/person/person-item/types.d.ts.map +1 -0
  100. package/build/blocks/person/person-item/types.js +1 -0
  101. package/build/components/ImagePicker/ImagePicker.d.ts +5 -0
  102. package/build/components/ImagePicker/ImagePicker.d.ts.map +1 -1
  103. package/build/components/ImagePicker/ImagePicker.js +18 -11
  104. package/build/index.d.ts +10 -0
  105. package/build/index.d.ts.map +1 -1
  106. package/build/index.js +5 -0
  107. package/build/types.d.ts +2 -0
  108. package/build/types.d.ts.map +1 -1
  109. package/package.json +1 -1
  110. package/src/blocks/column/column-item/constants.ts +20 -0
  111. package/src/blocks/column/column-item/edit.tsx +20 -4
  112. package/src/blocks/column/column-item/factory.tsx +5 -0
  113. package/src/blocks/column/column-item/index.ts +11 -1
  114. package/src/blocks/column/column-item/types.ts +1 -0
  115. package/src/blocks/contact/contact-item/editor.scss +4 -0
  116. package/src/blocks/contact/contact-item/factory.tsx +13 -5
  117. package/src/blocks/core/basic-button/edit.tsx +50 -1
  118. package/src/blocks/core/basic-button/factory.tsx +4 -0
  119. package/src/blocks/core/basic-button/index.ts +2 -0
  120. package/src/blocks/core/basic-button/types.ts +13 -1
  121. package/src/blocks/gallery/gallery-group/constants.ts +10 -0
  122. package/src/blocks/gallery/gallery-group/edit.tsx +117 -0
  123. package/src/blocks/gallery/gallery-group/editor.scss +18 -0
  124. package/src/blocks/gallery/gallery-group/factory.tsx +36 -0
  125. package/src/blocks/gallery/gallery-group/index.ts +11 -0
  126. package/src/blocks/gallery/gallery-group/types.ts +21 -0
  127. package/src/blocks/gallery/gallery-item/edit.tsx +46 -0
  128. package/src/blocks/gallery/gallery-item/editor.scss +8 -0
  129. package/src/blocks/gallery/gallery-item/factory.tsx +26 -0
  130. package/src/blocks/gallery/gallery-item/index.ts +10 -0
  131. package/src/blocks/gallery/gallery-item/types.ts +7 -0
  132. package/src/blocks/link/link-item/edit.tsx +9 -1
  133. package/src/blocks/link/link-item/factory.tsx +1 -0
  134. package/src/blocks/link/link-item/types.ts +1 -0
  135. package/src/blocks/map/map-group/constants.ts +1 -1
  136. package/src/blocks/map/map-group/edit.tsx +14 -10
  137. package/src/blocks/map/map-group/factory.tsx +5 -5
  138. package/src/blocks/map/map-group/index.ts +1 -1
  139. package/src/blocks/map/map-group/types.ts +2 -4
  140. package/src/blocks/person/person-group/constants.ts +2 -0
  141. package/src/blocks/person/person-group/edit.tsx +65 -0
  142. package/src/blocks/person/person-group/editor.scss +0 -0
  143. package/src/blocks/person/person-group/factory.tsx +35 -0
  144. package/src/blocks/person/person-group/icon.tsx +14 -0
  145. package/src/blocks/person/person-group/index.ts +15 -0
  146. package/src/blocks/person/person-group/types.ts +8 -0
  147. package/src/blocks/person/person-item/constants.ts +4 -0
  148. package/src/blocks/person/person-item/edit.tsx +103 -0
  149. package/src/blocks/person/person-item/editor.scss +35 -0
  150. package/src/blocks/person/person-item/factory.tsx +29 -0
  151. package/src/blocks/person/person-item/icon.tsx +7 -0
  152. package/src/blocks/person/person-item/index.ts +10 -0
  153. package/src/blocks/person/person-item/types.ts +12 -0
  154. package/src/components/ImagePicker/ImagePicker.tsx +22 -10
  155. package/src/components/ImagePicker/editor.scss +2 -2
  156. package/src/editor.scss +4 -0
  157. package/src/index.ts +10 -0
  158. package/src/types.ts +3 -0
@@ -0,0 +1,46 @@
1
+ import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
2
+ import {PanelBody} from '@wordpress/components'
3
+ import {__} from '@wordpress/i18n'
4
+ import clsx from 'clsx'
5
+ import type {GalleryItemAttributes, GalleryItemOptions} from './types'
6
+ import {ImagePickerControl} from '~/components/ImagePicker/ImagePicker'
7
+
8
+ export function createGalleryItemEdit(_options: GalleryItemOptions) {
9
+ return function Edit({
10
+ attributes,
11
+ setAttributes,
12
+ }: {
13
+ attributes: GalleryItemAttributes
14
+ setAttributes: (a: Partial<GalleryItemAttributes>) => void
15
+ }) {
16
+ const {img} = attributes
17
+
18
+ const blockProps = useBlockProps({className: clsx('i-gallery')})
19
+
20
+ return (
21
+ <>
22
+ <InspectorControls>
23
+ <PanelBody title={__('Obrázek', 'brilo-blocks')}>
24
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
25
+ </PanelBody>
26
+ </InspectorControls>
27
+
28
+ <div {...blockProps}>
29
+ <div className="i-gallery__image-wrapper">
30
+ {img.id ? (
31
+ <ImagePickerControl value={img} onChange={(val) => setAttributes({img: val})} />
32
+ ) : (
33
+ <div className="i-gallery__image-placeholder">
34
+ <ImagePickerControl
35
+ labels={{select: __('Vybrat obrázek', 'brilo-blocks')}}
36
+ value={img}
37
+ onChange={(val) => setAttributes({img: val})}
38
+ />
39
+ </div>
40
+ )}
41
+ </div>
42
+ </div>
43
+ </>
44
+ )
45
+ }
46
+ }
@@ -0,0 +1,8 @@
1
+ .i-gallery__image-wrapper {
2
+ padding: 8px;
3
+ background: #f5f5f5;
4
+ }
5
+
6
+ .i-gallery {
7
+ width: 100%;
8
+ }
@@ -0,0 +1,26 @@
1
+ import type {BlockConfiguration} from '@wordpress/blocks'
2
+ import {__} from '@wordpress/i18n'
3
+ import {createGalleryItemEdit} from './edit'
4
+ import type {GalleryItemAttributes, GalleryItemOptions} from './types'
5
+
6
+ export type {GalleryItemAttributes, GalleryItemOptions}
7
+
8
+ export function createGalleryItemBlock(options: GalleryItemOptions): BlockConfiguration<GalleryItemAttributes> {
9
+ return {
10
+ name: options.name,
11
+ title: options.title ?? __('Gallery Item', 'brilo-blocks'),
12
+ description: options.description,
13
+ category: options.category ?? 'layout',
14
+ ...(options.parent && {parent: options.parent}),
15
+ icon: options.icon ?? 'format-image',
16
+ supports: {html: false, customClassName: false},
17
+ attributes: {
18
+ img: {
19
+ type: 'object',
20
+ default: {id: 0, alt: ''},
21
+ },
22
+ },
23
+ edit: createGalleryItemEdit(options),
24
+ save: () => null,
25
+ } as unknown as BlockConfiguration<GalleryItemAttributes>
26
+ }
@@ -0,0 +1,10 @@
1
+ import {GalleryItemOptions} from './types'
2
+
3
+ export type {GalleryItemAttributes, GalleryItemOptions} from './types'
4
+ export {createGalleryItemBlock} from './factory'
5
+
6
+ export const galleryItemDefaults: GalleryItemOptions = {
7
+ name: 'brilo/gallery-item',
8
+ parent: ['brilo/gallery-group'],
9
+ template: [],
10
+ }
@@ -0,0 +1,7 @@
1
+ import type {BriloBlockType, Media} from '~/types'
2
+
3
+ export interface GalleryItemAttributes extends Record<string, unknown> {
4
+ img: Media
5
+ }
6
+
7
+ export interface GalleryItemOptions extends BriloBlockType {}
@@ -22,7 +22,7 @@ export function createLinkItemEdit(options: LinkItemOptions) {
22
22
  attributes: LinkItemAttributes
23
23
  setAttributes: (a: Partial<LinkItemAttributes>) => void
24
24
  }) {
25
- const {title, url, icon, color, underline_initial} = attributes
25
+ const {title, url, icon, color, underline_initial, size} = attributes
26
26
  const {paletteColors} = useTenantColorPalette()
27
27
  const hasIcon = icon.type !== 'none' && (icon.src || icon.media?.id)
28
28
 
@@ -87,6 +87,14 @@ export function createLinkItemEdit(options: LinkItemOptions) {
87
87
  checked={underline_initial}
88
88
  onChange={(v) => setAttributes({underline_initial: v})}
89
89
  />
90
+ <RangeControl
91
+ label={__('Velikost textu (px)', 'brilo-blocks')}
92
+ value={size}
93
+ onChange={(v) => setAttributes({size: v ?? 16})}
94
+ min={8}
95
+ max={80}
96
+ step={1}
97
+ />
90
98
  </PanelBody>
91
99
  </InspectorControls>
92
100
 
@@ -21,6 +21,7 @@ export function createLinkItemBlock(options: LinkItemOptions): BlockConfiguratio
21
21
  default: {type: 'none', src: '', media: {}, position: 'after', size: 24},
22
22
  },
23
23
  color: {type: 'string', default: ''},
24
+ size: {type: 'number', default: 16},
24
25
  underline_initial: {type: 'boolean', default: false},
25
26
  },
26
27
  edit: createLinkItemEdit(options),
@@ -15,6 +15,7 @@ export interface LinkItemAttributes extends Record<string, unknown> {
15
15
  url: {src: string; blank: boolean}
16
16
  icon: LinkItemIcon
17
17
  color: string
18
+ size: number
18
19
  underline_initial: boolean
19
20
  }
20
21
 
@@ -1,5 +1,5 @@
1
1
  import {__} from '@wordpress/i18n'
2
- import {HEADING_STYLES} from "~/constants";
2
+ import {HEADING_STYLES} from '~/constants'
3
3
 
4
4
  export const DEFAULT_HEADING_STYLES = HEADING_STYLES
5
5
 
@@ -1,24 +1,28 @@
1
1
  import {InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
2
2
  import {
3
- PanelBody, BaseControl, TextControl, SelectControl, TextareaControl,
3
+ PanelBody,
4
+ BaseControl,
5
+ TextControl,
6
+ SelectControl,
7
+ TextareaControl,
4
8
  __experimentalToggleGroupControl as ToggleGroupControl,
5
- __experimentalToggleGroupControlOption as ToggleGroupControlOption
9
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
6
10
  } from '@wordpress/components'
7
11
  import {__} from '@wordpress/i18n'
8
12
  import {ImagePickerControl} from '~/components/ImagePicker'
9
13
  import {MAP_TYPES} from './constants'
10
14
  import type {MapGroupAttributes, MapGroupOptions} from './types'
11
15
  import {Icon, mapMarker} from '@wordpress/icons'
12
- import {useGroupBlock} from "~/hooks/useGroupBlock";
13
- import clsx from "clsx";
14
- import type {HeadingLevels, HeadingStyles} from "~/blocks/groups/banner-group/types";
15
- import {HEADING_LEVELS, HEADING_STYLES} from "~/constants";
16
+ import {useGroupBlock} from '~/hooks/useGroupBlock'
17
+ import clsx from 'clsx'
18
+ import type {HeadingLevels, HeadingStyles} from '~/blocks/groups/banner-group/types'
19
+ import {HEADING_LEVELS, HEADING_STYLES} from '~/constants'
16
20
 
17
21
  export function createMapGroupEdit(options: MapGroupOptions) {
18
22
  return function Edit({
19
- attributes,
20
- setAttributes,
21
- }: {
23
+ attributes,
24
+ setAttributes,
25
+ }: {
22
26
  attributes: MapGroupAttributes
23
27
  setAttributes: (a: Partial<MapGroupAttributes>) => void
24
28
  }) {
@@ -60,7 +64,7 @@ export function createMapGroupEdit(options: MapGroupOptions) {
60
64
  ))}
61
65
  </ToggleGroupControl>
62
66
  </PanelBody>
63
-
67
+
64
68
  <PanelBody title={__('Nastavení mapy', 'brilo-blocks')}>
65
69
  <SelectControl
66
70
  label={__('Typ mapy', 'brilo-blocks')}
@@ -3,15 +3,15 @@ import {__} from '@wordpress/i18n'
3
3
  import {createMapGroupEdit} from './edit'
4
4
  import type {MapGroupAttributes, MapGroupOptions} from './types'
5
5
  import {MAP_TYPES} from './constants'
6
- import type {StringArray} from "~/types";
7
- import {DEFAULT_HEADING_STYLES, DEFAULT_VARIANTS} from "~/blocks/groups/banner-group/constants";
8
- import {InnerBlocks} from "@wordpress/block-editor";
9
- import {HEADING_LEVELS} from "~/constants";
6
+ import type {StringArray} from '~/types'
7
+ import {DEFAULT_HEADING_STYLES, DEFAULT_VARIANTS} from '~/blocks/groups/banner-group/constants'
8
+ import {InnerBlocks} from '@wordpress/block-editor'
9
+ import {HEADING_LEVELS} from '~/constants'
10
10
 
11
11
  export type {MapGroupAttributes, MapGroupOptions}
12
12
 
13
13
  export function createMapGroupBlock<THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES>(
14
- options: MapGroupOptions<THeadingStyles>
14
+ options: MapGroupOptions<THeadingStyles>,
15
15
  ): BlockConfiguration<MapGroupAttributes<THeadingStyles[number]>> {
16
16
  const headingStyles = options.headingStyles ?? DEFAULT_HEADING_STYLES
17
17
 
@@ -6,5 +6,5 @@ import type {MapGroupOptions} from './types'
6
6
  export const mapGroupDefaults: MapGroupOptions = {
7
7
  name: 'brilo/map-group',
8
8
  parent: ['brilo/base-section'],
9
- allowedBlocks: ['brilo/button-group', 'brilo/basic-button']
9
+ allowedBlocks: ['brilo/button-group', 'brilo/basic-button'],
10
10
  }
@@ -1,6 +1,6 @@
1
1
  import {BriloBlockType, Media, type OptionArray, type StringArray} from '~/types'
2
2
  import {DEFAULT_HEADING_STYLES, MAP_TYPES} from './constants'
3
- import {HEADING_LEVELS} from "~/constants";
3
+ import {HEADING_LEVELS} from '~/constants'
4
4
 
5
5
  export type MapType = (typeof MAP_TYPES)[number]['value']
6
6
 
@@ -22,9 +22,7 @@ export interface MapGroupAttributes<THeadingStyle extends string = HeadingStyles
22
22
  long: string
23
23
  }
24
24
 
25
- export interface MapGroupOptions<
26
- THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES,
27
- > extends BriloBlockType {
25
+ export interface MapGroupOptions<THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES> extends BriloBlockType {
28
26
  headingStyles?: THeadingStyles
29
27
  headingLevels?: HeadingLevels
30
28
  }
@@ -0,0 +1,2 @@
1
+ export const COLUMNS = [4, 3, 2] as const
2
+ export const HEADING_LEVELS = [2, 3, 4] as const
@@ -0,0 +1,65 @@
1
+ import {InspectorControls} from '@wordpress/block-editor'
2
+ import {
3
+ PanelBody,
4
+ __experimentalToggleGroupControl as ToggleGroupControl,
5
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
6
+ } from '@wordpress/components'
7
+ import {__} from '@wordpress/i18n'
8
+ import clsx from 'clsx'
9
+ import {useGroupBlock} from '~/hooks/useGroupBlock'
10
+ import {COLUMNS, HEADING_LEVELS} from './constants'
11
+ import type {PersonGroupAttributes, PersonGroupOptions} from './types'
12
+
13
+ export function createPersonGroupEdit(options: PersonGroupOptions) {
14
+ return function Edit({
15
+ attributes,
16
+ setAttributes,
17
+ }: {
18
+ attributes: PersonGroupAttributes
19
+ setAttributes: (a: Partial<PersonGroupAttributes>) => void
20
+ }) {
21
+ const {columns, headingLevel} = attributes
22
+
23
+ const {blockProps, innerBlocksProps} = useGroupBlock({
24
+ blockClassName: clsx(options.blockClassName ?? 'g-person wp-block-section'),
25
+ containerClassName: [options.containerClassName ?? 'u-grid-responsive', `--cols-${columns}`],
26
+ containerStyle: {'--grid-max-col-count': columns},
27
+ allowedBlocks: options.allowedBlocks,
28
+ orientation: 'horizontal',
29
+ template: options.template,
30
+ layout: {type: 'default'},
31
+ })
32
+
33
+ return (
34
+ <>
35
+ <InspectorControls>
36
+ <PanelBody title={__('Rozložení', 'brilo-blocks')}>
37
+ <ToggleGroupControl
38
+ isBlock
39
+ label={__('Počet sloupců', 'brilo-blocks')}
40
+ value={String(columns)}
41
+ onChange={(v) => setAttributes({columns: Number(v) as PersonGroupAttributes['columns']})}
42
+ >
43
+ {COLUMNS.map((c) => (
44
+ <ToggleGroupControlOption key={c} value={String(c)} label={String(c)} />
45
+ ))}
46
+ </ToggleGroupControl>
47
+ <ToggleGroupControl
48
+ isBlock
49
+ label={__('Úroveň nadpisu položek', 'brilo-blocks')}
50
+ value={String(headingLevel)}
51
+ onChange={(v) => setAttributes({headingLevel: Number(v)})}
52
+ >
53
+ {HEADING_LEVELS.map((l) => (
54
+ <ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
55
+ ))}
56
+ </ToggleGroupControl>
57
+ </PanelBody>
58
+ </InspectorControls>
59
+ <div {...blockProps}>
60
+ <div {...innerBlocksProps} />
61
+ </div>
62
+ </>
63
+ )
64
+ }
65
+ }
File without changes
@@ -0,0 +1,35 @@
1
+ import {InnerBlocks} from '@wordpress/block-editor'
2
+ import type {BlockConfiguration} from '@wordpress/blocks'
3
+ import {__} from '@wordpress/i18n'
4
+ import {COLUMNS, HEADING_LEVELS} from './constants'
5
+ import {createPersonGroupEdit} from './edit'
6
+ import {icon as defaultIcon} from './icon'
7
+ import type {PersonGroupAttributes, PersonGroupOptions} from './types'
8
+
9
+ export type {PersonGroupAttributes, PersonGroupOptions}
10
+
11
+ export function createPersonGroupBlock(options: PersonGroupOptions): BlockConfiguration<PersonGroupAttributes> {
12
+ return {
13
+ name: options.name,
14
+ title: options.title ?? __('Osoby', '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
+ headingLevel: {
27
+ type: 'number',
28
+ default: HEADING_LEVELS[0],
29
+ enum: [...HEADING_LEVELS],
30
+ },
31
+ },
32
+ edit: createPersonGroupEdit(options),
33
+ save: () => <InnerBlocks.Content />,
34
+ } as unknown as BlockConfiguration<PersonGroupAttributes>
35
+ }
@@ -0,0 +1,14 @@
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="2.5" y="1.5" width="15" height="17" stroke="black" fill="none" />
4
+ <path d="M7 13H13V14H7V13Z" fill="black" />
5
+ <path d="M6 15H14V16H6V15Z" fill="black" />
6
+ <path d="M8 6C8 4.89543 8.89543 4 10 4C11.1046 4 12 4.89543 12 6C12 7.10457 11.1046 8 10 8C8.89543 8 8 7.10457 8 6Z" fill="#357AB5" />
7
+ <path
8
+ fill-rule="evenodd"
9
+ clip-rule="evenodd"
10
+ d="M6.99664 11H13.0009C12.9997 9.34295 11.6561 8 9.99875 8C8.34144 8 6.99778 9.34295 6.99664 11Z"
11
+ fill="#357AB5"
12
+ />
13
+ </svg>
14
+ )
@@ -0,0 +1,15 @@
1
+ export type {PersonGroupAttributes, PersonGroupOptions} from './types'
2
+ export {createPersonGroupBlock} from './factory'
3
+
4
+ import type {PersonGroupOptions} from './types'
5
+
6
+ export const personGroupDefaults: PersonGroupOptions = {
7
+ name: 'brilo/person-group',
8
+ parent: ['brilo/base-section'],
9
+ allowedBlocks: ['brilo/person-item'],
10
+ template: [
11
+ ['brilo/person-item', {}],
12
+ ['brilo/person-item', {}],
13
+ ['brilo/person-item', {}],
14
+ ],
15
+ }
@@ -0,0 +1,8 @@
1
+ import {BriloBlockType} from '~/types'
2
+
3
+ export interface PersonGroupAttributes extends Record<string, unknown> {
4
+ columns: number
5
+ headingLevel: number
6
+ }
7
+
8
+ export interface PersonGroupOptions 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,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 {}