newspack-components 3.0.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 (197) 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 -186
  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 +6 -6
  18. package/dist/cjs/image-upload/index.test.js +2 -2
  19. package/dist/cjs/index.js +7 -21
  20. package/dist/cjs/modal/index.js +16 -18
  21. package/dist/cjs/modal/style.scss +18 -7
  22. package/dist/cjs/newspack-icon/index.js +2 -2
  23. package/dist/cjs/newspack-icon/style.scss +3 -5
  24. package/dist/cjs/notice/index.js +1 -2
  25. package/dist/cjs/notice/style.scss +11 -9
  26. package/dist/cjs/plugin-installer/index.js +3 -3
  27. package/dist/cjs/plugin-settings/SettingsSection.js +2 -0
  28. package/dist/cjs/plugin-settings/index.js +4 -1
  29. package/dist/cjs/plugin-toggle/index.js +2 -0
  30. package/dist/cjs/popover/style.scss +5 -6
  31. package/dist/cjs/progress-bar/index.test.js +8 -9
  32. package/dist/cjs/progress-bar/style.scss +1 -2
  33. package/dist/cjs/proxied-imports/router.js +1 -2
  34. package/dist/cjs/radio-control/style.scss +8 -11
  35. package/dist/cjs/section-header/index.js +21 -1
  36. package/dist/cjs/select-control/ButtonGroupControl.js +2 -0
  37. package/dist/cjs/settings/SettingsCard.js +2 -6
  38. package/dist/cjs/sortable-newsletter-list-control/index.js +7 -5
  39. package/dist/cjs/sortable-newsletter-list-control/style.scss +11 -1
  40. package/dist/cjs/steps-list/style.scss +0 -3
  41. package/dist/cjs/steps-list-item/style.scss +1 -2
  42. package/dist/cjs/style-card/index.js +1 -0
  43. package/dist/cjs/style-card/style.scss +4 -5
  44. package/dist/cjs/style.scss +15 -0
  45. package/dist/cjs/tabbed-navigation/index.js +17 -7
  46. package/dist/cjs/tabbed-navigation/style.scss +2 -6
  47. package/dist/cjs/utils/color.js +35 -0
  48. package/dist/cjs/web-preview/index.js +1 -1
  49. package/dist/cjs/web-preview/style.scss +11 -11
  50. package/dist/cjs/with-wizard/index.js +80 -3
  51. package/dist/cjs/with-wizard/style.scss +34 -13
  52. package/dist/cjs/with-wizard-screen/index.js +3 -3
  53. package/dist/cjs/with-wizard-screen/style.scss +9 -9
  54. package/dist/cjs/wizard/index.js +38 -13
  55. package/dist/cjs/wizard/store/index.js +13 -5
  56. package/dist/cjs/wizard/store/utils.js +3 -1
  57. package/dist/esm/action-card/action-card.d.js +1 -0
  58. package/dist/esm/action-card/index.js +286 -188
  59. package/dist/esm/action-card/style.scss +142 -44
  60. package/dist/esm/autocomplete-tokenfield/index.js +6 -2
  61. package/dist/esm/box-contrast/index.js +44 -0
  62. package/dist/esm/button/index.js +1 -1
  63. package/dist/esm/button-props/button-props.js +34 -0
  64. package/dist/esm/button-props/index.js +1 -0
  65. package/dist/esm/color-picker/index.js +11 -0
  66. package/dist/esm/custom-select-control/style.scss +7 -12
  67. package/dist/esm/footer/index.js +18 -25
  68. package/dist/esm/footer/style.scss +0 -36
  69. package/dist/esm/handoff-message/index.js +0 -3
  70. package/dist/esm/hooks/useObjectState.js +12 -2
  71. package/dist/esm/hooks/useObjectState.test.js +7 -7
  72. package/dist/esm/hooks/usePrompt.js +2 -2
  73. package/dist/esm/image-upload/index.test.js +2 -2
  74. package/dist/esm/index.js +1 -3
  75. package/dist/esm/modal/index.js +17 -19
  76. package/dist/esm/modal/style.scss +18 -7
  77. package/dist/esm/newspack-icon/index.js +2 -2
  78. package/dist/esm/newspack-icon/style.scss +3 -5
  79. package/dist/esm/notice/index.js +1 -2
  80. package/dist/esm/notice/style.scss +11 -9
  81. package/dist/esm/plugin-installer/index.js +3 -3
  82. package/dist/esm/plugin-settings/SettingsSection.js +2 -0
  83. package/dist/esm/plugin-settings/index.js +4 -1
  84. package/dist/esm/plugin-toggle/index.js +2 -0
  85. package/dist/esm/popover/style.scss +5 -6
  86. package/dist/esm/progress-bar/index.test.js +7 -7
  87. package/dist/esm/progress-bar/style.scss +1 -2
  88. package/dist/esm/radio-control/style.scss +8 -11
  89. package/dist/esm/section-header/index.js +22 -0
  90. package/dist/esm/select-control/ButtonGroupControl.js +2 -0
  91. package/dist/esm/settings/SettingsCard.js +2 -6
  92. package/dist/esm/sortable-newsletter-list-control/index.js +8 -6
  93. package/dist/esm/sortable-newsletter-list-control/style.scss +11 -1
  94. package/dist/esm/steps-list/style.scss +0 -3
  95. package/dist/esm/steps-list-item/style.scss +1 -2
  96. package/dist/esm/style-card/index.js +1 -0
  97. package/dist/esm/style-card/style.scss +4 -5
  98. package/dist/esm/style.scss +15 -0
  99. package/dist/esm/tabbed-navigation/index.js +17 -7
  100. package/dist/esm/tabbed-navigation/style.scss +2 -6
  101. package/dist/esm/utils/color.js +29 -0
  102. package/dist/esm/web-preview/index.js +1 -1
  103. package/dist/esm/web-preview/style.scss +11 -11
  104. package/dist/esm/with-wizard/index.js +81 -4
  105. package/dist/esm/with-wizard/style.scss +34 -13
  106. package/dist/esm/with-wizard-screen/index.js +1 -1
  107. package/dist/esm/with-wizard-screen/style.scss +9 -9
  108. package/dist/esm/wizard/index.js +39 -13
  109. package/dist/esm/wizard/store/index.js +14 -6
  110. package/dist/esm/wizard/store/utils.js +3 -1
  111. package/package.json +2 -2
  112. package/src/accordion/index.js +1 -3
  113. package/src/action-card/action-card.d.ts +40 -0
  114. package/src/action-card/index.js +284 -201
  115. package/src/action-card/style.scss +142 -44
  116. package/src/autocomplete-tokenfield/index.js +3 -2
  117. package/src/autocomplete-with-suggestions/index.js +52 -63
  118. package/src/box-contrast/index.tsx +44 -0
  119. package/src/button/index.tsx +1 -1
  120. package/src/button-card/index.js +1 -12
  121. package/src/card/index.js +1 -11
  122. package/src/category-autocomplete/index.js +4 -19
  123. package/src/color-picker/index.js +11 -7
  124. package/src/custom-select-control/style.scss +7 -12
  125. package/src/footer/index.js +6 -18
  126. package/src/footer/style.scss +0 -36
  127. package/src/form-token-field/index.js +1 -2
  128. package/src/grid/index.tsx +1 -8
  129. package/src/handoff/index.js +4 -11
  130. package/src/handoff-message/index.js +0 -3
  131. package/src/hooks/useObjectState.js +10 -2
  132. package/src/hooks/useObjectState.test.js +14 -14
  133. package/src/image-upload/index.js +3 -23
  134. package/src/index.js +1 -3
  135. package/src/modal/index.js +11 -17
  136. package/src/modal/style.scss +18 -7
  137. package/src/newspack-icon/index.js +3 -14
  138. package/src/newspack-icon/style.scss +3 -5
  139. package/src/notice/index.js +0 -2
  140. package/src/notice/style.scss +11 -9
  141. package/src/plugin-installer/index.js +8 -17
  142. package/src/plugin-settings/SettingsSection.js +3 -7
  143. package/src/plugin-settings/index.js +7 -14
  144. package/src/plugin-toggle/README.md +3 -3
  145. package/src/plugin-toggle/index.js +10 -13
  146. package/src/popover/index.js +1 -5
  147. package/src/popover/style.scss +5 -6
  148. package/src/position-control/index.js +65 -75
  149. package/src/progress-bar/index.js +2 -9
  150. package/src/progress-bar/index.test.js +4 -13
  151. package/src/progress-bar/style.scss +1 -2
  152. package/src/radio-control/style.scss +8 -11
  153. package/src/section-header/index.js +20 -0
  154. package/src/select-control/ButtonGroupControl.js +2 -9
  155. package/src/select-control/GroupedSelectControl.js +1 -9
  156. package/src/select-control/index.js +1 -5
  157. package/src/settings/MinMaxSetting.js +2 -14
  158. package/src/settings/SettingsCard.js +2 -11
  159. package/src/sortable-newsletter-list-control/index.js +10 -26
  160. package/src/sortable-newsletter-list-control/style.scss +11 -1
  161. package/src/steps-list/style.scss +0 -3
  162. package/src/steps-list-item/index.js +1 -4
  163. package/src/steps-list-item/style.scss +1 -2
  164. package/src/style-card/index.js +6 -21
  165. package/src/style-card/style.scss +4 -5
  166. package/src/style.scss +15 -0
  167. package/src/tabbed-navigation/index.js +19 -7
  168. package/src/tabbed-navigation/style.scss +2 -6
  169. package/src/text-control/index.tsx +2 -12
  170. package/src/utils/color.ts +32 -0
  171. package/src/web-preview/style.scss +11 -11
  172. package/src/with-wizard/index.js +67 -16
  173. package/src/with-wizard/style.scss +34 -13
  174. package/src/with-wizard-screen/index.js +1 -1
  175. package/src/with-wizard-screen/style.scss +9 -9
  176. package/src/wizard/components/WizardError.js +2 -7
  177. package/src/wizard/index.js +64 -62
  178. package/src/wizard/store/index.js +8 -10
  179. package/src/wizard/store/utils.js +3 -4
  180. package/dist/cjs/date-range-picker/index.js +0 -39
  181. package/dist/cjs/date-range-picker/style.scss +0 -148
  182. package/dist/cjs/newspack-logo/index.js +0 -54
  183. package/dist/cjs/newspack-logo/style.scss +0 -30
  184. package/dist/cjs/patrons-logo/index.js +0 -77
  185. package/dist/esm/date-range-picker/index.js +0 -31
  186. package/dist/esm/date-range-picker/style.scss +0 -148
  187. package/dist/esm/newspack-logo/index.js +0 -46
  188. package/dist/esm/newspack-logo/style.scss +0 -30
  189. package/dist/esm/patrons-logo/index.js +0 -70
  190. package/shared/scss/_colors.scss +0 -27
  191. package/src/date-range-picker/index.js +0 -31
  192. package/src/date-range-picker/style.scss +0 -148
  193. package/src/newspack-logo/index.js +0 -45
  194. package/src/newspack-logo/style.scss +0 -30
  195. package/src/patrons-logo/index.js +0 -76
  196. /package/{shared/js → src/button-props}/button-props.js +0 -0
  197. /package/{shared/js → src/button-props}/index.js +0 -0
