@wordpress/components 19.8.1 → 19.9.0

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.
Files changed (116) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  3. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  4. package/build/heading/hook.js +1 -1
  5. package/build/heading/hook.js.map +1 -1
  6. package/build/input-control/index.js +26 -4
  7. package/build/input-control/index.js.map +1 -1
  8. package/build/input-control/styles/input-control-styles.js +25 -25
  9. package/build/input-control/styles/input-control-styles.js.map +1 -1
  10. package/build/navigation/styles/navigation-styles.js +12 -12
  11. package/build/navigation/styles/navigation-styles.js.map +1 -1
  12. package/build/notice/index.native.js +44 -40
  13. package/build/notice/index.native.js.map +1 -1
  14. package/build/notice/list.native.js +27 -45
  15. package/build/notice/list.native.js.map +1 -1
  16. package/build/palette-edit/index.js +2 -1
  17. package/build/palette-edit/index.js.map +1 -1
  18. package/build/sandbox/index.js +2 -2
  19. package/build/sandbox/index.js.map +1 -1
  20. package/build/select-control/styles/select-control-styles.js +5 -5
  21. package/build/select-control/styles/select-control-styles.js.map +1 -1
  22. package/build/surface/styles.js +8 -8
  23. package/build/surface/styles.js.map +1 -1
  24. package/build/text/hook.js +5 -5
  25. package/build/text/hook.js.map +1 -1
  26. package/build/text/styles/text-mixins.native.js +1 -1
  27. package/build/text/styles/text-mixins.native.js.map +1 -1
  28. package/build/text/styles.js +7 -7
  29. package/build/text/styles.js.map +1 -1
  30. package/build/ui/spinner/component.js +1 -1
  31. package/build/ui/spinner/component.js.map +1 -1
  32. package/build/utils/colors-values.js +9 -24
  33. package/build/utils/colors-values.js.map +1 -1
  34. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  35. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  36. package/build-module/heading/hook.js +1 -1
  37. package/build-module/heading/hook.js.map +1 -1
  38. package/build-module/input-control/index.js +23 -3
  39. package/build-module/input-control/index.js.map +1 -1
  40. package/build-module/input-control/styles/input-control-styles.js +25 -25
  41. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  42. package/build-module/navigation/styles/navigation-styles.js +13 -13
  43. package/build-module/navigation/styles/navigation-styles.js.map +1 -1
  44. package/build-module/notice/index.native.js +45 -41
  45. package/build-module/notice/index.native.js.map +1 -1
  46. package/build-module/notice/list.native.js +28 -46
  47. package/build-module/notice/list.native.js.map +1 -1
  48. package/build-module/palette-edit/index.js +3 -2
  49. package/build-module/palette-edit/index.js.map +1 -1
  50. package/build-module/sandbox/index.js +2 -2
  51. package/build-module/sandbox/index.js.map +1 -1
  52. package/build-module/select-control/styles/select-control-styles.js +5 -5
  53. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  54. package/build-module/surface/styles.js +8 -8
  55. package/build-module/surface/styles.js.map +1 -1
  56. package/build-module/text/hook.js +5 -5
  57. package/build-module/text/hook.js.map +1 -1
  58. package/build-module/text/styles/text-mixins.native.js +2 -2
  59. package/build-module/text/styles/text-mixins.native.js.map +1 -1
  60. package/build-module/text/styles.js +7 -7
  61. package/build-module/text/styles.js.map +1 -1
  62. package/build-module/ui/spinner/component.js +1 -1
  63. package/build-module/ui/spinner/component.js.map +1 -1
  64. package/build-module/utils/colors-values.js +19 -23
  65. package/build-module/utils/colors-values.js.map +1 -1
  66. package/build-style/style-rtl.css +17 -0
  67. package/build-style/style.css +17 -0
  68. package/build-types/color-picker/styles.d.ts +1 -1
  69. package/build-types/input-control/index.d.ts +22 -3
  70. package/build-types/input-control/index.d.ts.map +1 -1
  71. package/build-types/input-control/input-field.d.ts +1 -1
  72. package/build-types/input-control/input-field.d.ts.map +1 -1
  73. package/build-types/input-control/stories/index.d.ts +5 -5
  74. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  75. package/build-types/input-control/types.d.ts +73 -3
  76. package/build-types/input-control/types.d.ts.map +1 -1
  77. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  78. package/build-types/text/test/index.d.ts +2 -0
  79. package/build-types/text/test/index.d.ts.map +1 -0
  80. package/build-types/utils/colors-values.d.ts +6 -146
  81. package/build-types/utils/colors-values.d.ts.map +1 -1
  82. package/package.json +17 -17
  83. package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
  84. package/src/heading/hook.ts +1 -1
  85. package/src/heading/test/__snapshots__/index.js.snap +3 -3
  86. package/src/input-control/README.md +2 -2
  87. package/src/input-control/index.tsx +22 -3
  88. package/src/input-control/stories/index.tsx +63 -0
  89. package/src/input-control/styles/input-control-styles.tsx +1 -2
  90. package/src/input-control/types.ts +73 -2
  91. package/src/navigation/styles/navigation-styles.js +5 -5
  92. package/src/notice/index.native.js +44 -54
  93. package/src/notice/list.native.js +27 -51
  94. package/src/notice/style.native.scss +1 -0
  95. package/src/palette-edit/index.js +8 -2
  96. package/src/query-controls/README.md +2 -2
  97. package/src/sandbox/index.js +2 -2
  98. package/src/select-control/styles/select-control-styles.ts +1 -1
  99. package/src/surface/styles.js +1 -1
  100. package/src/text/hook.js +1 -1
  101. package/src/text/styles/text-mixins.native.js +2 -2
  102. package/src/text/styles.js +1 -1
  103. package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
  104. package/src/text/test/{index.js → index.tsx} +12 -6
  105. package/src/toolbar-group/style.scss +20 -0
  106. package/src/tools-panel/test/__snapshots__/index.js.snap +1 -1
  107. package/src/ui/spinner/component.js +1 -1
  108. package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
  109. package/src/utils/colors-values.js +18 -22
  110. package/tsconfig.json +8 -2
  111. package/tsconfig.tsbuildinfo +1 -1
  112. package/build-types/spinner/styles/spinner-styles.d.ts +0 -5
  113. package/build-types/spinner/styles/spinner-styles.d.ts.map +0 -1
  114. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -15
  115. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +0 -1
  116. package/src/input-control/stories/index.js +0 -71
