@brilo/base-blocks 0.1.35 → 0.1.37
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/event/event-calendar-group/constants.d.ts +2 -0
- package/build/blocks/event/event-calendar-group/constants.d.ts.map +1 -0
- package/build/blocks/event/event-calendar-group/constants.js +2 -0
- package/build/blocks/event/event-calendar-group/edit.d.ts +6 -0
- package/build/blocks/event/event-calendar-group/edit.d.ts.map +1 -0
- package/build/blocks/event/event-calendar-group/edit.js +18 -0
- package/build/blocks/event/event-calendar-group/factory.d.ts +5 -0
- package/build/blocks/event/event-calendar-group/factory.d.ts.map +1 -0
- package/build/blocks/event/event-calendar-group/factory.js +25 -0
- package/build/blocks/event/event-calendar-group/icon.d.ts +2 -0
- package/build/blocks/event/event-calendar-group/icon.d.ts.map +1 -0
- package/build/blocks/event/event-calendar-group/icon.js +2 -0
- package/build/blocks/event/event-calendar-group/index.d.ts +6 -0
- package/build/blocks/event/event-calendar-group/index.d.ts.map +1 -0
- package/build/blocks/event/event-calendar-group/index.js +6 -0
- package/build/blocks/event/event-calendar-group/types.d.ts +12 -0
- package/build/blocks/event/event-calendar-group/types.d.ts.map +1 -0
- package/build/blocks/event/event-calendar-group/types.js +1 -0
- package/build/blocks/event/event-detail-content/constants.d.ts +2 -0
- package/build/blocks/event/event-detail-content/constants.d.ts.map +1 -0
- package/build/blocks/event/event-detail-content/constants.js +1 -0
- package/build/blocks/event/event-detail-content/edit.d.ts +6 -0
- package/build/blocks/event/event-detail-content/edit.d.ts.map +1 -0
- package/build/blocks/event/event-detail-content/edit.js +9 -0
- package/build/blocks/event/event-detail-content/factory.d.ts +5 -0
- package/build/blocks/event/event-detail-content/factory.d.ts.map +1 -0
- package/build/blocks/event/event-detail-content/factory.js +18 -0
- package/build/blocks/event/event-detail-content/icon.d.ts +2 -0
- package/build/blocks/event/event-detail-content/icon.d.ts.map +1 -0
- package/build/blocks/event/event-detail-content/icon.js +2 -0
- package/build/blocks/event/event-detail-content/index.d.ts +5 -0
- package/build/blocks/event/event-detail-content/index.d.ts.map +1 -0
- package/build/blocks/event/event-detail-content/index.js +5 -0
- package/build/blocks/event/event-detail-content/types.d.ts +6 -0
- package/build/blocks/event/event-detail-content/types.d.ts.map +1 -0
- package/build/blocks/event/event-detail-content/types.js +1 -0
- package/build/blocks/event/event-detail-header/constants.d.ts +2 -0
- package/build/blocks/event/event-detail-header/constants.d.ts.map +1 -0
- package/build/blocks/event/event-detail-header/constants.js +1 -0
- package/build/blocks/event/event-detail-header/edit.d.ts +6 -0
- package/build/blocks/event/event-detail-header/edit.d.ts.map +1 -0
- package/build/blocks/event/event-detail-header/edit.js +11 -0
- package/build/blocks/event/event-detail-header/factory.d.ts +5 -0
- package/build/blocks/event/event-detail-header/factory.d.ts.map +1 -0
- package/build/blocks/event/event-detail-header/factory.js +22 -0
- package/build/blocks/event/event-detail-header/icon.d.ts +2 -0
- package/build/blocks/event/event-detail-header/icon.d.ts.map +1 -0
- package/build/blocks/event/event-detail-header/icon.js +2 -0
- package/build/blocks/event/event-detail-header/index.d.ts +5 -0
- package/build/blocks/event/event-detail-header/index.d.ts.map +1 -0
- package/build/blocks/event/event-detail-header/index.js +5 -0
- package/build/blocks/event/event-detail-header/types.d.ts +9 -0
- package/build/blocks/event/event-detail-header/types.d.ts.map +1 -0
- package/build/blocks/event/event-detail-header/types.js +1 -0
- package/build/blocks/event/event-list-group/constants.d.ts +5 -0
- package/build/blocks/event/event-list-group/constants.d.ts.map +1 -0
- package/build/blocks/event/event-list-group/constants.js +5 -0
- package/build/blocks/event/event-list-group/edit.d.ts +6 -0
- package/build/blocks/event/event-list-group/edit.d.ts.map +1 -0
- package/build/blocks/event/event-list-group/edit.js +23 -0
- package/build/blocks/event/event-list-group/factory.d.ts +5 -0
- package/build/blocks/event/event-list-group/factory.d.ts.map +1 -0
- package/build/blocks/event/event-list-group/factory.js +28 -0
- package/build/blocks/event/event-list-group/icon.d.ts +2 -0
- package/build/blocks/event/event-list-group/icon.d.ts.map +1 -0
- package/build/blocks/event/event-list-group/icon.js +2 -0
- package/build/blocks/event/event-list-group/index.d.ts +8 -0
- package/build/blocks/event/event-list-group/index.d.ts.map +1 -0
- package/build/blocks/event/event-list-group/index.js +8 -0
- package/build/blocks/event/event-list-group/types.d.ts +30 -0
- package/build/blocks/event/event-list-group/types.d.ts.map +1 -0
- package/build/blocks/event/event-list-group/types.js +7 -0
- package/build/blocks/sections/base-section/attributes.d.ts +7 -0
- package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
- package/build/blocks/sections/base-section/attributes.js +7 -0
- package/build/blocks/sections/base-section/constants.d.ts +36 -0
- package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.js +16 -0
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/controls.js +22 -4
- package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
- package/build/blocks/sections/base-section/edit.js +21 -5
- package/build/blocks/sections/base-section/types.d.ts +14 -1
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/build/components/Event/EntitySelectModal.d.ts +27 -0
- package/build/components/Event/EntitySelectModal.d.ts.map +1 -0
- package/build/components/Event/EntitySelectModal.js +100 -0
- package/build/components/Event/EventSelectModal.d.ts +7 -0
- package/build/components/Event/EventSelectModal.d.ts.map +1 -0
- package/build/components/Event/EventSelectModal.js +42 -0
- package/build/components/Event/EventTermSelectModal.d.ts +7 -0
- package/build/components/Event/EventTermSelectModal.d.ts.map +1 -0
- package/build/components/Event/EventTermSelectModal.js +48 -0
- package/build/index.d.ts +8 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/build/types.d.ts +4 -0
- package/build/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blocks/event/event-calendar-group/constants.ts +3 -0
- package/src/blocks/event/event-calendar-group/edit.tsx +60 -0
- package/src/blocks/event/event-calendar-group/editor.scss +13 -0
- package/src/blocks/event/event-calendar-group/factory.tsx +30 -0
- package/src/blocks/event/event-calendar-group/icon.tsx +13 -0
- package/src/blocks/event/event-calendar-group/index.tsx +10 -0
- package/src/blocks/event/event-calendar-group/types.ts +13 -0
- package/src/blocks/event/event-detail-content/constants.ts +1 -0
- package/src/blocks/event/event-detail-content/edit.tsx +24 -0
- package/src/blocks/event/event-detail-content/factory.tsx +22 -0
- package/src/blocks/event/event-detail-content/icon.tsx +9 -0
- package/src/blocks/event/event-detail-content/index.ts +9 -0
- package/src/blocks/event/event-detail-content/types.ts +5 -0
- package/src/blocks/event/event-detail-header/constants.ts +2 -0
- package/src/blocks/event/event-detail-header/edit.tsx +49 -0
- package/src/blocks/event/event-detail-header/factory.tsx +26 -0
- package/src/blocks/event/event-detail-header/icon.tsx +8 -0
- package/src/blocks/event/event-detail-header/index.ts +9 -0
- package/src/blocks/event/event-detail-header/types.ts +9 -0
- package/src/blocks/event/event-list-group/constants.ts +6 -0
- package/src/blocks/event/event-list-group/edit.tsx +84 -0
- package/src/blocks/event/event-list-group/editor.scss +9 -0
- package/src/blocks/event/event-list-group/factory.tsx +33 -0
- package/src/blocks/event/event-list-group/icon.tsx +27 -0
- package/src/blocks/event/event-list-group/index.tsx +12 -0
- package/src/blocks/event/event-list-group/types.ts +27 -0
- package/src/blocks/sections/base-section/attributes.ts +7 -0
- package/src/blocks/sections/base-section/constants.ts +19 -0
- package/src/blocks/sections/base-section/controls.tsx +101 -1
- package/src/blocks/sections/base-section/edit.tsx +19 -3
- package/src/blocks/sections/base-section/types.ts +21 -1
- package/src/components/Event/EntitySelectModal.tsx +249 -0
- package/src/components/Event/EventSelectModal.tsx +51 -0
- package/src/components/Event/EventTermSelectModal.tsx +58 -0
- package/src/editor.scss +2 -0
- package/src/index.ts +36 -0
- package/src/types.ts +5 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {PanelBody, ToggleControl, TextControl, __experimentalInputControl as InputControl} from '@wordpress/components'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import type {EventCalendarGroupAttributes, EventCalendarGroupOptions} from './types'
|
|
5
|
+
import {Icon, calendar} from '@wordpress/icons'
|
|
6
|
+
|
|
7
|
+
export function createEventCalendarGroupEdit(options: EventCalendarGroupOptions) {
|
|
8
|
+
return function Edit({
|
|
9
|
+
attributes,
|
|
10
|
+
setAttributes,
|
|
11
|
+
}: {
|
|
12
|
+
attributes: EventCalendarGroupAttributes
|
|
13
|
+
setAttributes: (a: Partial<EventCalendarGroupAttributes>) => void
|
|
14
|
+
}) {
|
|
15
|
+
const {showNow, month, selectedCategories, emptyMessage} = attributes
|
|
16
|
+
|
|
17
|
+
const blockProps = useBlockProps({className: 'g-event-calendar wp-block-section'})
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<InspectorControls>
|
|
22
|
+
<PanelBody title={__('Nastavení kalendáře', 'brilo-blocks')} initialOpen>
|
|
23
|
+
<ToggleControl
|
|
24
|
+
label={__('Zobrazit aktuální měsíc', 'brilo-blocks')}
|
|
25
|
+
checked={showNow}
|
|
26
|
+
onChange={(value) => setAttributes({showNow: value})}
|
|
27
|
+
/>
|
|
28
|
+
{!showNow && (
|
|
29
|
+
<InputControl
|
|
30
|
+
label={'Výběr měsíce a roku'}
|
|
31
|
+
type={'month'}
|
|
32
|
+
value={month}
|
|
33
|
+
onChange={(value) => setAttributes({month: value})}
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
<TextControl
|
|
37
|
+
label={__('Zpráva při prázdném výsledku', 'brilo-blocks')}
|
|
38
|
+
value={emptyMessage}
|
|
39
|
+
onChange={(value) => setAttributes({emptyMessage: value})}
|
|
40
|
+
/>
|
|
41
|
+
</PanelBody>
|
|
42
|
+
</InspectorControls>
|
|
43
|
+
|
|
44
|
+
<div {...blockProps}>
|
|
45
|
+
<Icon icon={calendar} />
|
|
46
|
+
<div className="g-event-calendar__label">{__('Kalendář událostí', 'brilo-blocks')}</div>
|
|
47
|
+
<div className="g-event-calendar__instructions">
|
|
48
|
+
{showNow
|
|
49
|
+
? __('Zobrazuje události pro aktuální měsíc.', 'brilo-blocks')
|
|
50
|
+
: `${__('Zobrazuje události pro', 'brilo-blocks')} ${month}`}
|
|
51
|
+
</div>
|
|
52
|
+
{options.renderCategoryControl?.({
|
|
53
|
+
selectedItems: selectedCategories,
|
|
54
|
+
onChange: (ids: number[]) => setAttributes({selectedCategories: ids}),
|
|
55
|
+
})}
|
|
56
|
+
</div>
|
|
57
|
+
</>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {DEFAULT_EMPTY_MESSAGE} from './constants'
|
|
4
|
+
import {createEventCalendarGroupEdit} from './edit'
|
|
5
|
+
import {icon as defaultIcon} from './icon'
|
|
6
|
+
import type {EventCalendarGroupAttributes, EventCalendarGroupOptions} from './types'
|
|
7
|
+
|
|
8
|
+
export type {EventCalendarGroupAttributes, EventCalendarGroupOptions}
|
|
9
|
+
|
|
10
|
+
export function createEventCalendarGroupBlock(options: EventCalendarGroupOptions): BlockConfiguration<EventCalendarGroupAttributes> {
|
|
11
|
+
const emptyMessage = options.emptyMessage ?? DEFAULT_EMPTY_MESSAGE
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
name: options.name,
|
|
15
|
+
title: options.title ?? __('Kalendář událostí', 'brilo-blocks'),
|
|
16
|
+
description: options.description,
|
|
17
|
+
category: options.category ?? 'layout',
|
|
18
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
19
|
+
...(options.parent && {parent: options.parent}),
|
|
20
|
+
supports: {html: false, customClassName: false},
|
|
21
|
+
attributes: {
|
|
22
|
+
showNow: {type: 'boolean', default: true},
|
|
23
|
+
month: {type: 'string', default: ''},
|
|
24
|
+
selectedCategories: {type: 'array', default: []},
|
|
25
|
+
emptyMessage: {type: 'string', default: emptyMessage},
|
|
26
|
+
},
|
|
27
|
+
edit: createEventCalendarGroupEdit(options),
|
|
28
|
+
save: () => null,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
viewBox="0 0 24 24"
|
|
5
|
+
fill="currentColor"
|
|
6
|
+
width="24"
|
|
7
|
+
height="24"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
focusable="false"
|
|
10
|
+
>
|
|
11
|
+
<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z"></path>
|
|
12
|
+
</svg>
|
|
13
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {EventCalendarGroupAttributes, EventCalendarGroupOptions} from './types'
|
|
2
|
+
export {createEventCalendarGroupBlock} from './factory'
|
|
3
|
+
export {EventTermSelectModal} from '~/components/Event/EventTermSelectModal'
|
|
4
|
+
|
|
5
|
+
import type {EventCalendarGroupOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export const eventCalendarGroupDefaults: EventCalendarGroupOptions = {
|
|
8
|
+
name: 'brilo/event-calendar-group',
|
|
9
|
+
parent: ['brilo/base-section'],
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {BriloBlockType, SelectControlProps} from '~/types'
|
|
2
|
+
|
|
3
|
+
export interface EventCalendarGroupAttributes extends Record<string, unknown> {
|
|
4
|
+
showNow: boolean
|
|
5
|
+
month: string
|
|
6
|
+
selectedCategories: number[]
|
|
7
|
+
emptyMessage: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface EventCalendarGroupOptions extends BriloBlockType {
|
|
11
|
+
emptyMessage?: string
|
|
12
|
+
renderCategoryControl?: (props: SelectControlProps) => JSX.Element
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import type {EventDetailContentAttributes, EventDetailContentOptions} from './types'
|
|
4
|
+
|
|
5
|
+
export function createEventDetailContentEdit(_options: EventDetailContentOptions) {
|
|
6
|
+
return function Edit({
|
|
7
|
+
attributes: _attributes,
|
|
8
|
+
setAttributes: _setAttributes,
|
|
9
|
+
}: {
|
|
10
|
+
attributes: EventDetailContentAttributes
|
|
11
|
+
setAttributes: (a: Partial<EventDetailContentAttributes>) => void
|
|
12
|
+
}) {
|
|
13
|
+
const blockProps = useBlockProps({className: 'event-detail-content wp-block-section'})
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div {...blockProps}>
|
|
17
|
+
<div className="event-detail-content">
|
|
18
|
+
<div className="event-detail-content__label">{__('Obsah detailu události', 'brilo-blocks')}</div>
|
|
19
|
+
<div className="event-detail-content__instructions">{__('Zástupný blok pro obsah události.', 'brilo-blocks')}</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createEventDetailContentEdit} from './edit'
|
|
4
|
+
import {icon as defaultIcon} from './icon'
|
|
5
|
+
import type {EventDetailContentAttributes, EventDetailContentOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export type {EventDetailContentAttributes, EventDetailContentOptions}
|
|
8
|
+
|
|
9
|
+
export function createEventDetailContentBlock(options: EventDetailContentOptions): BlockConfiguration<EventDetailContentAttributes> {
|
|
10
|
+
return {
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: options.title ?? __('Obsah detailu události', 'brilo-blocks'),
|
|
13
|
+
description: options.description,
|
|
14
|
+
category: options.category ?? 'layout',
|
|
15
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
16
|
+
...(options.parent && {parent: options.parent}),
|
|
17
|
+
supports: {html: false, customClassName: false},
|
|
18
|
+
attributes: {},
|
|
19
|
+
edit: createEventDetailContentEdit(options),
|
|
20
|
+
save: () => null,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
<rect x="3" y="2" width="14" height="16" rx="1" stroke="black" fill="none" />
|
|
4
|
+
<line x1="6" y1="6" x2="14" y2="6" stroke="black" />
|
|
5
|
+
<line x1="6" y1="9" x2="14" y2="9" stroke="black" />
|
|
6
|
+
<line x1="6" y1="12" x2="14" y2="12" stroke="black" />
|
|
7
|
+
<line x1="6" y1="15" x2="10" y2="15" stroke="black" />
|
|
8
|
+
</svg>
|
|
9
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {EventDetailContentAttributes, EventDetailContentOptions} from './types'
|
|
2
|
+
export {createEventDetailContentBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {EventDetailContentOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const eventDetailContentDefaults: EventDetailContentOptions = {
|
|
7
|
+
name: 'brilo/event-detail-content',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {PanelBody, ToggleControl} from '@wordpress/components'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import type {EventDetailHeaderAttributes, EventDetailHeaderOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export function createEventDetailHeaderEdit(_options: EventDetailHeaderOptions) {
|
|
7
|
+
return function Edit({
|
|
8
|
+
attributes,
|
|
9
|
+
setAttributes,
|
|
10
|
+
}: {
|
|
11
|
+
attributes: EventDetailHeaderAttributes
|
|
12
|
+
setAttributes: (a: Partial<EventDetailHeaderAttributes>) => void
|
|
13
|
+
}) {
|
|
14
|
+
const {showDate, showPlace, showPrice} = attributes
|
|
15
|
+
|
|
16
|
+
const blockProps = useBlockProps({className: 'event-detail-header wp-block-section'})
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<InspectorControls>
|
|
21
|
+
<PanelBody title={__('Nastavení hlavičky', 'brilo-blocks')} initialOpen>
|
|
22
|
+
<ToggleControl
|
|
23
|
+
label={__('Zobrazit datum', 'brilo-blocks')}
|
|
24
|
+
checked={showDate}
|
|
25
|
+
onChange={(value) => setAttributes({showDate: value})}
|
|
26
|
+
/>
|
|
27
|
+
<ToggleControl
|
|
28
|
+
label={__('Zobrazit místo', 'brilo-blocks')}
|
|
29
|
+
checked={showPlace}
|
|
30
|
+
onChange={(value) => setAttributes({showPlace: value})}
|
|
31
|
+
/>
|
|
32
|
+
<ToggleControl
|
|
33
|
+
label={__('Zobrazit cenu', 'brilo-blocks')}
|
|
34
|
+
checked={showPrice}
|
|
35
|
+
onChange={(value) => setAttributes({showPrice: value})}
|
|
36
|
+
/>
|
|
37
|
+
</PanelBody>
|
|
38
|
+
</InspectorControls>
|
|
39
|
+
|
|
40
|
+
<div {...blockProps}>
|
|
41
|
+
<div className="event-detail-header">
|
|
42
|
+
<div className="event-detail-header__label">{__('Hlavička detailu události', 'brilo-blocks')}</div>
|
|
43
|
+
<div className="event-detail-header__instructions">{__('Zástupný blok pro hlavičku události.', 'brilo-blocks')}</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createEventDetailHeaderEdit} from './edit'
|
|
4
|
+
import {icon as defaultIcon} from './icon'
|
|
5
|
+
import type {EventDetailHeaderAttributes, EventDetailHeaderOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export type {EventDetailHeaderAttributes, EventDetailHeaderOptions}
|
|
8
|
+
|
|
9
|
+
export function createEventDetailHeaderBlock(options: EventDetailHeaderOptions): BlockConfiguration<EventDetailHeaderAttributes> {
|
|
10
|
+
return {
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: options.title ?? __('Hlavička detailu události', 'brilo-blocks'),
|
|
13
|
+
description: options.description,
|
|
14
|
+
category: options.category ?? 'layout',
|
|
15
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
16
|
+
...(options.parent && {parent: options.parent}),
|
|
17
|
+
supports: {html: false, customClassName: false},
|
|
18
|
+
attributes: {
|
|
19
|
+
showDate: {type: 'boolean', default: true},
|
|
20
|
+
showPlace: {type: 'boolean', default: true},
|
|
21
|
+
showPrice: {type: 'boolean', default: true},
|
|
22
|
+
},
|
|
23
|
+
edit: createEventDetailHeaderEdit(options),
|
|
24
|
+
save: () => null,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
<rect x="2" y="3" width="16" height="4" rx="1" stroke="black" fill="none" />
|
|
4
|
+
<line x1="2" y1="10" x2="14" y2="10" stroke="black" />
|
|
5
|
+
<line x1="2" y1="13" x2="18" y2="13" stroke="black" />
|
|
6
|
+
<line x1="2" y1="16" x2="10" y2="16" stroke="black" />
|
|
7
|
+
</svg>
|
|
8
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {EventDetailHeaderAttributes, EventDetailHeaderOptions} from './types'
|
|
2
|
+
export {createEventDetailHeaderBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {EventDetailHeaderOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const eventDetailHeaderDefaults: EventDetailHeaderOptions = {
|
|
7
|
+
name: 'brilo/event-detail-header',
|
|
8
|
+
parent: ['brilo/base-section'],
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type {BriloBlockType} from '~/types'
|
|
2
|
+
|
|
3
|
+
export interface EventDetailHeaderAttributes extends Record<string, unknown> {
|
|
4
|
+
showDate: boolean
|
|
5
|
+
showPlace: boolean
|
|
6
|
+
showPrice: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface EventDetailHeaderOptions extends BriloBlockType {}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {PanelBody, RangeControl, SelectControl, ToggleControl, TextControl} from '@wordpress/components'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {EVENTS_PER_PAGE_DEFAULT, EVENTS_PER_PAGE_MAX, EVENTS_PER_PAGE_MIN} from './constants'
|
|
5
|
+
import {EVENT_LIST_GROUP_MODES} from './types'
|
|
6
|
+
import type {EventListGroupAttributes, EventListGroupMode, EventListGroupOptions} from './types'
|
|
7
|
+
|
|
8
|
+
export function createEventListGroupEdit(options: EventListGroupOptions) {
|
|
9
|
+
return function Edit({
|
|
10
|
+
attributes,
|
|
11
|
+
setAttributes,
|
|
12
|
+
}: {
|
|
13
|
+
attributes: EventListGroupAttributes
|
|
14
|
+
setAttributes: (a: Partial<EventListGroupAttributes>) => void
|
|
15
|
+
}) {
|
|
16
|
+
const {mode, selectedEvents, selectedCategories, emptyMessage, postsPerPage, showPagination} = attributes
|
|
17
|
+
|
|
18
|
+
const blockProps = useBlockProps({className: 'g-event wp-block-section'})
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<InspectorControls>
|
|
23
|
+
<PanelBody title={__('Nastavení výpisu', 'brilo-blocks')} initialOpen>
|
|
24
|
+
<SelectControl
|
|
25
|
+
label={__('Režim', 'brilo-blocks')}
|
|
26
|
+
value={mode}
|
|
27
|
+
options={EVENT_LIST_GROUP_MODES.map((m) => ({label: m.label, value: m.value}))}
|
|
28
|
+
onChange={(mode) => setAttributes({mode: mode as EventListGroupMode})}
|
|
29
|
+
/>
|
|
30
|
+
|
|
31
|
+
{mode !== 'manual' && (
|
|
32
|
+
<>
|
|
33
|
+
<RangeControl
|
|
34
|
+
label={__('Počet příspěvků', 'brilo-blocks')}
|
|
35
|
+
value={postsPerPage}
|
|
36
|
+
onChange={(value) => setAttributes({postsPerPage: value ?? EVENTS_PER_PAGE_DEFAULT})}
|
|
37
|
+
min={EVENTS_PER_PAGE_MIN}
|
|
38
|
+
max={EVENTS_PER_PAGE_MAX}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
{mode !== 'filter' && (
|
|
42
|
+
<ToggleControl
|
|
43
|
+
label={__('Zobrazit stránkování', 'brilo-blocks')}
|
|
44
|
+
checked={showPagination}
|
|
45
|
+
onChange={(value) => setAttributes({showPagination: value})}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
48
|
+
</>
|
|
49
|
+
)}
|
|
50
|
+
|
|
51
|
+
<TextControl
|
|
52
|
+
label={__('Zpráva při prázdném výsledku', 'brilo-blocks')}
|
|
53
|
+
value={emptyMessage}
|
|
54
|
+
onChange={(value) => setAttributes({emptyMessage: value})}
|
|
55
|
+
/>
|
|
56
|
+
</PanelBody>
|
|
57
|
+
</InspectorControls>
|
|
58
|
+
|
|
59
|
+
<div {...blockProps}>
|
|
60
|
+
<div className="g-event__label">{__('Seznam událostí', 'brilo-blocks')}</div>
|
|
61
|
+
<div className="g-event__instructions">
|
|
62
|
+
{mode === 'manual' && __('Ručně vybrané události.', 'brilo-blocks')}
|
|
63
|
+
{mode === 'upcoming' && __('Zobrazuje nadcházející události.', 'brilo-blocks')}
|
|
64
|
+
{mode === 'past' && __('Zobrazuje proběhlé události.', 'brilo-blocks')}
|
|
65
|
+
{mode === 'filter' && __('S filtrováním.', 'brilo-blocks')}
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
{mode !== 'manual' &&
|
|
69
|
+
mode !== 'filter' &&
|
|
70
|
+
options.renderCategoryControl?.({
|
|
71
|
+
selectedItems: selectedCategories,
|
|
72
|
+
onChange: (ids: number[]) => setAttributes({selectedCategories: ids}),
|
|
73
|
+
})}
|
|
74
|
+
|
|
75
|
+
{mode === 'manual' &&
|
|
76
|
+
options.renderEventsControl?.({
|
|
77
|
+
selectedItems: selectedEvents,
|
|
78
|
+
onChange: (ids: number[]) => setAttributes({selectedEvents: ids}),
|
|
79
|
+
})}
|
|
80
|
+
</div>
|
|
81
|
+
</>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {DEFAULT_EMPTY_MESSAGE, EVENTS_PER_PAGE_DEFAULT} from './constants'
|
|
4
|
+
import {createEventListGroupEdit} from './edit'
|
|
5
|
+
import {icon as defaultIcon} from './icon'
|
|
6
|
+
import type {EventListGroupAttributes, EventListGroupOptions} from './types'
|
|
7
|
+
|
|
8
|
+
export type {EventListGroupAttributes, EventListGroupOptions}
|
|
9
|
+
|
|
10
|
+
export function createEventListGroupBlock(options: EventListGroupOptions): BlockConfiguration<EventListGroupAttributes> {
|
|
11
|
+
const emptyMessage = options.emptyMessage ?? DEFAULT_EMPTY_MESSAGE
|
|
12
|
+
const postsPerPage = options.postsPerPage ?? EVENTS_PER_PAGE_DEFAULT
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
name: options.name,
|
|
16
|
+
title: options.title ?? __('Seznam událostí', 'brilo-blocks'),
|
|
17
|
+
description: options.description,
|
|
18
|
+
category: options.category ?? 'layout',
|
|
19
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
20
|
+
...(options.parent && {parent: options.parent}),
|
|
21
|
+
supports: {html: false, customClassName: false},
|
|
22
|
+
attributes: {
|
|
23
|
+
mode: {type: 'string', default: 'upcoming'},
|
|
24
|
+
selectedEvents: {type: 'array', default: []},
|
|
25
|
+
selectedCategories: {type: 'array', default: []},
|
|
26
|
+
emptyMessage: {type: 'string', default: emptyMessage},
|
|
27
|
+
postsPerPage: {type: 'number', default: postsPerPage},
|
|
28
|
+
showPagination: {type: 'boolean', default: false},
|
|
29
|
+
},
|
|
30
|
+
edit: createEventListGroupEdit(options),
|
|
31
|
+
save: () => null,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 4H9V5H4V4Z" fill="black" />
|
|
4
|
+
<path d="M10 4H16V5H10V4Z" fill="black" />
|
|
5
|
+
<path
|
|
6
|
+
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"
|
|
7
|
+
fill="black"
|
|
8
|
+
/>
|
|
9
|
+
<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" />
|
|
10
|
+
<rect x="11.5" y="14.5" width="4" height="4" stroke="black" fill="none" />
|
|
11
|
+
<path d="M17 14H20V15H17V14Z" fill="black" />
|
|
12
|
+
<path d="M17 16H19V17H17V16Z" fill="black" />
|
|
13
|
+
<path d="M18 18H20V19H18V18Z" fill="#357AB5" />
|
|
14
|
+
<rect x="0.5" y="14.5" width="4" height="4" stroke="black" fill="none" />
|
|
15
|
+
<path d="M6 14H9V15H6V14Z" fill="black" />
|
|
16
|
+
<path d="M6 16H8V17H6V16Z" fill="black" />
|
|
17
|
+
<path d="M7 18H9V19H7V18Z" fill="#357AB5" />
|
|
18
|
+
<rect x="11.5" y="7.5" width="4" height="4" stroke="black" fill="none" />
|
|
19
|
+
<path d="M17 7H20V8H17V7Z" fill="black" />
|
|
20
|
+
<path d="M17 9H19V10H17V9Z" fill="black" />
|
|
21
|
+
<path d="M18 11H20V12H18V11Z" fill="#357AB5" />
|
|
22
|
+
<rect x="0.5" y="7.5" width="4" height="4" stroke="black" fill="none" />
|
|
23
|
+
<path d="M6 7H9V8H6V7Z" fill="black" />
|
|
24
|
+
<path d="M6 9H8V10H6V9Z" fill="black" />
|
|
25
|
+
<path d="M7 11H9V12H7V11Z" fill="#357AB5" />
|
|
26
|
+
</svg>
|
|
27
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type {EventListGroupAttributes, EventListGroupOptions, EventListGroupMode} from './types'
|
|
2
|
+
export {EVENT_LIST_GROUP_MODES} from './types'
|
|
3
|
+
export {createEventListGroupBlock} from './factory'
|
|
4
|
+
export {EventSelectModal} from '~/components/Event/EventSelectModal'
|
|
5
|
+
export {EventTermSelectModal} from '~/components/Event/EventTermSelectModal'
|
|
6
|
+
|
|
7
|
+
import type {EventListGroupOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export const eventListGroupDefaults: EventListGroupOptions = {
|
|
10
|
+
name: 'brilo/event-list-group',
|
|
11
|
+
parent: ['brilo/base-section'],
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
import type {BriloBlockType, SelectControlProps} from '~/types'
|
|
3
|
+
|
|
4
|
+
export const EVENT_LIST_GROUP_MODES = [
|
|
5
|
+
{value: 'manual', label: __('Výběr událostí', 'brilo-blocks')},
|
|
6
|
+
{value: 'upcoming', label: __('Nadcházející', 'brilo-blocks')},
|
|
7
|
+
{value: 'past', label: __('Proběhlé', 'brilo-blocks')},
|
|
8
|
+
{value: 'filter', label: __('S filtrováním', 'brilo-blocks')},
|
|
9
|
+
] as const
|
|
10
|
+
|
|
11
|
+
export type EventListGroupMode = (typeof EVENT_LIST_GROUP_MODES)[number]['value']
|
|
12
|
+
|
|
13
|
+
export interface EventListGroupAttributes extends Record<string, unknown> {
|
|
14
|
+
mode: EventListGroupMode
|
|
15
|
+
selectedEvents: number[]
|
|
16
|
+
selectedCategories: number[]
|
|
17
|
+
emptyMessage: string
|
|
18
|
+
postsPerPage: number
|
|
19
|
+
showPagination: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface EventListGroupOptions extends BriloBlockType {
|
|
23
|
+
emptyMessage?: string
|
|
24
|
+
postsPerPage?: number
|
|
25
|
+
renderCategoryControl?: (props: SelectControlProps) => JSX.Element
|
|
26
|
+
renderEventsControl?: (props: SelectControlProps) => JSX.Element
|
|
27
|
+
}
|
|
@@ -54,3 +54,22 @@ export const DECORATION_OFFSET_UNITS = [
|
|
|
54
54
|
{value: 'rem', label: 'rem', default: 0},
|
|
55
55
|
{value: '%', label: '%', default: 0},
|
|
56
56
|
]
|
|
57
|
+
|
|
58
|
+
export const BACKGROUND_IMAGE_FITS = [
|
|
59
|
+
{value: 'cover', label: __('Vyplnit (cover)', 'brilo-blocks')},
|
|
60
|
+
{value: 'contain', label: __('Celý obrázek (contain)', 'brilo-blocks')},
|
|
61
|
+
] as const
|
|
62
|
+
|
|
63
|
+
export const BACKGROUND_IMAGE_POSITIONS = [
|
|
64
|
+
{value: 'left top', label: __('Vlevo nahoře', 'brilo-blocks')},
|
|
65
|
+
{value: 'center top', label: __('Nahoře', 'brilo-blocks')},
|
|
66
|
+
{value: 'right top', label: __('Vpravo nahoře', 'brilo-blocks')},
|
|
67
|
+
{value: 'left center', label: __('Vlevo', 'brilo-blocks')},
|
|
68
|
+
{value: 'center center', label: __('Uprostřed', 'brilo-blocks')},
|
|
69
|
+
{value: 'right center', label: __('Vpravo', 'brilo-blocks')},
|
|
70
|
+
{value: 'left bottom', label: __('Vlevo dole', 'brilo-blocks')},
|
|
71
|
+
{value: 'center bottom', label: __('Dole', 'brilo-blocks')},
|
|
72
|
+
{value: 'right bottom', label: __('Vpravo dole', 'brilo-blocks')},
|
|
73
|
+
] as const
|
|
74
|
+
|
|
75
|
+
export const BACKGROUND_IMAGE_OVERLAY_OPACITY_DEFAULT = 40
|