@brilo/base-blocks 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +12 -0
- package/.prettierrc +8 -0
- package/README.md +59 -0
- package/USAGE.md +263 -0
- package/biome.json +38 -0
- package/bun.lock +1392 -0
- package/docs/block-anatomy.md +73 -0
- package/docs/conventions.md +204 -0
- package/docs/new-block.md +179 -0
- package/package.json +41 -0
- 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 +190 -0
- package/src/blocks/form/form-group/editor.scss +41 -0
- package/src/blocks/form/form-group/factory.tsx +35 -0
- package/src/blocks/form/form-group/index.ts +18 -0
- package/src/blocks/form/form-group/types.ts +22 -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
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export {HEADING_LEVELS as DEFAULT_LEVELS, HEADING_STYLES as DEFAULT_STYLES} from '~/constants'
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_ALIGNMENTS = [
|
|
6
|
+
{value: 'left', label: __('Vlevo', 'brilo-blocks')},
|
|
7
|
+
{value: 'center', label: __('Středem', 'brilo-blocks')},
|
|
8
|
+
{value: 'right', label: __('Vpravo', 'brilo-blocks')},
|
|
9
|
+
] as const
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {InspectorControls, RichText, useBlockProps} 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 {DEFAULT_ALIGNMENTS, DEFAULT_LEVELS, DEFAULT_STYLES} from './constants'
|
|
10
|
+
import type {BasicHeaderGroupAttributes, BasicHeaderGroupOptions, HeaderAlignment, HeadingStyle} from './types'
|
|
11
|
+
|
|
12
|
+
export function createBasicHeaderGroupEdit(options: BasicHeaderGroupOptions) {
|
|
13
|
+
const LEVELS = options.levels ?? DEFAULT_LEVELS
|
|
14
|
+
const STYLES = options.styles ?? DEFAULT_STYLES
|
|
15
|
+
const ALIGNMENTS = options.alignments ?? DEFAULT_ALIGNMENTS
|
|
16
|
+
|
|
17
|
+
return function Edit({
|
|
18
|
+
attributes,
|
|
19
|
+
setAttributes,
|
|
20
|
+
}: {
|
|
21
|
+
attributes: BasicHeaderGroupAttributes
|
|
22
|
+
setAttributes: (a: Partial<BasicHeaderGroupAttributes>) => void
|
|
23
|
+
}) {
|
|
24
|
+
const {heading, overline, content, textAlign} = attributes
|
|
25
|
+
const blockProps = useBlockProps({
|
|
26
|
+
className: clsx(options.blockClassName ?? 'g-header wp-block-section', `--textAlign-${textAlign}`),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<InspectorControls>
|
|
32
|
+
<PanelBody title={__('Nadpis', 'brilo-blocks')}>
|
|
33
|
+
<ToggleGroupControl
|
|
34
|
+
label={__('Úroveň nadpisu', 'brilo-blocks')}
|
|
35
|
+
value={String(heading.level)}
|
|
36
|
+
onChange={(value) =>
|
|
37
|
+
setAttributes({
|
|
38
|
+
heading: {...heading, level: Number(value) as BasicHeaderGroupAttributes['heading']['level']},
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
isBlock
|
|
42
|
+
>
|
|
43
|
+
{LEVELS.map((l) => (
|
|
44
|
+
<ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
|
|
45
|
+
))}
|
|
46
|
+
</ToggleGroupControl>
|
|
47
|
+
<ToggleGroupControl
|
|
48
|
+
label={__('Styl nadpisu', 'brilo-blocks')}
|
|
49
|
+
value={heading.style}
|
|
50
|
+
onChange={(value) => setAttributes({heading: {...heading, style: value as HeadingStyle}})}
|
|
51
|
+
isBlock
|
|
52
|
+
>
|
|
53
|
+
{STYLES.map((s) => (
|
|
54
|
+
<ToggleGroupControlOption key={s} value={s} label={s.toUpperCase()} />
|
|
55
|
+
))}
|
|
56
|
+
</ToggleGroupControl>
|
|
57
|
+
<ToggleGroupControl
|
|
58
|
+
label={__('Zarovnání', 'brilo-blocks')}
|
|
59
|
+
value={textAlign}
|
|
60
|
+
onChange={(value) => setAttributes({textAlign: value as HeaderAlignment})}
|
|
61
|
+
isBlock
|
|
62
|
+
>
|
|
63
|
+
{ALIGNMENTS.map((a) => (
|
|
64
|
+
<ToggleGroupControlOption key={a.value} value={a.value} label={a.label} />
|
|
65
|
+
))}
|
|
66
|
+
</ToggleGroupControl>
|
|
67
|
+
</PanelBody>
|
|
68
|
+
</InspectorControls>
|
|
69
|
+
<div {...blockProps}>
|
|
70
|
+
<RichText
|
|
71
|
+
tagName="span"
|
|
72
|
+
className="g-header__overline u-text-editable"
|
|
73
|
+
value={overline.title}
|
|
74
|
+
onChange={(value) => setAttributes({overline: {title: value}})}
|
|
75
|
+
placeholder={__('Overline...', 'brilo-blocks')}
|
|
76
|
+
allowedFormats={[]}
|
|
77
|
+
/>
|
|
78
|
+
<RichText
|
|
79
|
+
tagName={`h${heading.level}` as 'h1' | 'h2' | 'h3' | 'h4'}
|
|
80
|
+
className={clsx('g-header__heading', `--heading-style-${heading.style}`, 'u-text-editable')}
|
|
81
|
+
value={heading.title}
|
|
82
|
+
onChange={(value) => setAttributes({heading: {...heading, title: value}})}
|
|
83
|
+
placeholder={__('Nadpis...', 'brilo-blocks')}
|
|
84
|
+
allowedFormats={['core/bold', 'core/italic']}
|
|
85
|
+
/>
|
|
86
|
+
<RichText
|
|
87
|
+
tagName="div"
|
|
88
|
+
multiline="p"
|
|
89
|
+
className="g-header__content u-text-editable"
|
|
90
|
+
value={content}
|
|
91
|
+
onChange={(value) => setAttributes({content: value})}
|
|
92
|
+
placeholder={__('Perex...', 'brilo-blocks')}
|
|
93
|
+
allowedFormats={['core/bold', 'core/italic', 'core/link']}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.g-header {
|
|
3
|
+
padding: 12px 16px;
|
|
4
|
+
|
|
5
|
+
&.--textAlign-left {
|
|
6
|
+
text-align: left;
|
|
7
|
+
}
|
|
8
|
+
&.--textAlign-center {
|
|
9
|
+
text-align: center;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.g-header__overline {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
font-size: 11px;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
text-transform: uppercase;
|
|
18
|
+
letter-spacing: 1.5px;
|
|
19
|
+
color: #555;
|
|
20
|
+
background-color: #f0f0f0;
|
|
21
|
+
border-radius: 100px;
|
|
22
|
+
padding: 3px 10px;
|
|
23
|
+
margin-bottom: 8px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.g-header__heading {
|
|
27
|
+
margin: 0 0 10px;
|
|
28
|
+
font-weight: 700;
|
|
29
|
+
font-size: var(--heading-size, 24px);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.g-header__content {
|
|
33
|
+
margin-block: 4px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import type {NumberArray, OptionArray, StringArray} from '~/types'
|
|
4
|
+
import {DEFAULT_ALIGNMENTS, DEFAULT_LEVELS, DEFAULT_STYLES} from './constants'
|
|
5
|
+
import {createBasicHeaderGroupEdit} from './edit'
|
|
6
|
+
import {icon as defaultIcon} from './icon'
|
|
7
|
+
import type {BasicHeaderGroupAttributes, BasicHeaderGroupOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export type {BasicHeaderGroupAttributes, BasicHeaderGroupOptions}
|
|
10
|
+
|
|
11
|
+
export function createBasicHeaderGroupBlock<
|
|
12
|
+
TLevels extends NumberArray = typeof DEFAULT_LEVELS,
|
|
13
|
+
TStyles extends StringArray = typeof DEFAULT_STYLES,
|
|
14
|
+
TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS,
|
|
15
|
+
>(
|
|
16
|
+
options: BasicHeaderGroupOptions<TLevels, TStyles, TAlignments>,
|
|
17
|
+
): BlockConfiguration<BasicHeaderGroupAttributes<TLevels[number], TStyles[number], TAlignments[number]['value']>> {
|
|
18
|
+
const levels = options.levels ?? DEFAULT_LEVELS
|
|
19
|
+
const styles = options.styles ?? DEFAULT_STYLES
|
|
20
|
+
const alignments = options.alignments ?? DEFAULT_ALIGNMENTS
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
name: options.name,
|
|
24
|
+
title: options.title ?? __('Hlavička základní', 'brilo-blocks'),
|
|
25
|
+
description: options.description,
|
|
26
|
+
category: options.category ?? 'layout',
|
|
27
|
+
...(options.parent && {parent: options.parent}),
|
|
28
|
+
icon: options.icon ?? defaultIcon,
|
|
29
|
+
supports: {html: false, customClassName: false},
|
|
30
|
+
attributes: {
|
|
31
|
+
heading: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
default: {title: '', level: levels[1] ?? levels[0], style: styles[1] ?? styles[0]},
|
|
34
|
+
},
|
|
35
|
+
overline: {type: 'object', default: {title: ''}},
|
|
36
|
+
content: {type: 'string', default: ''},
|
|
37
|
+
textAlign: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
default: alignments[1]?.value ?? alignments[0].value,
|
|
40
|
+
enum: alignments.map((a) => a.value),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
edit: createBasicHeaderGroupEdit(options as unknown as BasicHeaderGroupOptions),
|
|
44
|
+
save: () => null,
|
|
45
|
+
} as unknown as BlockConfiguration<BasicHeaderGroupAttributes<TLevels[number], TStyles[number], TAlignments[number]['value']>>
|
|
46
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
<title>Basic Header Group</title>
|
|
4
|
+
<rect x="12" y="4" width="3" height="2" rx="1" fill="black" />
|
|
5
|
+
<rect x="5" y="4" width="6" height="2" rx="1" fill="black" />
|
|
6
|
+
<rect x="1" y="8" width="6" height="1" fill="black" />
|
|
7
|
+
<rect x="9" y="8" width="10" height="1" fill="black" />
|
|
8
|
+
<rect x="3" y="10" width="9" height="1" fill="black" />
|
|
9
|
+
<rect x="14" y="10" width="3" height="1" fill="black" />
|
|
10
|
+
<path
|
|
11
|
+
fillRule="evenodd"
|
|
12
|
+
clipRule="evenodd"
|
|
13
|
+
d="M7.5 13C6.67157 13 6 13.6716 6 14.5C6 15.3284 6.67157 16 7.5 16H12.5C13.3284 16 14 15.3284 14 14.5C14 13.6716 13.3284 13 12.5 13H7.5ZM12 14H8V15H12V14Z"
|
|
14
|
+
fill="#357AB5"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {BasicHeaderGroupAttributes, BasicHeaderGroupOptions} from './types'
|
|
2
|
+
export {createBasicHeaderGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {BasicHeaderGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const basicHeaderGroupDefaults: BasicHeaderGroupOptions = {
|
|
7
|
+
name: 'brilo/basic-header-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {BriloBlockType, NumberArray, OptionArray, StringArray} from '~/types'
|
|
2
|
+
import type {DEFAULT_ALIGNMENTS, DEFAULT_LEVELS, DEFAULT_STYLES} from './constants'
|
|
3
|
+
|
|
4
|
+
export type HeaderAlignment = (typeof DEFAULT_ALIGNMENTS)[number]['value']
|
|
5
|
+
export type HeadingLevel = (typeof DEFAULT_LEVELS)[number]
|
|
6
|
+
export type HeadingStyle = (typeof DEFAULT_STYLES)[number]
|
|
7
|
+
|
|
8
|
+
export interface BasicHeaderGroupAttributes<
|
|
9
|
+
TLevel extends number = HeadingLevel,
|
|
10
|
+
TStyle extends string = HeadingStyle,
|
|
11
|
+
TAlignment extends string = HeaderAlignment,
|
|
12
|
+
> extends Record<string, unknown> {
|
|
13
|
+
heading: {title: string; level: TLevel; style: TStyle}
|
|
14
|
+
overline: {title: string}
|
|
15
|
+
content: string
|
|
16
|
+
textAlign: TAlignment
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BasicHeaderGroupOptions<
|
|
20
|
+
TLevels extends NumberArray = typeof DEFAULT_LEVELS,
|
|
21
|
+
TStyles extends StringArray = typeof DEFAULT_STYLES,
|
|
22
|
+
TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS,
|
|
23
|
+
> extends BriloBlockType {
|
|
24
|
+
levels?: TLevels
|
|
25
|
+
styles?: TStyles
|
|
26
|
+
alignments?: TAlignments
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_ALIGNMENTS = [
|
|
4
|
+
{value: 'left', label: __('Vlevo', 'brilo-blocks'), icon: 'align-left'},
|
|
5
|
+
{value: 'center', label: __('Na střed', 'brilo-blocks'), icon: 'align-center'},
|
|
6
|
+
{value: 'right', label: __('Vpravo', 'brilo-blocks'), icon: 'align-right'},
|
|
7
|
+
] as const
|
|
@@ -0,0 +1,52 @@
|
|
|
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 {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
9
|
+
import {DEFAULT_ALIGNMENTS} from './constants'
|
|
10
|
+
import type {ButtonGroupAlignment, ButtonGroupAttributes, ButtonGroupOptions} from './types'
|
|
11
|
+
|
|
12
|
+
export function createButtonGroupEdit(options: ButtonGroupOptions) {
|
|
13
|
+
const alignments = options.alignments ?? DEFAULT_ALIGNMENTS
|
|
14
|
+
|
|
15
|
+
return function Edit({
|
|
16
|
+
attributes,
|
|
17
|
+
setAttributes,
|
|
18
|
+
}: {
|
|
19
|
+
attributes: ButtonGroupAttributes
|
|
20
|
+
setAttributes: (a: Partial<ButtonGroupAttributes>) => void
|
|
21
|
+
}) {
|
|
22
|
+
const {alignment} = attributes
|
|
23
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
24
|
+
blockClassName: [options.blockClassName ?? 'g-button-group wp-block-section', `--align-${alignment}`],
|
|
25
|
+
containerClassName: options.containerClassName ?? 'flex gap-3 g-button-group__inner',
|
|
26
|
+
allowedBlocks: options.allowedBlocks,
|
|
27
|
+
template: options.template,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<InspectorControls>
|
|
33
|
+
<PanelBody title={__('Skupina tlačítek', 'brilo-blocks')}>
|
|
34
|
+
<ToggleGroupControl
|
|
35
|
+
label={__('Zarovnání', 'brilo-blocks')}
|
|
36
|
+
value={alignment}
|
|
37
|
+
onChange={(v) => setAttributes({alignment: v as ButtonGroupAlignment})}
|
|
38
|
+
isBlock
|
|
39
|
+
>
|
|
40
|
+
{alignments.map((a) => (
|
|
41
|
+
<ToggleGroupControlOption key={a.value} value={a.value} label={a.label} />
|
|
42
|
+
))}
|
|
43
|
+
</ToggleGroupControl>
|
|
44
|
+
</PanelBody>
|
|
45
|
+
</InspectorControls>
|
|
46
|
+
<div {...blockProps}>
|
|
47
|
+
<div {...innerBlocksProps} />
|
|
48
|
+
</div>
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.g-button-group {
|
|
3
|
+
padding: 8px;
|
|
4
|
+
min-height: 44px;
|
|
5
|
+
|
|
6
|
+
&.--align-left {
|
|
7
|
+
--justify: flex-start;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&.--align-center {
|
|
11
|
+
--justify: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.--align-right {
|
|
15
|
+
--justify: flex-end;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.g-button-group__inner {
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
justify-content: var(--justify, flex-start);
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 {DEFAULT_ALIGNMENTS} from './constants'
|
|
6
|
+
import {createButtonGroupEdit} from './edit'
|
|
7
|
+
import type {ButtonGroupAttributes, ButtonGroupOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export type {ButtonGroupAttributes, ButtonGroupOptions}
|
|
10
|
+
|
|
11
|
+
export function createButtonGroupBlock<TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS>(
|
|
12
|
+
options: ButtonGroupOptions<TAlignments>,
|
|
13
|
+
): BlockConfiguration<ButtonGroupAttributes<TAlignments[number]['value']>> {
|
|
14
|
+
const alignments = options.alignments ?? DEFAULT_ALIGNMENTS
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
name: options.name,
|
|
18
|
+
title: options.title ?? __('Skupina tlačítek', 'brilo-blocks'),
|
|
19
|
+
description: options.description,
|
|
20
|
+
category: options.category ?? 'layout',
|
|
21
|
+
...(options.parent && {parent: options.parent}),
|
|
22
|
+
icon: options.icon ?? 'button',
|
|
23
|
+
supports: {html: false, customClassName: false},
|
|
24
|
+
attributes: {
|
|
25
|
+
alignment: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
default: alignments[1]?.value ?? alignments[0].value,
|
|
28
|
+
enum: alignments.map((a) => a.value),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
edit: createButtonGroupEdit(options as unknown as ButtonGroupOptions),
|
|
32
|
+
save: () => <InnerBlocks.Content />,
|
|
33
|
+
} as unknown as BlockConfiguration<ButtonGroupAttributes<TAlignments[number]['value']>>
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type {ButtonGroupAttributes, ButtonGroupOptions} from './types'
|
|
2
|
+
export {createButtonGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {ButtonGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const buttonGroupDefaults: ButtonGroupOptions = {
|
|
7
|
+
name: 'brilo/button-group',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
allowedBlocks: ['brilo/basic-button'],
|
|
10
|
+
template: [['brilo/basic-button', {}]],
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {OptionArray, BriloBlockType} from '~/types'
|
|
2
|
+
import type {DEFAULT_ALIGNMENTS} from './constants'
|
|
3
|
+
|
|
4
|
+
export type ButtonGroupAlignment = (typeof DEFAULT_ALIGNMENTS)[number]['value']
|
|
5
|
+
|
|
6
|
+
export interface ButtonGroupAttributes<TAlignment extends string = ButtonGroupAlignment> extends Record<string, unknown> {
|
|
7
|
+
alignment: TAlignment
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ButtonGroupOptions<TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS> extends BriloBlockType {
|
|
11
|
+
alignments?: TAlignments
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export {CONTENT_SIZES as DEFAULT_CONTENT_SIZES, HEADING_LEVELS} from '~/constants'
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_RATIOS = [
|
|
6
|
+
{value: '3:2', label: '3:2'},
|
|
7
|
+
{value: '4:3', label: '4:3'},
|
|
8
|
+
{value: '16:9', label: '16:9'},
|
|
9
|
+
{value: '1:1', label: '1:1'},
|
|
10
|
+
{value: '2:1', label: '2:1'},
|
|
11
|
+
{value: '3:4', label: '3:4'},
|
|
12
|
+
{value: 'auto', label: 'Auto'},
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export const CHIP_POSITIONS = [
|
|
16
|
+
{value: 'top-left', label: __('Vlevo nahoře', 'brilo-blocks')},
|
|
17
|
+
{value: 'top-right', label: __('Vpravo nahoře', 'brilo-blocks')},
|
|
18
|
+
{value: 'bottom-left', label: __('Vlevo dole', 'brilo-blocks')},
|
|
19
|
+
{value: 'bottom-right', label: __('Vpravo dole', 'brilo-blocks')},
|
|
20
|
+
] as const
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_CHIP_VARIANTS = [
|
|
23
|
+
{value: 'primary', label: __('Primární', 'brilo-blocks')},
|
|
24
|
+
{value: 'secondary', label: __('Sekundární', 'brilo-blocks')},
|
|
25
|
+
{value: 'neutral', label: __('Neutrální', 'brilo-blocks')},
|
|
26
|
+
] as const
|
|
27
|
+
|
|
28
|
+
export const DEFAULT_MEDIA_POSITIONS = [
|
|
29
|
+
{value: 'left', label: __('Vlevo', 'brilo-blocks')},
|
|
30
|
+
{value: 'right', label: __('Vpravo', 'brilo-blocks')},
|
|
31
|
+
] as const
|
|
32
|
+
|
|
33
|
+
export const DEFAULT_HEADING_STYLES = [
|
|
34
|
+
{value: 'h1', label: 'H1 styl'},
|
|
35
|
+
{value: 'h2', label: 'H2 styl'},
|
|
36
|
+
{value: 'h3', label: 'H3 styl'},
|
|
37
|
+
{value: 'h4', label: 'H4 styl'},
|
|
38
|
+
] as const
|
|
39
|
+
|
|
40
|
+
export const DEFAULT_GRID_STYLES = [
|
|
41
|
+
{value: '1-1', label: __('Půl na půl', 'brilo-blocks')},
|
|
42
|
+
{value: '2-1', label: __('2/3 + 1/3', 'brilo-blocks')},
|
|
43
|
+
] as const
|