@@ -67,8 +67,7 @@ class PluginInstaller extends Component {
67
67
  }
68
68
  result[ slug ] = {
69
69
  ...response[ slug ],
70
- installationStatus:
71
- response[ slug ].Status === 'active' ? PLUGIN_STATE_ACTIVE : PLUGIN_STATE_NONE,
70
+ installationStatus: response[ slug ].Status === 'active' ? PLUGIN_STATE_ACTIVE : PLUGIN_STATE_NONE,
72
71
  };
73
72
  return result;
74
73
  }, {} );
@@ -84,8 +83,7 @@ class PluginInstaller extends Component {
84
83
  .filter( slug => 'active' !== pluginInfo[ slug ].Status )
85
84
  .map( slug => () => this.installPlugin( slug ) );
86
85
  promises.reduce(
87
- ( promise, action ) =>
88
- promise.then( result => action().then( Array.prototype.concat.bind( result ) ) ),
86
+ ( promise, action ) => promise.then( result => action().then( Array.prototype.concat.bind( result ) ) ),
89
87
  Promise.resolve( [] )
90
88
  );
91
89
  };
@@ -155,7 +153,7 @@ class PluginInstaller extends Component {
155
153
  render() {
156
154
  const { autoInstall, isSmall, withoutFooterButton } = this.props;
157
155
  const { pluginInfo } = this.state;
158
- const { is_atomic: isAtomic } = window;
156
+ const { is_managed: isManaged } = window.newspack_aux_data || {};
159
157
  const slugs = Object.keys( pluginInfo );
160
158
 
161
159
  // Store all plugin status info for installer button text value based on current status.
@@ -166,12 +164,9 @@ class PluginInstaller extends Component {
166
164
  } );
167
165
 
168
166
  // Make sure plugin status falls in either one of these, to handle button text.
169
- const pluginInstalled = currentStatus =>
170
- currentStatus === 'active' || currentStatus === 'inactive';
167
+ const pluginInstalled = currentStatus => currentStatus === 'active' || currentStatus === 'inactive';
171
168
 
172
- const buttonText = currentPluginStatuses.every( pluginInstalled )
173
- ? __( 'Activate', 'newspack-plugin' )
174
- : __( 'Install', 'newspack-plugin' );
169
+ const buttonText = currentPluginStatuses.every( pluginInstalled ) ? __( 'Activate', 'newspack-plugin' ) : __( 'Install', 'newspack-plugin' );
175
170
 
176
171
  const needsInstall = slugs.some( slug => {
177
172
  const plugin = pluginInfo[ slug ];
@@ -190,8 +185,7 @@ class PluginInstaller extends Component {
190
185
  slugs.length > 0 &&
191
186
  slugs.map( slug => {
192
187
  const plugin = pluginInfo[ slug ];
193
- const { Name, Description, Download, Status, installationStatus, notification } =
194
- plugin;
188
+ const { Name, Description, Download, Status, installationStatus, notification } = plugin;
195
189
  const isWaiting = installationStatus === PLUGIN_STATE_INSTALLING;
196
190
  const isButton = ! isWaiting && Status !== 'active';
197
191
  const installable = Download || pluginInstalled( Status );
@@ -201,7 +195,7 @@ class PluginInstaller extends Component {
201
195
  } else if ( ! installable ) {
202
196
  actionText = (
203
197
  <span className="newspack-plugin-installer__status">
204
- { isAtomic
198
+ { isManaged
205
199
  ? __( 'Contact Newspack support to install', 'newspack-plugin' )
206
200
  : __( 'Plugin must be installed manually', 'newspack-plugin' ) }
207
201
  <span className="newspack-checkbox-icon" />
@@ -232,10 +226,7 @@ class PluginInstaller extends Component {
232
226
  );
233
227
  }
234
228
 
235
- const classes = classnames(
236
- 'newspack-action-card__plugin-installer',
237
- this.classForInstallationStatus( installationStatus )
238
- );
229
+ const classes = classnames( 'newspack-action-card__plugin-installer', this.classForInstallationStatus( installationStatus ) );
239
230
  const onClick = isButton ? () => this.installPlugin( slug ) : null;
240
231
  return (
241
232
  <ActionCard
@@ -53,8 +53,7 @@ const getControlType = setting => {
53
53
 
54
54
  const SettingsSection = props => {
55
55
  const [ saveDisabled, setSaveDisabled ] = useState( true );
56
- const { error, sectionKey, active, title, description, fields, disabled, onChange, onUpdate } =
57
- props;
56
+ const { error, sectionKey, active, title, description, fields, disabled, onChange, onUpdate } = props;
58
57
  const getControlProps = setting => ( {
59
58
  disabled,
60
59
  name: `${ setting.section }_${ setting.key }`,
@@ -75,11 +74,7 @@ const SettingsSection = props => {
75
74
  },
76
75
  } );
77
76
  const createFilter = ( name, defaultComponent = null ) => {
78
- return applyFilters(
79
- `newspack.settingSection.${ sectionKey }.${ name }`,
80
- defaultComponent,
81
- props
82
- );
77
+ return applyFilters( `newspack.settingSection.${ sectionKey }.${ name }`, defaultComponent, props );
83
78
  };
84
79
  let columns = 2;
85
80
  if ( fields.length % 3 === 0 ) {
@@ -89,6 +84,7 @@ const SettingsSection = props => {
89
84
  }
90
85
  return (
91
86
  <ActionCard
87
+ id={ props.id ?? null }
92
88
  isMedium
93
89
  disabled={ disabled }
94
90
  title={ title }
@@ -30,9 +30,7 @@ class PluginSettings extends Component {
30
30
  const { afterFetch, pluginSlug, isWizard } = this.props;
31
31
  this.setState( { inFlight: true } );
32
32
  apiFetch( {
33
- path: isWizard
34
- ? `/newspack/v1/wizard/${ pluginSlug }/settings`
35
- : `/${ pluginSlug }/v1/settings`,
33
+ path: isWizard ? `/newspack/v1/wizard/${ pluginSlug }/settings` : `/${ pluginSlug }/v1/settings`,
36
34
  } )
37
35
  .then( settings => {
38
36
  this.setState( { settings, error: null } );
@@ -80,9 +78,7 @@ class PluginSettings extends Component {
80
78
  const { afterUpdate, pluginSlug, isWizard } = this.props;
81
79
  this.setState( { inFlight: true } );
82
80
  apiFetch( {
83
- path: isWizard
84
- ? `/newspack/v1/wizard/${ pluginSlug }/settings`
85
- : `/${ pluginSlug }/v1/settings`,
81
+ path: isWizard ? `/newspack/v1/wizard/${ pluginSlug }/settings` : `/${ pluginSlug }/v1/settings`,
86
82
  method: 'POST',
87
83
  data: {
88
84
  section: sectionKey,
@@ -116,9 +112,7 @@ class PluginSettings extends Component {
116
112
  * @return {Object} The section setting.
117
113
  */
118
114
  getSectionInfo = sectionKey => {
119
- return this.state.settings[ sectionKey ]?.find(
120
- setting => ! setting.key || setting.key === 'active'
121
- );
115
+ return this.state.settings[ sectionKey ]?.find( setting => ! setting.key || setting.key === 'active' );
122
116
  };
123
117
 
124
118
  /**
@@ -163,20 +157,18 @@ class PluginSettings extends Component {
163
157
  * @return {?Array} List of section fields.
164
158
  */
165
159
  getSectionFields = sectionKey => {
166
- return this.state.settings[ sectionKey ]?.filter(
167
- setting => setting.key && setting.key !== 'active'
168
- );
160
+ return this.state.settings[ sectionKey ]?.filter( setting => setting.key && setting.key !== 'active' );
169
161
  };
170
162
 
171
163
  /**
172
164
  * Render.
173
165
  */
174
166
  render() {
175
- const { title, description, hasGreyHeader, children } = this.props;
167
+ const { title, description, hasGreyHeader, children, titleLevel = 1 } = this.props;
176
168
  const { settings, inFlight, error } = this.state;
177
169
  return (
178
170
  <Fragment>
179
- { title && <SectionHeader title={ title } description={ description } /> }
171
+ { title && <SectionHeader title={ title } heading={ titleLevel } description={ description } /> }
180
172
  { error && <Notice isError noticeText={ error.message } /> }
181
173
  <div
182
174
  className={ classnames( 'newspack-plugin-settings', {
@@ -187,6 +179,7 @@ class PluginSettings extends Component {
187
179
  <SettingsSection
188
180
  key={ sectionKey }
189
181
  disabled={ inFlight }
182
+ id={ `plugin-settings-${ sectionKey }` }
190
183
  sectionKey={ sectionKey }
191
184
  title={ this.getSectionTitle( sectionKey ) }
192
185
  description={ this.getSectionDescription( sectionKey ) }
@@ -26,11 +26,11 @@ ActionCards for WooCommerce and Instant Articles for WP with custom text and URL
26
26
  plugins={ {
27
27
  woocommerce: {
28
28
  actionText: __( 'Use WooCommerce' ),
29
- href: '/wp-admin/admin.php?page=newspack',
29
+ href: '/wp-admin/admin.php?page=newspack-dashboard',
30
30
  },
31
31
  'fb-instant-articles': {
32
32
  actionText: __( 'Configure Instant Articles' ),
33
- href: '/wp-admin/admin.php?page=newspack',
33
+ href: '/wp-admin/admin.php?page=newspack-dashboard',
34
34
  },
35
35
  } }
36
36
  />
@@ -46,7 +46,7 @@ ActionCards for WooCommerce and Instant Articles for WP. Page will refresh after
46
46
  },
47
47
  'fb-instant-articles': {
48
48
  actionText: __( 'Configure Instant Articles' ),
49
- href: '/wp-admin/admin.php?page=newspack',
49
+ href: '/wp-admin/admin.php?page=newspack-dashboard',
50
50
  },
51
51
  } }
52
52
  />
@@ -28,9 +28,7 @@ class PluginToggle extends Component {
28
28
  */
29
29
  retrievePluginInfo = () => {
30
30
  return new Promise( () => {
31
- apiFetch( { path: '/newspack/v1/plugins/' } ).then( pluginInfo =>
32
- this.setState( { pluginInfo } )
33
- );
31
+ apiFetch( { path: '/newspack/v1/plugins/' } ).then( pluginInfo => this.setState( { pluginInfo } ) );
34
32
  } );
35
33
  };
36
34
 
@@ -67,9 +65,7 @@ class PluginToggle extends Component {
67
65
  ...pluginInfo,
68
66
  [ plugin ]: {
69
67
  ...pluginInfo[ plugin ],
70
- error:
71
- e.message ||
72
- __( 'There was an error managing this plugin.', 'newspack-plugin' ),
68
+ error: e.message || __( 'There was an error managing this plugin.', 'newspack-plugin' ),
73
69
  },
74
70
  },
75
71
  } );
@@ -97,6 +93,7 @@ class PluginToggle extends Component {
97
93
  description={ description }
98
94
  actionText={ this.actionTextForPlugin( plugin ) }
99
95
  handoff={ handoff }
96
+ onClick={ plugin.onClick ?? null }
100
97
  href={ href }
101
98
  toggle
102
99
  toggleChecked={ this.isPluginInstalledAndActive( plugin ) }
@@ -117,13 +114,13 @@ class PluginToggle extends Component {
117
114
  .map( pluginSlug =>
118
115
  pluginsFromAPI[ pluginSlug ]
119
116
  ? Object.keys( pluginsFromAPI[ pluginSlug ] ).reduce(
120
- ( accumulator, key ) => ( {
121
- ...accumulator,
122
- [ key.charAt( 0 ).toLowerCase() + key.slice( 1 ) ]:
123
- pluginsFromAPI[ pluginSlug ][ key ],
124
- } ),
125
- {}
126
- ) : {}
117
+ ( accumulator, key ) => ( {
118
+ ...accumulator,
119
+ [ key.charAt( 0 ).toLowerCase() + key.slice( 1 ) ]: pluginsFromAPI[ pluginSlug ][ key ],
120
+ } ),
121
+ {}
122
+ )
123
+ : {}
127
124
  )
128
125
  .map( plugin => Object.assign( plugin, pluginsFromProps[ plugin.slug ] ) );
129
126
 
@@ -23,11 +23,7 @@ class Popover extends Component {
23
23
  */
24
24
  render() {
25
25
  const { className, padding, ...otherProps } = this.props;
26
- const classes = classnames(
27
- 'newspack-popover',
28
- padding && 'newspack-popover__padding-' + padding,
29
- className
30
- );
26
+ const classes = classnames( 'newspack-popover', padding && 'newspack-popover__padding-' + padding, className );
31
27
  return <BaseComponent className={ classes } { ...otherProps } />;
32
28
  }
33
29
  }
@@ -2,7 +2,6 @@
2
2
  * Popover
3
3
  */
4
4
 
5
- @use "../../../shared/scss/colors";
6
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
7
6
 
8
7
  .newspack-popover {
@@ -16,7 +15,7 @@
16
15
  padding: 6px 8px;
17
16
 
18
17
  &:hover {
19
- color: colors.$primary-500;
18
+ color: var(--wp-admin-theme-color);
20
19
 
21
20
  .components-menu-items__item-icon {
22
21
  fill: currentcolor;
@@ -24,7 +23,7 @@
24
23
  }
25
24
 
26
25
  &:focus:not(:disabled) {
27
- box-shadow: inset 0 0 0 2px colors.$primary-500;
26
+ box-shadow: inset 0 0 0 2px var(--wp-admin-theme-color);
28
27
  position: relative;
29
28
  z-index: 1;
30
29
  }
@@ -42,7 +41,7 @@
42
41
  &:focus,
43
42
  &:focus:enabled &:hover,
44
43
  &:not(:disabled, [aria-disabled="true"], .is-default):hover {
45
- color: colors.$primary-500;
44
+ color: var(--wp-admin-theme-color);
46
45
  }
47
46
  }
48
47
 
@@ -89,8 +88,8 @@
89
88
  min-height: 36px;
90
89
 
91
90
  &:focus ~ div.components-input-control__backdrop {
92
- border-color: colors.$primary-500;
93
- box-shadow: inset 0 0 0 1px colors.$primary-500;
91
+ border-color: var(--wp-admin-theme-color);
92
+ box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color);
94
93
  }
95
94
  }
96
95
 
@@ -14,93 +14,83 @@ import classnames from 'classnames';
14
14
  */
15
15
  import './style.scss';
16
16
 
17
- export default function PositionControl( {
18
- allowedPositions,
19
- value,
20
- label,
21
- help,
22
- onChange,
23
- size,
24
- ...props
25
- } ) {
17
+ export default function PositionControl( { allowedPositions, value, label, help, onChange, size, ...props } ) {
26
18
  /**
27
19
  * Set layout options
28
20
  */
29
21
  const options =
30
22
  size === 'full-width'
31
23
  ? [
32
- {
33
- value: 'top',
34
- /* translators: Overlay Position */
35
- label: __( 'Top', 'newspack-plugin' ),
36
- },
37
- {
38
- value: 'center',
39
- /* translators: Overlay Position */
40
- label: __( 'Center', 'newspack-plugin' ),
41
- },
42
- {
43
- value: 'bottom',
44
- /* translators: Overlay Position */
45
- label: __( 'Bottom', 'newspack-plugin' ),
46
- },
47
- ] : [
48
- {
49
- value: 'top_left',
50
- /* translators: Overlay Position */
51
- label: __( 'Top Left', 'newspack-plugin' ),
52
- },
53
- {
54
- value: 'top',
55
- /* translators: Overlay Position */
56
- label: __( 'Top Center', 'newspack-plugin' ),
57
- },
58
- {
59
- value: 'top_right',
60
- /* translators: Overlay Position */
61
- label: __( 'Top Right', 'newspack-plugin' ),
62
- },
63
- {
64
- value: 'center_left',
65
- /* translators: Overlay Position */
66
- label: __( 'Center Left', 'newspack-plugin' ),
67
- },
68
- {
69
- value: 'center',
70
- /* translators: Overlay Position */
71
- label: __( 'Center', 'newspack-plugin' ),
72
- },
73
- {
74
- value: 'center_right',
75
- /* translators: Overlay Position */
76
- label: __( 'Center Right', 'newspack-plugin' ),
77
- },
78
- {
79
- value: 'bottom_left',
80
- /* translators: Overlay Position */
81
- label: __( 'Bottom Left', 'newspack-plugin' ),
82
- },
83
- {
84
- value: 'bottom',
85
- /* translators: Overlay Position */
86
- label: __( 'Bottom Center', 'newspack-plugin' ),
87
- },
88
- {
89
- value: 'bottom_right',
90
- /* translators: Overlay Position */
91
- label: __( 'Bottom Right', 'newspack-plugin' ),
92
- },
93
- ];
24
+ {
25
+ value: 'top',
26
+ /* translators: Overlay Position */
27
+ label: __( 'Top', 'newspack-plugin' ),
28
+ },
29
+ {
30
+ value: 'center',
31
+ /* translators: Overlay Position */
32
+ label: __( 'Center', 'newspack-plugin' ),
33
+ },
34
+ {
35
+ value: 'bottom',
36
+ /* translators: Overlay Position */
37
+ label: __( 'Bottom', 'newspack-plugin' ),
38
+ },
39
+ ]
40
+ : [
41
+ {
42
+ value: 'top_left',
43
+ /* translators: Overlay Position */
44
+ label: __( 'Top Left', 'newspack-plugin' ),
45
+ },
46
+ {
47
+ value: 'top',
48
+ /* translators: Overlay Position */
49
+ label: __( 'Top Center', 'newspack-plugin' ),
50
+ },
51
+ {
52
+ value: 'top_right',
53
+ /* translators: Overlay Position */
54
+ label: __( 'Top Right', 'newspack-plugin' ),
55
+ },
56
+ {
57
+ value: 'center_left',
58
+ /* translators: Overlay Position */
59
+ label: __( 'Center Left', 'newspack-plugin' ),
60
+ },
61
+ {
62
+ value: 'center',
63
+ /* translators: Overlay Position */
64
+ label: __( 'Center', 'newspack-plugin' ),
65
+ },
66
+ {
67
+ value: 'center_right',
68
+ /* translators: Overlay Position */
69
+ label: __( 'Center Right', 'newspack-plugin' ),
70
+ },
71
+ {
72
+ value: 'bottom_left',
73
+ /* translators: Overlay Position */
74
+ label: __( 'Bottom Left', 'newspack-plugin' ),
75
+ },
76
+ {
77
+ value: 'bottom',
78
+ /* translators: Overlay Position */
79
+ label: __( 'Bottom Center', 'newspack-plugin' ),
80
+ },
81
+ {
82
+ value: 'bottom_right',
83
+ /* translators: Overlay Position */
84
+ label: __( 'Bottom Right', 'newspack-plugin' ),
85
+ },
86
+ ];
94
87
  return (
95
88
  <div className={ classnames( 'newspack-position-placement-control', 'size-' + size ) }>
96
89
  <p className="components-base-control__label">{ label }</p>
97
90
  <ButtonGroup aria-label={ __( 'Select Position', 'newspack-plugin' ) } { ...props }>
98
91
  { options.map( ( option, index ) => {
99
92
  return (
100
- <div
101
- key={ `newspack-position-placement-item-${ index }` }
102
- className={ option.value === value ? 'is-selected' : null }
103
- >
93
+ <div key={ `newspack-position-placement-item-${ index }` } className={ option.value === value ? 'is-selected' : null }>
104
94
  <Button
105
95
  isSmall
106
96
  title={ option.label }
@@ -34,10 +34,7 @@ class ProgressBar extends Component {
34
34
  render() {
35
35
  const { label, completed, total, displayFraction } = this.props;
36
36
  const cleanTotal = Math.max( 0, parseInt( total ) || 0 );
37
- const cleanCompleted = Math.max(
38
- 0,
39
- Math.min( parseInt( completed ) || 0, parseInt( cleanTotal ) )
40
- );
37
+ const cleanCompleted = Math.max( 0, Math.min( parseInt( completed ) || 0, parseInt( cleanTotal ) ) );
41
38
 
42
39
  const barStyle = {
43
40
  width: this.getCompletionPercentage( cleanCompleted, cleanTotal ) + '%',
@@ -59,11 +56,7 @@ class ProgressBar extends Component {
59
56
  ) }
60
57
 
61
58
  <div className="newspack-progress-bar__container">
62
- <div
63
- className="newspack-progress-bar__bar"
64
- style={ barStyle }
65
- data-testid="progress-bar-indicator"
66
- />
59
+ <div className="newspack-progress-bar__bar" style={ barStyle } data-testid="progress-bar-indicator" />
67
60
  </div>
68
61
  </div>
69
62
  );
@@ -23,9 +23,7 @@ describe( 'ProgressBar', () => {
23
23
 
24
24
  it( 'should render with both label and fraction', () => {
25
25
  const label = 'test label';
26
- const { getByText } = render(
27
- <ProgressBar completed="1" total="2" label={ label } displayFraction />
28
- );
26
+ const { getByText } = render( <ProgressBar completed="1" total="2" label={ label } displayFraction /> );
29
27
  expect( getByText( label ) ).toBeInTheDocument();
30
28
  expect( getByText( '1/2' ) ).toBeInTheDocument();
31
29
  } );
@@ -47,26 +45,19 @@ describe( 'ProgressBar', () => {
47
45
  ].forEach( ( { props, expectedWidth } ) => {
48
46
  it( `with expected progress of ${ expectedWidth }`, () => {
49
47
  const { getByTestId } = render( <ProgressBar { ...props } key={ expectedWidth } /> );
50
- expect( getByTestId( 'progress-bar-indicator' ) ).toHaveAttribute(
51
- 'style',
52
- `width: ${ expectedWidth }%;`
53
- );
48
+ expect( getByTestId( 'progress-bar-indicator' ) ).toHaveAttribute( 'style', `width: ${ expectedWidth }%;` );
54
49
  } );
55
50
  } );
56
51
  } );
57
52
 
58
53
  it( 'should handle non-numeric values in ProgressBar element', () => {
59
- const { getByText, getByTestId } = render(
60
- <ProgressBar completed="cats" total="dogs" displayFraction />
61
- );
54
+ const { getByText, getByTestId } = render( <ProgressBar completed="cats" total="dogs" displayFraction /> );
62
55
  expect( getByText( '0/0' ) ).toBeInTheDocument();
63
56
  expect( getByTestId( 'progress-bar-indicator' ) ).toHaveAttribute( 'style', 'width: 100%;' );
64
57
  } );
65
58
 
66
59
  it( 'should handle non-logical values in ProgressBar element', () => {
67
- const { getByText, getByTestId } = render(
68
- <ProgressBar completed="3" total="-1" displayFraction />
69
- );
60
+ const { getByText, getByTestId } = render( <ProgressBar completed="3" total="-1" displayFraction /> );
70
61
  expect( getByText( '0/0' ) ).toBeInTheDocument();
71
62
  expect( getByTestId( 'progress-bar-indicator' ) ).toHaveAttribute( 'style', 'width: 100%;' );
72
63
  } );
@@ -2,7 +2,6 @@
2
2
  * Progress Bar
3
3
  */
4
4
 
5
- @use "../../../shared/scss/colors";
6
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
7
6
 
8
7
  .newspack-progress-bar {
@@ -35,7 +34,7 @@
35
34
  }
36
35
 
37
36
  &__bar {
38
- background-color: colors.$primary-500;
37
+ background-color: var(--wp-admin-theme-color);
39
38
  height: 8px;
40
39
  transition: width 125ms ease-in-out;
41
40
  }
@@ -2,7 +2,6 @@
2
2
  * Radio Control
3
3
  */
4
4
 
5
- @use "../../../shared/scss/colors";
6
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
7
6
 
8
7
  .newspack-radio-control {
@@ -24,7 +23,6 @@
24
23
  }
25
24
 
26
25
  // Options
27
-
28
26
  .components-radio-control__option {
29
27
  align-items: center;
30
28
  display: flex;
@@ -40,20 +38,22 @@
40
38
  }
41
39
 
42
40
  // Radio
43
-
44
41
  input[type="radio"] {
45
42
  height: 24px;
46
- margin-right: 8px;
47
43
  width: 24px;
44
+ max-height: 24px;
45
+ max-width: 24px;
48
46
 
49
47
  @media screen and ( min-width: 782px ) {
50
48
  height: 20px;
51
49
  width: 20px;
50
+ max-height: 20px;
51
+ max-width: 20px;
52
52
  }
53
53
 
54
54
  &:checked {
55
- background-color: colors.$primary-500;
56
- border-color: colors.$primary-500;
55
+ background-color: var(--wp-admin-theme-color);
56
+ border-color: var(--wp-admin-theme-color);
57
57
 
58
58
  &::before {
59
59
  border: none;
@@ -61,20 +61,18 @@
61
61
  }
62
62
 
63
63
  &:focus {
64
- border-color: colors.$primary-500;
65
- box-shadow: 0 0 0 2px white, 0 0 0 3.5px colors.$primary-500;
64
+ border-color: var(--wp-admin-theme-color);
65
+ box-shadow: 0 0 0 2px white, 0 0 0 3.5px var(--wp-admin-theme-color);
66
66
  }
67
67
  }
68
68
 
69
69
  // Multiple Radio Controls
70
-
71
70
  & + & {
72
71
  margin-bottom: 32px;
73
72
  margin-top: -16px;
74
73
  }
75
74
 
76
75
  // Multiple Controls
77
-
78
76
  + .newspack-select-control,
79
77
  + .newspack-text-control {
80
78
  margin-bottom: 32px;
@@ -82,7 +80,6 @@
82
80
  }
83
81
 
84
82
  // Reset
85
-
86
83
  .components-base-control__field,
87
84
  .components-base-control__label,
88
85
  .components-base-control__help {
@@ -18,6 +18,25 @@ import './style.scss';
18
18
  */
19
19
  import classnames from 'classnames';
20
20
 
21
+ /**
22
+ * Represents a section header component.
23
+ *
24
+ * @typedef {Object} SectionHeaderProps
25
+ * @property {boolean} [centered=false] - Indicates if the header is centered.
26
+ * @property {?string} [className=null] - Additional CSS class name.
27
+ * @property {string|Function|*} [description] - Description of the section.
28
+ * @property {number} [heading=2] - HTML heading level, e.g., 1 for h1, 2 for h2, etc.
29
+ * @property {boolean} [isWhite=false] - Indicates if the header should use a white theme.
30
+ * @property {boolean} [noMargin=false] - Indicates if the header should have no margin.
31
+ * @property {string} title - The title of the section.
32
+ * @property {?string} [id=null] - Optional ID for the header element.
33
+ */
34
+
35
+ /**
36
+ * Creates a section header.
37
+ *
38
+ * @param {SectionHeaderProps} props - The properties for the section header.
39
+ */
21
40
  const SectionHeader = ( {
22
41
  centered = false,
23
42
  className = null,
@@ -58,6 +77,7 @@ const SectionHeader = ( {
58
77
  { typeof title === 'function' && <HeadingTag>{ title() }</HeadingTag> }
59
78
  { description && typeof description === 'string' && <p>{ description }</p> }
60
79
  { typeof description === 'function' && <p>{ description() }</p> }
80
+ { description && typeof description !== 'string' && typeof description !== 'function' && <p>{ description }</p> }
61
81
  </Grid>
62
82
  </div>
63
83
  );