@brilo/base-blocks 0.1.15 → 0.1.17
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/contact/contact-group/constants.d.ts +17 -0
- package/build/blocks/contact/contact-group/constants.d.ts.map +1 -1
- package/build/blocks/contact/contact-group/constants.js +10 -0
- package/build/blocks/contact/contact-group/edit.d.ts.map +1 -1
- package/build/blocks/contact/contact-group/edit.js +6 -4
- package/build/blocks/contact/contact-group/factory.d.ts.map +1 -1
- package/build/blocks/contact/contact-group/factory.js +5 -1
- package/build/blocks/contact/contact-group/types.d.ts +10 -1
- package/build/blocks/contact/contact-group/types.d.ts.map +1 -1
- package/build/blocks/contact/contact-item/index.d.ts.map +1 -1
- package/build/blocks/contact/contact-item/index.js +1 -0
- package/build/blocks/signpost/signpost-item/index.js +1 -1
- package/build/blocks/usp/usp-group/constants.d.ts +48 -35
- package/build/blocks/usp/usp-group/constants.d.ts.map +1 -1
- package/build/blocks/usp/usp-group/constants.js +27 -17
- package/build/blocks/usp/usp-group/edit.d.ts.map +1 -1
- package/build/blocks/usp/usp-group/edit.js +10 -7
- package/build/blocks/usp/usp-group/factory.d.ts +2 -2
- package/build/blocks/usp/usp-group/factory.d.ts.map +1 -1
- package/build/blocks/usp/usp-group/factory.js +27 -19
- package/build/blocks/usp/usp-group/types.d.ts +19 -13
- package/build/blocks/usp/usp-group/types.d.ts.map +1 -1
- package/build/blocks/usp/usp-item/buildPreviewStyle.d.ts +25 -0
- package/build/blocks/usp/usp-item/buildPreviewStyle.d.ts.map +1 -0
- package/build/blocks/usp/usp-item/buildPreviewStyle.js +30 -0
- package/build/blocks/usp/usp-item/edit.d.ts +5 -1
- package/build/blocks/usp/usp-item/edit.d.ts.map +1 -1
- package/build/blocks/usp/usp-item/edit.js +7 -3
- package/build/blocks/usp/usp-item/factory.d.ts.map +1 -1
- package/build/blocks/usp/usp-item/factory.js +1 -0
- package/build/components/ItemIconControl/ItemIconPreview.d.ts +1 -1
- package/build/components/ItemIconControl/ItemIconPreview.d.ts.map +1 -1
- package/build/components/ItemIconControl/ItemIconPreview.js +4 -4
- package/package.json +1 -1
- package/src/blocks/contact/contact-group/constants.ts +13 -0
- package/src/blocks/contact/contact-group/edit.tsx +54 -3
- package/src/blocks/contact/contact-group/factory.tsx +5 -1
- package/src/blocks/contact/contact-group/types.ts +12 -1
- package/src/blocks/contact/contact-item/index.ts +1 -0
- package/src/blocks/groups/text-and-media-group/editor.scss +14 -0
- package/src/blocks/signpost/signpost-item/index.ts +1 -1
- package/src/blocks/usp/usp-group/constants.ts +29 -17
- package/src/blocks/usp/usp-group/edit.tsx +109 -34
- package/src/blocks/usp/usp-group/factory.tsx +19 -27
- package/src/blocks/usp/usp-group/types.ts +22 -16
- package/src/blocks/usp/usp-item/buildPreviewStyle.ts +66 -0
- package/src/blocks/usp/usp-item/edit.tsx +15 -2
- package/src/blocks/usp/usp-item/editor.scss +140 -1
- package/src/blocks/usp/usp-item/factory.tsx +1 -0
- package/src/components/ItemIconControl/ItemIconPreview.tsx +4 -4
- package/src/components/ItemIconControl/types.d.ts +2 -0
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
DEFAULT_CONTENT_SIZES,
|
|
9
9
|
DEFAULT_DIRECTIONS,
|
|
10
10
|
DEFAULT_HEADING_STYLES,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
DEFAULT_ICON_BACKGROUND_SHAPES,
|
|
12
|
+
DEFAULT_ICON_BACKGROUND_SIZE,
|
|
13
|
+
DEFAULT_ICON_SIZE,
|
|
14
14
|
DEFAULT_SHADOWS,
|
|
15
15
|
HEADING_LEVELS,
|
|
16
16
|
} from './constants'
|
|
@@ -25,32 +25,18 @@ export function createUspGroupBlock<
|
|
|
25
25
|
TDirections extends OptionArray = typeof DEFAULT_DIRECTIONS,
|
|
26
26
|
THeadingStyles extends OptionArray = typeof DEFAULT_HEADING_STYLES,
|
|
27
27
|
TShadows extends OptionArray = typeof DEFAULT_SHADOWS,
|
|
28
|
-
|
|
29
|
-
TIconColors extends OptionArray = typeof DEFAULT_ICON_COLORS,
|
|
30
|
-
TIconBackgrounds extends OptionArray = typeof DEFAULT_ICON_BACKGROUNDS,
|
|
28
|
+
TIconBackgroundShapes extends OptionArray = typeof DEFAULT_ICON_BACKGROUND_SHAPES,
|
|
31
29
|
TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS,
|
|
32
30
|
TContentSizes extends OptionArray = typeof DEFAULT_CONTENT_SIZES,
|
|
33
31
|
>(
|
|
34
|
-
options: UspGroupOptions<
|
|
35
|
-
TColumns,
|
|
36
|
-
TDirections,
|
|
37
|
-
THeadingStyles,
|
|
38
|
-
TShadows,
|
|
39
|
-
TIconSizes,
|
|
40
|
-
TIconColors,
|
|
41
|
-
TIconBackgrounds,
|
|
42
|
-
TAlignments,
|
|
43
|
-
TContentSizes
|
|
44
|
-
>,
|
|
32
|
+
options: UspGroupOptions<TColumns, TDirections, THeadingStyles, TShadows, TIconBackgroundShapes, TAlignments, TContentSizes>,
|
|
45
33
|
): BlockConfiguration<
|
|
46
34
|
UspGroupAttributes<
|
|
47
35
|
TColumns[number],
|
|
48
36
|
TDirections[number]['value'],
|
|
49
37
|
THeadingStyles[number]['value'],
|
|
50
38
|
TShadows[number]['value'],
|
|
51
|
-
|
|
52
|
-
TIconColors[number]['value'],
|
|
53
|
-
TIconBackgrounds[number]['value'],
|
|
39
|
+
TIconBackgroundShapes[number]['value'],
|
|
54
40
|
TAlignments[number]['value'],
|
|
55
41
|
TContentSizes[number]['value']
|
|
56
42
|
>
|
|
@@ -59,9 +45,7 @@ export function createUspGroupBlock<
|
|
|
59
45
|
const directions = options.directions ?? DEFAULT_DIRECTIONS
|
|
60
46
|
const headingStyles = options.headingStyles ?? DEFAULT_HEADING_STYLES
|
|
61
47
|
const shadows = options.shadows ?? DEFAULT_SHADOWS
|
|
62
|
-
const
|
|
63
|
-
const iconColors = options.iconColors ?? DEFAULT_ICON_COLORS
|
|
64
|
-
const iconBackgrounds = options.iconBackgrounds ?? DEFAULT_ICON_BACKGROUNDS
|
|
48
|
+
const iconBackgroundShapes = options.iconBackgroundShapes ?? DEFAULT_ICON_BACKGROUND_SHAPES
|
|
65
49
|
const alignments = options.alignments ?? DEFAULT_ALIGNMENTS
|
|
66
50
|
const contentSizes = options.contentSizes ?? DEFAULT_CONTENT_SIZES
|
|
67
51
|
|
|
@@ -73,6 +57,7 @@ export function createUspGroupBlock<
|
|
|
73
57
|
...(options.parent && {parent: options.parent}),
|
|
74
58
|
icon: options.icon ?? {src: defaultIcon},
|
|
75
59
|
supports: {html: false, customClassName: false},
|
|
60
|
+
providesContext: {'brilo/usp-style': 'style'},
|
|
76
61
|
attributes: {
|
|
77
62
|
columns: {
|
|
78
63
|
type: 'number',
|
|
@@ -91,10 +76,19 @@ export function createUspGroupBlock<
|
|
|
91
76
|
card: false,
|
|
92
77
|
direction: directions[0].value,
|
|
93
78
|
align: alignments[0].value,
|
|
79
|
+
textAlign: '',
|
|
94
80
|
borderColor: '',
|
|
95
81
|
backgroundColor: '',
|
|
96
82
|
textColor: '',
|
|
97
|
-
icon: {
|
|
83
|
+
icon: {
|
|
84
|
+
size: DEFAULT_ICON_SIZE,
|
|
85
|
+
color: '',
|
|
86
|
+
background: '',
|
|
87
|
+
backgroundSize: DEFAULT_ICON_BACKGROUND_SIZE,
|
|
88
|
+
backgroundShape: iconBackgroundShapes[0].value,
|
|
89
|
+
borderColor: '',
|
|
90
|
+
borderWidth: 1,
|
|
91
|
+
},
|
|
98
92
|
},
|
|
99
93
|
},
|
|
100
94
|
},
|
|
@@ -106,9 +100,7 @@ export function createUspGroupBlock<
|
|
|
106
100
|
TDirections[number]['value'],
|
|
107
101
|
THeadingStyles[number]['value'],
|
|
108
102
|
TShadows[number]['value'],
|
|
109
|
-
|
|
110
|
-
TIconColors[number]['value'],
|
|
111
|
-
TIconBackgrounds[number]['value'],
|
|
103
|
+
TIconBackgroundShapes[number]['value'],
|
|
112
104
|
TAlignments[number]['value'],
|
|
113
105
|
TContentSizes[number]['value']
|
|
114
106
|
>
|
|
@@ -5,9 +5,7 @@ import type {
|
|
|
5
5
|
DEFAULT_CONTENT_SIZES,
|
|
6
6
|
DEFAULT_DIRECTIONS,
|
|
7
7
|
DEFAULT_HEADING_STYLES,
|
|
8
|
-
|
|
9
|
-
DEFAULT_ICON_COLORS,
|
|
10
|
-
DEFAULT_ICON_SIZES,
|
|
8
|
+
DEFAULT_ICON_BACKGROUND_SHAPES,
|
|
11
9
|
DEFAULT_SHADOWS,
|
|
12
10
|
HEADING_LEVELS,
|
|
13
11
|
} from './constants'
|
|
@@ -18,19 +16,20 @@ export type UspHeadingLevel = (typeof HEADING_LEVELS)[number]
|
|
|
18
16
|
export type UspHeadingStyle = (typeof DEFAULT_HEADING_STYLES)[number]['value']
|
|
19
17
|
export type UspShadow = (typeof DEFAULT_SHADOWS)[number]['value']
|
|
20
18
|
export type UspAlignment = (typeof DEFAULT_ALIGNMENTS)[number]['value']
|
|
21
|
-
export type UspIconSize = (typeof DEFAULT_ICON_SIZES)[number]['value']
|
|
22
|
-
export type UspIconColor = (typeof DEFAULT_ICON_COLORS)[number]['value']
|
|
23
|
-
export type UspIconBackground = (typeof DEFAULT_ICON_BACKGROUNDS)[number]['value']
|
|
24
19
|
export type UspContentSize = (typeof DEFAULT_CONTENT_SIZES)[number]['value']
|
|
20
|
+
export type UspIconBackgroundShape = (typeof DEFAULT_ICON_BACKGROUND_SHAPES)[number]['value']
|
|
21
|
+
|
|
22
|
+
export interface UspSizePreset {
|
|
23
|
+
value: number
|
|
24
|
+
label: string
|
|
25
|
+
}
|
|
25
26
|
|
|
26
27
|
export interface UspGroupAttributes<
|
|
27
28
|
TColumn extends number = UspColumns,
|
|
28
29
|
TDirection extends string = UspDirection,
|
|
29
30
|
THeadingStyle extends string = UspHeadingStyle,
|
|
30
31
|
TShadow extends string = UspShadow,
|
|
31
|
-
|
|
32
|
-
TIconColor extends string = UspIconColor,
|
|
33
|
-
TIconBackground extends string = UspIconBackground,
|
|
32
|
+
TIconBackgroundShape extends string = UspIconBackgroundShape,
|
|
34
33
|
TAlignment extends string = UspAlignment,
|
|
35
34
|
TContentSize extends string = UspContentSize,
|
|
36
35
|
> extends Record<string, unknown> {
|
|
@@ -42,10 +41,19 @@ export interface UspGroupAttributes<
|
|
|
42
41
|
card: boolean
|
|
43
42
|
direction: TDirection
|
|
44
43
|
align: TAlignment
|
|
44
|
+
textAlign: string
|
|
45
45
|
borderColor: string
|
|
46
46
|
backgroundColor: string
|
|
47
47
|
textColor: string
|
|
48
|
-
icon: {
|
|
48
|
+
icon: {
|
|
49
|
+
size: number
|
|
50
|
+
color: string
|
|
51
|
+
background: string
|
|
52
|
+
backgroundSize: number
|
|
53
|
+
backgroundShape: TIconBackgroundShape
|
|
54
|
+
borderColor: string
|
|
55
|
+
borderWidth: number
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
59
|
|
|
@@ -54,9 +62,7 @@ export interface UspGroupOptions<
|
|
|
54
62
|
TDirections extends OptionArray = typeof DEFAULT_DIRECTIONS,
|
|
55
63
|
THeadingStyles extends OptionArray = typeof DEFAULT_HEADING_STYLES,
|
|
56
64
|
TShadows extends OptionArray = typeof DEFAULT_SHADOWS,
|
|
57
|
-
|
|
58
|
-
TIconColors extends OptionArray = typeof DEFAULT_ICON_COLORS,
|
|
59
|
-
TIconBackgrounds extends OptionArray = typeof DEFAULT_ICON_BACKGROUNDS,
|
|
65
|
+
TIconBackgroundShapes extends OptionArray = typeof DEFAULT_ICON_BACKGROUND_SHAPES,
|
|
60
66
|
TAlignments extends OptionArray = typeof DEFAULT_ALIGNMENTS,
|
|
61
67
|
TContentSizes extends OptionArray = typeof DEFAULT_CONTENT_SIZES,
|
|
62
68
|
> extends BriloBlockType {
|
|
@@ -65,9 +71,9 @@ export interface UspGroupOptions<
|
|
|
65
71
|
directions?: TDirections
|
|
66
72
|
headingStyles?: THeadingStyles
|
|
67
73
|
shadows?: TShadows
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
iconSizePresets?: readonly UspSizePreset[]
|
|
75
|
+
iconBackgroundSizePresets?: readonly UspSizePreset[]
|
|
76
|
+
iconBackgroundShapes?: TIconBackgroundShapes
|
|
71
77
|
alignments?: TAlignments
|
|
72
78
|
contentSizes?: TContentSizes
|
|
73
79
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
|
|
3
|
+
export interface UspSharedStyle {
|
|
4
|
+
direction?: string
|
|
5
|
+
align?: string
|
|
6
|
+
textAlign?: string
|
|
7
|
+
shadow?: string
|
|
8
|
+
borderColor?: string
|
|
9
|
+
backgroundColor?: string
|
|
10
|
+
textColor?: string
|
|
11
|
+
icon?: {
|
|
12
|
+
size?: number
|
|
13
|
+
color?: string
|
|
14
|
+
background?: string
|
|
15
|
+
backgroundSize?: number
|
|
16
|
+
backgroundShape?: string
|
|
17
|
+
borderColor?: string
|
|
18
|
+
borderWidth?: number
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface UspPreviewStyle {
|
|
23
|
+
rootClassName: string
|
|
24
|
+
iconClassName: string
|
|
25
|
+
cssVars: Record<string, string>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function buildUspPreviewStyle(shared?: UspSharedStyle, resolveHex: (value: string) => string = (value) => value): UspPreviewStyle {
|
|
29
|
+
if (!shared) {
|
|
30
|
+
return {rootClassName: '', iconClassName: '', cssVars: {}}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const icon = shared.icon ?? {}
|
|
34
|
+
|
|
35
|
+
const rootClassName = clsx(
|
|
36
|
+
shared.direction && `--direction-${shared.direction}`,
|
|
37
|
+
shared.align && `--align-${shared.align}`,
|
|
38
|
+
shared.textAlign && `--body-align-${shared.textAlign}`,
|
|
39
|
+
shared.shadow && shared.shadow !== 'none' && `--shadow --shadow-${shared.shadow}`,
|
|
40
|
+
icon.background && '--icon-background',
|
|
41
|
+
icon.color && '--icon-color',
|
|
42
|
+
icon.borderColor && '--icon-bordered',
|
|
43
|
+
shared.backgroundColor && '--background-color',
|
|
44
|
+
shared.borderColor && '--border',
|
|
45
|
+
shared.textColor && '--text-color',
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const iconClassName = clsx(
|
|
49
|
+
icon.backgroundShape && icon.backgroundShape !== 'none' && `--background-shape --background-shape-${icon.backgroundShape}`,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const cssVars: Record<string, string> = {}
|
|
53
|
+
if (shared.borderColor) cssVars['--border-color'] = resolveHex(shared.borderColor)
|
|
54
|
+
if (shared.backgroundColor) cssVars['--background-color'] = resolveHex(shared.backgroundColor)
|
|
55
|
+
if (shared.textColor) cssVars['--text-color'] = resolveHex(shared.textColor)
|
|
56
|
+
if (icon.background) cssVars['--icon-background-color'] = resolveHex(icon.background)
|
|
57
|
+
if (icon.color) cssVars['--icon-color'] = resolveHex(icon.color)
|
|
58
|
+
if (icon.size) cssVars['--icon-size'] = `${icon.size}px`
|
|
59
|
+
if (icon.backgroundSize) cssVars['--icon-background-size'] = `${icon.backgroundSize}px`
|
|
60
|
+
if (icon.borderColor) {
|
|
61
|
+
cssVars['--icon-outline-color'] = resolveHex(icon.borderColor)
|
|
62
|
+
cssVars['--icon-outline-width'] = `${icon.borderWidth || 1}px`
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {rootClassName, iconClassName, cssVars}
|
|
66
|
+
}
|
|
@@ -3,6 +3,8 @@ import {PanelBody, ToggleControl, TextControl} from '@wordpress/components'
|
|
|
3
3
|
import {__} from '@wordpress/i18n'
|
|
4
4
|
import clsx from 'clsx'
|
|
5
5
|
import {ItemIconControl, ItemIconPreview} from '~/components/ItemIconControl'
|
|
6
|
+
import {useTenantColorPalette} from '~/hooks/useTenantColorPalette'
|
|
7
|
+
import {buildUspPreviewStyle, type UspSharedStyle} from './buildPreviewStyle'
|
|
6
8
|
import {ICON_TYPES} from './constants'
|
|
7
9
|
import type {UspItemAttributes, UspItemOptions} from './types'
|
|
8
10
|
|
|
@@ -10,13 +12,17 @@ export function createUspItemEdit(options: UspItemOptions) {
|
|
|
10
12
|
return function Edit({
|
|
11
13
|
attributes,
|
|
12
14
|
setAttributes,
|
|
15
|
+
context,
|
|
13
16
|
}: {
|
|
14
17
|
attributes: UspItemAttributes
|
|
15
18
|
setAttributes: (a: Partial<UspItemAttributes>) => void
|
|
19
|
+
context?: {'brilo/usp-style'?: UspSharedStyle}
|
|
16
20
|
}) {
|
|
17
21
|
const {title, content, url, icon} = attributes
|
|
22
|
+
const {resolveHex} = useTenantColorPalette()
|
|
23
|
+
const {rootClassName, iconClassName, cssVars} = buildUspPreviewStyle(context?.['brilo/usp-style'], resolveHex)
|
|
18
24
|
|
|
19
|
-
const blockProps = useBlockProps({className: 'i-usp'})
|
|
25
|
+
const blockProps = useBlockProps({className: clsx('i-usp', rootClassName), style: cssVars})
|
|
20
26
|
|
|
21
27
|
return (
|
|
22
28
|
<>
|
|
@@ -36,7 +42,14 @@ export function createUspItemEdit(options: UspItemOptions) {
|
|
|
36
42
|
|
|
37
43
|
<div {...blockProps}>
|
|
38
44
|
<div className="i-usp__inner wp-block-inner">
|
|
39
|
-
<ItemIconPreview
|
|
45
|
+
<ItemIconPreview
|
|
46
|
+
icon={icon}
|
|
47
|
+
className="i-usp__icon"
|
|
48
|
+
modifierClassName={iconClassName}
|
|
49
|
+
style={cssVars}
|
|
50
|
+
setAttributes={setAttributes}
|
|
51
|
+
options={options}
|
|
52
|
+
/>
|
|
40
53
|
|
|
41
54
|
<div className={clsx('i-usp__body', 'grow')}>
|
|
42
55
|
<RichText
|
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
.i-usp {
|
|
2
2
|
width: 100%;
|
|
3
3
|
margin-inline: 0;
|
|
4
|
+
text-align: var(--text-align, left);
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
|
|
7
|
+
&.--shadow {
|
|
8
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&.--shadow-md {
|
|
12
|
+
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.--border {
|
|
16
|
+
border: 1px solid var(--border-color, transparent);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.--background-color {
|
|
20
|
+
background-color: var(--background-color, transparent);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.--text-color {
|
|
24
|
+
color: var(--text-color);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.i-usp__inner {
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: 8px;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
align-items: flex-start;
|
|
33
|
+
|
|
34
|
+
.i-usp.--direction-horizontal & {
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.i-usp.--align-center & {
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.i-usp__body {
|
|
45
|
+
text-align: var(--body-text-align, inherit);
|
|
4
46
|
}
|
|
5
47
|
|
|
6
48
|
.i-usp__title {
|
|
@@ -11,7 +53,104 @@
|
|
|
11
53
|
|
|
12
54
|
.i-usp__content {
|
|
13
55
|
font-size: 14px;
|
|
14
|
-
color:
|
|
56
|
+
color: var(--text-color);
|
|
15
57
|
margin: 0;
|
|
16
58
|
line-height: 1.5;
|
|
17
59
|
}
|
|
60
|
+
|
|
61
|
+
.i-usp__icon {
|
|
62
|
+
--icon-box-size: max(var(--icon-background-size, 88px), var(--icon-size, 88px));
|
|
63
|
+
|
|
64
|
+
width: var(--icon-box-size);
|
|
65
|
+
height: var(--icon-box-size);
|
|
66
|
+
flex: 0 0 var(--icon-box-size);
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-template-areas: "pile";
|
|
69
|
+
place-items: center;
|
|
70
|
+
isolation: isolate;
|
|
71
|
+
|
|
72
|
+
&::before,
|
|
73
|
+
&::after {
|
|
74
|
+
content: "";
|
|
75
|
+
grid-area: pile;
|
|
76
|
+
width: var(--icon-background-size, 88px);
|
|
77
|
+
height: var(--icon-background-size, 88px);
|
|
78
|
+
border-radius: inherit;
|
|
79
|
+
clip-path: var(--icon-background-shape, none);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&::before {
|
|
83
|
+
z-index: 0;
|
|
84
|
+
background-color: var(--icon-outline-color, transparent);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&::after {
|
|
88
|
+
z-index: 1;
|
|
89
|
+
width: calc(var(--icon-background-size, 88px) - var(--icon-outline-width, 0px) * 2);
|
|
90
|
+
height: calc(var(--icon-background-size, 88px) - var(--icon-outline-width, 0px) * 2);
|
|
91
|
+
background-color: var(--icon-background-color, transparent);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
img,
|
|
95
|
+
svg,
|
|
96
|
+
span {
|
|
97
|
+
grid-area: pile;
|
|
98
|
+
position: relative;
|
|
99
|
+
z-index: 2;
|
|
100
|
+
width: var(--icon-size, 88px);
|
|
101
|
+
height: var(--icon-size, 88px);
|
|
102
|
+
object-fit: contain;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
svg path {
|
|
106
|
+
fill: var(--icon-color, currentcolor);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
span {
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
color: var(--icon-color, currentcolor);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&.--background-shape-circle {
|
|
117
|
+
--icon-background-shape: circle(50% at 50% 50%);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&.--background-shape-triangle {
|
|
121
|
+
--icon-background-shape: polygon(50% 0%, 0% 100%, 100% 100%);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&.--background-shape-rhombus {
|
|
125
|
+
--icon-background-shape: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&.--background-shape-octagon {
|
|
129
|
+
--icon-background-shape: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&.--background-shape-bevel {
|
|
133
|
+
--icon-background-shape: polygon(20% 0%, 80% 0%, 100% 20%, 100% 80%, 80% 100%, 20% 100%, 0% 80%, 0% 20%);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&.--background-shape-rabbet {
|
|
137
|
+
--icon-background-shape: polygon(
|
|
138
|
+
0% 15%,
|
|
139
|
+
15% 15%,
|
|
140
|
+
15% 0%,
|
|
141
|
+
85% 0%,
|
|
142
|
+
85% 15%,
|
|
143
|
+
100% 15%,
|
|
144
|
+
100% 85%,
|
|
145
|
+
85% 85%,
|
|
146
|
+
85% 100%,
|
|
147
|
+
15% 100%,
|
|
148
|
+
15% 85%,
|
|
149
|
+
0% 85%
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&.--background-shape-parallelogram {
|
|
154
|
+
--icon-background-shape: polygon(25% 0%, 100% 0%, 75% 100%, 0% 100%);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -15,6 +15,7 @@ export function createUspItemBlock(options: UspItemOptions): BlockConfiguration<
|
|
|
15
15
|
...(options.parent && {parent: options.parent}),
|
|
16
16
|
icon: options.icon ?? 'star-filled',
|
|
17
17
|
supports: {html: false, customClassName: false},
|
|
18
|
+
usesContext: ['brilo/usp-style'],
|
|
18
19
|
attributes: {
|
|
19
20
|
title: {type: 'string', default: ''},
|
|
20
21
|
content: {type: 'string', default: ''},
|
|
@@ -4,7 +4,7 @@ import {useMediaUrl} from '~/components/ImagePicker'
|
|
|
4
4
|
import type {ItemIconPreviewProps} from './types'
|
|
5
5
|
import {ItemIconModal} from './ItemIconModal'
|
|
6
6
|
|
|
7
|
-
export function ItemIconPreview({icon, className, options, setAttributes}: ItemIconPreviewProps) {
|
|
7
|
+
export function ItemIconPreview({icon, className, modifierClassName, style, options, setAttributes}: ItemIconPreviewProps) {
|
|
8
8
|
const [isModalOpen, setModalOpen] = useState(false)
|
|
9
9
|
const mediaIconUrl = useMediaUrl(icon.media?.id ?? 0)
|
|
10
10
|
const preselectedIconUrl = icon.type === 'preselected' && icon.src ? `${options.iconsSrc}${icon.src}.svg` : ''
|
|
@@ -13,7 +13,7 @@ export function ItemIconPreview({icon, className, options, setAttributes}: ItemI
|
|
|
13
13
|
if (icon.type === 'preselected') {
|
|
14
14
|
if (preselectedIconUrl) {
|
|
15
15
|
return (
|
|
16
|
-
<div className={clsx('i-item-icon', className)}>
|
|
16
|
+
<div className={clsx('i-item-icon', className, modifierClassName)} style={style}>
|
|
17
17
|
<img
|
|
18
18
|
src={preselectedIconUrl}
|
|
19
19
|
alt=""
|
|
@@ -43,7 +43,7 @@ export function ItemIconPreview({icon, className, options, setAttributes}: ItemI
|
|
|
43
43
|
if (icon.type === 'media') {
|
|
44
44
|
if (icon.media?.id && mediaIconUrl) {
|
|
45
45
|
return (
|
|
46
|
-
<div className={clsx('i-item-icon', className)}>
|
|
46
|
+
<div className={clsx('i-item-icon', className, modifierClassName)} style={style}>
|
|
47
47
|
<img src={mediaIconUrl} alt={icon.media.alt} className={clsx(className ? `${className}-img` : null, 'i-item-icon__img')} />
|
|
48
48
|
</div>
|
|
49
49
|
)
|
|
@@ -58,7 +58,7 @@ export function ItemIconPreview({icon, className, options, setAttributes}: ItemI
|
|
|
58
58
|
if (icon.type === 'number') {
|
|
59
59
|
if (icon.src) {
|
|
60
60
|
return (
|
|
61
|
-
<div className={clsx('i-item-icon', className)}>
|
|
61
|
+
<div className={clsx('i-item-icon', className, modifierClassName)} style={style}>
|
|
62
62
|
<span className={clsx(className ? `${className}-number` : 'i-item-icon__number')}>{icon.src}</span>
|
|
63
63
|
</div>
|
|
64
64
|
)
|
|
@@ -17,6 +17,8 @@ export interface ItemIconControlProps {
|
|
|
17
17
|
export interface ItemIconPreviewProps {
|
|
18
18
|
icon: Icon
|
|
19
19
|
className?: string
|
|
20
|
+
modifierClassName?: string
|
|
21
|
+
style?: Record<string, string>
|
|
20
22
|
options: ItemIconOptions
|
|
21
23
|
setAttributes: (attributes: {icon: Icon}) => void
|
|
22
24
|
}
|