@brilo/base-blocks 0.1.58 → 0.1.60

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 (100) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/blocks/food-menu/food-menu-group/FoodMenuPreview.js +2 -2
  3. package/build/blocks/food-menu/food-menu-group/edit.js +1 -1
  4. package/build/blocks/form/form-group/index.js +1 -1
  5. package/build/blocks/gallery/gallery-group/constants.d.ts +1 -19
  6. package/build/blocks/gallery/gallery-group/constants.d.ts.map +1 -1
  7. package/build/blocks/gallery/gallery-group/constants.js +1 -8
  8. package/build/blocks/gallery/gallery-group/edit.d.ts.map +1 -1
  9. package/build/blocks/gallery/gallery-group/edit.js +3 -19
  10. package/build/blocks/gallery/gallery-item/index.js +1 -1
  11. package/build/blocks/gallery/gallery-strip-group/constants.d.ts +34 -0
  12. package/build/blocks/gallery/gallery-strip-group/constants.d.ts.map +1 -0
  13. package/build/blocks/gallery/gallery-strip-group/constants.js +17 -0
  14. package/build/blocks/gallery/gallery-strip-group/edit.d.ts +7 -0
  15. package/build/blocks/gallery/gallery-strip-group/edit.d.ts.map +1 -0
  16. package/build/blocks/gallery/gallery-strip-group/edit.js +34 -0
  17. package/build/blocks/gallery/gallery-strip-group/factory.d.ts +5 -0
  18. package/build/blocks/gallery/gallery-strip-group/factory.d.ts.map +1 -0
  19. package/build/blocks/gallery/gallery-strip-group/factory.js +28 -0
  20. package/build/blocks/gallery/gallery-strip-group/index.d.ts +5 -0
  21. package/build/blocks/gallery/gallery-strip-group/index.d.ts.map +1 -0
  22. package/build/blocks/gallery/gallery-strip-group/index.js +7 -0
  23. package/build/blocks/gallery/gallery-strip-group/types.d.ts +18 -0
  24. package/build/blocks/gallery/gallery-strip-group/types.d.ts.map +1 -0
  25. package/build/blocks/gallery/gallery-strip-group/types.js +1 -0
  26. package/build/blocks/groups/text-and-media-group/index.d.ts.map +1 -1
  27. package/build/blocks/groups/text-and-media-group/index.js +2 -0
  28. package/build/blocks/hero/hero-item/index.js +1 -1
  29. package/build/blocks/review/review-summary-item/constants.d.ts +3 -0
  30. package/build/blocks/review/review-summary-item/constants.d.ts.map +1 -0
  31. package/build/blocks/review/review-summary-item/constants.js +2 -0
  32. package/build/blocks/review/review-summary-item/edit.d.ts +6 -0
  33. package/build/blocks/review/review-summary-item/edit.d.ts.map +1 -0
  34. package/build/blocks/review/review-summary-item/edit.js +17 -0
  35. package/build/blocks/review/review-summary-item/factory.d.ts +5 -0
  36. package/build/blocks/review/review-summary-item/factory.d.ts.map +1 -0
  37. package/build/blocks/review/review-summary-item/factory.js +23 -0
  38. package/build/blocks/review/review-summary-item/index.d.ts +5 -0
  39. package/build/blocks/review/review-summary-item/index.d.ts.map +1 -0
  40. package/build/blocks/review/review-summary-item/index.js +5 -0
  41. package/build/blocks/review/review-summary-item/types.d.ts +11 -0
  42. package/build/blocks/review/review-summary-item/types.d.ts.map +1 -0
  43. package/build/blocks/review/review-summary-item/types.js +1 -0
  44. package/build/blocks/urgency/urgency-item/constants.d.ts +56 -0
  45. package/build/blocks/urgency/urgency-item/constants.d.ts.map +1 -0
  46. package/build/blocks/urgency/urgency-item/constants.js +32 -0
  47. package/build/blocks/urgency/urgency-item/edit.d.ts +7 -0
  48. package/build/blocks/urgency/urgency-item/edit.d.ts.map +1 -0
  49. package/build/blocks/urgency/urgency-item/edit.js +83 -0
  50. package/build/blocks/urgency/urgency-item/factory.d.ts +5 -0
  51. package/build/blocks/urgency/urgency-item/factory.d.ts.map +1 -0
  52. package/build/blocks/urgency/urgency-item/factory.js +31 -0
  53. package/build/blocks/urgency/urgency-item/index.d.ts +5 -0
  54. package/build/blocks/urgency/urgency-item/index.d.ts.map +1 -0
  55. package/build/blocks/urgency/urgency-item/index.js +5 -0
  56. package/build/blocks/urgency/urgency-item/types.d.ts +22 -0
  57. package/build/blocks/urgency/urgency-item/types.d.ts.map +1 -0
  58. package/build/blocks/urgency/urgency-item/types.js +1 -0
  59. package/build/components/GalleryImagesAppender/index.d.ts +5 -0
  60. package/build/components/GalleryImagesAppender/index.d.ts.map +1 -0
  61. package/build/components/GalleryImagesAppender/index.js +12 -0
  62. package/build/constants.d.ts +19 -0
  63. package/build/constants.d.ts.map +1 -1
  64. package/build/constants.js +8 -0
  65. package/build/index.d.ts +6 -0
  66. package/build/index.d.ts.map +1 -1
  67. package/build/index.js +3 -0
  68. package/package.json +1 -1
  69. package/src/blocks/food-menu/food-menu-group/FoodMenuPreview.tsx +3 -3
  70. package/src/blocks/food-menu/food-menu-group/edit.tsx +2 -2
  71. package/src/blocks/form/form-group/index.ts +1 -1
  72. package/src/blocks/gallery/gallery-group/constants.ts +1 -8
  73. package/src/blocks/gallery/gallery-group/edit.tsx +3 -39
  74. package/src/blocks/gallery/gallery-group/editor.scss +0 -12
  75. package/src/blocks/gallery/gallery-item/index.ts +1 -1
  76. package/src/blocks/gallery/gallery-strip-group/constants.ts +22 -0
  77. package/src/blocks/gallery/gallery-strip-group/edit.tsx +112 -0
  78. package/src/blocks/gallery/gallery-strip-group/editor.scss +36 -0
  79. package/src/blocks/gallery/gallery-strip-group/factory.tsx +32 -0
  80. package/src/blocks/gallery/gallery-strip-group/index.ts +11 -0
  81. package/src/blocks/gallery/gallery-strip-group/types.ts +20 -0
  82. package/src/blocks/groups/text-and-media-group/index.ts +2 -0
  83. package/src/blocks/hero/hero-item/index.ts +1 -1
  84. package/src/blocks/review/review-summary-item/constants.ts +2 -0
  85. package/src/blocks/review/review-summary-item/edit.tsx +86 -0
  86. package/src/blocks/review/review-summary-item/editor.scss +44 -0
  87. package/src/blocks/review/review-summary-item/factory.tsx +27 -0
  88. package/src/blocks/review/review-summary-item/index.ts +9 -0
  89. package/src/blocks/review/review-summary-item/types.ts +11 -0
  90. package/src/blocks/urgency/urgency-item/constants.ts +39 -0
  91. package/src/blocks/urgency/urgency-item/edit.tsx +319 -0
  92. package/src/blocks/urgency/urgency-item/editor.scss +99 -0
  93. package/src/blocks/urgency/urgency-item/factory.tsx +36 -0
  94. package/src/blocks/urgency/urgency-item/index.ts +9 -0
  95. package/src/blocks/urgency/urgency-item/types.ts +23 -0
  96. package/src/components/GalleryImagesAppender/editor.scss +15 -0
  97. package/src/components/GalleryImagesAppender/index.tsx +29 -0
  98. package/src/constants.ts +9 -0
  99. package/src/editor.scss +4 -0
  100. package/src/index.ts +6 -0
