newspack-components 3.1.0 → 4.0.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 (191) hide show
  1. package/colors/colors.module.scss +277 -0
  2. package/copy-styles.js +8 -1
  3. package/dist/cjs/action-card/action-card.d.js +5 -0
  4. package/dist/cjs/action-card/index.js +282 -187
  5. package/dist/cjs/action-card/style.scss +142 -44
  6. package/dist/cjs/autocomplete-tokenfield/index.js +6 -2
  7. package/dist/cjs/box-contrast/index.js +49 -0
  8. package/dist/cjs/button/index.js +1 -1
  9. package/dist/cjs/button-props/button-props.js +41 -0
  10. package/dist/cjs/button-props/index.js +13 -0
  11. package/dist/cjs/color-picker/index.js +11 -0
  12. package/dist/cjs/custom-select-control/style.scss +7 -12
  13. package/dist/cjs/footer/index.js +17 -24
  14. package/dist/cjs/footer/style.scss +0 -36
  15. package/dist/cjs/handoff-message/index.js +0 -3
  16. package/dist/cjs/hooks/useObjectState.js +9 -0
  17. package/dist/cjs/hooks/useObjectState.test.js +5 -5
  18. package/dist/cjs/index.js +7 -21
  19. package/dist/cjs/modal/index.js +4 -1
  20. package/dist/cjs/modal/style.scss +18 -7
  21. package/dist/cjs/newspack-icon/index.js +2 -2
  22. package/dist/cjs/newspack-icon/style.scss +3 -5
  23. package/dist/cjs/notice/index.js +1 -2
  24. package/dist/cjs/notice/style.scss +11 -9
  25. package/dist/cjs/plugin-installer/index.js +3 -3
  26. package/dist/cjs/plugin-settings/SettingsSection.js +2 -0
  27. package/dist/cjs/plugin-settings/index.js +4 -1
  28. package/dist/cjs/plugin-toggle/index.js +2 -0
  29. package/dist/cjs/popover/style.scss +5 -6
  30. package/dist/cjs/progress-bar/index.test.js +1 -2
  31. package/dist/cjs/progress-bar/style.scss +1 -2
  32. package/dist/cjs/proxied-imports/router.js +1 -2
  33. package/dist/cjs/radio-control/style.scss +4 -10
  34. package/dist/cjs/section-header/index.js +21 -1
  35. package/dist/cjs/select-control/ButtonGroupControl.js +2 -0
  36. package/dist/cjs/settings/SettingsCard.js +2 -6
  37. package/dist/cjs/sortable-newsletter-list-control/index.js +7 -5
  38. package/dist/cjs/sortable-newsletter-list-control/style.scss +11 -1
  39. package/dist/cjs/steps-list/style.scss +0 -3
  40. package/dist/cjs/steps-list-item/style.scss +1 -2
  41. package/dist/cjs/style-card/index.js +1 -0
  42. package/dist/cjs/style-card/style.scss +4 -5
  43. package/dist/cjs/style.scss +15 -0
  44. package/dist/cjs/tabbed-navigation/index.js +17 -7
  45. package/dist/cjs/tabbed-navigation/style.scss +2 -6
  46. package/dist/cjs/utils/color.js +35 -0
  47. package/dist/cjs/web-preview/style.scss +11 -11
  48. package/dist/cjs/with-wizard/index.js +80 -3
  49. package/dist/cjs/with-wizard/style.scss +34 -13
  50. package/dist/cjs/with-wizard-screen/index.js +3 -3
  51. package/dist/cjs/with-wizard-screen/style.scss +9 -9
  52. package/dist/cjs/wizard/index.js +38 -13
  53. package/dist/cjs/wizard/store/index.js +13 -5
  54. package/dist/cjs/wizard/store/utils.js +3 -1
  55. package/dist/esm/action-card/action-card.d.js +1 -0
  56. package/dist/esm/action-card/index.js +286 -189
  57. package/dist/esm/action-card/style.scss +142 -44
  58. package/dist/esm/autocomplete-tokenfield/index.js +6 -2
  59. package/dist/esm/box-contrast/index.js +44 -0
  60. package/dist/esm/button/index.js +1 -1
  61. package/dist/esm/button-props/button-props.js +34 -0
  62. package/dist/esm/button-props/index.js +1 -0
  63. package/dist/esm/color-picker/index.js +11 -0
  64. package/dist/esm/custom-select-control/style.scss +7 -12
  65. package/dist/esm/footer/index.js +18 -25
  66. package/dist/esm/footer/style.scss +0 -36
  67. package/dist/esm/handoff-message/index.js +0 -3
  68. package/dist/esm/hooks/useObjectState.js +10 -0
  69. package/dist/esm/hooks/useObjectState.test.js +6 -6
  70. package/dist/esm/index.js +1 -3
  71. package/dist/esm/modal/index.js +4 -1
  72. package/dist/esm/modal/style.scss +18 -7
  73. package/dist/esm/newspack-icon/index.js +2 -2
  74. package/dist/esm/newspack-icon/style.scss +3 -5
  75. package/dist/esm/notice/index.js +1 -2
  76. package/dist/esm/notice/style.scss +11 -9
  77. package/dist/esm/plugin-installer/index.js +3 -3
  78. package/dist/esm/plugin-settings/SettingsSection.js +2 -0
  79. package/dist/esm/plugin-settings/index.js +4 -1
  80. package/dist/esm/plugin-toggle/index.js +2 -0
  81. package/dist/esm/popover/style.scss +5 -6
  82. package/dist/esm/progress-bar/style.scss +1 -2
  83. package/dist/esm/radio-control/style.scss +4 -10
  84. package/dist/esm/section-header/index.js +22 -0
  85. package/dist/esm/select-control/ButtonGroupControl.js +2 -0
  86. package/dist/esm/settings/SettingsCard.js +2 -6
  87. package/dist/esm/sortable-newsletter-list-control/index.js +8 -6
  88. package/dist/esm/sortable-newsletter-list-control/style.scss +11 -1
  89. package/dist/esm/steps-list/style.scss +0 -3
  90. package/dist/esm/steps-list-item/style.scss +1 -2
  91. package/dist/esm/style-card/index.js +1 -0
  92. package/dist/esm/style-card/style.scss +4 -5
  93. package/dist/esm/style.scss +15 -0
  94. package/dist/esm/tabbed-navigation/index.js +17 -7
  95. package/dist/esm/tabbed-navigation/style.scss +2 -6
  96. package/dist/esm/utils/color.js +29 -0
  97. package/dist/esm/web-preview/style.scss +11 -11
  98. package/dist/esm/with-wizard/index.js +81 -4
  99. package/dist/esm/with-wizard/style.scss +34 -13
  100. package/dist/esm/with-wizard-screen/index.js +1 -1
  101. package/dist/esm/with-wizard-screen/style.scss +9 -9
  102. package/dist/esm/wizard/index.js +39 -13
  103. package/dist/esm/wizard/store/index.js +13 -5
  104. package/dist/esm/wizard/store/utils.js +3 -1
  105. package/package.json +1 -1
  106. package/src/accordion/index.js +1 -3
  107. package/src/action-card/action-card.d.ts +40 -0
  108. package/src/action-card/index.js +284 -202
  109. package/src/action-card/style.scss +142 -44
  110. package/src/autocomplete-tokenfield/index.js +3 -2
  111. package/src/autocomplete-with-suggestions/index.js +52 -63
  112. package/src/box-contrast/index.tsx +44 -0
  113. package/src/button/index.tsx +1 -1
  114. package/src/button-card/index.js +1 -12
  115. package/src/card/index.js +1 -11
  116. package/src/category-autocomplete/index.js +4 -19
  117. package/src/color-picker/index.js +11 -7
  118. package/src/custom-select-control/style.scss +7 -12
  119. package/src/footer/index.js +6 -18
  120. package/src/footer/style.scss +0 -36
  121. package/src/form-token-field/index.js +1 -2
  122. package/src/grid/index.tsx +1 -8
  123. package/src/handoff/index.js +4 -11
  124. package/src/handoff-message/index.js +0 -3
  125. package/src/hooks/useObjectState.js +10 -2
  126. package/src/hooks/useObjectState.test.js +14 -14
  127. package/src/image-upload/index.js +3 -23
  128. package/src/index.js +1 -3
  129. package/src/modal/index.js +2 -2
  130. package/src/modal/style.scss +18 -7
  131. package/src/newspack-icon/index.js +3 -14
  132. package/src/newspack-icon/style.scss +3 -5
  133. package/src/notice/index.js +0 -2
  134. package/src/notice/style.scss +11 -9
  135. package/src/plugin-installer/index.js +8 -17
  136. package/src/plugin-settings/SettingsSection.js +3 -7
  137. package/src/plugin-settings/index.js +7 -14
  138. package/src/plugin-toggle/README.md +3 -3
  139. package/src/plugin-toggle/index.js +10 -13
  140. package/src/popover/index.js +1 -5
  141. package/src/popover/style.scss +5 -6
  142. package/src/position-control/index.js +65 -75
  143. package/src/progress-bar/index.js +2 -9
  144. package/src/progress-bar/index.test.js +4 -13
  145. package/src/progress-bar/style.scss +1 -2
  146. package/src/radio-control/style.scss +4 -10
  147. package/src/section-header/index.js +20 -0
  148. package/src/select-control/ButtonGroupControl.js +2 -9
  149. package/src/select-control/GroupedSelectControl.js +1 -9
  150. package/src/select-control/index.js +1 -5
  151. package/src/settings/MinMaxSetting.js +2 -14
  152. package/src/settings/SettingsCard.js +2 -11
  153. package/src/sortable-newsletter-list-control/index.js +10 -26
  154. package/src/sortable-newsletter-list-control/style.scss +11 -1
  155. package/src/steps-list/style.scss +0 -3
  156. package/src/steps-list-item/index.js +1 -4
  157. package/src/steps-list-item/style.scss +1 -2
  158. package/src/style-card/index.js +6 -21
  159. package/src/style-card/style.scss +4 -5
  160. package/src/style.scss +15 -0
  161. package/src/tabbed-navigation/index.js +19 -7
  162. package/src/tabbed-navigation/style.scss +2 -6
  163. package/src/text-control/index.tsx +2 -12
  164. package/src/utils/color.ts +32 -0
  165. package/src/web-preview/style.scss +11 -11
  166. package/src/with-wizard/index.js +67 -16
  167. package/src/with-wizard/style.scss +34 -13
  168. package/src/with-wizard-screen/index.js +1 -1
  169. package/src/with-wizard-screen/style.scss +9 -9
  170. package/src/wizard/components/WizardError.js +2 -7
  171. package/src/wizard/index.js +64 -62
  172. package/src/wizard/store/index.js +8 -10
  173. package/src/wizard/store/utils.js +3 -4
  174. package/dist/cjs/date-range-picker/index.js +0 -39
  175. package/dist/cjs/date-range-picker/style.scss +0 -148
  176. package/dist/cjs/newspack-logo/index.js +0 -54
  177. package/dist/cjs/newspack-logo/style.scss +0 -30
  178. package/dist/cjs/patrons-logo/index.js +0 -77
  179. package/dist/esm/date-range-picker/index.js +0 -31
  180. package/dist/esm/date-range-picker/style.scss +0 -148
  181. package/dist/esm/newspack-logo/index.js +0 -46
  182. package/dist/esm/newspack-logo/style.scss +0 -30
  183. package/dist/esm/patrons-logo/index.js +0 -70
  184. package/shared/scss/_colors.scss +0 -27
  185. package/src/date-range-picker/index.js +0 -31
  186. package/src/date-range-picker/style.scss +0 -148
  187. package/src/newspack-logo/index.js +0 -45
  188. package/src/newspack-logo/style.scss +0 -30
  189. package/src/patrons-logo/index.js +0 -76
  190. /package/{shared/js → src/button-props}/button-props.js +0 -0
  191. /package/{shared/js → src/button-props}/index.js +0 -0
