@brilo/base-blocks 0.1.64 → 0.1.65
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/gallery/gallery-strip-group/constants.d.ts +18 -10
- package/build/blocks/gallery/gallery-strip-group/constants.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-strip-group/constants.js +12 -5
- package/build/blocks/gallery/gallery-strip-group/edit.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-strip-group/edit.js +8 -7
- package/build/blocks/gallery/gallery-strip-group/factory.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-strip-group/factory.js +6 -2
- package/build/blocks/gallery/gallery-strip-group/types.d.ts +8 -3
- package/build/blocks/gallery/gallery-strip-group/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blocks/gallery/gallery-strip-group/constants.ts +15 -5
- package/src/blocks/gallery/gallery-strip-group/edit.tsx +59 -18
- package/src/blocks/gallery/gallery-strip-group/factory.tsx +6 -2
- package/src/blocks/gallery/gallery-strip-group/types.ts +8 -3
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export declare const VARIANTS: readonly [{
|
|
2
|
+
readonly value: 'default';
|
|
3
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Výchozí">;
|
|
4
|
+
}, {
|
|
5
|
+
readonly value: 'full-width';
|
|
6
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Na plnou šířku">;
|
|
7
|
+
}];
|
|
1
8
|
export declare const HEIGHTS: readonly [{
|
|
2
9
|
readonly value: 'sm';
|
|
3
10
|
readonly label: import("@wordpress/i18n").TransformedText<"Malá">;
|
|
@@ -8,16 +15,17 @@ export declare const HEIGHTS: readonly [{
|
|
|
8
15
|
readonly value: 'lg';
|
|
9
16
|
readonly label: import("@wordpress/i18n").TransformedText<"Velká">;
|
|
10
17
|
}];
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export declare const SPEED_MIN = 10;
|
|
19
|
+
export declare const SPEED_MAX = 200;
|
|
20
|
+
export declare const SPEED_DEFAULT = 60;
|
|
21
|
+
export declare const LEGACY_SPEEDS: {
|
|
22
|
+
readonly slow: 30;
|
|
23
|
+
readonly medium: 60;
|
|
24
|
+
readonly fast: 100;
|
|
25
|
+
};
|
|
26
|
+
export declare const MOBILE_SLOWDOWN_MIN = 1;
|
|
27
|
+
export declare const MOBILE_SLOWDOWN_MAX = 3;
|
|
28
|
+
export declare const MOBILE_SLOWDOWN_DEFAULT = 1.5;
|
|
21
29
|
export declare const DIRECTIONS: readonly [{
|
|
22
30
|
readonly value: 'left';
|
|
23
31
|
readonly label: import("@wordpress/i18n").TransformedText<"Doleva">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;aACjB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;EACX,CAAA;AAEV,eAAO,MAAM,MAAM;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;aAClB,KAAK,EAAE,SAAS;aAAE,KAAK;;aACvB,KAAK,EAAE,YAAY;aAAE,KAAK;EACnB,CAAA;AAEV,eAAO,MAAM,OAAO;aACjB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;EACX,CAAA;AAEV,eAAO,MAAM,SAAS,KAAK,CAAA;AAC3B,eAAO,MAAM,SAAS,MAAM,CAAA;AAC5B,eAAO,MAAM,aAAa,KAAK,CAAA;AAG/B,eAAO,MAAM,aAAa;aAAI,IAAI,EAAE,EAAE;aAAE,MAAM,EAAE,EAAE;aAAE,IAAI,EAAE,GAAG;CAAU,CAAA;AAEvE,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAE1C,eAAO,MAAM,UAAU;aACpB,KAAK,EAAE,MAAM;aAAE,KAAK;;aACpB,KAAK,EAAE,OAAO;aAAE,KAAK;EACd,CAAA;AAEV,OAAO,EAAC,cAAc,IAAI,cAAc,EAAC,MAAM,aAAa,CAAA;AAE5D,eAAO,MAAM,aAAa;aAAI,EAAE,EAAE,GAAG;aAAE,EAAE,EAAE,GAAG;aAAE,EAAE,EAAE,GAAG;CAAU,CAAA"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
+
export const VARIANTS = [
|
|
3
|
+
{ value: 'default', label: __('Výchozí', 'brilo-blocks') },
|
|
4
|
+
{ value: 'full-width', label: __('Na plnou šířku', 'brilo-blocks') },
|
|
5
|
+
];
|
|
2
6
|
export const HEIGHTS = [
|
|
3
7
|
{ value: 'sm', label: __('Malá', 'brilo-blocks') },
|
|
4
8
|
{ value: 'md', label: __('Střední', 'brilo-blocks') },
|
|
5
9
|
{ value: 'lg', label: __('Velká', 'brilo-blocks') },
|
|
6
10
|
];
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
export const SPEED_MIN = 10;
|
|
12
|
+
export const SPEED_MAX = 200;
|
|
13
|
+
export const SPEED_DEFAULT = 60;
|
|
14
|
+
// Blocks saved before the numeric speed store these presets in `speed`.
|
|
15
|
+
export const LEGACY_SPEEDS = { slow: 30, medium: 60, fast: 100 };
|
|
16
|
+
export const MOBILE_SLOWDOWN_MIN = 1;
|
|
17
|
+
export const MOBILE_SLOWDOWN_MAX = 3;
|
|
18
|
+
export const MOBILE_SLOWDOWN_DEFAULT = 1.5;
|
|
12
19
|
export const DIRECTIONS = [
|
|
13
20
|
{ value: 'left', label: __('Doleva', 'brilo-blocks') },
|
|
14
21
|
{ value: 'right', label: __('Doprava', 'brilo-blocks') },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/edit.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/edit.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAEV,2BAA2B,EAC3B,wBAAwB,EAIzB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,wBAAwB,8CAOxE;IACD,UAAU,EAAE,2BAA2B,CAAA;IACvC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,KAAK,IAAI,CAAA;IAChE,QAAQ,EAAE,MAAM,CAAA;CACjB,iCAyGF"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { InspectorControls } from '@wordpress/block-editor';
|
|
3
|
-
import { PanelBody, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, } from '@wordpress/components';
|
|
3
|
+
import { PanelBody, RangeControl, ToggleControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, } from '@wordpress/components';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { GalleryImagesAppender } from '../../../components/GalleryImagesAppender';
|
|
7
7
|
import { ItemSpacingPanel, itemSpacingStyle } from '../../../components/ItemSpacingControl';
|
|
8
8
|
import { useGroupBlock } from '../../../hooks/useGroupBlock';
|
|
9
|
-
import { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, HEIGHT_PIXELS,
|
|
9
|
+
import { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, HEIGHT_PIXELS, LEGACY_SPEEDS, MOBILE_SLOWDOWN_DEFAULT, MOBILE_SLOWDOWN_MAX, MOBILE_SLOWDOWN_MIN, SPEED_DEFAULT, SPEED_MAX, SPEED_MIN, VARIANTS, } from './constants';
|
|
10
10
|
export function createGalleryStripGroupEdit(options) {
|
|
11
11
|
var _a;
|
|
12
12
|
const RATIOS = (_a = options.ratios) !== null && _a !== void 0 ? _a : DEFAULT_RATIOS;
|
|
13
13
|
return function Edit({ attributes, setAttributes, clientId, }) {
|
|
14
|
-
var _a, _b, _c;
|
|
15
|
-
const { height, ratio, speed, direction, spacing } = attributes;
|
|
14
|
+
var _a, _b, _c, _d;
|
|
15
|
+
const { variant, height, ratio, speed, mobileSlowdown, direction, pauseOnHover, lightbox, spacing } = attributes;
|
|
16
16
|
const heightPx = (_a = HEIGHT_PIXELS[height]) !== null && _a !== void 0 ? _a : HEIGHT_PIXELS.md;
|
|
17
17
|
const [ratioWidth, ratioHeight] = ratio.split(':').map(Number);
|
|
18
|
+
const speedValue = typeof speed === 'number' ? speed : ((_b = LEGACY_SPEEDS[speed]) !== null && _b !== void 0 ? _b : SPEED_DEFAULT);
|
|
18
19
|
const { blockProps, innerBlocksProps } = useGroupBlock({
|
|
19
|
-
blockClassName: clsx((
|
|
20
|
-
containerClassName: (
|
|
20
|
+
blockClassName: clsx((_c = options.blockClassName) !== null && _c !== void 0 ? _c : 'g-gallery g-gallery-strip wp-block-section', `--direction-${direction}`),
|
|
21
|
+
containerClassName: (_d = options.containerClassName) !== null && _d !== void 0 ? _d : 'g-gallery-strip__track',
|
|
21
22
|
containerStyle: {
|
|
22
23
|
'--gallery-strip-height': `${heightPx}px`,
|
|
23
24
|
'--gallery-strip-item-width': `${Math.round((heightPx * ratioWidth) / ratioHeight)}px`,
|
|
@@ -29,6 +30,6 @@ export function createGalleryStripGroupEdit(options) {
|
|
|
29
30
|
template: options.template,
|
|
30
31
|
layout: { type: 'default' },
|
|
31
32
|
});
|
|
32
|
-
return (_jsxs(_Fragment, { children: [_jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Rozložení', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { isBlock: true, label: __('Výška', 'brilo-blocks'), value: height, onChange: (v) => setAttributes({ height: v }), children: HEIGHTS.map((h) => (_jsx(ToggleGroupControlOption, { value: h.value, label: h.label }, h.value))) }), _jsx(ToggleGroupControl, { isBlock: true, label: __('Poměr stran', 'brilo-blocks'), value: ratio, onChange: (v) => setAttributes({ ratio: v }), children: RATIOS.map((r) => (_jsx(ToggleGroupControlOption, { value: r.value, label: r.label }, r.value))) })] }), _jsxs(PanelBody, { title: __('Animace', 'brilo-blocks'), children: [_jsx(
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Rozložení', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { isBlock: true, label: __('Šířka', 'brilo-blocks'), value: variant, onChange: (v) => setAttributes({ variant: v }), children: VARIANTS.map((v) => (_jsx(ToggleGroupControlOption, { value: v.value, label: v.label }, v.value))) }), _jsx(ToggleGroupControl, { isBlock: true, label: __('Výška', 'brilo-blocks'), value: height, onChange: (v) => setAttributes({ height: v }), children: HEIGHTS.map((h) => (_jsx(ToggleGroupControlOption, { value: h.value, label: h.label }, h.value))) }), _jsx(ToggleGroupControl, { isBlock: true, label: __('Poměr stran', 'brilo-blocks'), value: ratio, onChange: (v) => setAttributes({ ratio: v }), children: RATIOS.map((r) => (_jsx(ToggleGroupControlOption, { value: r.value, label: r.label }, r.value))) })] }), _jsxs(PanelBody, { title: __('Animace', 'brilo-blocks'), children: [_jsx(RangeControl, { label: __('Rychlost (px/s)', 'brilo-blocks'), value: speedValue, onChange: (v) => setAttributes({ speed: v !== null && v !== void 0 ? v : SPEED_DEFAULT }), min: SPEED_MIN, max: SPEED_MAX, step: 5 }), _jsx(RangeControl, { label: __('Zpomalení na mobilu', 'brilo-blocks'), help: __('Násobek doby posunu na menších displejích (1 = stejně rychle jako na desktopu).', 'brilo-blocks'), value: mobileSlowdown, onChange: (v) => setAttributes({ mobileSlowdown: v !== null && v !== void 0 ? v : MOBILE_SLOWDOWN_DEFAULT }), min: MOBILE_SLOWDOWN_MIN, max: MOBILE_SLOWDOWN_MAX, step: 0.1 }), _jsx(ToggleGroupControl, { isBlock: true, label: __('Směr', 'brilo-blocks'), value: direction, onChange: (v) => setAttributes({ direction: v }), children: DIRECTIONS.map((d) => (_jsx(ToggleGroupControlOption, { value: d.value, label: d.label }, d.value))) }), _jsx(ToggleControl, { label: __('Pozastavit při najetí myší', 'brilo-blocks'), checked: pauseOnHover, onChange: (v) => setAttributes({ pauseOnHover: v }) })] }), _jsx(PanelBody, { title: __('Galerie', 'brilo-blocks'), children: _jsx(ToggleControl, { label: __('Po kliknutí otevřít galerii', 'brilo-blocks'), checked: lightbox, onChange: (v) => setAttributes({ lightbox: v }) }) }), _jsx(ItemSpacingPanel, { spacing: spacing, onChange: (v) => setAttributes({ spacing: v }) })] }), _jsx("div", { ...blockProps, children: _jsx("div", { ...innerBlocksProps }) })] }));
|
|
33
34
|
};
|
|
34
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAKzD,OAAO,KAAK,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAElF,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,CAAA;AAEnE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,wBAAwB,GAAG,kBAAkB,CAAC,2BAA2B,CAAC,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAKzD,OAAO,KAAK,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAElF,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,CAAA;AAEnE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,wBAAwB,GAAG,kBAAkB,CAAC,2BAA2B,CAAC,CAyB/H"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { InnerBlocks } from '@wordpress/block-editor';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
4
|
import { ITEM_SPACING_ATTRIBUTE } from '../../../components/ItemSpacingControl';
|
|
5
|
-
import { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS,
|
|
5
|
+
import { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, MOBILE_SLOWDOWN_DEFAULT, SPEED_DEFAULT, VARIANTS } from './constants';
|
|
6
6
|
import { createGalleryStripGroupEdit } from './edit';
|
|
7
7
|
export function createGalleryStripGroupBlock(options) {
|
|
8
8
|
var _a, _b, _c, _d, _e;
|
|
@@ -16,10 +16,14 @@ export function createGalleryStripGroupBlock(options) {
|
|
|
16
16
|
icon: (_e = options.icon) !== null && _e !== void 0 ? _e : 'images-alt2',
|
|
17
17
|
supports: { html: false, customClassName: false },
|
|
18
18
|
attributes: {
|
|
19
|
+
variant: { type: 'string', default: VARIANTS[0].value, enum: VARIANTS.map((v) => v.value) },
|
|
19
20
|
height: { type: 'string', default: HEIGHTS[1].value, enum: HEIGHTS.map((h) => h.value) },
|
|
20
21
|
ratio: { type: 'string', default: ratios[0].value, enum: ratios.map((r) => r.value) },
|
|
21
|
-
speed: { type: '
|
|
22
|
+
speed: { type: ['number', 'string'], default: SPEED_DEFAULT },
|
|
23
|
+
mobileSlowdown: { type: 'number', default: MOBILE_SLOWDOWN_DEFAULT },
|
|
22
24
|
direction: { type: 'string', default: DIRECTIONS[0].value, enum: DIRECTIONS.map((d) => d.value) },
|
|
25
|
+
pauseOnHover: { type: 'boolean', default: false },
|
|
26
|
+
lightbox: { type: 'boolean', default: false },
|
|
23
27
|
...ITEM_SPACING_ATTRIBUTE,
|
|
24
28
|
},
|
|
25
29
|
edit: createGalleryStripGroupEdit(options),
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type { BriloBlockType, OptionArray } from '../../../types';
|
|
2
|
-
import type { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS,
|
|
2
|
+
import type { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, LEGACY_SPEEDS, VARIANTS } from './constants';
|
|
3
|
+
export type GalleryStripVariant = (typeof VARIANTS)[number]['value'];
|
|
3
4
|
export type GalleryStripHeight = (typeof HEIGHTS)[number]['value'];
|
|
4
|
-
export type
|
|
5
|
+
export type GalleryStripLegacySpeed = keyof typeof LEGACY_SPEEDS;
|
|
5
6
|
export type GalleryStripRatio = (typeof DEFAULT_RATIOS)[number]['value'];
|
|
6
7
|
export type GalleryStripDirection = (typeof DIRECTIONS)[number]['value'];
|
|
7
8
|
export interface GalleryStripGroupAttributes extends Record<string, unknown> {
|
|
9
|
+
variant: GalleryStripVariant;
|
|
8
10
|
height: GalleryStripHeight;
|
|
9
11
|
ratio: GalleryStripRatio;
|
|
10
|
-
speed:
|
|
12
|
+
speed: number | GalleryStripLegacySpeed;
|
|
13
|
+
mobileSlowdown: number;
|
|
11
14
|
direction: GalleryStripDirection;
|
|
15
|
+
pauseOnHover: boolean;
|
|
16
|
+
lightbox: boolean;
|
|
12
17
|
spacing?: number;
|
|
13
18
|
}
|
|
14
19
|
export interface GalleryStripGroupOptions extends BriloBlockType {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AACxD,OAAO,KAAK,EAAC,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AACxD,OAAO,KAAK,EAAC,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAA;AAE7F,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AACpE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAClE,MAAM,MAAM,uBAAuB,GAAG,MAAM,OAAO,aAAa,CAAA;AAChE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AACxE,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAExE,MAAM,WAAW,2BAA4B,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1E,OAAO,EAAE,mBAAmB,CAAA;IAC5B,MAAM,EAAE,kBAAkB,CAAA;IAC1B,KAAK,EAAE,iBAAiB,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,uBAAuB,CAAA;IACvC,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,qBAAqB,CAAA;IAChC,YAAY,EAAE,OAAO,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import {__} from '@wordpress/i18n'
|
|
2
2
|
|
|
3
|
+
export const VARIANTS = [
|
|
4
|
+
{value: 'default', label: __('Výchozí', 'brilo-blocks')},
|
|
5
|
+
{value: 'full-width', label: __('Na plnou šířku', 'brilo-blocks')},
|
|
6
|
+
] as const
|
|
7
|
+
|
|
3
8
|
export const HEIGHTS = [
|
|
4
9
|
{value: 'sm', label: __('Malá', 'brilo-blocks')},
|
|
5
10
|
{value: 'md', label: __('Střední', 'brilo-blocks')},
|
|
6
11
|
{value: 'lg', label: __('Velká', 'brilo-blocks')},
|
|
7
12
|
] as const
|
|
8
13
|
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
export const SPEED_MIN = 10
|
|
15
|
+
export const SPEED_MAX = 200
|
|
16
|
+
export const SPEED_DEFAULT = 60
|
|
17
|
+
|
|
18
|
+
// Blocks saved before the numeric speed store these presets in `speed`.
|
|
19
|
+
export const LEGACY_SPEEDS = {slow: 30, medium: 60, fast: 100} as const
|
|
20
|
+
|
|
21
|
+
export const MOBILE_SLOWDOWN_MIN = 1
|
|
22
|
+
export const MOBILE_SLOWDOWN_MAX = 3
|
|
23
|
+
export const MOBILE_SLOWDOWN_DEFAULT = 1.5
|
|
14
24
|
|
|
15
25
|
export const DIRECTIONS = [
|
|
16
26
|
{value: 'left', label: __('Doleva', 'brilo-blocks')},
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
2
|
import {
|
|
3
3
|
PanelBody,
|
|
4
|
+
RangeControl,
|
|
5
|
+
ToggleControl,
|
|
4
6
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
5
7
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
6
8
|
} from '@wordpress/components'
|
|
@@ -9,14 +11,27 @@ import clsx from 'clsx'
|
|
|
9
11
|
import {GalleryImagesAppender} from '~/components/GalleryImagesAppender'
|
|
10
12
|
import {ItemSpacingPanel, itemSpacingStyle} from '~/components/ItemSpacingControl'
|
|
11
13
|
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
12
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_RATIOS,
|
|
16
|
+
DIRECTIONS,
|
|
17
|
+
HEIGHTS,
|
|
18
|
+
HEIGHT_PIXELS,
|
|
19
|
+
LEGACY_SPEEDS,
|
|
20
|
+
MOBILE_SLOWDOWN_DEFAULT,
|
|
21
|
+
MOBILE_SLOWDOWN_MAX,
|
|
22
|
+
MOBILE_SLOWDOWN_MIN,
|
|
23
|
+
SPEED_DEFAULT,
|
|
24
|
+
SPEED_MAX,
|
|
25
|
+
SPEED_MIN,
|
|
26
|
+
VARIANTS,
|
|
27
|
+
} from './constants'
|
|
13
28
|
import type {
|
|
14
29
|
GalleryStripDirection,
|
|
15
30
|
GalleryStripGroupAttributes,
|
|
16
31
|
GalleryStripGroupOptions,
|
|
17
32
|
GalleryStripHeight,
|
|
18
33
|
GalleryStripRatio,
|
|
19
|
-
|
|
34
|
+
GalleryStripVariant,
|
|
20
35
|
} from './types'
|
|
21
36
|
|
|
22
37
|
export function createGalleryStripGroupEdit(options: GalleryStripGroupOptions) {
|
|
@@ -31,16 +46,13 @@ export function createGalleryStripGroupEdit(options: GalleryStripGroupOptions) {
|
|
|
31
46
|
setAttributes: (a: Partial<GalleryStripGroupAttributes>) => void
|
|
32
47
|
clientId: string
|
|
33
48
|
}) {
|
|
34
|
-
const {height, ratio, speed, direction, spacing} = attributes
|
|
49
|
+
const {variant, height, ratio, speed, mobileSlowdown, direction, pauseOnHover, lightbox, spacing} = attributes
|
|
35
50
|
const heightPx = HEIGHT_PIXELS[height] ?? HEIGHT_PIXELS.md
|
|
36
51
|
const [ratioWidth, ratioHeight] = ratio.split(':').map(Number)
|
|
52
|
+
const speedValue = typeof speed === 'number' ? speed : (LEGACY_SPEEDS[speed] ?? SPEED_DEFAULT)
|
|
37
53
|
|
|
38
54
|
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
39
|
-
blockClassName: clsx(
|
|
40
|
-
options.blockClassName ?? 'g-gallery g-gallery-strip wp-block-section',
|
|
41
|
-
`--speed-${speed}`,
|
|
42
|
-
`--direction-${direction}`,
|
|
43
|
-
),
|
|
55
|
+
blockClassName: clsx(options.blockClassName ?? 'g-gallery g-gallery-strip wp-block-section', `--direction-${direction}`),
|
|
44
56
|
containerClassName: options.containerClassName ?? 'g-gallery-strip__track',
|
|
45
57
|
containerStyle: {
|
|
46
58
|
'--gallery-strip-height': `${heightPx}px`,
|
|
@@ -58,6 +70,16 @@ export function createGalleryStripGroupEdit(options: GalleryStripGroupOptions) {
|
|
|
58
70
|
<>
|
|
59
71
|
<InspectorControls>
|
|
60
72
|
<PanelBody title={__('Rozložení', 'brilo-blocks')}>
|
|
73
|
+
<ToggleGroupControl
|
|
74
|
+
isBlock
|
|
75
|
+
label={__('Šířka', 'brilo-blocks')}
|
|
76
|
+
value={variant}
|
|
77
|
+
onChange={(v) => setAttributes({variant: v as GalleryStripVariant})}
|
|
78
|
+
>
|
|
79
|
+
{VARIANTS.map((v) => (
|
|
80
|
+
<ToggleGroupControlOption key={v.value} value={v.value} label={v.label} />
|
|
81
|
+
))}
|
|
82
|
+
</ToggleGroupControl>
|
|
61
83
|
<ToggleGroupControl
|
|
62
84
|
isBlock
|
|
63
85
|
label={__('Výška', 'brilo-blocks')}
|
|
@@ -80,16 +102,23 @@ export function createGalleryStripGroupEdit(options: GalleryStripGroupOptions) {
|
|
|
80
102
|
</ToggleGroupControl>
|
|
81
103
|
</PanelBody>
|
|
82
104
|
<PanelBody title={__('Animace', 'brilo-blocks')}>
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
<RangeControl
|
|
106
|
+
label={__('Rychlost (px/s)', 'brilo-blocks')}
|
|
107
|
+
value={speedValue}
|
|
108
|
+
onChange={(v) => setAttributes({speed: v ?? SPEED_DEFAULT})}
|
|
109
|
+
min={SPEED_MIN}
|
|
110
|
+
max={SPEED_MAX}
|
|
111
|
+
step={5}
|
|
112
|
+
/>
|
|
113
|
+
<RangeControl
|
|
114
|
+
label={__('Zpomalení na mobilu', 'brilo-blocks')}
|
|
115
|
+
help={__('Násobek doby posunu na menších displejích (1 = stejně rychle jako na desktopu).', 'brilo-blocks')}
|
|
116
|
+
value={mobileSlowdown}
|
|
117
|
+
onChange={(v) => setAttributes({mobileSlowdown: v ?? MOBILE_SLOWDOWN_DEFAULT})}
|
|
118
|
+
min={MOBILE_SLOWDOWN_MIN}
|
|
119
|
+
max={MOBILE_SLOWDOWN_MAX}
|
|
120
|
+
step={0.1}
|
|
121
|
+
/>
|
|
93
122
|
<ToggleGroupControl
|
|
94
123
|
isBlock
|
|
95
124
|
label={__('Směr', 'brilo-blocks')}
|
|
@@ -100,6 +129,18 @@ export function createGalleryStripGroupEdit(options: GalleryStripGroupOptions) {
|
|
|
100
129
|
<ToggleGroupControlOption key={d.value} value={d.value} label={d.label} />
|
|
101
130
|
))}
|
|
102
131
|
</ToggleGroupControl>
|
|
132
|
+
<ToggleControl
|
|
133
|
+
label={__('Pozastavit při najetí myší', 'brilo-blocks')}
|
|
134
|
+
checked={pauseOnHover}
|
|
135
|
+
onChange={(v) => setAttributes({pauseOnHover: v})}
|
|
136
|
+
/>
|
|
137
|
+
</PanelBody>
|
|
138
|
+
<PanelBody title={__('Galerie', 'brilo-blocks')}>
|
|
139
|
+
<ToggleControl
|
|
140
|
+
label={__('Po kliknutí otevřít galerii', 'brilo-blocks')}
|
|
141
|
+
checked={lightbox}
|
|
142
|
+
onChange={(v) => setAttributes({lightbox: v})}
|
|
143
|
+
/>
|
|
103
144
|
</PanelBody>
|
|
104
145
|
<ItemSpacingPanel spacing={spacing} onChange={(v) => setAttributes({spacing: v})} />
|
|
105
146
|
</InspectorControls>
|
|
@@ -2,7 +2,7 @@ import {InnerBlocks} from '@wordpress/block-editor'
|
|
|
2
2
|
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
3
|
import {__} from '@wordpress/i18n'
|
|
4
4
|
import {ITEM_SPACING_ATTRIBUTE} from '~/components/ItemSpacingControl'
|
|
5
|
-
import {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS,
|
|
5
|
+
import {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, MOBILE_SLOWDOWN_DEFAULT, SPEED_DEFAULT, VARIANTS} from './constants'
|
|
6
6
|
import {createGalleryStripGroupEdit} from './edit'
|
|
7
7
|
import type {GalleryStripGroupAttributes, GalleryStripGroupOptions} from './types'
|
|
8
8
|
|
|
@@ -20,10 +20,14 @@ export function createGalleryStripGroupBlock(options: GalleryStripGroupOptions):
|
|
|
20
20
|
icon: options.icon ?? 'images-alt2',
|
|
21
21
|
supports: {html: false, customClassName: false},
|
|
22
22
|
attributes: {
|
|
23
|
+
variant: {type: 'string', default: VARIANTS[0].value, enum: VARIANTS.map((v) => v.value)},
|
|
23
24
|
height: {type: 'string', default: HEIGHTS[1].value, enum: HEIGHTS.map((h) => h.value)},
|
|
24
25
|
ratio: {type: 'string', default: ratios[0].value, enum: ratios.map((r) => r.value)},
|
|
25
|
-
speed: {type: '
|
|
26
|
+
speed: {type: ['number', 'string'], default: SPEED_DEFAULT},
|
|
27
|
+
mobileSlowdown: {type: 'number', default: MOBILE_SLOWDOWN_DEFAULT},
|
|
26
28
|
direction: {type: 'string', default: DIRECTIONS[0].value, enum: DIRECTIONS.map((d) => d.value)},
|
|
29
|
+
pauseOnHover: {type: 'boolean', default: false},
|
|
30
|
+
lightbox: {type: 'boolean', default: false},
|
|
27
31
|
...ITEM_SPACING_ATTRIBUTE,
|
|
28
32
|
},
|
|
29
33
|
edit: createGalleryStripGroupEdit(options),
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type {BriloBlockType, OptionArray} from '~/types'
|
|
2
|
-
import type {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS,
|
|
2
|
+
import type {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, LEGACY_SPEEDS, VARIANTS} from './constants'
|
|
3
3
|
|
|
4
|
+
export type GalleryStripVariant = (typeof VARIANTS)[number]['value']
|
|
4
5
|
export type GalleryStripHeight = (typeof HEIGHTS)[number]['value']
|
|
5
|
-
export type
|
|
6
|
+
export type GalleryStripLegacySpeed = keyof typeof LEGACY_SPEEDS
|
|
6
7
|
export type GalleryStripRatio = (typeof DEFAULT_RATIOS)[number]['value']
|
|
7
8
|
export type GalleryStripDirection = (typeof DIRECTIONS)[number]['value']
|
|
8
9
|
|
|
9
10
|
export interface GalleryStripGroupAttributes extends Record<string, unknown> {
|
|
11
|
+
variant: GalleryStripVariant
|
|
10
12
|
height: GalleryStripHeight
|
|
11
13
|
ratio: GalleryStripRatio
|
|
12
|
-
speed:
|
|
14
|
+
speed: number | GalleryStripLegacySpeed
|
|
15
|
+
mobileSlowdown: number
|
|
13
16
|
direction: GalleryStripDirection
|
|
17
|
+
pauseOnHover: boolean
|
|
18
|
+
lightbox: boolean
|
|
14
19
|
spacing?: number
|
|
15
20
|
}
|
|
16
21
|
|