@@ -0,0 +1,112 @@
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 {GalleryImagesAppender} from '~/components/GalleryImagesAppender'
10
+ import {ItemSpacingPanel, itemSpacingStyle} from '~/components/ItemSpacingControl'
11
+ import {useGroupBlock} from '~/hooks/useGroupBlock'
12
+ import {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, HEIGHT_PIXELS, SPEEDS} from './constants'
13
+ import type {
14
+ GalleryStripDirection,
15
+ GalleryStripGroupAttributes,
16
+ GalleryStripGroupOptions,
17
+ GalleryStripHeight,
18
+ GalleryStripRatio,
19
+ GalleryStripSpeed,
20
+ } from './types'
21
+
22
+ export function createGalleryStripGroupEdit(options: GalleryStripGroupOptions) {
23
+ const RATIOS = options.ratios ?? DEFAULT_RATIOS
24
+
25
+ return function Edit({
26
+ attributes,
27
+ setAttributes,
28
+ clientId,
29
+ }: {
30
+ attributes: GalleryStripGroupAttributes
31
+ setAttributes: (a: Partial<GalleryStripGroupAttributes>) => void
32
+ clientId: string
33
+ }) {
34
+ const {height, ratio, speed, direction, spacing} = attributes
35
+ const heightPx = HEIGHT_PIXELS[height] ?? HEIGHT_PIXELS.md
36
+ const [ratioWidth, ratioHeight] = ratio.split(':').map(Number)
37
+
38
+ const {blockProps, innerBlocksProps} = useGroupBlock({
39
+ blockClassName: clsx(
40
+ options.blockClassName ?? 'g-gallery g-gallery-strip wp-block-section',
41
+ `--speed-${speed}`,
42
+ `--direction-${direction}`,
43
+ ),
44
+ containerClassName: options.containerClassName ?? 'g-gallery-strip__track',
45
+ containerStyle: {
46
+ '--gallery-strip-height': `${heightPx}px`,
47
+ '--gallery-strip-item-width': `${Math.round((heightPx * ratioWidth) / ratioHeight)}px`,
48
+ ...itemSpacingStyle(spacing),
49
+ },
50
+ allowedBlocks: options.allowedBlocks,
51
+ orientation: 'horizontal',
52
+ renderAppender: () => <GalleryImagesAppender clientId={clientId} itemBlock={options.allowedBlocks[0]} />,
53
+ template: options.template,
54
+ layout: {type: 'default'},
55
+ })
56
+
57
+ return (
58
+ <>
59
+ <InspectorControls>
60
+ <PanelBody title={__('Rozložení', 'brilo-blocks')}>
61
+ <ToggleGroupControl
62
+ isBlock
63
+ label={__('Výška', 'brilo-blocks')}
64
+ value={height}
65
+ onChange={(v) => setAttributes({height: v as GalleryStripHeight})}
66
+ >
67
+ {HEIGHTS.map((h) => (
68
+ <ToggleGroupControlOption key={h.value} value={h.value} label={h.label} />
69
+ ))}
70
+ </ToggleGroupControl>
71
+ <ToggleGroupControl
72
+ isBlock
73
+ label={__('Poměr stran', 'brilo-blocks')}
74
+ value={ratio}
75
+ onChange={(v) => setAttributes({ratio: v as GalleryStripRatio})}
76
+ >
77
+ {RATIOS.map((r) => (
78
+ <ToggleGroupControlOption key={r.value} value={r.value} label={r.label} />
79
+ ))}
80
+ </ToggleGroupControl>
81
+ </PanelBody>
82
+ <PanelBody title={__('Animace', 'brilo-blocks')}>
83
+ <ToggleGroupControl
84
+ isBlock
85
+ label={__('Rychlost', 'brilo-blocks')}
86
+ value={speed}
87
+ onChange={(v) => setAttributes({speed: v as GalleryStripSpeed})}
88
+ >
89
+ {SPEEDS.map((s) => (
90
+ <ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
91
+ ))}
92
+ </ToggleGroupControl>
93
+ <ToggleGroupControl
94
+ isBlock
95
+ label={__('Směr', 'brilo-blocks')}
96
+ value={direction}
97
+ onChange={(v) => setAttributes({direction: v as GalleryStripDirection})}
98
+ >
99
+ {DIRECTIONS.map((d) => (
100
+ <ToggleGroupControlOption key={d.value} value={d.value} label={d.label} />
101
+ ))}
102
+ </ToggleGroupControl>
103
+ </PanelBody>
104
+ <ItemSpacingPanel spacing={spacing} onChange={(v) => setAttributes({spacing: v})} />
105
+ </InspectorControls>
106
+ <div {...blockProps}>
107
+ <div {...innerBlocksProps} />
108
+ </div>
109
+ </>
110
+ )
111
+ }
112
+ }
@@ -0,0 +1,36 @@
1
+ .g-gallery-strip {
2
+ // Horizontal scroll only: items get a fixed width (height × ratio) and grow
3
+ // vertically to fit the gallery-item controls instead of overflowing.
4
+ .g-gallery-strip__track {
5
+ display: flex;
6
+ flex-wrap: nowrap;
7
+ align-items: stretch;
8
+ gap: 16px;
9
+ overflow-x: auto;
10
+ overflow-y: hidden;
11
+ }
12
+
13
+ .g-gallery-strip__track > .wp-block,
14
+ .g-gallery-strip__track > .block-list-appender {
15
+ flex: 0 0 var(--gallery-strip-item-width);
16
+ width: var(--gallery-strip-item-width);
17
+ display: flex;
18
+ flex-direction: column;
19
+ min-height: var(--gallery-strip-height);
20
+ margin: 0;
21
+ }
22
+
23
+ .i-gallery {
24
+ display: flex;
25
+ flex: 1;
26
+ flex-direction: column;
27
+ }
28
+
29
+ .i-gallery__image-wrapper {
30
+ flex: 1;
31
+ }
32
+
33
+ .g-gallery__appender {
34
+ min-height: var(--gallery-strip-height);
35
+ }
36
+ }
@@ -0,0 +1,32 @@
1
+ import {InnerBlocks} from '@wordpress/block-editor'
2
+ import type {BlockConfiguration} from '@wordpress/blocks'
3
+ import {__} from '@wordpress/i18n'
4
+ import {ITEM_SPACING_ATTRIBUTE} from '~/components/ItemSpacingControl'
5
+ import {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, SPEEDS} from './constants'
6
+ import {createGalleryStripGroupEdit} from './edit'
7
+ import type {GalleryStripGroupAttributes, GalleryStripGroupOptions} from './types'
8
+
9
+ export type {GalleryStripGroupAttributes, GalleryStripGroupOptions}
10
+
11
+ export function createGalleryStripGroupBlock(options: GalleryStripGroupOptions): BlockConfiguration<GalleryStripGroupAttributes> {
12
+ const ratios = options.ratios ?? DEFAULT_RATIOS
13
+
14
+ return {
15
+ name: options.name,
16
+ title: options.title ?? __('Pás obrázků', 'brilo-blocks'),
17
+ description: options.description ?? __('Nekonečně se posouvající pás obrázků', 'brilo-blocks'),
18
+ category: options.category ?? 'layout',
19
+ ...(options.parent && {parent: options.parent}),
20
+ icon: options.icon ?? 'images-alt2',
21
+ supports: {html: false, customClassName: false},
22
+ attributes: {
23
+ height: {type: 'string', default: HEIGHTS[1].value, enum: HEIGHTS.map((h) => h.value)},
24
+ ratio: {type: 'string', default: ratios[0].value, enum: ratios.map((r) => r.value)},
25
+ speed: {type: 'string', default: SPEEDS[1].value, enum: SPEEDS.map((s) => s.value)},
26
+ direction: {type: 'string', default: DIRECTIONS[0].value, enum: DIRECTIONS.map((d) => d.value)},
27
+ ...ITEM_SPACING_ATTRIBUTE,
28
+ },
29
+ edit: createGalleryStripGroupEdit(options),
30
+ save: () => <InnerBlocks.Content />,
31
+ } as unknown as BlockConfiguration<GalleryStripGroupAttributes>
32
+ }
@@ -0,0 +1,11 @@
1
+ export type {GalleryStripGroupAttributes, GalleryStripGroupOptions} from './types'
2
+ export {createGalleryStripGroupBlock} from './factory'
3
+
4
+ import type {GalleryStripGroupOptions} from './types'
5
+
6
+ export const galleryStripGroupDefaults: GalleryStripGroupOptions = {
7
+ name: 'brilo/gallery-strip-group',
8
+ parent: ['brilo/base-section'],
9
+ allowedBlocks: ['brilo/gallery-item'],
10
+ template: [],
11
+ }
@@ -0,0 +1,20 @@
1
+ import type {BriloBlockType, OptionArray} from '~/types'
2
+ import type {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, SPEEDS} from './constants'
3
+
4
+ export type GalleryStripHeight = (typeof HEIGHTS)[number]['value']
5
+ export type GalleryStripSpeed = (typeof SPEEDS)[number]['value']
6
+ export type GalleryStripRatio = (typeof DEFAULT_RATIOS)[number]['value']
7
+ export type GalleryStripDirection = (typeof DIRECTIONS)[number]['value']
8
+
9
+ export interface GalleryStripGroupAttributes extends Record<string, unknown> {
10
+ height: GalleryStripHeight
11
+ ratio: GalleryStripRatio
12
+ speed: GalleryStripSpeed
13
+ direction: GalleryStripDirection
14
+ spacing?: number
15
+ }
16
+
17
+ export interface GalleryStripGroupOptions extends BriloBlockType {
18
+ allowedBlocks: string[]
19
+ ratios?: OptionArray
20
+ }
@@ -15,5 +15,7 @@ export const textAndMediaGroupDefaults: TextAndMediaGroupOptions = {
15
15
  'core/heading',
16
16
  'core/list',
17
17
  'core/paragraph',
18
+ 'brilo/review-summary-item',
19
+ 'brilo/urgency-item',
18
20
  ],