@@ -7,6 +7,7 @@ import type {
7
7
  ChangeEvent,
8
8
  SyntheticEvent,
9
9
  PointerEvent,
10
+ HTMLInputTypeAttribute,
10
11
  } from 'react';
11
12
  import type { useDrag } from '@use-gesture/react';
12
13
 
@@ -14,8 +15,8 @@ import type { useDrag } from '@use-gesture/react';
14
15
  * Internal dependencies
15
16
  */
16
17
  import type { StateReducer } from './reducer/state';
17
- import type { FlexProps } from '../flex/types';
18
18
  import type { WordPressComponentProps } from '../ui/context';
19
+ import type { FlexProps } from '../flex/types';
19
20
 
20
21
  export type LabelPosition = 'top' | 'bottom' | 'side' | 'edge';
21
22
 
@@ -27,9 +28,31 @@ export type Size = 'default' | 'small' | '__unstable-large';
27
28
 
28
29
  interface BaseProps {
29
30
  __unstableInputWidth?: CSSProperties[ 'width' ];
31
+ /**
32
+ * If true, the label will only be visible to screen readers.
33
+ *
34
+ * @default false
35
+ */
30
36
  hideLabelFromVision?: boolean;
37
+ /**
38
+ * Whether the component should be in a focused state.
39
+ * Used to coordinate focus states when the actual focused element and the component handling
40
+ * visual focus are separate.
41
+ *
42
+ * @default false
43
+ */
31
44
  isFocused: boolean;
45
+ /**
46
+ * The position of the label.
47
+ *
48
+ * @default 'top'
49
+ */
32
50
  labelPosition?: LabelPosition;
51
+ /**
52
+ * Adjusts the size of the input.
53
+ *
54
+ * @default 'default'
55
+ */
33
56
  size?: Size;
34
57
  }
