@brilo/base-blocks 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/blocks/form/form-group/edit.d.ts.map +1 -1
- package/build/blocks/form/form-group/edit.js +17 -3
- package/build/blocks/form/form-group/factory.d.ts.map +1 -1
- package/build/blocks/form/form-group/factory.js +1 -0
- package/build/blocks/form/form-group/types.d.ts +1 -0
- package/build/blocks/form/form-group/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/blocks/column/column-group/edit.tsx +56 -0
- package/src/blocks/column/column-group/editor.scss +7 -0
- package/src/blocks/column/column-group/factory.tsx +29 -0
- package/src/blocks/column/column-group/index.ts +14 -0
- package/src/blocks/column/column-group/types.ts +8 -0
- package/src/blocks/column/column-item/constants.ts +1 -0
- package/src/blocks/column/column-item/edit.tsx +48 -0
- package/src/blocks/column/column-item/editor.scss +34 -0
- package/src/blocks/column/column-item/factory.tsx +25 -0
- package/src/blocks/column/column-item/index.ts +10 -0
- package/src/blocks/column/column-item/types.ts +7 -0
- package/src/blocks/compare/compare-group/constants.ts +1 -0
- package/src/blocks/compare/compare-group/edit.tsx +52 -0
- package/src/blocks/compare/compare-group/factory.tsx +29 -0
- package/src/blocks/compare/compare-group/icon.tsx +7 -0
- package/src/blocks/compare/compare-group/index.ts +13 -0
- package/src/blocks/compare/compare-group/types.ts +12 -0
- package/src/blocks/compare/compare-item/edit.tsx +38 -0
- package/src/blocks/compare/compare-item/editor.scss +15 -0
- package/src/blocks/compare/compare-item/factory.tsx +28 -0
- package/src/blocks/compare/compare-item/icon.tsx +9 -0
- package/src/blocks/compare/compare-item/index.ts +13 -0
- package/src/blocks/compare/compare-item/types.ts +9 -0
- package/src/blocks/compare/compare-option/constants.ts +7 -0
- package/src/blocks/compare/compare-option/edit.tsx +64 -0
- package/src/blocks/compare/compare-option/editor.scss +26 -0
- package/src/blocks/compare/compare-option/factory.tsx +35 -0
- package/src/blocks/compare/compare-option/icon.tsx +7 -0
- package/src/blocks/compare/compare-option/index.ts +8 -0
- package/src/blocks/compare/compare-option/types.ts +12 -0
- package/src/blocks/contact/contact-group/constants.ts +3 -0
- package/src/blocks/contact/contact-group/edit.tsx +57 -0
- package/src/blocks/contact/contact-group/editor.scss +20 -0
- package/src/blocks/contact/contact-group/factory.tsx +35 -0
- package/src/blocks/contact/contact-group/index.ts +12 -0
- package/src/blocks/contact/contact-group/types.ts +12 -0
- package/src/blocks/contact/contact-item/constants.ts +17 -0
- package/src/blocks/contact/contact-item/edit.tsx +93 -0
- package/src/blocks/contact/contact-item/editor.scss +38 -0
- package/src/blocks/contact/contact-item/factory.tsx +35 -0
- package/src/blocks/contact/contact-item/index.ts +23 -0
- package/src/blocks/contact/contact-item/types.ts +21 -0
- package/src/blocks/core/basic-button/constants.ts +17 -0
- package/src/blocks/core/basic-button/edit.tsx +107 -0
- package/src/blocks/core/basic-button/editor.scss +80 -0
- package/src/blocks/core/basic-button/factory.tsx +54 -0
- package/src/blocks/core/basic-button/index.ts +8 -0
- package/src/blocks/core/basic-button/types.ts +29 -0
- package/src/blocks/core/basic-heading/constants.ts +1 -0
- package/src/blocks/core/basic-heading/edit.tsx +76 -0
- package/src/blocks/core/basic-heading/editor.scss +8 -0
- package/src/blocks/core/basic-heading/factory.tsx +40 -0
- package/src/blocks/core/basic-heading/index.ts +8 -0
- package/src/blocks/core/basic-heading/types.ts +20 -0
- package/src/blocks/core/basic-overline/edit.tsx +28 -0
- package/src/blocks/core/basic-overline/editor.scss +14 -0
- package/src/blocks/core/basic-overline/factory.tsx +22 -0
- package/src/blocks/core/basic-overline/index.ts +8 -0
- package/src/blocks/core/basic-overline/types.ts +7 -0
- package/src/blocks/faq/faq-group/constants.ts +11 -0
- package/src/blocks/faq/faq-group/edit.tsx +55 -0
- package/src/blocks/faq/faq-group/editor.scss +11 -0
- package/src/blocks/faq/faq-group/factory.tsx +39 -0
- package/src/blocks/faq/faq-group/index.ts +11 -0
- package/src/blocks/faq/faq-group/types.ts +14 -0
- package/src/blocks/faq/faq-item/edit.tsx +50 -0
- package/src/blocks/faq/faq-item/editor.scss +57 -0
- package/src/blocks/faq/faq-item/factory.tsx +24 -0
- package/src/blocks/faq/faq-item/index.ts +9 -0
- package/src/blocks/faq/faq-item/types.ts +7 -0
- package/src/blocks/form/form-field/constants.ts +14 -0
- package/src/blocks/form/form-field/edit.tsx +178 -0
- package/src/blocks/form/form-field/editor.scss +71 -0
- package/src/blocks/form/form-field/factory.tsx +32 -0
- package/src/blocks/form/form-field/index.ts +10 -0
- package/src/blocks/form/form-field/types.ts +18 -0
- package/src/blocks/form/form-group/constants.ts +16 -0
- package/src/blocks/form/form-group/edit.tsx +214 -0
- package/src/blocks/form/form-group/editor.scss +41 -0
- package/src/blocks/form/form-group/factory.tsx +36 -0
- package/src/blocks/form/form-group/index.ts +18 -0
- package/src/blocks/form/form-group/types.ts +23 -0
- package/src/blocks/groups/banner-group/constants.ts +15 -0
- package/src/blocks/groups/banner-group/edit.tsx +122 -0
- package/src/blocks/groups/banner-group/editor.scss +18 -0
- package/src/blocks/groups/banner-group/factory.tsx +64 -0
- package/src/blocks/groups/banner-group/icon.tsx +13 -0
- package/src/blocks/groups/banner-group/index.ts +11 -0
- package/src/blocks/groups/banner-group/types.ts +30 -0
- package/src/blocks/groups/basic-header-group/constants.ts +9 -0
- package/src/blocks/groups/basic-header-group/edit.tsx +99 -0
- package/src/blocks/groups/basic-header-group/editor.scss +35 -0
- package/src/blocks/groups/basic-header-group/factory.tsx +46 -0
- package/src/blocks/groups/basic-header-group/icon.tsx +17 -0
- package/src/blocks/groups/basic-header-group/index.ts +9 -0
- package/src/blocks/groups/basic-header-group/types.ts +27 -0
- package/src/blocks/groups/button-group/constants.ts +7 -0
- package/src/blocks/groups/button-group/edit.tsx +52 -0
- package/src/blocks/groups/button-group/editor.scss +23 -0
- package/src/blocks/groups/button-group/factory.tsx +34 -0
- package/src/blocks/groups/button-group/index.ts +11 -0
- package/src/blocks/groups/button-group/types.ts +12 -0
- package/src/blocks/groups/text-and-media-group/constants.ts +43 -0
- package/src/blocks/groups/text-and-media-group/edit.tsx +241 -0
- package/src/blocks/groups/text-and-media-group/editor.scss +123 -0
- package/src/blocks/groups/text-and-media-group/factory.tsx +100 -0
- package/src/blocks/groups/text-and-media-group/icon.tsx +37 -0
- package/src/blocks/groups/text-and-media-group/index.ts +18 -0
- package/src/blocks/groups/text-and-media-group/types.ts +60 -0
- package/src/blocks/hero/hero-group/constants.ts +23 -0
- package/src/blocks/hero/hero-group/edit.tsx +85 -0
- package/src/blocks/hero/hero-group/editor.scss +0 -0
- package/src/blocks/hero/hero-group/factory.tsx +45 -0
- package/src/blocks/hero/hero-group/icon.tsx +28 -0
- package/src/blocks/hero/hero-group/index.ts +11 -0
- package/src/blocks/hero/hero-group/types.ts +22 -0
- package/src/blocks/hero/hero-item/constants.ts +15 -0
- package/src/blocks/hero/hero-item/edit.tsx +107 -0
- package/src/blocks/hero/hero-item/editor.scss +87 -0
- package/src/blocks/hero/hero-item/factory.tsx +49 -0
- package/src/blocks/hero/hero-item/index.ts +10 -0
- package/src/blocks/hero/hero-item/types.ts +38 -0
- package/src/blocks/map/map-group/constants.ts +20 -0
- package/src/blocks/map/map-group/edit.tsx +108 -0
- package/src/blocks/map/map-group/editor.scss +24 -0
- package/src/blocks/map/map-group/factory.tsx +51 -0
- package/src/blocks/map/map-group/index.ts +9 -0
- package/src/blocks/map/map-group/types.ts +16 -0
- package/src/blocks/newsletter/newsletter-form/constants.ts +5 -0
- package/src/blocks/newsletter/newsletter-form/edit.tsx +194 -0
- package/src/blocks/newsletter/newsletter-form/editor.scss +68 -0
- package/src/blocks/newsletter/newsletter-form/factory.tsx +59 -0
- package/src/blocks/newsletter/newsletter-form/index.ts +11 -0
- package/src/blocks/newsletter/newsletter-form/types.ts +45 -0
- package/src/blocks/post/post-slider-group/constants.ts +3 -0
- package/src/blocks/post/post-slider-group/edit.tsx +76 -0
- package/src/blocks/post/post-slider-group/factory.tsx +43 -0
- package/src/blocks/post/post-slider-group/icon.tsx +13 -0
- package/src/blocks/post/post-slider-group/index.ts +9 -0
- package/src/blocks/post/post-slider-group/types.ts +20 -0
- package/src/blocks/responsive-grid/responsive-grid-group/edit.tsx +95 -0
- package/src/blocks/responsive-grid/responsive-grid-group/factory.tsx +33 -0
- package/src/blocks/responsive-grid/responsive-grid-group/index.ts +13 -0
- package/src/blocks/responsive-grid/responsive-grid-group/types.ts +9 -0
- package/src/blocks/responsive-grid/responsive-grid-item/edit.tsx +19 -0
- package/src/blocks/responsive-grid/responsive-grid-item/factory.tsx +20 -0
- package/src/blocks/responsive-grid/responsive-grid-item/index.ts +9 -0
- package/src/blocks/responsive-grid/responsive-grid-item/types.ts +5 -0
- package/src/blocks/sections/base-section/attributes.ts +17 -0
- package/src/blocks/sections/base-section/constants.ts +18 -0
- package/src/blocks/sections/base-section/controls.tsx +70 -0
- package/src/blocks/sections/base-section/edit.tsx +34 -0
- package/src/blocks/sections/base-section/editor.scss +24 -0
- package/src/blocks/sections/base-section/factory.tsx +47 -0
- package/src/blocks/sections/base-section/icon.tsx +6 -0
- package/src/blocks/sections/base-section/index.ts +14 -0
- package/src/blocks/sections/base-section/types.ts +26 -0
- package/src/blocks/signpost/signpost-group/constants.ts +3 -0
- package/src/blocks/signpost/signpost-group/edit.tsx +75 -0
- package/src/blocks/signpost/signpost-group/editor.scss +0 -0
- package/src/blocks/signpost/signpost-group/factory.tsx +40 -0
- package/src/blocks/signpost/signpost-group/icon.tsx +19 -0
- package/src/blocks/signpost/signpost-group/index.ts +15 -0
- package/src/blocks/signpost/signpost-group/types.ts +9 -0
- package/src/blocks/signpost/signpost-item/constants.ts +4 -0
- package/src/blocks/signpost/signpost-item/edit.tsx +90 -0
- package/src/blocks/signpost/signpost-item/editor.scss +25 -0
- package/src/blocks/signpost/signpost-item/factory.tsx +29 -0
- package/src/blocks/signpost/signpost-item/icon.tsx +7 -0
- package/src/blocks/signpost/signpost-item/index.ts +10 -0
- package/src/blocks/signpost/signpost-item/types.ts +12 -0
- package/src/blocks/step/step-group/constants.ts +6 -0
- package/src/blocks/step/step-group/edit.tsx +64 -0
- package/src/blocks/step/step-group/editor.scss +19 -0
- package/src/blocks/step/step-group/factory.tsx +36 -0
- package/src/blocks/step/step-group/icon.tsx +27 -0
- package/src/blocks/step/step-group/index.ts +15 -0
- package/src/blocks/step/step-group/types.ts +13 -0
- package/src/blocks/step/step-item/constants.ts +6 -0
- package/src/blocks/step/step-item/edit.tsx +60 -0
- package/src/blocks/step/step-item/editor.scss +18 -0
- package/src/blocks/step/step-item/factory.tsx +27 -0
- package/src/blocks/step/step-item/index.ts +11 -0
- package/src/blocks/step/step-item/types.ts +12 -0
- package/src/blocks/testimonial/testimonial-group/constants.ts +27 -0
- package/src/blocks/testimonial/testimonial-group/edit.tsx +74 -0
- package/src/blocks/testimonial/testimonial-group/editor.scss +38 -0
- package/src/blocks/testimonial/testimonial-group/factory.tsx +44 -0
- package/src/blocks/testimonial/testimonial-group/icon.tsx +33 -0
- package/src/blocks/testimonial/testimonial-group/index.ts +15 -0
- package/src/blocks/testimonial/testimonial-group/types.ts +19 -0
- package/src/blocks/testimonial/testimonial-item/edit.tsx +48 -0
- package/src/blocks/testimonial/testimonial-item/editor.scss +20 -0
- package/src/blocks/testimonial/testimonial-item/factory.tsx +35 -0
- package/src/blocks/testimonial/testimonial-item/index.ts +9 -0
- package/src/blocks/testimonial/testimonial-item/types.ts +9 -0
- package/src/blocks/text-and-form/text-and-form-group/constants.ts +6 -0
- package/src/blocks/text-and-form/text-and-form-group/edit.tsx +59 -0
- package/src/blocks/text-and-form/text-and-form-group/editor.scss +21 -0
- package/src/blocks/text-and-form/text-and-form-group/factory.tsx +38 -0
- package/src/blocks/text-and-form/text-and-form-group/icon.tsx +23 -0
- package/src/blocks/text-and-form/text-and-form-group/index.ts +9 -0
- package/src/blocks/text-and-form/text-and-form-group/types.ts +23 -0
- package/src/blocks/text-and-form/text-and-form-text-column/constants.ts +10 -0
- package/src/blocks/text-and-form/text-and-form-text-column/edit.tsx +94 -0
- package/src/blocks/text-and-form/text-and-form-text-column/editor.scss +29 -0
- package/src/blocks/text-and-form/text-and-form-text-column/factory.tsx +41 -0
- package/src/blocks/text-and-form/text-and-form-text-column/index.ts +18 -0
- package/src/blocks/text-and-form/text-and-form-text-column/types.ts +23 -0
- package/src/blocks/usp/usp-group/constants.ts +54 -0
- package/src/blocks/usp/usp-group/edit.tsx +197 -0
- package/src/blocks/usp/usp-group/editor.scss +24 -0
- package/src/blocks/usp/usp-group/factory.tsx +113 -0
- package/src/blocks/usp/usp-group/icon.tsx +18 -0
- package/src/blocks/usp/usp-group/index.ts +15 -0
- package/src/blocks/usp/usp-group/types.ts +70 -0
- package/src/blocks/usp/usp-item/constants.ts +7 -0
- package/src/blocks/usp/usp-item/edit.tsx +65 -0
- package/src/blocks/usp/usp-item/editor.scss +17 -0
- package/src/blocks/usp/usp-item/factory.tsx +30 -0
- package/src/blocks/usp/usp-item/index.ts +11 -0
- package/src/blocks/usp/usp-item/types.ts +17 -0
- package/src/components/IconControl/IconControl.tsx +55 -0
- package/src/components/IconControl/editor.scss +53 -0
- package/src/components/IconControl/index.ts +2 -0
- package/src/components/IconControl/index.tsx +1 -0
- package/src/components/ImagePicker/ImagePicker.tsx +124 -0
- package/src/components/ImagePicker/editor.scss +79 -0
- package/src/components/ImagePicker/index.ts +2 -0
- package/src/components/ImagePicker/index.tsx +1 -0
- package/src/components/ItemIconControl/ItemIconControl.tsx +72 -0
- package/src/components/ItemIconControl/ItemIconModal.tsx +12 -0
- package/src/components/ItemIconControl/ItemIconPreview.tsx +93 -0
- package/src/components/ItemIconControl/editor.scss +52 -0
- package/src/components/ItemIconControl/index.ts +2 -0
- package/src/components/ItemIconControl/types.d.ts +30 -0
- package/src/constants.ts +20 -0
- package/src/editor.scss +34 -0
- package/src/globals.scss +237 -0
- package/src/hooks/useGroupBlock.ts +53 -0
- package/src/index.ts +122 -0
- package/src/types.ts +33 -0
- package/src/utils/createEditAdapter.ts +11 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type {TextAndMediaGroupAttributes, TextAndMediaGroupOptions} from './types'
|
|
2
|
+
export {createTextAndMediaGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {TextAndMediaGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const textAndMediaGroupDefaults: TextAndMediaGroupOptions = {
|
|
7
|
+
name: 'brilo/text-and-media-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
allowedBlocks: [
|
|
10
|
+
'brilo/basic-button',
|
|
11
|
+
'brilo/basic-heading',
|
|
12
|
+
'brilo/basic-overline',
|
|
13
|
+
'brilo/button-group',
|
|
14
|
+
'core/heading',
|
|
15
|
+
'core/list',
|
|
16
|
+
'core/paragraph',
|
|
17
|
+
],
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {BriloBlockType, OptionArray} from '~/types'
|
|
2
|
+
import type {
|
|
3
|
+
CHIP_POSITIONS,
|
|
4
|
+
DEFAULT_CHIP_VARIANTS,
|
|
5
|
+
DEFAULT_CONTENT_SIZES,
|
|
6
|
+
DEFAULT_GRID_STYLES,
|
|
7
|
+
DEFAULT_HEADING_STYLES,
|
|
8
|
+
DEFAULT_MEDIA_POSITIONS,
|
|
9
|
+
DEFAULT_RATIOS,
|
|
10
|
+
HEADING_LEVELS,
|
|
11
|
+
} from './constants'
|
|
12
|
+
|
|
13
|
+
export type MediaPositions = (typeof DEFAULT_MEDIA_POSITIONS)[number]['value']
|
|
14
|
+
export type Ratios = (typeof DEFAULT_RATIOS)[number]['value']
|
|
15
|
+
export type GridStyles = (typeof DEFAULT_GRID_STYLES)[number]['value']
|
|
16
|
+
export type HeadingStyles = (typeof DEFAULT_HEADING_STYLES)[number]['value']
|
|
17
|
+
export type HeadingLevels = (typeof HEADING_LEVELS)[number]
|
|
18
|
+
export type ContentSizes = (typeof DEFAULT_CONTENT_SIZES)[number]['value']
|
|
19
|
+
export type ChipPositions = (typeof CHIP_POSITIONS)[number]['value']
|
|
20
|
+
export type ChipVariants = (typeof DEFAULT_CHIP_VARIANTS)[number]['value']
|
|
21
|
+
|
|
22
|
+
export interface TextAndMediaGroupAttributes<
|
|
23
|
+
TRatio extends string = Ratios,
|
|
24
|
+
TMediaPosition extends string = MediaPositions,
|
|
25
|
+
TGridStyle extends string = GridStyles,
|
|
26
|
+
THeadingStyle extends string = HeadingStyles,
|
|
27
|
+
TContentSize extends string = ContentSizes,
|
|
28
|
+
TChipVariant extends string = ChipVariants,
|
|
29
|
+
> extends Record<string, unknown> {
|
|
30
|
+
header: {
|
|
31
|
+
heading: {title: string; level: HeadingLevels; style: THeadingStyle}
|
|
32
|
+
overline: {title: string}
|
|
33
|
+
}
|
|
34
|
+
mediaPosition: TMediaPosition
|
|
35
|
+
img: {
|
|
36
|
+
id: number
|
|
37
|
+
alt: string
|
|
38
|
+
video: {src: string}
|
|
39
|
+
chip: {title: string; position: ChipPositions; variant: TChipVariant}
|
|
40
|
+
}
|
|
41
|
+
ratio: TRatio
|
|
42
|
+
gridStyle: TGridStyle
|
|
43
|
+
content: {size: TContentSize}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TextAndMediaGroupOptions<
|
|
47
|
+
TRatios extends OptionArray = typeof DEFAULT_RATIOS,
|
|
48
|
+
TMediaPositions extends OptionArray = typeof DEFAULT_MEDIA_POSITIONS,
|
|
49
|
+
TGridStyles extends OptionArray = typeof DEFAULT_GRID_STYLES,
|
|
50
|
+
THeadingStyles extends OptionArray = typeof DEFAULT_HEADING_STYLES,
|
|
51
|
+
TContentSizes extends OptionArray = typeof DEFAULT_CONTENT_SIZES,
|
|
52
|
+
TChipVariants extends OptionArray = typeof DEFAULT_CHIP_VARIANTS,
|
|
53
|
+
> extends BriloBlockType {
|
|
54
|
+
ratios?: TRatios
|
|
55
|
+
mediaPositions?: TMediaPositions
|
|
56
|
+
gridStyles?: TGridStyles
|
|
57
|
+
headingStyles?: THeadingStyles
|
|
58
|
+
contentSizes?: TContentSizes
|
|
59
|
+
chipVariants?: TChipVariants
|
|
60
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const VARIANTS = [
|
|
4
|
+
{
|
|
5
|
+
value: 'default',
|
|
6
|
+
label: __('Výchozí', 'brilo-blocks'),
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: 'full-width',
|
|
10
|
+
label: __('Na plnou šířku', 'brilo-blocks'),
|
|
11
|
+
},
|
|
12
|
+
] as const
|
|
13
|
+
|
|
14
|
+
export const EFFECTS = [
|
|
15
|
+
{
|
|
16
|
+
value: 'creative',
|
|
17
|
+
label: __('Slide', 'brilo-blocks'),
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: 'fade',
|
|
21
|
+
label: __('Fade', 'brilo-blocks'),
|
|
22
|
+
},
|
|
23
|
+
] as const
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
SelectControl,
|
|
5
|
+
ToggleControl,
|
|
6
|
+
__experimentalNumberControl as NumberControl,
|
|
7
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
8
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
9
|
+
} from '@wordpress/components'
|
|
10
|
+
import {__} from '@wordpress/i18n'
|
|
11
|
+
import clsx from 'clsx'
|
|
12
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
13
|
+
import {EFFECTS, VARIANTS} from './constants'
|
|
14
|
+
import type {Effect, HeroGroupAttributes, HeroGroupOptions, Variant} from './types'
|
|
15
|
+
|
|
16
|
+
export function createHeroGroupEdit(options: HeroGroupOptions) {
|
|
17
|
+
const VARIANTS_OPTIONS = options.variants ?? VARIANTS
|
|
18
|
+
const EFFECTS_OPTIONS = options.effects ?? EFFECTS
|
|
19
|
+
|
|
20
|
+
return function Edit({
|
|
21
|
+
attributes,
|
|
22
|
+
setAttributes,
|
|
23
|
+
}: {
|
|
24
|
+
attributes: HeroGroupAttributes
|
|
25
|
+
setAttributes: (a: Partial<HeroGroupAttributes>) => void
|
|
26
|
+
}) {
|
|
27
|
+
const {variant, effect, autoplay, autoplaySpeed, pauseOnHover} = attributes
|
|
28
|
+
|
|
29
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
30
|
+
blockClassName: clsx(options.blockClassName ?? 'g-hero wp-block-section', `--variant-${variant}`, `--effect-${effect}`),
|
|
31
|
+
containerClassName: [options.containerClassName ?? 'g-hero__container'],
|
|
32
|
+
allowedBlocks: options.allowedBlocks,
|
|
33
|
+
orientation: 'horizontal',
|
|
34
|
+
template: options.template,
|
|
35
|
+
layout: {type: 'default'},
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
<InspectorControls>
|
|
41
|
+
<PanelBody title={__('Rozložení a efekty', 'brilo-blocks')}>
|
|
42
|
+
<ToggleGroupControl
|
|
43
|
+
isBlock
|
|
44
|
+
label={__('Varianta', 'brilo-blocks')}
|
|
45
|
+
value={variant}
|
|
46
|
+
onChange={(v) => setAttributes({variant: v as Variant})}
|
|
47
|
+
>
|
|
48
|
+
{VARIANTS_OPTIONS.map((v) => (
|
|
49
|
+
<ToggleGroupControlOption key={v.value} value={v.value} label={v.label} />
|
|
50
|
+
))}
|
|
51
|
+
</ToggleGroupControl>
|
|
52
|
+
<SelectControl
|
|
53
|
+
label={__('Efekt přechodu', 'brilo-blocks')}
|
|
54
|
+
value={effect}
|
|
55
|
+
options={EFFECTS_OPTIONS as any}
|
|
56
|
+
onChange={(v) => setAttributes({effect: v as Effect})}
|
|
57
|
+
/>
|
|
58
|
+
</PanelBody>
|
|
59
|
+
<PanelBody title={__('Nastavení slideru', 'brilo-blocks')}>
|
|
60
|
+
<ToggleControl
|
|
61
|
+
label={__('Automatické přehrávání', 'brilo-blocks')}
|
|
62
|
+
checked={autoplay}
|
|
63
|
+
onChange={(v) => setAttributes({autoplay: v})}
|
|
64
|
+
/>
|
|
65
|
+
{autoplay && (
|
|
66
|
+
<NumberControl
|
|
67
|
+
label={__('Rychlost přehrávání (ms)', 'brilo-blocks')}
|
|
68
|
+
value={autoplaySpeed}
|
|
69
|
+
onChange={(v) => setAttributes({autoplaySpeed: parseInt(v ?? '3000')})}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
<ToggleControl
|
|
73
|
+
label={__('Pozastavit při najetí myší', 'brilo-blocks')}
|
|
74
|
+
checked={pauseOnHover}
|
|
75
|
+
onChange={(v) => setAttributes({pauseOnHover: v})}
|
|
76
|
+
/>
|
|
77
|
+
</PanelBody>
|
|
78
|
+
</InspectorControls>
|
|
79
|
+
<div {...blockProps}>
|
|
80
|
+
<div {...innerBlocksProps} />
|
|
81
|
+
</div>
|
|
82
|
+
</>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
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 {EFFECTS, VARIANTS} from './constants'
|
|
6
|
+
import {createHeroGroupEdit} from './edit'
|
|
7
|
+
import type {HeroGroupAttributes, HeroGroupOptions} from './types'
|
|
8
|
+
import {icon} from './icon'
|
|
9
|
+
|
|
10
|
+
export type {HeroGroupAttributes, HeroGroupOptions}
|
|
11
|
+
|
|
12
|
+
export function createHeroGroupBlock<TVariants extends OptionArray = typeof VARIANTS, TEffects extends OptionArray = typeof EFFECTS>(
|
|
13
|
+
options: HeroGroupOptions<TVariants, TEffects>,
|
|
14
|
+
): BlockConfiguration<HeroGroupAttributes<TVariants[number]['value'], TEffects[number]['value']>> {
|
|
15
|
+
const variants = options.variants ?? VARIANTS
|
|
16
|
+
const effects = options.effects ?? EFFECTS
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
name: options.name,
|
|
20
|
+
title: options.title ?? __('Hero Slider', 'brilo-blocks'),
|
|
21
|
+
description: options.description,
|
|
22
|
+
category: options.category ?? 'layout',
|
|
23
|
+
...(options.parent && {parent: options.parent}),
|
|
24
|
+
icon: options.icon ?? icon,
|
|
25
|
+
supports: {html: false, customClassName: false},
|
|
26
|
+
attributes: {
|
|
27
|
+
items: {type: 'array', default: []},
|
|
28
|
+
variant: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
default: variants[0].value,
|
|
31
|
+
enum: variants.map((v) => v.value),
|
|
32
|
+
},
|
|
33
|
+
autoplay: {type: 'boolean', default: false},
|
|
34
|
+
autoplaySpeed: {type: 'number', default: 3000},
|
|
35
|
+
pauseOnHover: {type: 'boolean', default: true},
|
|
36
|
+
effect: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
default: effects[0].value,
|
|
39
|
+
enum: effects.map((e) => e.value),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
edit: createHeroGroupEdit(options as unknown as HeroGroupOptions),
|
|
43
|
+
save: () => <InnerBlocks.Content />,
|
|
44
|
+
} as unknown as BlockConfiguration<HeroGroupAttributes<TVariants[number]['value'], TEffects[number]['value']>>
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 4H8V5H4V4Z" fill="black" />
|
|
4
|
+
<path d="M7 19H9V20H7V19Z" fill="black" />
|
|
5
|
+
<path d="M10 19H11V20H10V19Z" fill="black" />
|
|
6
|
+
<path d="M12 19H13V20H12V19Z" fill="black" />
|
|
7
|
+
<path d="M9 4H16V5H9V4Z" fill="black" />
|
|
8
|
+
<path
|
|
9
|
+
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"
|
|
10
|
+
fill="black"
|
|
11
|
+
/>
|
|
12
|
+
<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" />
|
|
13
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.5 11L6 15L13 15L9.5 11Z" fill="black" />
|
|
14
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M1 10L1 7H19V10H18V8H2V10H1ZM19 15V18H1L1 15H2V17H18V15H19Z" fill="black" />
|
|
15
|
+
<path
|
|
16
|
+
d="M14 11C14 11.5523 13.5523 12 13 12C12.4477 12 12 11.5523 12 11C12 10.4477 12.4477 10 13 10C13.5523 10 14 10.4477 14 11Z"
|
|
17
|
+
fill="black"
|
|
18
|
+
/>
|
|
19
|
+
<path
|
|
20
|
+
d="M0 12.5C0 11.6716 0.671573 11 1.5 11C2.32843 11 3 11.6716 3 12.5C3 13.3284 2.32843 14 1.5 14C0.671573 14 0 13.3284 0 12.5Z"
|
|
21
|
+
fill="#357AB5"
|
|
22
|
+
/>
|
|
23
|
+
<path
|
|
24
|
+
d="M17 12.5C17 11.6716 17.6716 11 18.5 11C19.3284 11 20 11.6716 20 12.5C20 13.3284 19.3284 14 18.5 14C17.6716 14 17 13.3284 17 12.5Z"
|
|
25
|
+
fill="#357AB5"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type {HeroGroupAttributes, HeroGroupOptions} from './types'
|
|
2
|
+
export {createHeroGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {HeroGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const heroGroupDefaults: HeroGroupOptions = {
|
|
7
|
+
name: 'brilo/hero-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
allowedBlocks: ['brilo/hero-item'],
|
|
10
|
+
template: [['brilo/hero-item', {}]],
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {BriloBlockType, OptionArray} from '~/types'
|
|
2
|
+
import type {HeroSliderItem} from '../hero-item/types'
|
|
3
|
+
import type {EFFECTS, VARIANTS} from './constants'
|
|
4
|
+
|
|
5
|
+
export type Variant = (typeof VARIANTS)[number]['value']
|
|
6
|
+
export type Effect = (typeof EFFECTS)[number]['value']
|
|
7
|
+
|
|
8
|
+
export interface HeroGroupAttributes<TVariant extends string = Variant, TEffect extends string = Effect> extends Record<string, unknown> {
|
|
9
|
+
items: HeroSliderItem[]
|
|
10
|
+
variant: TVariant
|
|
11
|
+
autoplay: boolean
|
|
12
|
+
autoplaySpeed: number
|
|
13
|
+
pauseOnHover: boolean
|
|
14
|
+
effect: TEffect
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface HeroGroupOptions<TVariants extends OptionArray = typeof VARIANTS, TEffects extends OptionArray = typeof EFFECTS>
|
|
18
|
+
extends BriloBlockType {
|
|
19
|
+
allowedBlocks: string[]
|
|
20
|
+
variants?: TVariants
|
|
21
|
+
effects?: TEffects
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const CONTENT_POSITIONS = [
|
|
4
|
+
{value: 'top left', label: __('Vlevo nahoře', 'brilo-blocks')},
|
|
5
|
+
{value: 'top center', label: __('Uprostřed nahoře', 'brilo-blocks')},
|
|
6
|
+
{value: 'top right', label: __('Vpravo nahoře', 'brilo-blocks')},
|
|
7
|
+
{value: 'center left', label: __('Vlevo uprostřed', 'brilo-blocks')},
|
|
8
|
+
{value: 'center center', label: __('Uprostřed', 'brilo-blocks')},
|
|
9
|
+
{value: 'center right', label: __('Vpravo uprostřed', 'brilo-blocks')},
|
|
10
|
+
{value: 'bottom left', label: __('Vlevo dole', 'brilo-blocks')},
|
|
11
|
+
{value: 'bottom center', label: __('Uprostřed dole', 'brilo-blocks')},
|
|
12
|
+
{value: 'bottom right', label: __('Vpravo dole', 'brilo-blocks')},
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export const HEADING_LEVELS = [1, 2, 3] as const
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {InspectorControls, RichText, useBlockProps, useInnerBlocksProps} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
5
|
+
AlignmentMatrixControl,
|
|
6
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
7
|
+
BaseControl,
|
|
8
|
+
TextControl,
|
|
9
|
+
ToggleControl,
|
|
10
|
+
} from '@wordpress/components'
|
|
11
|
+
import {__} from '@wordpress/i18n'
|
|
12
|
+
import {ImagePickerBody, ImagePickerControl} from '~/components/ImagePicker'
|
|
13
|
+
import {CONTENT_POSITIONS, HEADING_LEVELS} from './constants'
|
|
14
|
+
import type {ContentPosition, HeroItemAttributes, HeroItemOptions} from './types'
|
|
15
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
16
|
+
import clsx from 'clsx'
|
|
17
|
+
|
|
18
|
+
export function createHeroItemEdit(options: HeroItemOptions) {
|
|
19
|
+
return function Edit({
|
|
20
|
+
attributes,
|
|
21
|
+
setAttributes,
|
|
22
|
+
}: {
|
|
23
|
+
attributes: HeroItemAttributes
|
|
24
|
+
setAttributes: (a: Partial<HeroItemAttributes>) => void
|
|
25
|
+
}) {
|
|
26
|
+
const {title, img, headingLevel, contentPosition, url, focalPoint} = attributes
|
|
27
|
+
|
|
28
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
29
|
+
blockClassName: clsx(options.blockClassName ?? 'i-hero'),
|
|
30
|
+
containerClassName: [options.containerClassName ?? 'i-hero__content wp-block-inner-content'],
|
|
31
|
+
allowedBlocks: options.allowedBlocks,
|
|
32
|
+
orientation: 'vertical',
|
|
33
|
+
template: options.template,
|
|
34
|
+
layout: {type: 'default'},
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<InspectorControls>
|
|
40
|
+
<PanelBody title={__('Nastavení položky', 'brilo-blocks')}>
|
|
41
|
+
<ImagePickerControl value={{id: img.id, alt: img.alt}} onChange={(v) => setAttributes({img: {...img, ...v}})} />
|
|
42
|
+
|
|
43
|
+
<BaseControl label={__('Focal point (desktop)', 'brilo-blocks')}>
|
|
44
|
+
<AlignmentMatrixControl
|
|
45
|
+
value={focalPoint.point as any}
|
|
46
|
+
onChange={(v) => setAttributes({focalPoint: {...focalPoint, point: (v ?? 'center center') as ContentPosition}})}
|
|
47
|
+
/>
|
|
48
|
+
</BaseControl>
|
|
49
|
+
|
|
50
|
+
<BaseControl label={__('Focal point (mobil)', 'brilo-blocks')}>
|
|
51
|
+
<AlignmentMatrixControl
|
|
52
|
+
value={(focalPoint.sm?.point ?? 'center center') as any}
|
|
53
|
+
onChange={(v) => setAttributes({focalPoint: {...focalPoint, sm: {point: (v ?? 'center center') as ContentPosition}}})}
|
|
54
|
+
/>
|
|
55
|
+
</BaseControl>
|
|
56
|
+
|
|
57
|
+
<ToggleGroupControl
|
|
58
|
+
isBlock
|
|
59
|
+
label={__('Úroveň nadpisu položek', 'brilo-blocks')}
|
|
60
|
+
value={String(headingLevel)}
|
|
61
|
+
onChange={(v) => setAttributes({headingLevel: Number(v ?? HEADING_LEVELS[1])})}
|
|
62
|
+
>
|
|
63
|
+
{HEADING_LEVELS.map((l) => (
|
|
64
|
+
<ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
|
|
65
|
+
))}
|
|
66
|
+
</ToggleGroupControl>
|
|
67
|
+
|
|
68
|
+
<BaseControl label={__('Pozice obsahu', 'brilo-blocks')}>
|
|
69
|
+
<AlignmentMatrixControl value={contentPosition} onChange={(v) => setAttributes({contentPosition: v as ContentPosition})} />
|
|
70
|
+
</BaseControl>
|
|
71
|
+
|
|
72
|
+
<TextControl
|
|
73
|
+
label={__('URL odkazu', 'brilo-blocks')}
|
|
74
|
+
value={url.src}
|
|
75
|
+
onChange={(v) => setAttributes({url: {...url, src: v}})}
|
|
76
|
+
/>
|
|
77
|
+
<ToggleControl
|
|
78
|
+
label={__('Otevřít v novém okně', 'brilo-blocks')}
|
|
79
|
+
checked={url.blank}
|
|
80
|
+
onChange={(v) => setAttributes({url: {...url, blank: v}})}
|
|
81
|
+
/>
|
|
82
|
+
</PanelBody>
|
|
83
|
+
</InspectorControls>
|
|
84
|
+
|
|
85
|
+
<div {...blockProps}>
|
|
86
|
+
<div className="i-hero__image-wrap">
|
|
87
|
+
<ImagePickerBody
|
|
88
|
+
value={{id: img.id, alt: img.alt}}
|
|
89
|
+
onChange={(v) => setAttributes({img: {...img, ...v}})}
|
|
90
|
+
placeholder={__('Vyberte obrázek', 'brilo-blocks')}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
<div className={`i-hero__overlay --${contentPosition.replace(' ', '-')}`}>
|
|
94
|
+
<RichText
|
|
95
|
+
tagName={`h${headingLevel}` as any}
|
|
96
|
+
className="i-hero__title u-text-editable"
|
|
97
|
+
value={title}
|
|
98
|
+
onChange={(v) => setAttributes({title: v})}
|
|
99
|
+
placeholder={__('Nadpis...', 'brilo-blocks')}
|
|
100
|
+
/>
|
|
101
|
+
<div {...innerBlocksProps} />
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.i-hero {
|
|
2
|
+
position: relative;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.i-hero__title {
|
|
7
|
+
margin-top: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.i-hero__overlay {
|
|
11
|
+
position: absolute;
|
|
12
|
+
padding: 2rem;
|
|
13
|
+
background: rgba(255, 255, 255, 0.95);
|
|
14
|
+
max-width: 80%;
|
|
15
|
+
z-index: 1;
|
|
16
|
+
|
|
17
|
+
&.--top-left {
|
|
18
|
+
top: 2rem;
|
|
19
|
+
left: 2rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.--top-center {
|
|
23
|
+
top: 2rem;
|
|
24
|
+
left: 50%;
|
|
25
|
+
transform: translateX(-50%);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.--top-right {
|
|
29
|
+
top: 2rem;
|
|
30
|
+
right: 2rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.--center-left {
|
|
34
|
+
top: 50%;
|
|
35
|
+
left: 2rem;
|
|
36
|
+
transform: translateY(-50%);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.--center-center {
|
|
40
|
+
top: 50%;
|
|
41
|
+
left: 50%;
|
|
42
|
+
transform: translate(-50%, -50%);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&.--center-right {
|
|
46
|
+
top: 50%;
|
|
47
|
+
right: 2rem;
|
|
48
|
+
transform: translateY(-50%);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.--bottom-left {
|
|
52
|
+
bottom: 2rem;
|
|
53
|
+
left: 2rem;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&.--bottom-center {
|
|
57
|
+
bottom: 2rem;
|
|
58
|
+
left: 50%;
|
|
59
|
+
transform: translateX(-50%);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&.--bottom-right {
|
|
63
|
+
bottom: 2rem;
|
|
64
|
+
right: 2rem;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.i-hero__image-wrap {
|
|
69
|
+
position: relative;
|
|
70
|
+
width: 100%;
|
|
71
|
+
aspect-ratio: 2 / 1;
|
|
72
|
+
|
|
73
|
+
button {
|
|
74
|
+
height: 100%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
img,
|
|
78
|
+
.components-placeholder,
|
|
79
|
+
.image-picker-body {
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: 0;
|
|
82
|
+
left: 0;
|
|
83
|
+
width: 100%;
|
|
84
|
+
height: 100%;
|
|
85
|
+
object-fit: cover;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {CONTENT_POSITIONS, HEADING_LEVELS} from './constants'
|
|
4
|
+
import {createHeroItemEdit} from './edit'
|
|
5
|
+
import type {HeroItemAttributes, HeroItemOptions} from './types'
|
|
6
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
7
|
+
|
|
8
|
+
export type {HeroItemAttributes, HeroItemOptions}
|
|
9
|
+
|
|
10
|
+
export function createHeroItemBlock(options: HeroItemOptions): BlockConfiguration<HeroItemAttributes> {
|
|
11
|
+
const contentPositions = options.contentPositions ?? CONTENT_POSITIONS
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
name: options.name,
|
|
15
|
+
title: options.title ?? __('Hero položka', 'brilo-blocks'),
|
|
16
|
+
description: options.description,
|
|
17
|
+
category: options.category ?? 'layout',
|
|
18
|
+
...(options.parent && {parent: options.parent}),
|
|
19
|
+
icon: options.icon ?? 'cover-image',
|
|
20
|
+
supports: {html: false, customClassName: false},
|
|
21
|
+
attributes: {
|
|
22
|
+
title: {type: 'string', default: ''},
|
|
23
|
+
img: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
default: {id: 0, url: '', alt: ''},
|
|
26
|
+
},
|
|
27
|
+
headingLevel: {
|
|
28
|
+
type: 'number',
|
|
29
|
+
default: HEADING_LEVELS[0],
|
|
30
|
+
enum: [...HEADING_LEVELS],
|
|
31
|
+
},
|
|
32
|
+
contentPosition: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
default: contentPositions[4].value,
|
|
35
|
+
enum: contentPositions.map((p) => p.value),
|
|
36
|
+
},
|
|
37
|
+
url: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
default: {src: '', blank: false},
|
|
40
|
+
},
|
|
41
|
+
focalPoint: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
default: {point: 'center center', sm: {point: 'center center'}},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
edit: createHeroItemEdit(options),
|
|
47
|
+
save: () => <InnerBlocks.Content />,
|
|
48
|
+
} as unknown as BlockConfiguration<HeroItemAttributes>
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {HeroItemAttributes, HeroItemOptions} from './types'
|
|
2
|
+
export {createHeroItemBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {HeroItemOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const heroItemDefaults: HeroItemOptions = {
|
|
7
|
+
name: 'brilo/hero-item',
|
|
8
|
+
parent: ['brilo/hero-group'],
|
|
9
|
+
allowedBlocks: ['core/list', 'core/paragraph', 'brilo/button-group'],
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {BriloBlockType, Media, OptionArray} from '~/types'
|
|
2
|
+
import {CONTENT_POSITIONS, HEADING_LEVELS} from './constants'
|
|
3
|
+
|
|
4
|
+
export type ContentPosition = (typeof CONTENT_POSITIONS)[number]['value']
|
|
5
|
+
export type HeadingLevel = (typeof HEADING_LEVELS)[number]
|
|
6
|
+
|
|
7
|
+
export type HeroItemUrl = {
|
|
8
|
+
src: string
|
|
9
|
+
blank: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type HeroSliderItem = {
|
|
13
|
+
title: string
|
|
14
|
+
img: Media
|
|
15
|
+
headingLevel: number
|
|
16
|
+
contentPosition: ContentPosition
|
|
17
|
+
url: HeroItemUrl
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type HeroItemFocalPoint = {
|
|
21
|
+
point: ContentPosition
|
|
22
|
+
sm?: {
|
|
23
|
+
point: ContentPosition
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface HeroItemAttributes extends Record<string, unknown> {
|
|
28
|
+
title: string
|
|
29
|
+
img: Media
|
|
30
|
+
headingLevel: number
|
|
31
|
+
contentPosition: ContentPosition
|
|
32
|
+
url: HeroItemUrl
|
|
33
|
+
focalPoint: HeroItemFocalPoint
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface HeroItemOptions extends BriloBlockType {
|
|
37
|
+
contentPositions?: OptionArray
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const MAP_TYPES = [
|
|
4
|
+
{
|
|
5
|
+
value: 'gps',
|
|
6
|
+
label: __('GPS', 'brilo-blocks'),
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: 'element',
|
|
10
|
+
label: __('Element', 'brilo-blocks'),
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
value: 'url',
|
|
14
|
+
label: __('URL', 'brilo-blocks'),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: 'image',
|
|
18
|
+
label: __('Obrázek', 'brilo-blocks'),
|
|
19
|
+
},
|
|
20
|
+
] as const
|