@brilo/base-blocks 0.1.40 → 0.1.41
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/.tsbuildinfo +1 -1
- package/build/blocks/career/career-benefits/constants.d.ts +17 -0
- package/build/blocks/career/career-benefits/constants.d.ts.map +1 -0
- package/build/blocks/career/career-benefits/constants.js +7 -0
- package/build/blocks/career/career-benefits/edit.d.ts +6 -0
- package/build/blocks/career/career-benefits/edit.d.ts.map +1 -0
- package/build/blocks/career/career-benefits/edit.js +14 -0
- package/build/blocks/career/career-benefits/factory.d.ts +5 -0
- package/build/blocks/career/career-benefits/factory.d.ts.map +1 -0
- package/build/blocks/career/career-benefits/factory.js +22 -0
- package/build/blocks/career/career-benefits/icon.d.ts +2 -0
- package/build/blocks/career/career-benefits/icon.d.ts.map +1 -0
- package/build/blocks/career/career-benefits/icon.js +2 -0
- package/build/blocks/career/career-benefits/index.d.ts +5 -0
- package/build/blocks/career/career-benefits/index.d.ts.map +1 -0
- package/build/blocks/career/career-benefits/index.js +5 -0
- package/build/blocks/career/career-benefits/types.d.ts +8 -0
- package/build/blocks/career/career-benefits/types.d.ts.map +1 -0
- package/build/blocks/career/career-benefits/types.js +1 -0
- package/build/blocks/career/career-header/constants.d.ts +16 -0
- package/build/blocks/career/career-header/constants.d.ts.map +1 -1
- package/build/blocks/career/career-header/constants.js +7 -0
- package/build/blocks/career/career-header/edit.d.ts.map +1 -1
- package/build/blocks/career/career-header/edit.js +7 -5
- package/build/blocks/career/career-header/factory.d.ts.map +1 -1
- package/build/blocks/career/career-header/factory.js +2 -0
- package/build/blocks/career/career-header/types.d.ts +2 -0
- package/build/blocks/career/career-header/types.d.ts.map +1 -1
- package/build/blocks/layout/box/controls.d.ts +8 -0
- package/build/blocks/layout/box/controls.d.ts.map +1 -0
- package/build/blocks/layout/box/controls.js +13 -0
- package/build/blocks/layout/box/edit.d.ts +4 -0
- package/build/blocks/layout/box/edit.d.ts.map +1 -0
- package/build/blocks/layout/box/edit.js +35 -0
- package/build/blocks/layout/box/factory.d.ts +4 -0
- package/build/blocks/layout/box/factory.d.ts.map +1 -0
- package/build/blocks/layout/box/factory.js +28 -0
- package/build/blocks/layout/box/icon.d.ts +2 -0
- package/build/blocks/layout/box/icon.d.ts.map +1 -0
- package/build/blocks/layout/box/icon.js +2 -0
- package/build/blocks/layout/box/index.d.ts +5 -0
- package/build/blocks/layout/box/index.d.ts.map +1 -0
- package/build/blocks/layout/box/index.js +6 -0
- package/build/blocks/layout/box/types.d.ts +25 -0
- package/build/blocks/layout/box/types.d.ts.map +1 -0
- package/build/blocks/layout/box/types.js +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -0
- package/package.json +1 -1
- package/src/blocks/career/career-benefits/constants.ts +7 -0
- package/src/blocks/career/career-benefits/edit.tsx +55 -0
- package/src/blocks/career/career-benefits/factory.tsx +26 -0
- package/src/blocks/career/career-benefits/icon.tsx +10 -0
- package/src/blocks/career/career-benefits/index.ts +9 -0
- package/src/blocks/career/career-benefits/types.ts +9 -0
- package/src/blocks/career/career-header/constants.ts +8 -0
- package/src/blocks/career/career-header/edit.tsx +21 -4
- package/src/blocks/career/career-header/factory.tsx +2 -0
- package/src/blocks/career/career-header/types.ts +2 -0
- package/src/blocks/layout/box/controls.tsx +64 -0
- package/src/blocks/layout/box/edit.tsx +52 -0
- package/src/blocks/layout/box/factory.tsx +31 -0
- package/src/blocks/layout/box/icon.tsx +5 -0
- package/src/blocks/layout/box/index.ts +10 -0
- package/src/blocks/layout/box/types.ts +27 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,10 @@
|
|
|
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="M3 5.5L5 7.5L9 3.5" stroke="black" strokeWidth="1.2" fill="none" />
|
|
4
|
+
<path d="M3 10.5L5 12.5L9 8.5" stroke="black" strokeWidth="1.2" fill="none" />
|
|
5
|
+
<path d="M3 15.5L5 17.5L9 13.5" stroke="black" strokeWidth="1.2" fill="none" />
|
|
6
|
+
<line x1="11" y1="5" x2="18" y2="5" stroke="black" />
|
|
7
|
+
<line x1="11" y1="10" x2="18" y2="10" stroke="black" />
|
|
8
|
+
<line x1="11" y1="15" x2="18" y2="15" stroke="black" />
|
|
9
|
+
</svg>
|
|
10
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {CareerBenefitsAttributes, CareerBenefitsOptions} from './types'
|
|
2
|
+
export {createCareerBenefitsBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {CareerBenefitsOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const careerBenefitsDefaults: CareerBenefitsOptions = {
|
|
7
|
+
name: 'brilo/career-benefits',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
1
|
export const DEFAULT_ALLOWED_BLOCKS: string[] = ['brilo/button-group']
|
|
2
|
+
|
|
3
|
+
export const TITLE_STYLES = [
|
|
4
|
+
{value: 'h1', label: 'H1'},
|
|
5
|
+
{value: 'h2', label: 'H2'},
|
|
6
|
+
{value: 'h3', label: 'H3'},
|
|
7
|
+
{value: 'h4', label: 'H4'},
|
|
8
|
+
{value: 'h5', label: 'H5'},
|
|
9
|
+
] as const
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {InspectorControls, useBlockProps, useInnerBlocksProps} from '@wordpress/block-editor'
|
|
2
|
-
import {PanelBody, ToggleControl} from '@wordpress/components'
|
|
1
|
+
import {ColorPalette, InspectorControls, useBlockProps, useInnerBlocksProps} from '@wordpress/block-editor'
|
|
2
|
+
import {PanelBody, SelectControl, ToggleControl} from '@wordpress/components'
|
|
3
3
|
import {__} from '@wordpress/i18n'
|
|
4
|
-
import {
|
|
4
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
5
|
+
import {DEFAULT_ALLOWED_BLOCKS, TITLE_STYLES} from './constants'
|
|
5
6
|
import type {CareerHeaderAttributes, CareerHeaderOptions} from './types'
|
|
6
7
|
|
|
7
8
|
export function createCareerHeaderEdit(options: CareerHeaderOptions) {
|
|
@@ -12,7 +13,8 @@ export function createCareerHeaderEdit(options: CareerHeaderOptions) {
|
|
|
12
13
|
attributes: CareerHeaderAttributes
|
|
13
14
|
setAttributes: (a: Partial<CareerHeaderAttributes>) => void
|
|
14
15
|
}) {
|
|
15
|
-
const {showExcerpt, showLocation, showSalary, showBenefits, showEmploymentType} = attributes
|
|
16
|
+
const {showExcerpt, showLocation, showSalary, showBenefits, showEmploymentType, titleColor, titleStyle} = attributes
|
|
17
|
+
const {paletteColors} = useTenantColorPalette()
|
|
16
18
|
|
|
17
19
|
const blockProps = useBlockProps({className: 'wp-block-section'})
|
|
18
20
|
const innerBlocksProps = useInnerBlocksProps({}, {allowedBlocks: options.allowedBlocks ?? DEFAULT_ALLOWED_BLOCKS})
|
|
@@ -47,6 +49,21 @@ export function createCareerHeaderEdit(options: CareerHeaderOptions) {
|
|
|
47
49
|
onChange={(value) => setAttributes({showEmploymentType: value})}
|
|
48
50
|
/>
|
|
49
51
|
</PanelBody>
|
|
52
|
+
|
|
53
|
+
<PanelBody title={__('Titulek', 'brilo-blocks')}>
|
|
54
|
+
<SelectControl
|
|
55
|
+
label={__('Styl titulku', 'brilo-blocks')}
|
|
56
|
+
value={titleStyle}
|
|
57
|
+
options={TITLE_STYLES.map((s): {value: string; label: string} => ({value: s.value, label: s.label}))}
|
|
58
|
+
onChange={(value) => setAttributes({titleStyle: value})}
|
|
59
|
+
/>
|
|
60
|
+
<p>{__('Barva titulku', 'brilo-blocks')}</p>
|
|
61
|
+
<ColorPalette
|
|
62
|
+
colors={paletteColors}
|
|
63
|
+
value={titleColor || undefined}
|
|
64
|
+
onChange={(value) => setAttributes({titleColor: value ?? ''})}
|
|
65
|
+
/>
|
|
66
|
+
</PanelBody>
|
|
50
67
|
</InspectorControls>
|
|
51
68
|
|
|
52
69
|
<div {...blockProps}>
|
|
@@ -22,6 +22,8 @@ export function createCareerHeaderBlock(options: CareerHeaderOptions): BlockConf
|
|
|
22
22
|
showSalary: {type: 'boolean', default: true},
|
|
23
23
|
showBenefits: {type: 'boolean', default: true},
|
|
24
24
|
showEmploymentType: {type: 'boolean', default: true},
|
|
25
|
+
titleColor: {type: 'string', default: ''},
|
|
26
|
+
titleStyle: {type: 'string', default: 'h2'},
|
|
25
27
|
},
|
|
26
28
|
edit: createCareerHeaderEdit(options),
|
|
27
29
|
save: () => <InnerBlocks.Content />,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as blockEditor from '@wordpress/block-editor'
|
|
2
|
+
import {ColorPalette, ContrastChecker} from '@wordpress/block-editor'
|
|
3
|
+
import {BoxControl, PanelBody, __experimentalUnitControl as UnitControl} from '@wordpress/components'
|
|
4
|
+
import {__} from '@wordpress/i18n'
|
|
5
|
+
import type {ComponentType} from 'react'
|
|
6
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
7
|
+
import type {BoxAttributes, BoxBorderRadius} from './types'
|
|
8
|
+
|
|
9
|
+
// `__experimentalBorderRadiusControl` is a real runtime export of @wordpress/block-editor (see
|
|
10
|
+
// packages/block-editor/src/components/border-radius-control) but isn't covered by the community
|
|
11
|
+
// @types/wordpress__block-editor typings, so it's pulled off the namespace import and cast by hand.
|
|
12
|
+
interface BorderRadiusControlProps {
|
|
13
|
+
values?: string | BoxBorderRadius
|
|
14
|
+
onChange: (next: string | BoxBorderRadius | undefined) => void
|
|
15
|
+
}
|
|
16
|
+
const BorderRadiusControl = (blockEditor as unknown as {__experimentalBorderRadiusControl: ComponentType<BorderRadiusControlProps>})
|
|
17
|
+
.__experimentalBorderRadiusControl
|
|
18
|
+
|
|
19
|
+
interface BoxControlsProps {
|
|
20
|
+
attributes: BoxAttributes
|
|
21
|
+
setAttributes: (attrs: Partial<BoxAttributes>) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function BoxControls({attributes, setAttributes}: BoxControlsProps) {
|
|
25
|
+
const {padding, margin, borderRadius, borderWidth, borderColor, background, textColor} = attributes
|
|
26
|
+
const {paletteColors, resolveHex} = useTenantColorPalette()
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<PanelBody title={__('Rozestupy', 'brilo-blocks')}>
|
|
31
|
+
<BoxControl label={__('Padding', 'brilo-blocks')} values={padding} onChange={(next) => setAttributes({padding: next})} />
|
|
32
|
+
<BoxControl label={__('Margin', 'brilo-blocks')} values={margin} onChange={(next) => setAttributes({margin: next})} />
|
|
33
|
+
</PanelBody>
|
|
34
|
+
|
|
35
|
+
<PanelBody title={__('Ohraničení', 'brilo-blocks')}>
|
|
36
|
+
<UnitControl
|
|
37
|
+
label={__('Šířka okraje', 'brilo-blocks')}
|
|
38
|
+
value={borderWidth}
|
|
39
|
+
min={0}
|
|
40
|
+
onChange={(next) => setAttributes({borderWidth: (next as string) ?? ''})}
|
|
41
|
+
/>
|
|
42
|
+
<p>{__('Barva okraje', 'brilo-blocks')}</p>
|
|
43
|
+
<ColorPalette
|
|
44
|
+
colors={paletteColors}
|
|
45
|
+
value={borderColor || undefined}
|
|
46
|
+
onChange={(value) => setAttributes({borderColor: value ?? ''})}
|
|
47
|
+
/>
|
|
48
|
+
<BorderRadiusControl values={borderRadius} onChange={(next) => setAttributes({borderRadius: next ?? ''})} />
|
|
49
|
+
</PanelBody>
|
|
50
|
+
|
|
51
|
+
<PanelBody title={__('Barvy', 'brilo-blocks')}>
|
|
52
|
+
<p>{__('Pozadí', 'brilo-blocks')}</p>
|
|
53
|
+
<ColorPalette
|
|
54
|
+
colors={paletteColors}
|
|
55
|
+
value={background || undefined}
|
|
56
|
+
onChange={(value) => setAttributes({background: value ?? ''})}
|
|
57
|
+
/>
|
|
58
|
+
<p>{__('Barva textu', 'brilo-blocks')}</p>
|
|
59
|
+
<ColorPalette colors={paletteColors} value={textColor || undefined} onChange={(value) => setAttributes({textColor: value ?? ''})} />
|
|
60
|
+
{!!background && !!textColor && <ContrastChecker backgroundColor={resolveHex(background)} textColor={resolveHex(textColor)} />}
|
|
61
|
+
</PanelBody>
|
|
62
|
+
</>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps, useInnerBlocksProps} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockEditProps} from '@wordpress/blocks'
|
|
3
|
+
import type {CSSProperties} from 'react'
|
|
4
|
+
import {BoxControls} from './controls'
|
|
5
|
+
import type {BoxAttributes, BoxOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export function createBoxEdit(options: BoxOptions) {
|
|
8
|
+
return function Edit({attributes, setAttributes}: BlockEditProps<BoxAttributes>) {
|
|
9
|
+
const {padding, margin, borderRadius, borderWidth, borderColor, background, textColor} = attributes
|
|
10
|
+
|
|
11
|
+
const style: CSSProperties = {
|
|
12
|
+
...(padding?.top && {paddingTop: padding.top}),
|
|
13
|
+
...(padding?.right && {paddingRight: padding.right}),
|
|
14
|
+
...(padding?.bottom && {paddingBottom: padding.bottom}),
|
|
15
|
+
...(padding?.left && {paddingLeft: padding.left}),
|
|
16
|
+
...(margin?.top && {marginTop: margin.top}),
|
|
17
|
+
...(margin?.right && {marginRight: margin.right}),
|
|
18
|
+
...(margin?.bottom && {marginBottom: margin.bottom}),
|
|
19
|
+
...(margin?.left && {marginLeft: margin.left}),
|
|
20
|
+
...(typeof borderRadius === 'string' && borderRadius && {borderRadius}),
|
|
21
|
+
...(typeof borderRadius === 'object' && borderRadius !== null
|
|
22
|
+
? {
|
|
23
|
+
...(borderRadius.topLeft && {borderTopLeftRadius: borderRadius.topLeft}),
|
|
24
|
+
...(borderRadius.topRight && {borderTopRightRadius: borderRadius.topRight}),
|
|
25
|
+
...(borderRadius.bottomLeft && {borderBottomLeftRadius: borderRadius.bottomLeft}),
|
|
26
|
+
...(borderRadius.bottomRight && {borderBottomRightRadius: borderRadius.bottomRight}),
|
|
27
|
+
}
|
|
28
|
+
: {}),
|
|
29
|
+
...(borderWidth && {borderWidth, borderStyle: 'solid' as CSSProperties['borderStyle']}),
|
|
30
|
+
...(borderColor && {borderColor}),
|
|
31
|
+
...(background && {backgroundColor: background}),
|
|
32
|
+
...(textColor && {color: textColor}),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const blockProps = useBlockProps({className: options.blockClassName ?? 'g-box', style})
|
|
36
|
+
const innerBlocksProps = useInnerBlocksProps(
|
|
37
|
+
{className: options.containerClassName ?? 'g-box__inner'},
|
|
38
|
+
{allowedBlocks: options.allowedBlocks, template: options.template, templateLock: false},
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<InspectorControls>
|
|
44
|
+
<BoxControls attributes={attributes} setAttributes={setAttributes} />
|
|
45
|
+
</InspectorControls>
|
|
46
|
+
<div {...blockProps}>
|
|
47
|
+
<div {...innerBlocksProps} />
|
|
48
|
+
</div>
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createBoxEdit} from './edit'
|
|
5
|
+
import {icon as defaultIcon} from './icon'
|
|
6
|
+
import type {BoxAttributes, BoxOptions} from './types'
|
|
7
|
+
|
|
8
|
+
export function createBoxBlock(options: BoxOptions): BlockConfiguration<BoxAttributes> {
|
|
9
|
+
return {
|
|
10
|
+
name: options.name,
|
|
11
|
+
title: options.title ?? __('Box', 'brilo-blocks'),
|
|
12
|
+
description:
|
|
13
|
+
options.description ??
|
|
14
|
+
__('Obecné pouzdro pro libovolný obsah s vlastním paddingem, marginem, ohraničením a barvami.', 'brilo-blocks'),
|
|
15
|
+
category: options.category ?? 'layout',
|
|
16
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
17
|
+
...(options.parent && {parent: options.parent}),
|
|
18
|
+
supports: {html: false, customClassName: false},
|
|
19
|
+
attributes: {
|
|
20
|
+
padding: {type: 'object', default: {}},
|
|
21
|
+
margin: {type: 'object', default: {}},
|
|
22
|
+
borderRadius: {type: ['string', 'object'], default: ''},
|
|
23
|
+
borderWidth: {type: 'string', default: ''},
|
|
24
|
+
borderColor: {type: 'string', default: ''},
|
|
25
|
+
background: {type: 'string', default: ''},
|
|
26
|
+
textColor: {type: 'string', default: ''},
|
|
27
|
+
},
|
|
28
|
+
edit: createBoxEdit(options),
|
|
29
|
+
save: () => <InnerBlocks.Content />,
|
|
30
|
+
} as BlockConfiguration<BoxAttributes>
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {BoxAttributes, BoxBorderRadius, BoxOptions, BoxSpacing} from './types'
|
|
2
|
+
export {createBoxBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {BoxOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const boxDefaults: BoxOptions = {
|
|
7
|
+
name: 'brilo/box',
|
|
8
|
+
blockClassName: 'g-box',
|
|
9
|
+
containerClassName: 'g-box__inner',
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {BriloBlockType} from '~/types'
|
|
2
|
+
|
|
3
|
+
export interface BoxSpacing {
|
|
4
|
+
top?: string
|
|
5
|
+
right?: string
|
|
6
|
+
bottom?: string
|
|
7
|
+
left?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface BoxBorderRadius {
|
|
11
|
+
topLeft?: string
|
|
12
|
+
topRight?: string
|
|
13
|
+
bottomLeft?: string
|
|
14
|
+
bottomRight?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface BoxAttributes extends Record<string, unknown> {
|
|
18
|
+
padding: BoxSpacing
|
|
19
|
+
margin: BoxSpacing
|
|
20
|
+
borderRadius: string | BoxBorderRadius
|
|
21
|
+
borderWidth: string
|
|
22
|
+
borderColor: string
|
|
23
|
+
background: string
|
|
24
|
+
textColor: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BoxOptions extends BriloBlockType {}
|
package/src/index.ts
CHANGED
|
@@ -219,7 +219,11 @@ export type {
|
|
|
219
219
|
export {createJobPositionGroupBlock, jobPositionGroupDefaults, JobPositionsSelectModal} from './blocks/career/job-position-group'
|
|
220
220
|
export type {CareerHeaderAttributes, CareerHeaderOptions} from './blocks/career/career-header'
|
|
221
221
|
export {createCareerHeaderBlock, careerHeaderDefaults} from './blocks/career/career-header'
|
|
222
|
+
export type {CareerBenefitsAttributes, CareerBenefitsOptions} from './blocks/career/career-benefits'
|
|
223
|
+
export {createCareerBenefitsBlock, careerBenefitsDefaults} from './blocks/career/career-benefits'
|
|
222
224
|
export type {PostContentAttributes, PostContentOptions} from './blocks/post/post-content'
|
|
223
225
|
export {createPostContentBlock, postContentDefaults} from './blocks/post/post-content'
|
|
224
226
|
export type {ShareAttributes, ShareOptions} from './blocks/share/share'
|
|
225
227
|
export {createShareBlock, shareDefaults} from './blocks/share/share'
|
|
228
|
+
export type {BoxAttributes, BoxBorderRadius, BoxOptions, BoxSpacing} from './blocks/layout/box'
|
|
229
|
+
export {createBoxBlock, boxDefaults} from './blocks/layout/box'
|