35
58
 
@@ -39,10 +62,35 @@ export type InputChangeCallback<
39
62
  > = ( nextValue: string | undefined, extra: { event: E } & P ) => void;
40
63
 
41
64
  export interface InputFieldProps extends BaseProps {
65
+ /**
66
+ * Determines the drag axis.
67
+ *
68
+ * @default 'n'
69
+ */
42
70
  dragDirection?: DragDirection;
71
+ /**
72
+ * If `isDragEnabled` is true, this controls the amount of `px` to have been dragged before
73
+ * the drag gesture is actually triggered.
74
+ *
75
+ * @default 10
76
+ */
43
77
  dragThreshold?: number;
78
+ /**
79
+ * If true, enables mouse drag gestures.
80
+ *
81
+ * @default false
82
+ */
44
83
  isDragEnabled?: boolean;
84
+ /**
85
+ * If true, the `ENTER` key press is required in order to trigger an `onChange`.
86
+ * If enabled, a change is also triggered when tabbing away (`onBlur`).
87
+ *
88
+ * @default false
89
+ */
45
90
  isPressEnterToChange?: boolean;
91
+ /**
92
+ * A function that receives the value of the input.
93
+ */
46
94
  onChange?: InputChangeCallback;
47
95
  onValidate?: (
48
96
  nextValue: string,
@@ -50,24 +98,47 @@ export interface InputFieldProps extends BaseProps {
50
98
  ) => void;
51
99
  setIsFocused: ( isFocused: boolean ) => void;
52
100
  stateReducer?: StateReducer;
101
+ /**
102
+ * The current value of the input.
103
+ */
53
104
  value?: string;
54
105
  onDragEnd?: ( dragProps: DragProps ) => void;
55
106
  onDragStart?: ( dragProps: DragProps ) => void;
56
107
  onDrag?: ( dragProps: DragProps ) => void;
108
+ /**
109
+ * Type of the input element to render.
110
+ *
111
+ * @default 'text'
112
+ */
113
+ type?: HTMLInputTypeAttribute;
57
114
  }
58
115
 
59
116
  export interface InputBaseProps extends BaseProps, FlexProps {
60
117
  children: ReactNode;
118
+ /**
119
+ * Renders an element on the left side of the input.
120
+ */
61
121
  prefix?: ReactNode;
122
+ /**
123
+ * Renders an element on the right side of the input.
124
+ */
62
125
  suffix?: ReactNode;
126
+ /**
127
+ * If true, the `input` will be disabled.
128
+ *
129
+ * @default false
130
+ */
63
131
  disabled?: boolean;
64
132
  className?: string;
65
133
  id?: string;
134
+ /**
135
+ * If this property is added, a label will be generated using label property as the content.
136
+ */
66
137
  label?: ReactNode;
67
138
  }
68
139
 
69
140
  export interface InputControlProps
70
- extends Omit< InputBaseProps, 'children' | 'isFocused' >,
141
+ extends Omit< InputBaseProps, 'children' | 'isFocused' | keyof FlexProps >,
71
142
  /**
72
143
  * The `prefix` prop in `WordPressComponentProps< InputFieldProps, 'input', false >` comes from the
73
144
  * `HTMLInputAttributes` and clashes with the one from `InputBaseProps`. So we have to omit it from
@@ -11,7 +11,7 @@ import { isRTL } from '@wordpress/i18n';
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
- import { BASE, G2, UI } from '../../utils/colors-values';
14
+ import { COLORS } from '../../utils/colors-values';
15
15
  import Button from '../../button';
16
16
  import { Text } from '../../text';
17
17
  import { Heading } from '../../heading';
@@ -155,18 +155,18 @@ export const ItemBaseUI = styled.li`
155
155
  }
156
156
 
157
157
  &.is-active {
158
- background-color: ${ UI.theme };
159
- color: ${ BASE.white };
158
+ background-color: ${ COLORS.ui.theme };
159
+ color: ${ COLORS.white };
160
160
 
161
161
  > button,
162
162
  > a {
163
- color: ${ BASE.white };
163
+ color: ${ COLORS.white };
164
164
  opacity: 1;
165
165
  }
166
166
  }
167
167
 
168
168
  > svg path {
169
- color: ${ G2.lightGray.ui };
169
+ color: ${ COLORS.gray[ 600 ] };
170
170
  }
171
171
  `;
172
172
 
@@ -7,15 +7,14 @@ import {
7
7
  Text,
8
8
  TouchableWithoutFeedback,
9
9
  View,
10
- Dimensions,
11
- Platform,
10
+ useWindowDimensions,
12
11
  } from 'react-native';
13
12
  import { BlurView } from '@react-native-community/blur';
14
13
 
15
14
  /**
16
15
  * WordPress dependencies
17
16
  */
18
- import { useEffect, useRef, useState } from '@wordpress/element';
17
+ import { useEffect, useRef, Platform } from '@wordpress/element';
19
18
  import { usePreferredColorSchemeStyle } from '@wordpress/compose';
20
19
 
21
20
  /**
@@ -23,57 +22,48 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
23
22
  */
24
23
  import styles from './style.scss';
25
24
 
26
- const Notice = ( { onNoticeHidden, content, id, status } ) => {
27
- const [ width, setWidth ] = useState( Dimensions.get( 'window' ).width );
28
- const [ visible, setVisible ] = useState( true );
25
+ const HIDE_TIMER = 3000;
29
26
 
27
+ const Notice = ( { onNoticeHidden, content, id, status } ) => {
28
+ const { width } = useWindowDimensions();
30
29
  const animationValue = useRef( new Animated.Value( 0 ) ).current;
31
30
  const timer = useRef( null );
32
- const isIOS = Platform.OS === 'ios';
33
-
34
- const onDimensionsChange = () => {
35
- setWidth( Dimensions.get( 'window' ).width );
36
- };
37
-
38
- useEffect( () => {
39
- const dimensionsChangeSubscription = Dimensions.addEventListener(
40
- 'change',
41
- onDimensionsChange
42
- );
43
- return () => {
44
- dimensionsChangeSubscription.remove();
45
- };
46
- }, [] );
47
31
 
48
32
  useEffect( () => {
49
33
  startAnimation();
34
+
50
35
  return () => {
51
36
  clearTimeout( timer?.current );
52
37
  };
53
- }, [ visible, id ] );
38
+ }, [] );
54
39
 
55
- const onHide = () => {
56
- setVisible( false );
57
- };
40
+ function onHide() {
41
+ Animated.timing( animationValue, {
42
+ toValue: 0,
43
+ duration: 150,
44
+ useNativeDriver: true,
45
+ easing: Easing.out( Easing.quad ),
46
+ } ).start( ( { finished } ) => {
47
+ if ( finished && onNoticeHidden ) {
48
+ onNoticeHidden( id );
49
+ }
50
+ } );
51
+ }
58
52
 
59
- const startAnimation = () => {
53
+ function startAnimation() {
60
54
  Animated.timing( animationValue, {
61
- toValue: visible ? 1 : 0,
62
- duration: visible ? 300 : 150,
55
+ toValue: 1,
56
+ duration: 300,
63
57
  useNativeDriver: true,
64
58
  easing: Easing.out( Easing.quad ),
65
- } ).start( () => {
66
- if ( visible && onNoticeHidden ) {
59
+ } ).start( ( { finished } ) => {
60
+ if ( finished && onNoticeHidden ) {
67
61
  timer.current = setTimeout( () => {
68
62
  onHide();
69
- }, 3000 );
70
- }
71
-
72
- if ( ! visible && onNoticeHidden ) {
73
- onNoticeHidden( id );
63
+ }, HIDE_TIMER );
74
64
  }
75
65
  } );
76
- };
66
+ }
77
67
 
