@brilo/base-blocks 0.1.43 → 0.1.44

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 (99) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/blocks/compare/compare-group/constants.d.ts +27 -0
  3. package/build/blocks/compare/compare-group/constants.d.ts.map +1 -1
  4. package/build/blocks/compare/compare-group/constants.js +23 -0
  5. package/build/blocks/compare/compare-group/edit.d.ts.map +1 -1
  6. package/build/blocks/compare/compare-group/edit.js +12 -7
  7. package/build/blocks/compare/compare-group/factory.d.ts.map +1 -1
  8. package/build/blocks/compare/compare-group/factory.js +10 -1
  9. package/build/blocks/compare/compare-group/index.d.ts +1 -1
  10. package/build/blocks/compare/compare-group/index.d.ts.map +1 -1
  11. package/build/blocks/compare/compare-group/types.d.ts +7 -1
  12. package/build/blocks/compare/compare-group/types.d.ts.map +1 -1
  13. package/build/blocks/compare/compare-item/edit.d.ts.map +1 -1
  14. package/build/blocks/compare/compare-item/edit.js +6 -4
  15. package/build/blocks/compare/compare-item/factory.d.ts.map +1 -1
  16. package/build/blocks/compare/compare-item/factory.js +4 -0
  17. package/build/blocks/compare/compare-item/types.d.ts +2 -0
  18. package/build/blocks/compare/compare-item/types.d.ts.map +1 -1
  19. package/build/blocks/core/basic-icon/buildPreviewStyle.d.ts +8 -0
  20. package/build/blocks/core/basic-icon/buildPreviewStyle.d.ts.map +1 -0
  21. package/build/blocks/core/basic-icon/buildPreviewStyle.js +22 -0
  22. package/build/blocks/core/basic-icon/constants.d.ts +84 -0
  23. package/build/blocks/core/basic-icon/constants.d.ts.map +1 -0
  24. package/build/blocks/core/basic-icon/constants.js +41 -0
  25. package/build/blocks/core/basic-icon/edit.d.ts +6 -0
  26. package/build/blocks/core/basic-icon/edit.d.ts.map +1 -0
  27. package/build/blocks/core/basic-icon/edit.js +22 -0
  28. package/build/blocks/core/basic-icon/factory.d.ts +5 -0
  29. package/build/blocks/core/basic-icon/factory.d.ts.map +1 -0
  30. package/build/blocks/core/basic-icon/factory.js +38 -0
  31. package/build/blocks/core/basic-icon/index.d.ts +5 -0
  32. package/build/blocks/core/basic-icon/index.d.ts.map +1 -0
  33. package/build/blocks/core/basic-icon/index.js +7 -0
  34. package/build/blocks/core/basic-icon/types.d.ts +30 -0
  35. package/build/blocks/core/basic-icon/types.d.ts.map +1 -0
  36. package/build/blocks/core/basic-icon/types.js +1 -0
  37. package/build/blocks/faq/faq-group/constants.d.ts +29 -0
  38. package/build/blocks/faq/faq-group/constants.d.ts.map +1 -1
  39. package/build/blocks/faq/faq-group/constants.js +15 -0
  40. package/build/blocks/faq/faq-group/edit.d.ts.map +1 -1
  41. package/build/blocks/faq/faq-group/edit.js +12 -5
  42. package/build/blocks/faq/faq-group/factory.d.ts.map +1 -1
  43. package/build/blocks/faq/faq-group/factory.js +35 -17
  44. package/build/blocks/faq/faq-group/index.d.ts +1 -1
  45. package/build/blocks/faq/faq-group/index.d.ts.map +1 -1
  46. package/build/blocks/faq/faq-group/types.d.ts +20 -1
  47. package/build/blocks/faq/faq-group/types.d.ts.map +1 -1
  48. package/build/blocks/review/review-group/constants.d.ts +10 -0
  49. package/build/blocks/review/review-group/constants.d.ts.map +1 -1
  50. package/build/blocks/review/review-group/constants.js +5 -0
  51. package/build/blocks/review/review-group/edit.d.ts.map +1 -1
  52. package/build/blocks/review/review-group/edit.js +8 -5
  53. package/build/blocks/review/review-group/factory.d.ts.map +1 -1
  54. package/build/blocks/review/review-group/factory.js +34 -21
  55. package/build/blocks/review/review-group/index.d.ts +1 -1
  56. package/build/blocks/review/review-group/index.d.ts.map +1 -1
  57. package/build/blocks/review/review-group/types.d.ts +10 -1
  58. package/build/blocks/review/review-group/types.d.ts.map +1 -1
  59. package/build/blocks/video/video-group/edit.d.ts.map +1 -1
  60. package/build/blocks/video/video-group/edit.js +2 -2
  61. package/build/blocks/video/video-group/factory.d.ts.map +1 -1
  62. package/build/blocks/video/video-group/factory.js +4 -0
  63. package/build/blocks/video/video-group/types.d.ts +1 -0
  64. package/build/blocks/video/video-group/types.d.ts.map +1 -1
  65. package/build/index.d.ts +2 -0
  66. package/build/index.d.ts.map +1 -1
  67. package/build/index.js +1 -0
  68. package/package.json +1 -1
  69. package/src/blocks/compare/compare-group/constants.ts +27 -0
  70. package/src/blocks/compare/compare-group/edit.tsx +27 -4
  71. package/src/blocks/compare/compare-group/factory.tsx +10 -1
  72. package/src/blocks/compare/compare-group/index.ts +7 -1
  73. package/src/blocks/compare/compare-group/types.ts +5 -1
  74. package/src/blocks/compare/compare-item/edit.tsx +32 -13
  75. package/src/blocks/compare/compare-item/editor.scss +16 -0
  76. package/src/blocks/compare/compare-item/factory.tsx +4 -0
  77. package/src/blocks/compare/compare-item/types.ts +2 -0
  78. package/src/blocks/core/basic-icon/buildPreviewStyle.ts +40 -0
  79. package/src/blocks/core/basic-icon/constants.ts +48 -0
  80. package/src/blocks/core/basic-icon/edit.tsx +170 -0
  81. package/src/blocks/core/basic-icon/editor.scss +119 -0
  82. package/src/blocks/core/basic-icon/factory.tsx +42 -0
  83. package/src/blocks/core/basic-icon/index.ts +17 -0
  84. package/src/blocks/core/basic-icon/types.ts +34 -0
  85. package/src/blocks/faq/faq-group/constants.ts +18 -0
  86. package/src/blocks/faq/faq-group/edit.tsx +118 -4
  87. package/src/blocks/faq/faq-group/factory.tsx +33 -13
  88. package/src/blocks/faq/faq-group/index.ts +9 -1
  89. package/src/blocks/faq/faq-group/types.ts +22 -1
  90. package/src/blocks/review/review-group/constants.ts +6 -0
  91. package/src/blocks/review/review-group/edit.tsx +47 -3
  92. package/src/blocks/review/review-group/factory.tsx +31 -16
  93. package/src/blocks/review/review-group/index.ts +10 -1
  94. package/src/blocks/review/review-group/types.ts +11 -1
  95. package/src/blocks/video/video-group/edit.tsx +8 -1
  96. package/src/blocks/video/video-group/factory.tsx +4 -0
  97. package/src/blocks/video/video-group/types.ts +1 -0
  98. package/src/editor.scss +1 -0
  99. package/src/index.ts +7 -0