19
21
  }
@@ -6,5 +6,5 @@ import type {HeroItemOptions} from './types'
6
6
  export const heroItemDefaults: HeroItemOptions = {
7
7
  name: 'brilo/hero-item',
8
8
  parent: ['brilo/hero-group'],
9
- allowedBlocks: ['core/list', 'core/paragraph', 'brilo/button-group'],
9
+ allowedBlocks: ['core/list', 'core/paragraph', 'brilo/button-group', 'brilo/review-summary-item'],
10
10
  }
@@ -0,0 +1,2 @@
1
+ export const RATING_MAX = 5
2
+ export const RATING_STEP = 0.1
@@ -0,0 +1,86 @@
1
+ import {InspectorControls, RichText, useBlockProps} from '@wordpress/block-editor'
2
+ import {PanelBody, RangeControl, TextControl, ToggleControl} from '@wordpress/components'
3
+ import {__} from '@wordpress/i18n'
4
+ import clsx from 'clsx'
5
+ import type {CSSProperties} from 'react'
6
+ import {RATING_MAX, RATING_STEP} from './constants'
7
+ import type {ReviewSummaryItemAttributes, ReviewSummaryItemOptions} from './types'
8
+
9
+ const roundToHalf = (value: number) => Math.round(value * 2) / 2
10
+
11
+ export function createReviewSummaryItemEdit(options: ReviewSummaryItemOptions) {
12
+ return function Edit({
13
+ attributes,
14
+ setAttributes,
15
+ }: {
16
+ attributes: ReviewSummaryItemAttributes
17
+ setAttributes: (a: Partial<ReviewSummaryItemAttributes>) => void
18
+ }) {
19
+ const {rating, count, countLabel, showMax, description} = attributes
20
+ const hasRating = typeof rating === 'number'
21
+ const hasCount = typeof count === 'number' && count > 0
22
+
23
+ const blockProps = useBlockProps({className: clsx(options.blockClassName ?? 'i-review-summary-item wp-block-section')})
24
+
25
+ return (
26
+ <>
27
+ <InspectorControls>
28
+ <PanelBody title={__('Hodnocení', 'brilo-blocks')}>
29
+ <RangeControl
30
+ label={__('Průměrné hodnocení', 'brilo-blocks')}
31
+ help={__('Bez hodnoty se hvězdičky ani číslo nezobrazí.', 'brilo-blocks')}
32
+ value={rating}
33
+ onChange={(v) => setAttributes({rating: v})}
34
+ min={0}
35
+ max={RATING_MAX}
36
+ step={RATING_STEP}
37
+ allowReset
38
+ withInputField
39
+ />
40
+ <ToggleControl label={__('Zobrazit „/ 5"', 'brilo-blocks')} checked={showMax} onChange={(v) => setAttributes({showMax: v})} />
41
+ <TextControl
42
+ type="number"
43
+ min={0}
44
+ label={__('Počet recenzí', 'brilo-blocks')}
45
+ help={__('Při nule nebo prázdné hodnotě se počet nezobrazí.', 'brilo-blocks')}
46
+ value={typeof count === 'number' ? String(count) : ''}
47
+ onChange={(v) => setAttributes({count: v === '' ? undefined : Math.max(0, Number.parseInt(v, 10) || 0)})}
48
+ />
49
+ <TextControl label={__('Popisek počtu', 'brilo-blocks')} value={countLabel} onChange={(v) => setAttributes({countLabel: v})} />
50
+ </PanelBody>
51
+ </InspectorControls>
52
+
53
+ <div {...blockProps}>
54
+ <div className="i-review-summary-item__score">
55
+ {hasRating && (
56
+ <>
57
+ <span
58
+ className="i-review-summary-item__stars"
59
+ style={{'--rating-fill': `${(roundToHalf(rating) / RATING_MAX) * 100}%`} as CSSProperties}
60
+ >
61
+ ★★★★★
62
+ </span>
63
+ <strong className="i-review-summary-item__value">
64
+ {rating.toLocaleString(undefined, {minimumFractionDigits: 1, maximumFractionDigits: 1})}
65
+ {showMax && ` / ${RATING_MAX}`}
66
+ </strong>
67
+ </>
68
+ )}
69
+ {hasCount && <span className="i-review-summary-item__count">{`${count} ${countLabel}`}</span>}
70
+ {!hasRating && !hasCount && (
71
+ <span className="i-review-summary-item__placeholder">{__('Nastavte hodnocení v postranním panelu', 'brilo-blocks')}</span>
72
+ )}
73
+ </div>
74
+ <RichText
75
+ tagName="p"
76
+ className="i-review-summary-item__description u-text-editable"
77
+ value={description}
78
+ onChange={(v) => setAttributes({description: v})}
79
+ placeholder={__('Popis hodnocení...', 'brilo-blocks')}
80
+ allowedFormats={['core/bold', 'core/italic', 'core/link', 'brilo-blocks/text-color']}
81
+ />
82
+ </div>
83
+ </>
84
+ )
85
+ }
86
+ }
@@ -0,0 +1,44 @@
1
+ .i-review-summary-item {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 8px;
5
+ }
6
+
7
+ .i-review-summary-item__score {
8
+ display: flex;
9
+ flex-wrap: wrap;
10
+ align-items: center;
11
+ gap: 8px;
12
+ }
13
+
14
+ .i-review-summary-item__stars {
15
+ position: relative;
16
+ display: inline-block;
17
+ font-size: 20px;
18
+ line-height: 1;
19
+ letter-spacing: 2px;
20
+ color: #d0d5dd;
21
+
22
+ &::before {
23
+ content: "★★★★★";
24
+ position: absolute;
25
+ inset: 0;
26
+ width: var(--rating-fill, 0%);
27
+ overflow: hidden;
28
+ color: #1e2d45;
29
+ }
30
+ }
31
+
32
+ .i-review-summary-item__value {
33
+ font-size: 18px;
34
+ }
35
+
36
+ .i-review-summary-item__count,
37
+ .i-review-summary-item__placeholder {
38
+ font-size: 14px;
39
+ color: #50575e;
40
+ }
41
+
42
+ .i-review-summary-item__description {
43
+ margin: 0;
44
+ }
@@ -0,0 +1,27 @@
1
+ import type {BlockConfiguration} from '@wordpress/blocks'
2
+ import {__} from '@wordpress/i18n'
3
+ import {createReviewSummaryItemEdit} from './edit'
4
+ import type {ReviewSummaryItemAttributes, ReviewSummaryItemOptions} from './types'
5
+
6
+ export type {ReviewSummaryItemAttributes, ReviewSummaryItemOptions}
7
+
8
+ export function createReviewSummaryItemBlock(options: ReviewSummaryItemOptions): BlockConfiguration<ReviewSummaryItemAttributes> {
9
+ return {
10
+ name: options.name,
11
+ title: options.title ?? __('Souhrn hodnocení', 'brilo-blocks'),
12
+ description: options.description ?? __('Průměrné hodnocení hvězdičkami s počtem recenzí a popisem', 'brilo-blocks'),
13
+ category: options.category ?? 'layout',
14
+ ...(options.parent && {parent: options.parent}),
15
+ icon: options.icon ?? 'star-half',
16
+ supports: {html: false, customClassName: false},
17
+ attributes: {
18
+ rating: {type: 'number'},
19
+ count: {type: 'number'},
20
+ countLabel: {type: 'string', default: __('hodnocení', 'brilo-blocks')},
21
+ showMax: {type: 'boolean', default: false},
22
+ description: {type: 'string', default: ''},
23
+ },
24
+ edit: createReviewSummaryItemEdit(options),
25
+ save: () => null,
26
+ } as unknown as BlockConfiguration<ReviewSummaryItemAttributes>
27
+ }
@@ -0,0 +1,9 @@
1
+ export type {ReviewSummaryItemAttributes, ReviewSummaryItemOptions} from './types'
2
+ export {createReviewSummaryItemBlock} from './factory'
3
+
4
+ import type {ReviewSummaryItemOptions} from './types'
5
+
6
+ export const reviewSummaryItemDefaults: ReviewSummaryItemOptions = {
7
+ name: 'brilo/review-summary-item',
8
+ parent: ['brilo/base-section', 'brilo/text-and-media-group', 'brilo/hero-item'],
9
+ }
@@ -0,0 +1,11 @@
1
+ import type {BriloBlockType} from '~/types'
2
+
3
+ export interface ReviewSummaryItemAttributes extends Record<string, unknown> {
4
+ rating?: number
5
+ count?: number
6
+ countLabel: string
7
+ showMax: boolean
8
+ description: string
9
+ }
10
+
11
+ export interface ReviewSummaryItemOptions extends BriloBlockType {}
@@ -0,0 +1,39 @@
1
+ import {__} from '@wordpress/i18n'
2
+
3
+ export {CONTENT_SIZES as TEXT_SIZES} from '~/constants'
4
+
5
+ export const TYPES = [
6
+ {value: 'deadline', label: __('Termín', 'brilo-blocks')},
7
+ {value: 'capacity', label: __('Volná místa', 'brilo-blocks')},
8
+ {value: 'season', label: __('Sezóna', 'brilo-blocks')},
9
+ ] as const
10
+
11
+ export const DEADLINE_DISPLAYS = [
12
+ {value: 'countdown', label: __('Odpočet', 'brilo-blocks')},
13
+ {value: 'date', label: __('Datum', 'brilo-blocks')},
14
+ ] as const
15
+
16
+ export const TEXTS = {
17
+ countdown: __('Nabídka končí za', 'brilo-blocks'),
18
+ date: __('Nabídka platí do', 'brilo-blocks'),
19
+ capacity: __('Zbývá volných míst', 'brilo-blocks'),
20
+ season: __('Nabídka platí pouze tuto sezónu', 'brilo-blocks'),
21
+ } as const
22
+
23
+ export const COUNTDOWN_UNITS = [
24
+ {key: 'days', label: __('dní', 'brilo-blocks')},
25
+ {key: 'hours', label: __('hod', 'brilo-blocks')},
26
+ {key: 'minutes', label: __('min', 'brilo-blocks')},
27
+ {key: 'seconds', label: __('sek', 'brilo-blocks')},
28
+ ] as const
29
+
30
+ export const NUMBER_SIZE_MIN = 16
31
+ export const NUMBER_SIZE_MAX = 120
32
+
33
+ export const NUMBER_SIZE_PRESETS = [
34
+ {value: 32, label: __('XS', 'brilo-blocks')},
35
+ {value: 40, label: __('SM', 'brilo-blocks')},
36
+ {value: 48, label: __('MD', 'brilo-blocks')},
37
+ {value: 60, label: __('LG', 'brilo-blocks')},
38
+ {value: 72, label: __('XL', 'brilo-blocks')},
39
+ ] as const