78
68
  const noticeSolidStyles = usePreferredColorSchemeStyle(
79
69
  styles.noticeSolid,
@@ -95,25 +85,25 @@ const Notice = ( { onNoticeHidden, content, id, status } ) => {
95
85
  status === 'error' && errorTextStyles,
96
86
  ];
97
87
 
88
+ const containerStyles = [
89
+ styles.notice,
90
+ ! Platform.isIOS && noticeSolidStyles,
91
+ {
92
+ width,
93
+ transform: [
94
+ {
95
+ translateY: animationValue.interpolate( {
96
+ inputRange: [ 0, 1 ],
97
+ outputRange: [ -24, 0 ],
98
+ } ),
99
+ },
100
+ ],
101
+ },
102
+ ];
103
+
98
104
  return (
99
105
  <>
100
- <Animated.View
101
- style={ [
102
- styles.notice,
103
- ! isIOS && noticeSolidStyles,
104
- {
105
- width,
106
- transform: [
107
- {
108
- translateY: animationValue.interpolate( {
109
- inputRange: [ 0, 1 ],
110
- outputRange: [ -24, 0 ],
111
- } ),
112
- },
113
- ],
114
- },
115
- ] }
116
- >
106
+ <Animated.View style={ containerStyles }>
117
107
  <TouchableWithoutFeedback onPress={ onHide }>
118
108
  <View style={ styles.noticeContent }>
119
109
  <Text numberOfLines={ 3 } style={ textStyles }>
@@ -121,7 +111,7 @@ const Notice = ( { onNoticeHidden, content, id, status } ) => {
121
111
  </Text>
122
112
  </View>
123
113
  </TouchableWithoutFeedback>
124
- { isIOS && (
114
+ { Platform.isIOS && (
125
115
  <BlurView
126
116
  style={ styles.blurBackground }
127
117
  blurType="prominent"
@@ -6,9 +6,8 @@ import { View } from 'react-native';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { Component } from '@wordpress/element';
10
- import { withDispatch, withSelect } from '@wordpress/data';
11
- import { compose } from '@wordpress/compose';
9
+ import { useSelect, useDispatch } from '@wordpress/data';
10
+ import { store as noticesStore } from '@wordpress/notices';
12
11
 
13
12
  /**
14
13
  * Internal dependencies
@@ -16,60 +15,37 @@ import { compose } from '@wordpress/compose';
16
15
  import Notice from './';
17
16
  import styles from './style.scss';
18
17
 
19
- class NoticeList extends Component {
20
- constructor() {
21
- super( ...arguments );
22
- this.removeNotice = this.removeNotice.bind( this );
23
- }
18
+ function NoticeList() {
19
+ const { notices } = useSelect( ( select ) => {
20
+ const { getNotices } = select( noticesStore );
21
+ return {
22
+ notices: getNotices(),
23
+ };
24
+ }, [] );
24
25
 
25
- removeNotice( id ) {
26
- const { removeNotice } = this.props;
26
+ const { removeNotice } = useDispatch( noticesStore );
27
+
28
+ function onRemoveNotice( id ) {
27
29
  removeNotice( id );
28
30
  }
29
31
 
30
- render() {
31
- const { notices, shouldStack } = this.props;
32
-
33
- if ( ! notices.length ) {
34
- return null;
35
- }
32
+ if ( ! notices.length ) {
33
+ return null;
34
+ }
36
35
 
37
- return (
38
- <View style={ styles.list } key={ notices.length }>
39
- { shouldStack ? (
40
- notices
41
- .reverse()
42
- .map( ( notice ) => (
43
- <Notice
44
- { ...notice }
45
- key={ notice.id }
46
- onNoticeHidden={ this.removeNotice }
47
- ></Notice>
48
- ) )
49
- ) : (
36
+ return (
37
+ <View style={ styles.list }>
38
+ { notices.map( ( notice ) => {
39
+ return (
50
40
  <Notice
51
- { ...notices[ notices.length - 1 ] }
52
- onNoticeHidden={ this.removeNotice }
41
+ { ...notice }
42
+ key={ notice.id }
43
+ onNoticeHidden={ onRemoveNotice }
53
44
  ></Notice>
54
- ) }
55
- </View>
56
- );
57
- }
45
+ );
46
+ } ) }
47
+ </View>
48
+ );
58
49
  }
59
50
 
60
- export default compose( [
61
- withSelect( ( select ) => {
62
- const { getNotices } = select( 'core/notices' );
63
-
64
- return {
65
- notices: getNotices(),
66
- };
67
- } ),
68
- withDispatch( ( dispatch ) => {
69
- const { removeNotice } = dispatch( 'core/notices' );
70
-
71
- return {
72
- removeNotice,
73
- };
74
- } ),
75
- ] )( NoticeList );
51
+ export default NoticeList;
@@ -33,6 +33,7 @@
33
33
 
34
34
  .notice {
35
35
  justify-content: center;
36
+ position: absolute;
36
37
  }
37
38
 
38
39
  .noticeContent {
@@ -9,7 +9,10 @@ import { kebabCase } from 'lodash';
9
9
  import { useState, useRef, useEffect } from '@wordpress/element';
10
10
  import { __, sprintf } from '@wordpress/i18n';
11
11
  import { lineSolid, moreVertical, plus } from '@wordpress/icons';
12
- import { __experimentalUseFocusOutside as useFocusOutside } from '@wordpress/compose';
12
+ import {
13
+ __experimentalUseFocusOutside as useFocusOutside,
14
+ useDebounce,
15
+ } from '@wordpress/compose';
13
16
 
14
17
  /**
15
18
  * Internal dependencies
@@ -197,6 +200,9 @@ function PaletteEditListView( {
197
200
  }
198
201
  };
199
202
  }, [] );
203
+
204
+ const debounceOnChange = useDebounce( onChange, 100 );
205
+
200
206
  return (
201
207
  <VStack spacing={ 3 }>
202
208
  <ItemGroup isRounded>
@@ -212,7 +218,7 @@ function PaletteEditListView( {
212
218
  }
213
219
  } }
214
220
  onChange={ ( newElement ) => {
215
- onChange(
221
+ debounceOnChange(
216
222
  elements.map(
217
223
  ( currentElement, currentIndex ) => {
218
224
  if ( currentIndex === index ) {
@@ -51,7 +51,7 @@ const MyQueryControls = () => {
51
51
  selectedCategoryId={ category }
52
52
  onCategoryChange={ ( newCategory ) => updateQuery( { category: newCategory } ) }
53
53
  onNumberOfItemsChange={ ( newNumberOfItems ) =>
54
- updateQuery( { numberOfItems: newCategory } )
54
+ updateQuery( { numberOfItems: newNumberOfItems } )
55
55
  }
56
56
  />
57
57
  );
@@ -104,7 +104,7 @@ const MyQueryControls = () => {
104
104
  selectedCategories={ selectedCategories }
105
105
  onCategoryChange={ ( category ) => updateQuery( { selectedCategories: category } ) }
106
106
  onNumberOfItemsChange={ ( newNumberOfItems ) =>
107
- updateQuery( { numberOfItems: newCategory } )
107
+ updateQuery( { numberOfItems: newNumberOfItems } )
108
108
  }
109
109
  />
110
110
  );
@@ -227,11 +227,11 @@ export default function Sandbox( {
227
227
 
228
228
  useEffect( () => {
229
229
  trySandbox();
230
- }, [ title, type, styles, scripts ] );
230
+ }, [ title, styles, scripts ] );
231
231
 
232
232
  useEffect( () => {
233
233
  trySandbox( true );
234
- }, [ html ] );
234
+ }, [ html, type ] );
235
235
 
236
236
  return (
237
237
  <iframe
@@ -96,7 +96,7 @@ export const Select = styled.select< SelectProps >`
96
96
  box-sizing: border-box;
97
97
  border: none;
98
98
  box-shadow: none !important;
99
- color: ${ COLORS.black };
99
+ color: ${ COLORS.gray[ 900 ] };
100
100
  display: block;
101
101
  font-family: inherit;
102
102
  margin: 0;
@@ -10,7 +10,7 @@ import { CONFIG, COLORS } from '../utils';
10
10
 
11
11
  export const Surface = css`
12
12
  background-color: ${ CONFIG.surfaceColor };
13
- color: ${ COLORS.darkGray.primary };
13
+ color: ${ COLORS.gray[ 900 ] };
14
14
  position: relative;
15
15
  `;
16
16
 
package/src/text/hook.js CHANGED
@@ -105,7 +105,7 @@ export default function useText( props ) {
105
105
  getOptimalTextShade( optimizeReadabilityFor ) === 'dark';
106
106
 
107
107
  sx.optimalTextColor = isOptimalTextColorDark
108
- ? css( { color: COLORS.black } )
108
+ ? css( { color: COLORS.gray[ 900 ] } )
109
109
  : css( { color: COLORS.white } );
110
110
  }
111
111
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { fontFamily } from './font-family';
5
5
  import css from './emotion-css';
6
- import { G2 } from '../../utils/colors-values';
6
+ import { COLORS } from '../../utils/colors-values';
7
7
 
8
8
  const fontWeightNormal = `font-weight: 400;`;
9
9
  const fontWeightMedium = `font-weight: 500;`;
@@ -81,7 +81,7 @@ const sectionHeading = `
81
81
  font-size: 11px;
82
82
  line-height: 1.4;
83
83
  text-transform: uppercase;
84
- color: ${ G2.gray[ 700 ] }
84
+ color: ${ COLORS.gray[ 700 ] }
85
85
  `;
86
86
 
87
87
  /**
@@ -9,7 +9,7 @@ import { css } from '@emotion/react';
9
9
  import { COLORS, CONFIG } from '../utils';
10
10
 
11
11
  export const Text = css`
12
- color: ${ COLORS.darkGray.primary };
12
+ color: ${ COLORS.gray[ 900 ] };
13
13
  line-height: ${ CONFIG.fontLineHeightBase };
14
14
  margin: 0;
15
15
  `;
@@ -1,5 +1,21 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`Text should render align 1`] = `
4
+ Snapshot Diff:
5
+ - Received styles
6
+ + Base styles
7
+
8
+ @@ -3,7 +3,8 @@
9
+ "color": "#1e1e1e",
10
+ "font-size": "calc((13 / 13) * 13px)",
11
+ "font-weight": "normal",
12
+ "line-height": "1.2",
13
+ "margin": "0",
14
+ + "text-align": "center",
15
+ },
16
+ ]
17
+ `;
18
+
3
19
  exports[`Text should render highlighted words with highlightCaseSensitive 1`] = `
4
20
  .emotion-0 {
5
21
  color: #1e1e1e;
@@ -59,14 +59,20 @@ describe( 'Text', () => {
59
59
 
60
60
  test( 'should render as another element', () => {
61
61
  const { container } = render( <Text as="div">Lorem ipsum.</Text> );
62
- expect( container.firstChild.nodeName ).toBe( 'DIV' );
62
+ expect( container.firstChild?.nodeName ).toBe( 'DIV' );
63
63
  } );
64
64
 
65
65
  test( 'should render align', () => {
66
- const { container } = render(
66
+ const { container: centerAlignedContainer } = render(
67
67
  <Text align="center">Lorem ipsum.</Text>
68
68
  );
69
- expect( container.firstChild ).toHaveStyle( { textAlign: 'center' } );
69
+ const { container: defaultAlignedContainer } = render(
70
+ <Text>Lorem ipsum.</Text>
71
+ );
72
+
73
+ expect(
74
+ defaultAlignedContainer.children[ 0 ]
75
+ ).toMatchStyleDiffSnapshot( centerAlignedContainer.children[ 0 ] );
70
76
  } );
71
77
 
72
78
  test( 'should render color', () => {
@@ -89,7 +95,7 @@ describe( 'Text', () => {
89
95
  const wrapper = render(
90
96
  <Text highlightWords={ [ 'm' ] }>Lorem ipsum.</Text>
91
97
  );
92
- expect( wrapper.container.firstChild.childNodes ).toHaveLength( 5 );
98
+ expect( wrapper.container.firstChild?.childNodes ).toHaveLength( 5 );
93
99
  const words = await wrapper.findAllByText( 'm' );
94
100
  expect( words ).toHaveLength( 2 );
95
101
  words.forEach( ( word ) => expect( word.tagName ).toEqual( 'MARK' ) );
@@ -100,7 +106,7 @@ describe( 'Text', () => {
100
106
  <Text highlightWords={ undefined }>Lorem ipsum.</Text>
101
107
  );
102
108
  // It'll have a length of 1 because there shouldn't be anything but the single span being rendered.
103
- expect( container.firstChild.childNodes ).toHaveLength( 1 );
109
+ expect( container.firstChild?.childNodes ).toHaveLength( 1 );
104
110
  } );
105
111
 
106
112
  test( 'should render highlighted words with highlightCaseSensitive', () => {
@@ -112,7 +118,7 @@ describe( 'Text', () => {
112
118
 
113
119
  expect( container.firstChild ).toMatchSnapshot();
114
120
  // It'll have a length of 1 because there shouldn't be anything but the single span being rendered.
115
- expect( container.firstChild.childNodes ).toHaveLength( 1 );
121
+ expect( container.firstChild?.childNodes ).toHaveLength( 1 );
116
122
  } );
117
123
 
118
124
  test( 'should render isBlock', () => {
@@ -5,6 +5,8 @@
5
5
  display: inline-flex;
6
6
  flex-shrink: 0;
7
7
  flex-wrap: wrap;
8
+ padding-left: $grid-unit-15 * 0.5; // 6px.
9
+ padding-right: $grid-unit-15 * 0.5;
8
10
 
9
11
  // Unset for nested toolbar groups. Increase specificity.
10
12
  & .components-toolbar-group.components-toolbar-group {
@@ -13,6 +15,24 @@
13
15
  }
14
16
 
15
17
  line-height: 0;
18
+
19
+ // Size multiple sequential buttons to be optically balanced.
20
+ // Icons are 36px, as set by a 24px icon and 12px padding.
21
+ .components-button.components-button, // This needs specificity to override padding values inherited from the button component.
22
+ .components-button.has-icon.has-icon {
23
+ min-width: $block-toolbar-height - $grid-unit-15;
24
+ padding-left: $grid-unit-15 * 0.5; // 6px.
25
+ padding-right: $grid-unit-15 * 0.5;
26
+
27
+ svg {
28
+ min-width: $button-size-small; // This is the optimal icon size, and we size the whole button after this.
29
+ }
30
+
31
+ &::before {
32
+ left: 2px;
33
+ right: 2px;
34
+ }
35
+ }
16
36
  }
17
37
 
18
38
  // Legacy toolbar group
@@ -64,7 +64,7 @@ exports[`ToolsPanel first and last panel items should apply first/last classes t
64
64
  color: #1e1e1e;
65
65
  line-height: 1.2;
66
66
  margin: 0;
67
- color: #050505;
67
+ color: #1e1e1e;
68
68
  font-size: calc(1.95 * 13px);
69
69
  font-weight: 600;
70
70
  display: block;
@@ -21,7 +21,7 @@ import { COLORS } from '../../utils/colors-values';
21
21
  */
22
22
  function Spinner( props, forwardedRef ) {
23
23
  const {
24
- color = COLORS.black,
24
+ color = COLORS.gray[ 900 ],
25
25
  size = BASE_SIZE,
26
26
  ...otherProps
27
27
  } = useContextSystem( props, 'Spinner' );