@@ -0,0 +1,34 @@
1
+ import type {IconType} from '~/components/IconControl'
2
+ import type {BriloBlockType, Icon} from '~/types'
3
+ import type {DEFAULT_ALIGNMENTS, DEFAULT_ICON_BACKGROUND_SHAPES} from './constants'
4
+
5
+ export type BasicIconAlignment = (typeof DEFAULT_ALIGNMENTS)[number]['value']
6
+ export type BasicIconBackgroundShape = (typeof DEFAULT_ICON_BACKGROUND_SHAPES)[number]['value']
7
+
8
+ export interface BasicIconSizePreset {
9
+ value: number
10
+ label: string
11
+ }
12
+
13
+ export interface BasicIconStyle {
14
+ align: BasicIconAlignment
15
+ icon: {
16
+ size: number
17
+ color: string
18
+ background: string
19
+ backgroundSize: number
20
+ backgroundShape: BasicIconBackgroundShape
21
+ borderColor: string
22
+ borderWidth: number
23
+ }
24
+ }
25
+
26
+ export interface BasicIconAttributes extends Record<string, unknown> {
27
+ icon: Icon
28
+ style: BasicIconStyle
29
+ }
30
+
31
+ export interface BasicIconOptions extends BriloBlockType {
32
+ icons: IconType[]
33
+ iconsSrc: string
34
+ }
@@ -9,3 +9,21 @@ export const DEFAULT_ICON_VARIANTS = [
9
9
  {value: 'info', label: __('Informace', 'brilo-blocks')},
10
10
  {value: 'message', label: __('Zpráva', 'brilo-blocks')},
11
11
  ] as const
