@brilo/base-blocks 0.1.39 → 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/form/form-field/constants.d.ts +33 -1
- package/build/blocks/form/form-field/constants.d.ts.map +1 -1
- package/build/blocks/form/form-field/constants.js +17 -1
- package/build/blocks/form/form-field/edit.d.ts.map +1 -1
- package/build/blocks/form/form-field/edit.js +10 -4
- package/build/blocks/form/form-field/factory.d.ts.map +1 -1
- package/build/blocks/form/form-field/factory.js +7 -1
- package/build/blocks/form/form-field/types.d.ts +8 -1
- package/build/blocks/form/form-field/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/form/form-field/constants.ts +22 -1
- package/src/blocks/form/form-field/edit.tsx +80 -13
- package/src/blocks/form/form-field/factory.tsx +7 -1
- package/src/blocks/form/form-field/types.ts +14 -1
- 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,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'
|