@@ -10,7 +10,7 @@
10
10
  margin-bottom: 8px;
11
11
  }
12
12
 
13
- .components-custom-select-control__button {
13
+ button {
14
14
  border-color: wp-colors.$gray-700;
15
15
  border-radius: 2px;
16
16
  color: wp-colors.$gray-900;
@@ -41,6 +41,10 @@
41
41
  }
42
42
  }
43
43
 
44
+ button + div {
45
+ min-width: 200px;
46
+ }
47
+
44
48
  .components-custom-select-control__menu {
45
49
  border-color: wp-colors.$gray-700;
46
50
  border-radius: 2px;
@@ -54,7 +58,6 @@
54
58
  cursor: pointer;
55
59
  display: flex;
56
60
  line-height: inherit;
57
- margin: 0 0 0 28px;
58
61
  padding: 6px 8px;
59
62
  transition: color 125ms ease-in-out;
60
63
 
@@ -77,16 +80,8 @@
77
80
 
78
81
  &.is-selected {
79
82
  margin-left: 0;
80
-
81
- &::before {
82
- background:
83
- url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTguMyA1LjZMOS45IDE2LjlsLTQuNi0zLjQtLjkgMS4yIDUuOCA0LjMgOS4zLTEyLjZ6IiBmaWxsPSIjMzM2NmZmIj48L3BhdGg+PC9zdmc+Cg==")
84
- 0 0 no-repeat;
85
- content: "";
86
- display: block;
87
- height: 24px;
88
- margin: 0 4px 0 0;
89
- width: 24px;
83
+ span svg {
84
+ fill: var(--wp-admin-theme-color);
90
85
  }
91
86
  }
92
87
  }
@@ -11,10 +11,9 @@ import { ExternalLink } from '@wordpress/components';
11
11
  /**
12
12
  * Internal dependencies.
13
13
  */
14
- import { PatronsLogo } from '../';
15
14
  import './style.scss';
16
15
 
17
- const Footer = ( { simple } ) => {
16
+ const Footer = ( { simple = undefined } ) => {
18
17
  const {
19
18
  components_demo: componentsDemo = false,
20
19
  support = false,
@@ -75,23 +74,12 @@ const Footer = ( { simple } ) => {
75
74
  return (
76
75
  <div className="newspack-footer">
77
76
  { ! simple && (
78
- <div className="newspack-footer__inner">
79
- <ul>
80
- { footerElements.map( ( { url, label, external }, index ) => (
81
- <li key={ index }>
82
- { external ? (
83
- <ExternalLink href={ url }>{ label }</ExternalLink>
84
- ) : (
85
- <a href={ url }>{ label }</a>
86
- ) }
87
- </li>
88
- ) ) }
89
- </ul>
90
- </div>
77
+ <ul>
78
+ { footerElements.map( ( { url, label, external }, index ) => (
79
+ <li key={ index }>{ external ? <ExternalLink href={ url }>{ label }</ExternalLink> : <a href={ url }>{ label }</a> }</li>
80
+ ) ) }
81
+ </ul>
91
82
  ) }
92
- <div className="newspack-footer__logo">
93
- <PatronsLogo />
94
- </div>
95
83
  </div>
96
84
  );
97
85
  };
@@ -5,16 +5,13 @@
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
6
 
7
7
  .newspack-footer {
8
- align-items: stretch;
9
8
  background: white;
10
9
  border: 0 solid wp-colors.$gray-300;
11
10
  border-width: 1px 0;
12
11
  bottom: 0;
13
12
  color: wp-colors.$gray-700;
14
13
  display: flex;
15
- flex-wrap: wrap;
16
14
  font-size: 12px;
17
- justify-content: space-between;
18
15
  left: 0;
19
16
  line-height: 16px;
20
17
  position: absolute;
@@ -22,17 +19,6 @@
22
19
 
23
20
  @media screen and ( min-width: 783px ) {
24
21
  bottom: 40px;
25
- flex-wrap: nowrap;
26
- }
27
-
28
- &__inner {
29
- align-items: center;
30
- display: flex;
31
- flex: 0 0 100%;
32
-
33
- @media screen and ( min-width: 783px ) {
34
- flex: 1 1 auto;
35
- }
36
22
  }
37
23
 
38
24
  ul {
@@ -57,26 +43,4 @@
57
43
  }
58
44
  }
59
45
  }
60
-
61
- &__logo {
62
- align-items: center;
63
- background: wp-colors.$gray-900;
64
- display: flex;
65
- margin: 0 0 -1px;
66
- padding: 16px;
67
- width: 100%;
68
-
69
- @media screen and ( min-width: 783px ) {
70
- margin: -1px 0 -1px 8px;
71
- max-width: 33.33%;
72
- width: auto;
73
- }
74
-
75
- .patrons-logo {
76
- display: block;
77
- fill: white;
78
- max-height: 16px;
79
- width: auto;
80
- }
81
- }
82
46
  }
@@ -23,8 +23,7 @@ class FormTokenField extends Component {
23
23
  * Render.
24
24
  */
25
25
  render() {
26
- const { className, description, hideHelpFromVision, hideLabelFromVision, ...otherProps } =
27
- this.props;
26
+ const { className, description, hideHelpFromVision, hideLabelFromVision, ...otherProps } = this.props;
28
27
  const classes = classnames( 'newspack-form-token-field__input-container', className );
29
28
  return (
30
29
  <div
@@ -12,14 +12,7 @@ import './style.scss';
12
12
  */
13
13
  import classnames from 'classnames';
14
14
 
15
- const Grid = ( {
16
- className = '',
17
- columns = 2,
18
- gutter = 32,
19
- noMargin = false,
20
- rowGap = 0,
21
- ...otherProps
22
- } ) => {
15
+ const Grid = ( { className = '', columns = 2, gutter = 32, noMargin = false, rowGap = 0, ...otherProps } ) => {
23
16
  const classes = classnames(
24
17
  'newspack-grid',
25
18
  noMargin && 'newspack-grid--no-margin',
@@ -53,8 +53,7 @@ class Handoff extends Component {
53
53
  const defaults = {
54
54
  modalBody: null,
55
55
  modalTitle: pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
56
- primaryButton:
57
- pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
56
+ primaryButton: pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
58
57
  primaryModalButton: __( 'Manage', 'newspack-plugin' ),
59
58
  dismissModalButton: __( 'Dismiss', 'newspack-plugin' ),
60
59
  };
@@ -96,8 +95,7 @@ class Handoff extends Component {
96
95
  ...otherProps
97
96
  } = this.props;
98
97
  const { pluginInfo, showModal } = this.state;
99
- const { modalBody, modalTitle, primaryButton, primaryModalButton, dismissModalButton } =
100
- this.textForPlugin( pluginInfo );
98
+ const { modalBody, modalTitle, primaryButton, primaryModalButton, dismissModalButton } = this.textForPlugin( pluginInfo );
101
99
  const { Configured, Name, Slug, Status } = pluginInfo;
102
100
  const classes = classnames( Configured && 'is-configured', className );
103
101
  return (
@@ -107,9 +105,7 @@ class Handoff extends Component {
107
105
  className={ classes }
108
106
  isSecondary={ ! otherProps.isPrimary && ! otherProps.isTertiary && ! otherProps.isLink }
109
107
  { ...otherProps }
110
- onClick={ () =>
111
- useModal ? this.setState( { showModal: true } ) : this.goToPlugin( Slug )
112
- }
108
+ onClick={ () => ( useModal ? this.setState( { showModal: true } ) : this.goToPlugin( Slug ) ) }
113
109
  >
114
110
  { children ? children : primaryButton }
115
111
  </Button>
@@ -132,10 +128,7 @@ class Handoff extends Component {
132
128
  </Button>
133
129
  ) }
134
130
  { showModal && (
135
- <Modal
136
- title={ modalTitle }
137
- onRequestClose={ () => this.setState( { showModal: false } ) }
138
- >
131
+ <Modal title={ modalTitle } onRequestClose={ () => this.setState( { showModal: false } ) }>
139
132
  <p>{ modalBody }</p>
140
133
  <Card buttonsCard noBorder className="justify-end">
141
134
  <Button variant="secondary" onClick={ () => this.setState( { showModal: false } ) }>
@@ -30,9 +30,6 @@ export default function HandoffMessage() {
30
30
  setHandoffMessage( false );
31
31
  }
32
32
  }, 100 );
33
-
34
- // Clean up the notification when unmounting.
35
- return () => window.localStorage.removeItem( HANDOFF_KEY );
36
33
  }, [] );
37
34
  if ( ! handoffMessage ) {
38
35
  return null;
@@ -6,6 +6,11 @@ import { useState } from '@wordpress/element';
6
6
  import isArray from 'lodash/isArray';
7
7
  import mergeWith from 'lodash/mergeWith';
8
8
 
9
+ /**
10
+ * @typedef {Object} StateObjectUpdate
11
+ * @property {Object.<string, any>} [update] The update object with key-value pairs to merge into the state.
12
+ */
13
+
9
14
  const mergeCustomizer = ( objValue, srcValue ) => {
10
15
  if ( isArray( objValue ) ) {
11
16
  // If it's an array, replace it (instead of concatenating).
@@ -16,12 +21,15 @@ const mergeCustomizer = ( objValue, srcValue ) => {
16
21
  /**
17
22
  * A useState for an object.
18
23
  * Nested objects will be nested, but arrays replaced.
24
+ *
25
+ * @template T
26
+ * @param {T} initial Initial state object.
27
+ * @return {[T, (keyOrUpdate: string | Partial<T>) => (value?: any) => void]} The state object and a function to update it.
19
28
  */
20
29
  export default ( initial = {} ) => {
21
30
  const [ stateObject, setStateObject ] = useState( initial );
22
31
 
23
- const runUpdate = update =>
24
- setStateObject( _stateObject => mergeWith( {}, _stateObject, update, mergeCustomizer ) );
32
+ const runUpdate = update => setStateObject( _stateObject => mergeWith( {}, _stateObject, update, mergeCustomizer ) );
25
33
 
26
34
  const updateStateObject = keyOrUpdate => {
27
35
  if ( typeof keyOrUpdate === 'string' ) {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render, screen, fireEvent } from '@testing-library/react';
2
+ import { render, screen, fireEvent, act } from '@testing-library/react';
3
3
 
4
4
  import useObjectState from './useObjectState';
5
5
 
@@ -12,19 +12,13 @@ const TestComponent = () => {
12
12
  <button onClick={ () => updateState( { widgets: [] } ) }>Remove widgets</button>
13
13
  <button onClick={ () => updateState( { widgets: [ 1 ] } ) }>Add widget</button>
14
14
  <button onClick={ () => updateState( { attributes: { bar: 2 } } ) }>Nested update</button>
15
- <input
16
- type="text"
17
- value={ state.name }
18
- onChange={ e => updateState( { name: e.target.value } ) }
19
- placeholder="name"
20
- />
15
+ <input type="text" value={ state.name } onChange={ e => updateState( { name: e.target.value } ) } placeholder="name" />
21
16
  </div>
22
17
  );
23
18
  };
24
19
 
25
20
  describe( 'useObjectState', () => {
26
- const getState = () =>
27
- JSON.parse( screen.getByPlaceholderText( 'state' ).getAttribute( 'value' ) );
21
+ const getState = () => JSON.parse( screen.getByPlaceholderText( 'state' ).getAttribute( 'value' ) );
28
22
 
29
23
  beforeEach( () => {
30
24
  render( <TestComponent /> );
@@ -32,17 +26,23 @@ describe( 'useObjectState', () => {
32
26
 
33
27
  it( 'updates arrays', () => {
34
28
  expect( getState() ).toStrictEqual( INIT_STATE );
35
- screen.getByText( 'Remove widgets' ).click();
29
+ act( () => screen.getByText( 'Remove widgets' ).click() );
36
30
  expect( getState() ).toMatchObject( { widgets: [] } );
37
- screen.getByText( 'Add widget' ).click();
31
+ act( () => screen.getByText( 'Add widget' ).click() );
38
32
  expect( getState() ).toMatchObject( { widgets: [ 1 ] } );
39
33
  } );
40
34
  it( 'updates a simple value', () => {
41
- fireEvent.change( screen.getByPlaceholderText( 'name' ), { target: { value: 'Ramon' } } );
35
+ act( () =>
36
+ fireEvent.change( screen.getByPlaceholderText( 'name' ), {
37
+ target: { value: 'Ramon' },
38
+ } )
39
+ );
42
40
  expect( getState() ).toMatchObject( { name: 'Ramon' } );
43
41
  } );
44
42
  it( 'updates a nested object', () => {
45
- screen.getByText( 'Nested update' ).click();
46
- expect( getState() ).toMatchObject( { attributes: { bar: 2, baz: 1 } } );
43
+ act( () => screen.getByText( 'Nested update' ).click() );
44
+ expect( getState() ).toMatchObject( {
45
+ attributes: { bar: 2, baz: 1 },
46
+ } );
47
47
  } );
48
48
  } );
@@ -72,18 +72,7 @@ class ImageUpload extends Component {
72
72
  * Render.
73
73
  */
74
74
  render = () => {
75
- const {
76
- buttonLabel,
77
- className,
78
- disabled,
79
- help,
80
- image,
81
- info,
82
- isCovering,
83
- label,
84
- onChange,
85
- style = {},
86
- } = this.props;
75
+ const { buttonLabel, className, disabled, help, image, info, isCovering, label, onChange, style = {} } = this.props;
87
76
  const classes = classnames(
88
77
  'newspack-image-upload__image',
89
78
  { 'newspack-image-upload__image--has-image': image },
@@ -99,22 +88,13 @@ class ImageUpload extends Component {
99
88
  <div className={ classes } style={ { ...style } }>
100
89
  { image?.url ? (
101
90
  <>
102
- <img
103
- data-testid="image-upload"
104
- src={ image.url }
105
- alt={ __( 'Image preview', 'newspack-plugin' ) }
106
- />
91
+ <img data-testid="image-upload" src={ image.url } alt={ __( 'Image preview', 'newspack-plugin' ) } />
107
92
  <div className="newspack-image-upload__controls">
108
93
  <Button disabled={ disabled } onClick={ this.openModal } isLink>
109
94
  { __( 'Replace', 'newspack-plugin' ) }
110
95
  </Button>
111
96
  <span className="sep" />
112
- <Button
113
- disabled={ disabled }
114
- onClick={ () => onChange( null ) }
115
- isLink
116
- isDestructive
117
- >
97
+ <Button disabled={ disabled } onClick={ () => onChange( null ) } isLink isDestructive>
118
98
  { __( 'Remove', 'newspack-plugin' ) }
119
99
  </Button>
120
100
  </div>
package/src/index.js CHANGED
@@ -4,6 +4,7 @@ export { default as AutocompleteTokenField } from './autocomplete-tokenfield';
4
4
  export { default as AutocompleteWithSuggestions } from './autocomplete-with-suggestions';
5
5
  export { default as Button } from './button';
6
6
  export { default as ButtonCard } from './button-card';
7
+ export { default as BoxContrast } from './box-contrast';
7
8
  export { default as Card } from './card';
8
9
  export { default as CategoryAutocomplete } from './category-autocomplete';
9
10
  export { default as ColorPicker } from './color-picker';
@@ -18,9 +19,7 @@ export { default as GlobalNotices } from './global-notices';
18
19
  export { default as Grid } from './grid';
19
20
  export { default as Modal } from './modal';
20
21
  export { default as NewspackIcon } from './newspack-icon';
21
- export { default as NewspackLogo } from './newspack-logo';
22
22
  export { default as Notice } from './notice';
23
- export { default as PatronsLogo } from './patrons-logo';
24
23
  export { default as PluginInstaller } from './plugin-installer';
25
24
  export { default as PluginSettings } from './plugin-settings';
26
25
  export { default as PluginToggle } from './plugin-toggle';
@@ -29,7 +28,6 @@ export { default as ProgressBar } from './progress-bar';
29
28
  export { default as RadioControl } from './radio-control';
30
29
  export { default as SectionHeader } from './section-header';
31
30
  export { default as SelectControl } from './select-control';
32
- export { default as DateRangePicker } from './date-range-picker';
33
31
  export { default as Settings } from './settings';
34
32
  export { default as StepsList } from './steps-list';
35
33
  export { default as StepsListItem } from './steps-list-item';
@@ -18,15 +18,15 @@ import './style.scss';
18
18
  */
19
19
  import classnames from 'classnames';
20
20
 
21
- function Modal( { className, isWide, isNarrow, ...otherProps }, ref ) {
21
+ function Modal( { className, isWide, isNarrow, hideTitle, ...otherProps }, ref ) {
22
22
  const classes = classnames(
23
23
  'newspack-modal',
24
24
  isWide && 'newspack-modal--wide',
25
25
  isNarrow && 'newspack-modal--narrow',
26
+ hideTitle && 'newspack-modal--hide-title', // Note: also hides the X close button.
26
27
  className
27
28
  );
28
29
 
29
30
  return <BaseComponent className={ classes } { ...otherProps } ref={ ref } />;
30
-
31
31
  }
32
32
  export default forwardRef( Modal );
@@ -2,16 +2,16 @@
2
2
  * Modal
3
3
  */
4
4
 
5
- @use "../../../shared/scss/colors";
5
+ @use "../../../colors/colors.module" as colors;
6
6
 
7
7
  .newspack-modal {
8
8
  // Color
9
- --wp-admin-theme-color: #{colors.$primary-500};
10
- --wp-admin-theme-color--rgb: #{colors.$primary-500--rgb};
11
- --wp-admin-theme-color-darker-10: #{colors.$primary-600};
12
- --wp-admin-theme-color-darker-10--rgb: #{colors.$primary-600--rgb};
13
- --wp-admin-theme-color-darker-20: #{colors.$primary-700};
14
- --wp-admin-theme-color-darker-20--rgb: #{colors.$primary-700--rgb};
9
+ --wp-admin-theme-color: #{colors.$primary-600};
10
+ --wp-admin-theme-color--rgb: #{colors.$primary-600--rgb};
11
+ --wp-admin-theme-color-darker-10: #{colors.$primary-700};
12
+ --wp-admin-theme-color-darker-10--rgb: #{colors.$primary-700--rgb};
13
+ --wp-admin-theme-color-darker-20: #{colors.$primary-800};
14
+ --wp-admin-theme-color-darker-20--rgb: #{colors.$primary-800--rgb};
15
15
 
16
16
  @media screen and ( min-width: 744px ) {
17
17
  max-width: 680px;
@@ -28,6 +28,17 @@
28
28
  width: 360px;
29
29
  }
30
30
 
31
+ &--hide-title {
32
+ .components-modal__header {
33
+ display: none;
34
+ }
35
+
36
+ .components-modal__content {
37
+ margin-top: 0;
38
+ padding-top: 32px;
39
+ }
40
+ }
41
+
31
42
  @media screen and ( min-width: 960px ) {
32
43
  max-height: calc(100% - 128px);
33
44
  }
@@ -24,24 +24,13 @@ class NewspackIcon extends Component {
24
24
  */
25
25
  render() {
26
26
  const { className, simple, size, white } = this.props;
27
- const classes = classnames(
28
- 'newspack-icon',
29
- simple && 'newspack-icon--simple',
30
- white && 'newspack-icon--white',
31
- className
32
- );
27
+ const classes = classnames( 'newspack-icon', simple && 'newspack-icon--simple', white && 'newspack-icon--white', className );
33
28
  return (
34
- <SVG
35
- xmlns="http://www.w3.org/2000/svg"
36
- height={ size }
37
- width={ size }
38
- viewBox="0 0 32 32"
39
- className={ classes }
40
- >
29
+ <SVG xmlns="http://www.w3.org/2000/svg" height={ size } width={ size } viewBox="0 0 24 24" className={ classes }>
41
30
  <Path
42
31
  fillRule="evenodd"
43
32
  clipRule="evenodd"
44
- d="M32 16c0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16S7.164 0 16 0s16 7.164 16 16zm-10.732.622h1.72v-1.124h-2.823l1.103 1.124zm-3.249-3.31h4.97v-1.124h-6.072l1.102 1.124zm-3.248-3.31h8.217V8.877h-9.32l1.103 1.125zM9.01 8.877l13.977 14.246h-4.66l-5.866-5.98v5.98h-3.45V8.877z"
33
+ d="M24 12C24 18.6271 18.6271 24 12 24C5.37213 24 0 18.6271 0 12C0 5.3729 5.3729 0 12 0C18.6271 0 24 5.3729 24 12ZM17.4545 17.4546L6.54545 6.54545V17.4545H8.72727V11.8182L14.3636 17.4546H17.4545ZM11.2727 8.18182H17.4545V6.54545H9.63636L11.2727 8.18182ZM17.4545 11.2727H14.3636L12.7273 9.63636H17.4545V11.2727ZM17.4545 12.7273V14.3636L15.8182 12.7273H17.4545Z"
45
34
  />
46
35
  </SVG>
47
36
  );
@@ -2,21 +2,19 @@
2
2
  * Newspack Icon
3
3
  */
4
4
 
5
- @use "../../../shared/scss/colors";
6
-
7
5
  .newspack-icon {
8
- background: colors.$primary-500;
6
+ background: var(--wp-admin-theme-color);
9
7
  fill: white;
10
8
  padding: 12px;
11
9
 
12
10
  &--white {
13
11
  background: white;
14
- fill: colors.$primary-500;
12
+ fill: var(--wp-admin-theme-color);
15
13
  }
16
14
 
17
15
  &--simple {
18
16
  background: none;
19
- fill: colors.$primary-500;
17
+ fill: var(--wp-admin-theme-color);
20
18
  padding: 0;
21
19
  }
22
20
 
@@ -7,7 +7,6 @@
7
7
  */
8
8
  import { Component, RawHTML } from '@wordpress/element';
9
9
  import { Icon, bug, check, help, info } from '@wordpress/icons';
10
- import { __ } from '@wordpress/i18n';
11
10
 
12
11
  /**
13
12
  * Internal dependencies.
@@ -62,7 +61,6 @@ class Notice extends Component {
62
61
  { <Icon icon={ noticeIcon } /> }
63
62
  <div className="newspack-notice__content">
64
63
  { rawHTML ? <RawHTML>{ noticeText }</RawHTML> : noticeText }
65
- { debugMode && __( 'Debug Mode', 'newspack-plugin' ) }
66
64
  { children || null }
67
65
  </div>
68
66
  </div>
@@ -4,7 +4,7 @@
4
4
 
5
5
  @use "sass:color";
6
6
  @use "~@wordpress/base-styles/colors" as wp-colors;
7
- @use "../../../shared/scss/colors";
7
+ @use "../../../colors/colors.module" as colors;
8
8
 
9
9
  .newspack-notice {
10
10
  align-items: center;
@@ -13,7 +13,7 @@
13
13
  display: flex;
14
14
  justify-content: flex-start;
15
15
  margin: 32px 0;
16
- padding: 6px 8px;
16
+ padding: 8px 12px;
17
17
 
18
18
  > svg {
19
19
  display: block;
@@ -23,24 +23,26 @@
23
23
  }
24
24
 
25
25
  &__is-debug {
26
- background: colors.$primary-700;
27
- border-radius: 2px;
26
+ background: colors.$primary-600;
27
+ border-radius: 50%;
28
28
  bottom: 16px;
29
29
  box-shadow: 0 0 8px 4px rgba(black, 0.08);
30
30
  color: white;
31
31
  font-weight: bold;
32
32
  margin: 0 16px;
33
+ padding: 6px;
33
34
  position: fixed;
34
35
  text-transform: uppercase;
35
36
  z-index: 9997;
36
37
 
37
38
  > svg {
38
39
  fill: white;
40
+ margin: 0;
39
41
  }
40
42
  }
41
43
 
42
44
  &__is-error {
43
- background: color.adjust(wp-colors.$alert-red, $lightness: 51%);
45
+ background: color.adjust(wp-colors.$alert-red, $lightness: 35%);
44
46
 
45
47
  > svg {
46
48
  fill: wp-colors.$alert-red;
@@ -49,7 +51,7 @@
49
51
  }
50
52
 
51
53
  &__is-handoff {
52
- background: color.adjust(wp-colors.$alert-yellow, $lightness: 30%);
54
+ background: color.adjust(wp-colors.$alert-yellow, $lightness: 35%);
53
55
  margin-top: 0;
54
56
  position: sticky;
55
57
  top: 46px;
@@ -64,12 +66,12 @@
64
66
  background: colors.$primary-050;
65
67
 
66
68
  > svg {
67
- fill: colors.$primary-500;
69
+ fill: var(--wp-admin-theme-color);
68
70
  }
69
71
  }
70
72
 
71
73
  &__is-success {
72
- background: color.adjust(wp-colors.$alert-green, $lightness: 42%);
74
+ background: color.adjust(wp-colors.$alert-green, $lightness: 45%);
73
75
 
74
76
  > svg {
75
77
  fill: wp-colors.$alert-green;
@@ -77,7 +79,7 @@
77
79
  }
78
80
 
79
81
  &__is-warning {
80
- background: color.adjust(wp-colors.$alert-yellow, $lightness: 30%);
82
+ background: color.adjust(wp-colors.$alert-yellow, $lightness: 35%);
81
83
 
82
84
  > svg {
83
85
  fill: wp-colors.$alert-yellow;