12
+
13
+ export const DEFAULT_SHADOWS = [
14
+ {value: 'none', label: __('Žádný', 'brilo-blocks')},
15
+ {value: 'sm', label: __('Malý', 'brilo-blocks')},
16
+ {value: 'md', label: __('Střední', 'brilo-blocks')},
17
+ ] as const
18
+
19
+ export const DEFAULT_ICON_SIZE = 24
20
+ export const ICON_SIZE_MIN = 12
21
+ export const ICON_SIZE_MAX = 64
22
+
23
+ export const DEFAULT_ICON_SIZE_PRESETS = [
24
+ {value: 16, label: __('XS', 'brilo-blocks')},
25
+ {value: 20, label: __('SM', 'brilo-blocks')},
26
+ {value: 24, label: __('MD', 'brilo-blocks')},
27
+ {value: 32, label: __('LG', 'brilo-blocks')},
28
+ {value: 40, label: __('XL', 'brilo-blocks')},
29
+ ] as const
@@ -1,12 +1,60 @@
1
1
  import {InspectorControls} from '@wordpress/block-editor'
2
- import {PanelBody, SelectControl} from '@wordpress/components'
2
+ import {
3
+ BaseControl,
4
+ Button,
5
+ ColorPalette,
6
+ PanelBody,
7
+ RangeControl,
8
+ SelectControl,
9
+ __experimentalToggleGroupControl as ToggleGroupControl,
10
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
11
+ } from '@wordpress/components'
3
12
  import {__} from '@wordpress/i18n'
4
13
  import {useGroupBlock} from '~/hooks/useGroupBlock'
5
- import {DEFAULT_ICON_VARIANTS, FAQ_HEADING_LEVELS} from './constants'
6
- import type {FaqGroupAttributes, FaqGroupOptions, FaqHeadingLevel, FaqIconVariant} from './types'
14
+ import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
15
+ import {
16
+ DEFAULT_ICON_SIZE_PRESETS,
17
+ DEFAULT_ICON_VARIANTS,
18
+ DEFAULT_SHADOWS,
19
+ FAQ_HEADING_LEVELS,
20
+ ICON_SIZE_MAX,
21
+ ICON_SIZE_MIN,
22
+ } from './constants'
23
+ import type {FaqGroupAttributes, FaqGroupOptions, FaqHeadingLevel, FaqIconVariant, FaqShadow, FaqSizePreset} from './types'
24
+
25
+ function PresetSizeControl({
26
+ label,
27
+ value,
28
+ presets,
29
+ min,
30
+ max,
31
+ onChange,
32
+ }: {
33
+ label: string
34
+ value: number
35
+ presets: readonly FaqSizePreset[]
36
+ min: number
37
+ max: number
38
+ onChange: (v: number) => void
39
+ }) {
40
+ return (
41
+ <BaseControl label={label} id={`faq-group-size-${label}`}>
42
+ <div style={{display: 'flex', gap: 4, marginBottom: 8, flexWrap: 'wrap'}}>
43
+ {presets.map((p) => (
44
+ <Button key={p.label} variant={value === p.value ? 'primary' : 'secondary'} size="small" onClick={() => onChange(p.value)}>
45
+ {p.label}
46
+ </Button>
47
+ ))}
48
+ </div>
49
+ <RangeControl value={value} onChange={(v) => onChange(v ?? min)} min={min} max={max} step={1} withInputField />
50
+ </BaseControl>
51
+ )
52
+ }
7
53
 
