@wordpress/components 21.0.6 → 21.0.7
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/CHANGELOG.md +18 -0
- package/build/autocomplete/index.js +11 -9
- package/build/autocomplete/index.js.map +1 -1
- package/build/circular-option-picker/index.js +14 -14
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/color-palette/index.js +83 -30
- package/build/color-palette/index.js.map +1 -1
- package/build/color-palette/styles.js +3 -3
- package/build/color-palette/styles.js.map +1 -1
- package/build/color-palette/types.js +6 -0
- package/build/color-palette/types.js.map +1 -0
- package/build/form-token-field/index.js +12 -10
- package/build/form-token-field/index.js.map +1 -1
- package/build/popover/index.js +1 -26
- package/build/popover/index.js.map +1 -1
- package/build-module/autocomplete/index.js +10 -9
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/circular-option-picker/index.js +14 -14
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/color-palette/index.js +81 -28
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-palette/styles.js +3 -3
- package/build-module/color-palette/styles.js.map +1 -1
- package/build-module/color-palette/types.js +2 -0
- package/build-module/color-palette/types.js.map +1 -0
- package/build-module/form-token-field/index.js +11 -10
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/popover/index.js +1 -26
- package/build-module/popover/index.js.map +1 -1
- package/build-types/border-control/types.d.ts +1 -1
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/circular-option-picker/index.d.ts +4 -24
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts +33 -18
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +21 -0
- package/build-types/color-palette/stories/index.d.ts.map +1 -0
- package/build-types/color-palette/styles.d.ts +2 -1
- package/build-types/color-palette/styles.d.ts.map +1 -1
- package/build-types/color-palette/test/index.d.ts +2 -0
- package/build-types/color-palette/test/index.d.ts.map +1 -0
- package/build-types/color-palette/types.d.ts +86 -0
- package/build-types/color-palette/types.d.ts.map +1 -0
- package/build-types/confirm-dialog/component.d.ts +4 -4
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +0 -14
- package/build-types/popover/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/autocomplete/index.js +18 -9
- package/src/border-control/types.ts +1 -1
- package/src/circular-option-picker/index.js +14 -20
- package/src/color-palette/README.md +51 -49
- package/src/color-palette/{index.js → index.tsx} +132 -51
- package/src/color-palette/stories/{index.js → index.tsx} +38 -27
- package/src/color-palette/{styles.js → styles.ts} +0 -0
- package/src/color-palette/test/__snapshots__/index.tsx.snap +270 -0
- package/src/color-palette/test/index.tsx +164 -0
- package/src/color-palette/types.ts +93 -0
- package/src/form-token-field/index.tsx +21 -10
- package/src/form-token-field/test/index.tsx +167 -73
- package/src/popover/README.md +3 -9
- package/src/popover/index.tsx +1 -25
- package/src/popover/types.ts +0 -14
- package/tsconfig.tsbuildinfo +1 -1
- package/src/color-palette/test/__snapshots__/index.js.snap +0 -1207
- package/src/color-palette/test/index.js +0 -118
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
4
|
+
import type { ForwardedRef } from 'react';
|
|
5
5
|
import { colord, extend } from 'colord';
|
|
6
6
|
import namesPlugin from 'colord/plugins/names';
|
|
7
7
|
import a11yPlugin from 'colord/plugins/a11y';
|
|
@@ -10,7 +10,7 @@ import a11yPlugin from 'colord/plugins/a11y';
|
|
|
10
10
|
* WordPress dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { __, sprintf } from '@wordpress/i18n';
|
|
13
|
-
import { useCallback, useMemo } from '@wordpress/element';
|
|
13
|
+
import { useCallback, useMemo, forwardRef } from '@wordpress/element';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -23,6 +23,15 @@ import { Flex, FlexItem } from '../flex';
|
|
|
23
23
|
import { Truncate } from '../truncate';
|
|
24
24
|
import { ColorHeading } from './styles';
|
|
25
25
|
import DropdownContentWrapper from '../dropdown/dropdown-content-wrapper';
|
|
26
|
+
import type {
|
|
27
|
+
ColorObject,
|
|
28
|
+
ColorPaletteProps,
|
|
29
|
+
CustomColorPickerDropdownProps,
|
|
30
|
+
MultiplePalettesProps,
|
|
31
|
+
PaletteObject,
|
|
32
|
+
SinglePaletteProps,
|
|
33
|
+
} from './types';
|
|
34
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
26
35
|
|
|
27
36
|
extend( [ namesPlugin, a11yPlugin ] );
|
|
28
37
|
|
|
@@ -33,7 +42,7 @@ function SinglePalette( {
|
|
|
33
42
|
onChange,
|
|
34
43
|
value,
|
|
35
44
|
actions,
|
|
36
|
-
} ) {
|
|
45
|
+
}: SinglePaletteProps ) {
|
|
37
46
|
const colorOptions = useMemo( () => {
|
|
38
47
|
return colors.map( ( { color, name }, index ) => {
|
|
39
48
|
const colordColor = colord( color );
|
|
@@ -74,6 +83,11 @@ function SinglePalette( {
|
|
|
74
83
|
);
|
|
75
84
|
} );
|
|
76
85
|
}, [ colors, value, onChange, clearColor ] );
|
|
86
|
+
|
|
87
|
+
if ( colors.length === 0 ) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
77
91
|
return (
|
|
78
92
|
<CircularOptionPicker
|
|
79
93
|
className={ className }
|
|
@@ -90,7 +104,11 @@ function MultiplePalettes( {
|
|
|
90
104
|
onChange,
|
|
91
105
|
value,
|
|
92
106
|
actions,
|
|
93
|
-
} ) {
|
|
107
|
+
}: MultiplePalettesProps ) {
|
|
108
|
+
if ( colors.length === 0 ) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
94
112
|
return (
|
|
95
113
|
<VStack spacing={ 3 } className={ className }>
|
|
96
114
|
{ colors.map( ( { name, colors: colorPalette }, index ) => {
|
|
@@ -117,7 +135,7 @@ export function CustomColorPickerDropdown( {
|
|
|
117
135
|
isRenderedInSidebar,
|
|
118
136
|
popoverProps: receivedPopoverProps,
|
|
119
137
|
...props
|
|
120
|
-
} ) {
|
|
138
|
+
}: CustomColorPickerDropdownProps ) {
|
|
121
139
|
const popoverProps = useMemo(
|
|
122
140
|
() => ( {
|
|
123
141
|
shift: true,
|
|
@@ -148,9 +166,9 @@ export function CustomColorPickerDropdown( {
|
|
|
148
166
|
}
|
|
149
167
|
|
|
150
168
|
export const extractColorNameFromCurrentValue = (
|
|
151
|
-
currentValue,
|
|
152
|
-
colors = [],
|
|
153
|
-
showMultiplePalettes = false
|
|
169
|
+
currentValue?: ColorPaletteProps[ 'value' ],
|
|
170
|
+
colors: ColorPaletteProps[ 'colors' ] = [],
|
|
171
|
+
showMultiplePalettes: ColorPaletteProps[ '__experimentalHasMultipleOrigins' ] = false
|
|
154
172
|
) => {
|
|
155
173
|
if ( ! currentValue ) {
|
|
156
174
|
return '';
|
|
@@ -162,7 +180,10 @@ export const extractColorNameFromCurrentValue = (
|
|
|
162
180
|
: colord( currentValue ).toHex();
|
|
163
181
|
|
|
164
182
|
// Normalize format of `colors` to simplify the following loop
|
|
165
|
-
|
|
183
|
+
type normalizedPaletteObject = { colors: ColorObject[] };
|
|
184
|
+
const colorPalettes: normalizedPaletteObject[] = showMultiplePalettes
|
|
185
|
+
? ( colors as PaletteObject[] )
|
|
186
|
+
: [ { colors: colors as ColorObject[] } ];
|
|
166
187
|
for ( const { colors: paletteColors } of colorPalettes ) {
|
|
167
188
|
for ( const { name: colorName, color: colorValue } of paletteColors ) {
|
|
168
189
|
const normalizedColorValue = currentValueIsCssVariable
|
|
@@ -179,28 +200,62 @@ export const extractColorNameFromCurrentValue = (
|
|
|
179
200
|
return __( 'Custom' );
|
|
180
201
|
};
|
|
181
202
|
|
|
182
|
-
export const showTransparentBackground = ( currentValue ) => {
|
|
203
|
+
export const showTransparentBackground = ( currentValue?: string ) => {
|
|
183
204
|
if ( typeof currentValue === 'undefined' ) {
|
|
184
205
|
return true;
|
|
185
206
|
}
|
|
186
207
|
return colord( currentValue ).alpha() === 0;
|
|
187
208
|
};
|
|
188
209
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
colors
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
210
|
+
const areColorsMultiplePalette = (
|
|
211
|
+
colors: NonNullable< ColorPaletteProps[ 'colors' ] >
|
|
212
|
+
): colors is PaletteObject[] => {
|
|
213
|
+
return colors.every( ( colorObj ) =>
|
|
214
|
+
Array.isArray( ( colorObj as PaletteObject ).colors )
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
function UnforwardedColorPalette(
|
|
219
|
+
props: WordPressComponentProps< ColorPaletteProps, 'div' >,
|
|
220
|
+
forwardedRef: ForwardedRef< any >
|
|
221
|
+
) {
|
|
222
|
+
const {
|
|
223
|
+
clearable = true,
|
|
224
|
+
colors = [],
|
|
225
|
+
disableCustomColors = false,
|
|
226
|
+
enableAlpha,
|
|
227
|
+
onChange,
|
|
228
|
+
value,
|
|
229
|
+
__experimentalHasMultipleOrigins = false,
|
|
230
|
+
__experimentalIsRenderedInSidebar = false,
|
|
231
|
+
...otherProps
|
|
232
|
+
} = props;
|
|
200
233
|
const clearColor = useCallback( () => onChange( undefined ), [ onChange ] );
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
234
|
+
|
|
235
|
+
const buttonLabelName = useMemo(
|
|
236
|
+
() =>
|
|
237
|
+
extractColorNameFromCurrentValue(
|
|
238
|
+
value,
|
|
239
|
+
colors,
|
|
240
|
+
__experimentalHasMultipleOrigins
|
|
241
|
+
),
|
|
242
|
+
[ value, colors, __experimentalHasMultipleOrigins ]
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
// Make sure that the `colors` array has a format (single/multiple) that is
|
|
246
|
+
// compatible with the `__experimentalHasMultipleOrigins` flag. This is true
|
|
247
|
+
// when __experimentalHasMultipleOrigins and areColorsMultiplePalette() are
|
|
248
|
+
// either both `true` or both `false`.
|
|
249
|
+
if (
|
|
250
|
+
colors.length > 0 &&
|
|
251
|
+
__experimentalHasMultipleOrigins !== areColorsMultiplePalette( colors )
|
|
252
|
+
) {
|
|
253
|
+
// eslint-disable-next-line no-console
|
|
254
|
+
console.warn(
|
|
255
|
+
'wp.components.ColorPalette: please specify a format for the `colors` prop that is compatible with the `__experimentalHasMultipleOrigins` prop.'
|
|
256
|
+
);
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
204
259
|
|
|
205
260
|
const renderCustomColorPicker = () => (
|
|
206
261
|
<DropdownContentWrapper paddingSize="none">
|
|
@@ -212,20 +267,11 @@ export default function ColorPalette( {
|
|
|
212
267
|
</DropdownContentWrapper>
|
|
213
268
|
);
|
|
214
269
|
|
|
215
|
-
const colordColor = colord( value );
|
|
270
|
+
const colordColor = colord( value ?? '' );
|
|
216
271
|
|
|
217
272
|
const valueWithoutLeadingHash = value?.startsWith( '#' )
|
|
218
273
|
? value.substring( 1 )
|
|
219
274
|
: value ?? '';
|
|
220
|
-
const buttonLabelName = useMemo(
|
|
221
|
-
() =>
|
|
222
|
-
extractColorNameFromCurrentValue(
|
|
223
|
-
value,
|
|
224
|
-
colors,
|
|
225
|
-
showMultiplePalettes
|
|
226
|
-
),
|
|
227
|
-
[ value, colors, showMultiplePalettes ]
|
|
228
|
-
);
|
|
229
275
|
|
|
230
276
|
const customColorAccessibleLabel = !! valueWithoutLeadingHash
|
|
231
277
|
? sprintf(
|
|
@@ -238,8 +284,20 @@ export default function ColorPalette( {
|
|
|
238
284
|
)
|
|
239
285
|
: __( 'Custom color picker.' );
|
|
240
286
|
|
|
287
|
+
const paletteCommonProps = {
|
|
288
|
+
clearable,
|
|
289
|
+
clearColor,
|
|
290
|
+
onChange,
|
|
291
|
+
value,
|
|
292
|
+
actions: !! clearable && (
|
|
293
|
+
<CircularOptionPicker.ButtonAction onClick={ clearColor }>
|
|
294
|
+
{ __( 'Clear' ) }
|
|
295
|
+
</CircularOptionPicker.ButtonAction>
|
|
296
|
+
),
|
|
297
|
+
};
|
|
298
|
+
|
|
241
299
|
return (
|
|
242
|
-
<VStack spacing={ 3 }
|
|
300
|
+
<VStack spacing={ 3 } ref={ forwardedRef } { ...otherProps }>
|
|
243
301
|
{ ! disableCustomColors && (
|
|
244
302
|
<CustomColorPickerDropdown
|
|
245
303
|
isRenderedInSidebar={ __experimentalIsRenderedInSidebar }
|
|
@@ -284,22 +342,45 @@ export default function ColorPalette( {
|
|
|
284
342
|
) }
|
|
285
343
|
/>
|
|
286
344
|
) }
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
{ __( 'Clear' ) }
|
|
299
|
-
</CircularOptionPicker.ButtonAction>
|
|
300
|
-
)
|
|
301
|
-
}
|
|
302
|
-
/>
|
|
345
|
+
{ __experimentalHasMultipleOrigins ? (
|
|
346
|
+
<MultiplePalettes
|
|
347
|
+
{ ...paletteCommonProps }
|
|
348
|
+
colors={ colors as PaletteObject[] }
|
|
349
|
+
/>
|
|
350
|
+
) : (
|
|
351
|
+
<SinglePalette
|
|
352
|
+
{ ...paletteCommonProps }
|
|
353
|
+
colors={ colors as ColorObject[] }
|
|
354
|
+
/>
|
|
355
|
+
) }
|
|
303
356
|
</VStack>
|
|
304
357
|
);
|
|
305
358
|
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Allows the user to pick a color from a list of pre-defined color entries.
|
|
362
|
+
*
|
|
363
|
+
* ```jsx
|
|
364
|
+
* import { ColorPalette } from '@wordpress/components';
|
|
365
|
+
* import { useState } from '@wordpress/element';
|
|
366
|
+
*
|
|
367
|
+
* const MyColorPalette = () => {
|
|
368
|
+
* const [ color, setColor ] = useState ( '#f00' )
|
|
369
|
+
* const colors = [
|
|
370
|
+
* { name: 'red', color: '#f00' },
|
|
371
|
+
* { name: 'white', color: '#fff' },
|
|
372
|
+
* { name: 'blue', color: '#00f' },
|
|
373
|
+
* ];
|
|
374
|
+
* return (
|
|
375
|
+
* <ColorPalette
|
|
376
|
+
* colors={ colors }
|
|
377
|
+
* value={ color }
|
|
378
|
+
* onChange={ ( color ) => setColor( color ) }
|
|
379
|
+
* />
|
|
380
|
+
* );
|
|
381
|
+
* } );
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
export const ColorPalette = forwardRef( UnforwardedColorPalette );
|
|
385
|
+
|
|
386
|
+
export default ColorPalette;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { CSSProperties } from 'react';
|
|
5
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* WordPress dependencies
|
|
3
9
|
*/
|
|
@@ -6,34 +12,25 @@ import { useState } from '@wordpress/element';
|
|
|
6
12
|
/**
|
|
7
13
|
* Internal dependencies
|
|
8
14
|
*/
|
|
9
|
-
import ColorPalette from '
|
|
15
|
+
import ColorPalette from '..';
|
|
10
16
|
import Popover from '../../popover';
|
|
11
17
|
import { Provider as SlotFillProvider } from '../../slot-fill';
|
|
18
|
+
import type { ColorObject, PaletteObject } from '../types';
|
|
12
19
|
|
|
13
|
-
const meta = {
|
|
20
|
+
const meta: ComponentMeta< typeof ColorPalette > = {
|
|
14
21
|
title: 'Components/ColorPalette',
|
|
15
22
|
component: ColorPalette,
|
|
16
23
|
argTypes: {
|
|
24
|
+
// Removing the control because setting this prop without changing the
|
|
25
|
+
// format of the `colors` prop can break the component.
|
|
17
26
|
__experimentalHasMultipleOrigins: {
|
|
18
27
|
control: {
|
|
19
28
|
type: null,
|
|
20
29
|
},
|
|
21
30
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
clearable: {
|
|
28
|
-
control: {
|
|
29
|
-
type: 'boolean',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
disableCustomColors: {
|
|
33
|
-
control: {
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
31
|
+
as: { control: { type: null } },
|
|
32
|
+
onChange: { action: 'onChange', control: { type: null } },
|
|
33
|
+
value: { control: { type: null } },
|
|
37
34
|
},
|
|
38
35
|
parameters: {
|
|
39
36
|
controls: { expanded: true },
|
|
@@ -42,14 +39,26 @@ const meta = {
|
|
|
42
39
|
};
|
|
43
40
|
export default meta;
|
|
44
41
|
|
|
45
|
-
const Template
|
|
42
|
+
const Template: ComponentStory< typeof ColorPalette > = ( {
|
|
43
|
+
onChange,
|
|
44
|
+
...args
|
|
45
|
+
} ) => {
|
|
46
46
|
const firstColor =
|
|
47
|
-
args.colors
|
|
48
|
-
|
|
47
|
+
( args.colors as ColorObject[] )[ 0 ].color ||
|
|
48
|
+
( args.colors as PaletteObject[] )[ 0 ].colors[ 0 ].color;
|
|
49
|
+
const [ color, setColor ] = useState< string | undefined >( firstColor );
|
|
49
50
|
|
|
50
51
|
return (
|
|
51
52
|
<SlotFillProvider>
|
|
52
|
-
<ColorPalette
|
|
53
|
+
<ColorPalette
|
|
54
|
+
{ ...args }
|
|
55
|
+
value={ color }
|
|
56
|
+
onChange={ ( newColor ) => {
|
|
57
|
+
setColor( newColor );
|
|
58
|
+
onChange?.( newColor );
|
|
59
|
+
} }
|
|
60
|
+
/>
|
|
61
|
+
{ /* @ts-expect-error The 'Slot' component hasn't been typed yet. */ }
|
|
53
62
|
<Popover.Slot />
|
|
54
63
|
</SlotFillProvider>
|
|
55
64
|
);
|
|
@@ -92,14 +101,16 @@ MultipleOrigins.args = {
|
|
|
92
101
|
],
|
|
93
102
|
};
|
|
94
103
|
|
|
95
|
-
export const CSSVariables = ( args ) => {
|
|
104
|
+
export const CSSVariables: ComponentStory< typeof ColorPalette > = ( args ) => {
|
|
96
105
|
return (
|
|
97
106
|
<div
|
|
98
|
-
style={
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
style={
|
|
108
|
+
{
|
|
109
|
+
'--red': '#f00',
|
|
110
|
+
'--yellow': '#ff0',
|
|
111
|
+
'--blue': '#00f',
|
|
112
|
+
} as CSSProperties
|
|
113
|
+
}
|
|
103
114
|
>
|
|
104
115
|
<Template { ...args } />
|
|
105
116
|
</div>
|
|
File without changes
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ColorPalette should allow disabling custom color picker 1`] = `
|
|
4
|
+
.emotion-0 {
|
|
5
|
+
display: -webkit-box;
|
|
6
|
+
display: -webkit-flex;
|
|
7
|
+
display: -ms-flexbox;
|
|
8
|
+
display: flex;
|
|
9
|
+
-webkit-align-items: normal;
|
|
10
|
+
-webkit-box-align: normal;
|
|
11
|
+
-ms-flex-align: normal;
|
|
12
|
+
align-items: normal;
|
|
13
|
+
-webkit-flex-direction: column;
|
|
14
|
+
-ms-flex-direction: column;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: calc(4px * 3);
|
|
17
|
+
-webkit-box-pack: justify;
|
|
18
|
+
-webkit-justify-content: space-between;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.emotion-0>* {
|
|
23
|
+
min-height: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
<div>
|
|
27
|
+
<div
|
|
28
|
+
class="components-flex components-h-stack components-v-stack emotion-0 emotion-1"
|
|
29
|
+
data-wp-c16t="true"
|
|
30
|
+
data-wp-component="VStack"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
class="components-circular-option-picker"
|
|
34
|
+
>
|
|
35
|
+
<div
|
|
36
|
+
class="components-circular-option-picker__swatches"
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
class="components-circular-option-picker__option-wrapper"
|
|
40
|
+
>
|
|
41
|
+
<button
|
|
42
|
+
aria-label="Color: red"
|
|
43
|
+
aria-pressed="true"
|
|
44
|
+
class="components-button components-circular-option-picker__option is-pressed"
|
|
45
|
+
style="background-color: rgb(255, 0, 0); color: rgb(255, 0, 0);"
|
|
46
|
+
type="button"
|
|
47
|
+
/>
|
|
48
|
+
<svg
|
|
49
|
+
aria-hidden="true"
|
|
50
|
+
fill="#000"
|
|
51
|
+
focusable="false"
|
|
52
|
+
height="24"
|
|
53
|
+
viewBox="0 0 24 24"
|
|
54
|
+
width="24"
|
|
55
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
56
|
+
>
|
|
57
|
+
<path
|
|
58
|
+
d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
|
|
59
|
+
/>
|
|
60
|
+
</svg>
|
|
61
|
+
</div>
|
|
62
|
+
<div
|
|
63
|
+
class="components-circular-option-picker__option-wrapper"
|
|
64
|
+
>
|
|
65
|
+
<button
|
|
66
|
+
aria-label="Color: white"
|
|
67
|
+
aria-pressed="false"
|
|
68
|
+
class="components-button components-circular-option-picker__option"
|
|
69
|
+
style="background-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"
|
|
70
|
+
type="button"
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
<div
|
|
74
|
+
class="components-circular-option-picker__option-wrapper"
|
|
75
|
+
>
|
|
76
|
+
<button
|
|
77
|
+
aria-label="Color: blue"
|
|
78
|
+
aria-pressed="false"
|
|
79
|
+
class="components-button components-circular-option-picker__option"
|
|
80
|
+
style="background-color: rgb(0, 0, 255); color: rgb(0, 0, 255);"
|
|
81
|
+
type="button"
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
<div
|
|
86
|
+
class="components-circular-option-picker__custom-clear-wrapper"
|
|
87
|
+
>
|
|
88
|
+
<button
|
|
89
|
+
class="components-button components-circular-option-picker__clear is-tertiary"
|
|
90
|
+
type="button"
|
|
91
|
+
>
|
|
92
|
+
Clear
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
|
|
101
|
+
.emotion-0 {
|
|
102
|
+
display: -webkit-box;
|
|
103
|
+
display: -webkit-flex;
|
|
104
|
+
display: -ms-flexbox;
|
|
105
|
+
display: flex;
|
|
106
|
+
-webkit-align-items: normal;
|
|
107
|
+
-webkit-box-align: normal;
|
|
108
|
+
-ms-flex-align: normal;
|
|
109
|
+
align-items: normal;
|
|
110
|
+
-webkit-flex-direction: column;
|
|
111
|
+
-ms-flex-direction: column;
|
|
112
|
+
flex-direction: column;
|
|
113
|
+
gap: calc(4px * 3);
|
|
114
|
+
-webkit-box-pack: justify;
|
|
115
|
+
-webkit-justify-content: space-between;
|
|
116
|
+
justify-content: space-between;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.emotion-0>* {
|
|
120
|
+
min-height: 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.emotion-2 {
|
|
124
|
+
display: -webkit-box;
|
|
125
|
+
display: -webkit-flex;
|
|
126
|
+
display: -ms-flexbox;
|
|
127
|
+
display: flex;
|
|
128
|
+
-webkit-align-items: flex-start;
|
|
129
|
+
-webkit-box-align: flex-start;
|
|
130
|
+
-ms-flex-align: flex-start;
|
|
131
|
+
align-items: flex-start;
|
|
132
|
+
-webkit-flex-direction: row;
|
|
133
|
+
-ms-flex-direction: row;
|
|
134
|
+
flex-direction: row;
|
|
135
|
+
gap: calc(4px * 2);
|
|
136
|
+
-webkit-box-pack: justify;
|
|
137
|
+
-webkit-justify-content: space-between;
|
|
138
|
+
justify-content: space-between;
|
|
139
|
+
width: 100%;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.emotion-2>* {
|
|
143
|
+
min-width: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.emotion-5 {
|
|
147
|
+
display: block;
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
text-overflow: ellipsis;
|
|
150
|
+
white-space: nowrap;
|
|
151
|
+
display: block;
|
|
152
|
+
max-height: 100%;
|
|
153
|
+
max-width: 100%;
|
|
154
|
+
min-height: 0;
|
|
155
|
+
min-width: 0;
|
|
156
|
+
-webkit-flex: 1;
|
|
157
|
+
-ms-flex: 1;
|
|
158
|
+
flex: 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.emotion-7 {
|
|
162
|
+
display: block;
|
|
163
|
+
max-height: 100%;
|
|
164
|
+
max-width: 100%;
|
|
165
|
+
min-height: 0;
|
|
166
|
+
min-width: 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
<div>
|
|
170
|
+
<div
|
|
171
|
+
class="components-flex components-h-stack components-v-stack emotion-0 emotion-1"
|
|
172
|
+
data-wp-c16t="true"
|
|
173
|
+
data-wp-component="VStack"
|
|
174
|
+
>
|
|
175
|
+
<div
|
|
176
|
+
class="components-dropdown"
|
|
177
|
+
tabindex="-1"
|
|
178
|
+
>
|
|
179
|
+
<button
|
|
180
|
+
aria-expanded="false"
|
|
181
|
+
aria-haspopup="true"
|
|
182
|
+
aria-label="Custom color picker. The currently selected color is called \\"red\\" and has a value of \\"f00\\"."
|
|
183
|
+
class="components-flex components-color-palette__custom-color emotion-2 emotion-1"
|
|
184
|
+
data-wp-c16t="true"
|
|
185
|
+
data-wp-component="Flex"
|
|
186
|
+
style="background: rgb(255, 0, 0); color: rgb(0, 0, 0);"
|
|
187
|
+
>
|
|
188
|
+
<span
|
|
189
|
+
class="components-truncate components-flex-item components-color-palette__custom-color-name emotion-1 emotion-5 emotion-1"
|
|
190
|
+
data-wp-c16t="true"
|
|
191
|
+
data-wp-component="FlexItem"
|
|
192
|
+
>
|
|
193
|
+
red
|
|
194
|
+
</span>
|
|
195
|
+
<span
|
|
196
|
+
class="components-flex-item components-color-palette__custom-color-value emotion-7 emotion-1"
|
|
197
|
+
data-wp-c16t="true"
|
|
198
|
+
data-wp-component="FlexItem"
|
|
199
|
+
>
|
|
200
|
+
f00
|
|
201
|
+
</span>
|
|
202
|
+
</button>
|
|
203
|
+
</div>
|
|
204
|
+
<div
|
|
205
|
+
class="components-circular-option-picker"
|
|
206
|
+
>
|
|
207
|
+
<div
|
|
208
|
+
class="components-circular-option-picker__swatches"
|
|
209
|
+
>
|
|
210
|
+
<div
|
|
211
|
+
class="components-circular-option-picker__option-wrapper"
|
|
212
|
+
>
|
|
213
|
+
<button
|
|
214
|
+
aria-label="Color: red"
|
|
215
|
+
aria-pressed="true"
|
|
216
|
+
class="components-button components-circular-option-picker__option is-pressed"
|
|
217
|
+
style="background-color: rgb(255, 0, 0); color: rgb(255, 0, 0);"
|
|
218
|
+
type="button"
|
|
219
|
+
/>
|
|
220
|
+
<svg
|
|
221
|
+
aria-hidden="true"
|
|
222
|
+
fill="#000"
|
|
223
|
+
focusable="false"
|
|
224
|
+
height="24"
|
|
225
|
+
viewBox="0 0 24 24"
|
|
226
|
+
width="24"
|
|
227
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
228
|
+
>
|
|
229
|
+
<path
|
|
230
|
+
d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
|
|
231
|
+
/>
|
|
232
|
+
</svg>
|
|
233
|
+
</div>
|
|
234
|
+
<div
|
|
235
|
+
class="components-circular-option-picker__option-wrapper"
|
|
236
|
+
>
|
|
237
|
+
<button
|
|
238
|
+
aria-label="Color: white"
|
|
239
|
+
aria-pressed="false"
|
|
240
|
+
class="components-button components-circular-option-picker__option"
|
|
241
|
+
style="background-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"
|
|
242
|
+
type="button"
|
|
243
|
+
/>
|
|
244
|
+
</div>
|
|
245
|
+
<div
|
|
246
|
+
class="components-circular-option-picker__option-wrapper"
|
|
247
|
+
>
|
|
248
|
+
<button
|
|
249
|
+
aria-label="Color: blue"
|
|
250
|
+
aria-pressed="false"
|
|
251
|
+
class="components-button components-circular-option-picker__option"
|
|
252
|
+
style="background-color: rgb(0, 0, 255); color: rgb(0, 0, 255);"
|
|
253
|
+
type="button"
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
<div
|
|
258
|
+
class="components-circular-option-picker__custom-clear-wrapper"
|
|
259
|
+
>
|
|
260
|
+
<button
|
|
261
|
+
class="components-button components-circular-option-picker__clear is-tertiary"
|
|
262
|
+
type="button"
|
|
263
|
+
>
|
|
264
|
+
Clear
|
|
265
|
+
</button>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
`;
|