8
54
  export function createFaqGroupEdit(options: FaqGroupOptions) {
9
55
  const ICON_VARIANTS = options.iconVariants ?? DEFAULT_ICON_VARIANTS
56
+ const ICON_SIZE_PRESETS = options.iconSizePresets ?? DEFAULT_ICON_SIZE_PRESETS
57
+ const exclude = options.exclude ?? []
10
58
 
11
59
  return function Edit({
12
60
  attributes,
@@ -15,7 +63,8 @@ export function createFaqGroupEdit(options: FaqGroupOptions) {
15
63
  attributes: FaqGroupAttributes
16
64
  setAttributes: (a: Partial<FaqGroupAttributes>) => void
17
65
  }) {
18
- const {headingLevel, iconVariant} = attributes
66
+ const {headingLevel, iconVariant, style} = attributes
67
+ const {paletteColors} = useTenantColorPalette()
19
68
 
20
69
  const {blockProps, innerBlocksProps} = useGroupBlock({
21
70
  blockClassName: options.blockClassName ?? 'g-faq wp-block-section',
@@ -44,7 +93,72 @@ export function createFaqGroupEdit(options: FaqGroupOptions) {
44
93
  options={ICON_VARIANTS.map((v) => ({value: v.value, label: v.label}))}
45
94
  onChange={(value) => setAttributes({iconVariant: value as FaqIconVariant})}
46
95
  />
96
+ {!exclude.includes('colors') && style && (
97
+ <>
98
+ <PresetSizeControl
99
+ label={__('Velikost', 'brilo-blocks')}
100
+ value={style.icon.size}
101
+ presets={ICON_SIZE_PRESETS}
102
+ min={ICON_SIZE_MIN}
103
+ max={ICON_SIZE_MAX}
104
+ onChange={(v) => setAttributes({style: {...style, icon: {...style.icon, size: v}}})}
105
+ />
106
+ <BaseControl label={__('Barva', 'brilo-blocks')} id="faq-group-icon-color">
107
+ <ColorPalette
108
+ colors={paletteColors}
109
+ value={style.icon.color || undefined}
110
+ onChange={(value) => setAttributes({style: {...style, icon: {...style.icon, color: value ?? ''}}})}
111
+ />
112
+ </BaseControl>
113
+ <BaseControl label={__('Pozadí', 'brilo-blocks')} id="faq-group-icon-background-color">
114
+ <ColorPalette
115
+ colors={paletteColors}
116
+ value={style.icon.background || undefined}
117
+ onChange={(value) => setAttributes({style: {...style, icon: {...style.icon, background: value ?? ''}}})}
118
+ />
119
+ </BaseControl>
120
+ </>
121
+ )}
47
122
  </PanelBody>
123
+ {!exclude.includes('colors') && style && (
124
+ <PanelBody title={__('Styl', 'brilo-blocks')}>
125
+ <ToggleGroupControl
126
+ isBlock
127
+ label={__('Stín', 'brilo-blocks')}
128
+ value={style.shadow}
129
+ onChange={(v) => setAttributes({style: {...style, shadow: v as FaqShadow}})}
130
+ >
131
+ {DEFAULT_SHADOWS.map((s) => (
132
+ <ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
133
+ ))}
134
+ </ToggleGroupControl>
135
+ <BaseControl
136
+ label={__('Barva okraje', 'brilo-blocks')}
137
+ help={__('Bez vybrané barvy se okraj nevykreslí.', 'brilo-blocks')}
138
+ id="faq-group-border-color"
139
+ >
140
+ <ColorPalette
141
+ colors={paletteColors}
142
+ value={style.borderColor || undefined}
143
+ onChange={(value) => setAttributes({style: {...style, borderColor: value ?? ''}})}
144
+ />
145
+ </BaseControl>
146
+ <BaseControl label={__('Barva pozadí', 'brilo-blocks')} id="faq-group-background-color">
147
+ <ColorPalette
148
+ colors={paletteColors}
149
+ value={style.backgroundColor || undefined}
150
+ onChange={(value) => setAttributes({style: {...style, backgroundColor: value ?? ''}})}
151
+ />
152
+ </BaseControl>
153
+ <BaseControl label={__('Barva textu', 'brilo-blocks')} id="faq-group-text-color">
154
+ <ColorPalette
155
+ colors={paletteColors}
156
+ value={style.textColor || undefined}
157
+ onChange={(value) => setAttributes({style: {...style, textColor: value ?? ''}})}
158
+ />
159
+ </BaseControl>
160
+ </PanelBody>
161
+ )}
48
162
  </InspectorControls>
49
163
  <div {...blockProps}>
50
164
  <div {...innerBlocksProps} />
@@ -2,7 +2,7 @@ import {InnerBlocks} from '@wordpress/block-editor'
2
2
  import type {BlockConfiguration} from '@wordpress/blocks'
3
3
  import {__} from '@wordpress/i18n'
4
4
  import type {OptionArray} from '~/types'
5
- import {DEFAULT_ICON_VARIANTS, FAQ_HEADING_LEVELS} from './constants'
5
+ import {DEFAULT_ICON_SIZE, DEFAULT_ICON_VARIANTS, DEFAULT_SHADOWS, FAQ_HEADING_LEVELS} from './constants'
6
6
  import {createFaqGroupEdit} from './edit'
7
7
  import type {FaqGroupAttributes, FaqGroupOptions} from './types'
8
8
 
@@ -12,6 +12,37 @@ export function createFaqGroupBlock<TIconVariants extends OptionArray = typeof D
12
12
  options: FaqGroupOptions<TIconVariants>,
13
13
  ): BlockConfiguration<FaqGroupAttributes<TIconVariants[number]['value']>> {
14
14
  const iconVariants = options.iconVariants ?? DEFAULT_ICON_VARIANTS
15
+ const exclude = options.exclude ?? []
16
+
17
+ const attributes: Record<string, unknown> = {
18
+ headingLevel: {
19
+ type: 'string',
20
+ default: FAQ_HEADING_LEVELS[1],
21
+ enum: [...FAQ_HEADING_LEVELS],
22
+ },
23
+ iconVariant: {
24
+ type: 'string',
25
+ default: iconVariants[1]?.value ?? iconVariants[0].value,
26
+ enum: iconVariants.map((v) => v.value),
27
+ },
28
+ }
29
+
30
+ if (!exclude.includes('colors')) {
31
+ attributes.style = {
32
+ type: 'object',
33
+ default: {
34
+ shadow: DEFAULT_SHADOWS[0].value,
35
+ borderColor: '',
36
+ backgroundColor: '',
37
+ textColor: '',
38
+ icon: {
39
+ color: '',
40
+ background: '',
41
+ size: DEFAULT_ICON_SIZE,
42
+ },
43
+ },
44
+ }
45
+ }
15
46
 
16
47
  return {
17
48
  name: options.name,
@@ -21,18 +52,7 @@ export function createFaqGroupBlock<TIconVariants extends OptionArray = typeof D
21
52
  ...(options.parent && {parent: options.parent}),
22
53
  icon: options.icon ?? 'editor-help',
23
54
  supports: {html: false, customClassName: false},
24
- attributes: {
25
- headingLevel: {
26
- type: 'string',
27
- default: FAQ_HEADING_LEVELS[1],
28
- enum: [...FAQ_HEADING_LEVELS],
29
- },
30
- iconVariant: {
31
- type: 'string',
32
- default: iconVariants[1]?.value ?? iconVariants[0].value,
33
- enum: iconVariants.map((v) => v.value),
34
- },
35
- },
55
+ attributes,
36
56
  edit: createFaqGroupEdit(options as unknown as FaqGroupOptions),
37
57
  save: () => <InnerBlocks.Content />,
38
58
  } as unknown as BlockConfiguration<FaqGroupAttributes<TIconVariants[number]['value']>>
@@ -1,4 +1,12 @@
1
- export type {FaqGroupAttributes, FaqGroupOptions} from './types'
1
+ export type {
2
+ ExcludableFaqAttr,
3
+ FaqGroupAttributes,
4
+ FaqGroupOptions,
5
+ FaqHeadingLevel,
6
+ FaqIconVariant,
7
+ FaqShadow,
8
+ FaqSizePreset,
9
+ } from './types'
2
10
  export {createFaqGroupBlock} from './factory'
3
11
 
4
12
  import type {FaqGroupOptions} from './types'
@@ -1,14 +1,35 @@
1
1
  import type {BriloBlockType, OptionArray} from '~/types'
2
- import type {DEFAULT_ICON_VARIANTS, FAQ_HEADING_LEVELS} from './constants'
2
+ import type {DEFAULT_ICON_VARIANTS, DEFAULT_SHADOWS, FAQ_HEADING_LEVELS} from './constants'
3
3
 
4
4
  export type FaqHeadingLevel = (typeof FAQ_HEADING_LEVELS)[number]
5
5
  export type FaqIconVariant = (typeof DEFAULT_ICON_VARIANTS)[number]['value']
6
+ export type FaqShadow = (typeof DEFAULT_SHADOWS)[number]['value']
7
+
8
+ export type ExcludableFaqAttr = 'colors'
9
+
10
+ export interface FaqSizePreset {
11
+ value: number
12
+ label: string
13
+ }
6
14
 
7
15
  export interface FaqGroupAttributes<TIconVariant extends string = FaqIconVariant> extends Record<string, unknown> {
8
16
  headingLevel: FaqHeadingLevel
9
17
  iconVariant: TIconVariant
18
+ style: {
19
+ shadow: FaqShadow
20
+ borderColor: string
21
+ backgroundColor: string
22
+ textColor: string
23
+ icon: {
24
+ color: string
25
+ background: string
26
+ size: number
27
+ }
28
+ }
10
29
  }
11
30
 
12
31
  export interface FaqGroupOptions<TIconVariants extends OptionArray = typeof DEFAULT_ICON_VARIANTS> extends BriloBlockType {
13
32
  iconVariants?: TIconVariants
33
+ iconSizePresets?: readonly FaqSizePreset[]
34
+ exclude?: ExcludableFaqAttr[]
14
35
  }
@@ -13,6 +13,12 @@ export const VARIANTS = [
13
13
 
14
14
  export const COLUMNS = [2, 3, 4] as const
15
15
 
16
+ export const DEFAULT_SHADOWS = [
17
+ {value: 'none', label: __('Žádný', 'brilo-blocks')},
18
+ {value: 'sm', label: __('Malý', 'brilo-blocks')},
19
+ {value: 'md', label: __('Střední', 'brilo-blocks')},
20
+ ] as const
21
+
16
22
  export const IMAGE_MODES = [
17
23
  {value: 'avatar', label: __('Zobrazit', 'brilo-blocks')},
18
24
  {value: 'none', label: __('Skrýt', 'brilo-blocks')},
@@ -1,6 +1,8 @@
1
1
  import {InspectorControls} from '@wordpress/block-editor'
2
2
  import type {BlockEditProps} from '@wordpress/blocks'
3
3
  import {
4
+ BaseControl,
5
+ ColorPalette,
4
6
  PanelBody,
5
7
  SelectControl,
6
8
  ToggleControl,
@@ -10,14 +12,17 @@ import {
10
12
  import {__} from '@wordpress/i18n'
11
13
  import clsx from 'clsx'
12
14
  import {useGroupBlock} from '~/hooks/useGroupBlock'
13
- import {COLUMNS, VARIANTS} from './constants'
14
- import type {ReviewColumns, ReviewGroupAttributes, ReviewGroupOptions, ReviewImageMode, Variant} from './types'
15
+ import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
16
+ import {COLUMNS, DEFAULT_SHADOWS, VARIANTS} from './constants'
17
+ import type {ReviewColumns, ReviewGroupAttributes, ReviewGroupOptions, ReviewImageMode, ReviewShadow, Variant} from './types'
15
18
 
16
19
  export function createReviewGroupEdit(options: ReviewGroupOptions) {
17
20
  const VARIANTS_OPTIONS = options.variants ?? VARIANTS
21
+ const exclude = options.exclude ?? []
18
22
 
19
23
  return function ReviewGroupEdit({attributes, setAttributes}: BlockEditProps<ReviewGroupAttributes>) {
20
- const {columns, image, variant} = attributes
24
+ const {columns, image, variant, style} = attributes
25
+ const {paletteColors} = useTenantColorPalette()
21
26
 
22
27
  const {blockProps, innerBlocksProps} = useGroupBlock({
23
28
  blockClassName: clsx(
@@ -62,6 +67,45 @@ export function createReviewGroupEdit(options: ReviewGroupOptions) {
62
67
  onChange={(checked) => setAttributes({image: (checked ? 'avatar' : 'none') as ReviewImageMode})}
63
68
  />
64
69
  </PanelBody>
70
+ {!exclude.includes('colors') && style && (
71
+ <PanelBody title={__('Styl', 'brilo-blocks')}>
72
+ <ToggleGroupControl
73
+ isBlock
74
+ label={__('Stín', 'brilo-blocks')}
75
+ value={style.shadow}
76
+ onChange={(v) => setAttributes({style: {...style, shadow: v as ReviewShadow}})}
77
+ >
78
+ {DEFAULT_SHADOWS.map((s) => (
79
+ <ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
80
+ ))}
81
+ </ToggleGroupControl>
82
+ <BaseControl
83
+ label={__('Barva okraje', 'brilo-blocks')}
84
+ help={__('Bez vybrané barvy se okraj nevykreslí.', 'brilo-blocks')}
85
+ id="review-group-border-color"
86
+ >
87
+ <ColorPalette
88
+ colors={paletteColors}
89
+ value={style.borderColor || undefined}
90
+ onChange={(value) => setAttributes({style: {...style, borderColor: value ?? ''}})}
91
+ />
92
+ </BaseControl>
93
+ <BaseControl label={__('Barva pozadí', 'brilo-blocks')} id="review-group-background-color">
94
+ <ColorPalette
95
+ colors={paletteColors}
96
+ value={style.backgroundColor || undefined}
97
+ onChange={(value) => setAttributes({style: {...style, backgroundColor: value ?? ''}})}
98
+ />
99
+ </BaseControl>
100
+ <BaseControl label={__('Barva textu', 'brilo-blocks')} id="review-group-text-color">
101
+ <ColorPalette
102
+ colors={paletteColors}
103
+ value={style.textColor || undefined}
104
+ onChange={(value) => setAttributes({style: {...style, textColor: value ?? ''}})}
105
+ />
106
+ </BaseControl>
107
+ </PanelBody>
108
+ )}
65
109
  </InspectorControls>
66
110
  <div {...blockProps}>
67
111
  <div {...innerBlocksProps} />
@@ -2,7 +2,7 @@ import {InnerBlocks} from '@wordpress/block-editor'
2
2
  import type {BlockConfiguration} from '@wordpress/blocks'
3
3
  import {__} from '@wordpress/i18n'
4
4
  import type {OptionArray} from '~/types'
5
- import {COLUMNS, VARIANTS} from './constants'
5
+ import {COLUMNS, DEFAULT_SHADOWS, VARIANTS} from './constants'
6
6
  import {createReviewGroupEdit} from './edit'
7
7
  import {icon as defaultIcon} from './icon'
8
8
  import type {ReviewGroupAttributes, ReviewGroupOptions} from './types'
@@ -13,6 +13,35 @@ export function createReviewGroupBlock<TVariants extends OptionArray = typeof VA
13
13
  options: ReviewGroupOptions<TVariants>,
14
14
  ): BlockConfiguration<ReviewGroupAttributes<TVariants[number]['value']>> {
15
15
  const variants = options.variants ?? VARIANTS
16
+ const exclude = options.exclude ?? []
17
+
18
+ const attributes: Record<string, unknown> = {
19
+ variant: {
20
+ type: 'string',
21
+ default: variants[0].value,
22
+ enum: variants.map((v) => v.value),
23
+ },
24
+ columns: {
25
+ type: 'number',
26
+ default: COLUMNS[1],
27
+ },
28
+ image: {
29
+ type: 'string',
30
+ default: 'none',
31
+ },
32
+ }
33
+
34
+ if (!exclude.includes('colors')) {
35
+ attributes.style = {
36
+ type: 'object',
37
+ default: {
38
+ shadow: DEFAULT_SHADOWS[0].value,
39
+ borderColor: '',
40
+ backgroundColor: '',
41
+ textColor: '',
42
+ },
43
+ }
44
+ }
16
45
 
17
46
  return {
18
47
  name: options.name,
@@ -22,21 +51,7 @@ export function createReviewGroupBlock<TVariants extends OptionArray = typeof VA
22
51
  ...(options.parent && {parent: options.parent}),
23
52
  icon: options.icon ?? {src: defaultIcon},
24
53
  supports: {html: false, customClassName: false},
25
- attributes: {
26
- variant: {
27
- type: 'string',
28
- default: variants[0].value,
29
- enum: variants.map((v) => v.value),
30
- },
31
- columns: {
32
- type: 'number',
33
- default: COLUMNS[1],
34
- },
35
- image: {
36
- type: 'string',
37
- default: 'none',
38
- },
39
- },
54
+ attributes,
40
55
  edit: createReviewGroupEdit(options as unknown as ReviewGroupOptions),
41
56
  save: () => <InnerBlocks.Content />,
42
57
  } as unknown as BlockConfiguration<ReviewGroupAttributes<TVariants[number]['value']>>
@@ -1,6 +1,15 @@
1
1
  import type {ReviewGroupOptions} from './types'
2
2
 
3
- export type {ReviewColumns, ReviewGroupAttributes, ReviewGroupOptions, ReviewImageMode, ReviewVariant, Variant} from './types'
3
+ export type {
4
+ ExcludableReviewAttr,
5
+ ReviewColumns,
6
+ ReviewGroupAttributes,
7
+ ReviewGroupOptions,
8
+ ReviewImageMode,
9
+ ReviewShadow,
10
+ ReviewVariant,
11
+ Variant,
12
+ } from './types'
4
13
  export {createReviewGroupBlock} from './factory'
5
14
 
6
15
  export const reviewGroupDefaults: ReviewGroupOptions = {
@@ -1,17 +1,27 @@
1
1
  import type {BriloBlockType, OptionArray} from '~/types'
2
- import type {COLUMNS, IMAGE_MODES, VARIANTS} from './constants'
2
+ import type {COLUMNS, DEFAULT_SHADOWS, IMAGE_MODES, VARIANTS} from './constants'
3
3
 
4
4
  export type Variant = (typeof VARIANTS)[number]['value']
5
5
  export type ReviewVariant = Variant
6
6
  export type ReviewColumns = (typeof COLUMNS)[number]
7
7
  export type ReviewImageMode = (typeof IMAGE_MODES)[number]['value']
8
+ export type ReviewShadow = (typeof DEFAULT_SHADOWS)[number]['value']
9
+
10
+ export type ExcludableReviewAttr = 'colors'
8
11
 
9
12
  export interface ReviewGroupAttributes<TVariant extends string = Variant> extends Record<string, unknown> {
10
13
  variant: TVariant
11
14
  columns: ReviewColumns
12
15
  image: ReviewImageMode
16
+ style: {
17
+ shadow: ReviewShadow
18
+ borderColor: string
19
+ backgroundColor: string
20
+ textColor: string
21
+ }
13
22
  }
14
23
 
15
24
  export interface ReviewGroupOptions<TVariants extends OptionArray = typeof VARIANTS> extends BriloBlockType {
16
25
  variants?: TVariants
26
+ exclude?: ExcludableReviewAttr[]
17
27
  }
@@ -19,7 +19,7 @@ function extractYoutubeId(url: string): string | null {
19
19
 
20
20
  export function createVideoGroupEdit(_options: VideoGroupOptions) {
21
21
  return function VideoGroupEdit({attributes, setAttributes}: BlockEditProps<VideoGroupAttributes>) {
22
- const {type, url, mediaId, caption, size, poster} = attributes
22
+ const {type, url, mediaId, caption, size, poster, playButtonTitle} = attributes
23
23
 
24
24
  const youtubeId = type === 'youtube' ? extractYoutubeId(url) : null
25
25
  const youtubeThumbnail = youtubeId ? `https://img.youtube.com/vi/${youtubeId}/maxresdefault.jpg` : null
@@ -42,6 +42,13 @@ export function createVideoGroupEdit(_options: VideoGroupOptions) {
42
42
  <ToggleGroupControlOption key={t.value} value={t.value} label={t.label} />
43
43
  ))}
44
44
  </ToggleGroupControl>
45
+
46
+ <TextControl
47
+ label={__('Text tlačítka přehrát', 'brilo-blocks')}
48
+ value={playButtonTitle}
49
+ onChange={(value) => setAttributes({playButtonTitle: value})}
50
+ placeholder={__('Přehrát video', 'brilo-blocks')}
51
+ />
45
52
  </PanelBody>
46
53
 
47
54
  {type === 'youtube' && (
@@ -44,6 +44,10 @@ export function createVideoGroupBlock(options: VideoGroupOptions): BlockConfigur
44
44
  id: 0,
45
45
  },
46
46
  },
47
+ playButtonTitle: {
48
+ type: 'string',
49
+ default: __('Přehrát video', 'brilo-blocks'),
50
+ },
47
51
  },
48
52
  edit: createVideoGroupEdit(options),
49
53
  save: () => null,
@@ -16,6 +16,7 @@ export interface VideoGroupAttributes extends Record<string, unknown> {
16
16
  caption: string
17
17
  size: VideoSize
18
18
  poster: VideoPoster
19
+ playButtonTitle: string
19
20
  }
20
21
 
21
22
  export interface VideoGroupOptions extends BriloBlockType {}
package/src/editor.scss CHANGED
@@ -10,6 +10,7 @@
10
10
  @forward "./blocks/contact/contact-item/editor";
11
11
  @forward "./blocks/core/basic-button/editor";
12
12
  @forward "./blocks/core/basic-heading/editor";
13
+ @forward "./blocks/core/basic-icon/editor";
13
14
  @forward "./blocks/core/basic-overline/editor";
14
15
  @forward "./blocks/faq/faq-group/editor";
15
16
  @forward "./blocks/faq/faq-item/editor";
package/src/index.ts CHANGED
@@ -48,6 +48,13 @@ export type {BasicHeadingAttributes, BasicHeadingOptions} from './blocks/core/ba
48
48
  export {basicHeadingDefaults, createBasicHeadingBlock} from './blocks/core/basic-heading'
49
49
  export type {BasicOverlineAttributes, BasicOverlineOptions} from './blocks/core/basic-overline'
50
50
  export {basicOverlineDefaults, createBasicOverlineBlock} from './blocks/core/basic-overline'
51
+ export type {
52
+ BasicIconAlignment,
53
+ BasicIconAttributes,
54
+ BasicIconBackgroundShape,
55
+ BasicIconOptions,
56
+ } from './blocks/core/basic-icon'
57
+ export {basicIconDefaults, createBasicIconBlock} from './blocks/core/basic-icon'
51
58
  export type {HeroItemAttributes, HeroItemOptions} from './blocks/hero/hero-item'
52
59
  export {createHeroItemBlock, heroItemDefaults} from './blocks/hero/hero-item'
53
60
  export type {HeroGroupAttributes, HeroGroupOptions} from './blocks/hero/hero-group'