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
@@ -3,15 +3,13 @@
3
3
  */
4
4
 
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
- @use "../../../shared/scss/colors";
7
6
 
8
- // Reset Padding of the Admin Page
7
+ // Styling for full-page-react Wizards (ignoring admin-header-only wizards).
8
+ body.newspack-wizard-page:not(.newspack-admin-header) {
9
9
 
10
- .toplevel_page_newspack:not(.menu-top),
11
- body[class*="newspack_page_newspack-"],
12
- body[class*="admin_page_newspack-"] {
13
10
  background: white;
14
11
 
12
+ // Reset Padding
15
13
  #wpcontent {
16
14
  padding-left: 0;
17
15
  }
@@ -20,6 +18,13 @@ body[class*="admin_page_newspack-"] {
20
18
  padding-bottom: 220px;
21
19
  min-height: 100vh;
22
20
 
21
+ // For admin notices directly ">" at top of page above the Wizard header.
22
+ // PHP code should hide these notices, but just incase add this style.
23
+ > .notice {
24
+ margin-bottom: 20px;
25
+ margin-left: 22px;
26
+ }
27
+
23
28
  @media screen and ( min-width: 783px ) {
24
29
  padding-bottom: 202px;
25
30
  }
@@ -30,6 +35,24 @@ body[class*="admin_page_newspack-"] {
30
35
  }
31
36
  }
32
37
 
38
+ // Styling for wizards that are admin-header-only.
39
+ body.newspack-wizard-page.newspack-admin-header {
40
+
41
+ // For mobile.
42
+ @media screen and (max-width: 600px) {
43
+
44
+ // The header bar (and tabs) need padding.
45
+ #newspack-wizards-admin-header {
46
+ padding-top: 46px;
47
+ }
48
+
49
+ // Since the padding was added to the header bar, remove from body.
50
+ #wpbody {
51
+ padding-top: 0;
52
+ }
53
+ }
54
+ }
55
+
33
56
  svg {
34
57
  &.newspack--error {
35
58
  fill: wp-colors.$alert-red;
@@ -41,15 +64,14 @@ svg {
41
64
  }
42
65
 
43
66
  // Blue Screen
44
-
45
67
  .newspack-wizard__blue {
46
68
  #wpwrap {
47
- background: colors.$primary-500;
69
+ background: var(--wp-admin-theme-color);
48
70
  }
49
71
 
50
72
  .newspack-footer {
51
- background: colors.$primary-500;
52
- border-color: colors.$primary-500;
73
+ background: var(--wp-admin-theme-color);
74
+ border-color: var(--wp-admin-theme-color);
53
75
  justify-content: center;
54
76
 
55
77
  &__logo {
@@ -73,7 +95,6 @@ svg {
73
95
  }
74
96
 
75
97
  // Loading
76
-
77
98
  .newspack-wizard__is-loading {
78
99
  background: white;
79
100
  cursor: wait;
@@ -92,7 +113,7 @@ svg {
92
113
  }
93
114
 
94
115
  &::before {
95
- background: colors.$primary-500;
116
+ background: var(--wp-admin-theme-color);
96
117
  box-shadow:
97
118
  24px 0 0 white,
98
119
  69px 0 0 -15px wp-colors.$gray-900,
@@ -137,7 +158,7 @@ svg {
137
158
 
138
159
  // Blue Screen
139
160
  .newspack-wizard__blue & {
140
- background: colors.$primary-500;
161
+ background: var(--wp-admin-theme-color);
141
162
 
142
163
  &::before {
143
164
  animation: loading-quiet 1.25s ease-in-out infinite;
@@ -193,7 +214,7 @@ svg {
193
214
 
194
215
  &::before {
195
216
  animation: loading-quiet 1.25s ease-in-out infinite;
196
- background: colors.$primary-500;
217
+ background: var(--wp-admin-theme-color);
197
218
  height: 8px;
198
219
  right: 100%;
199
220
  z-index: 9999;
@@ -8,7 +8,7 @@ import { category } from '@wordpress/icons';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { Button, Handoff, NewspackIcon, Notice, HandoffMessage, TabbedNavigation } from '../';
11
- import { buttonProps } from '../../../shared/js/';
11
+ import { buttonProps } from '../button-props';
12
12
  import './style.scss';
13
13
 
14
14
  /**
@@ -3,16 +3,16 @@
3
3
  */
4
4
 
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
- @use "../../../shared/scss/colors";
6
+ @use "../../../colors/colors.module" as colors;
7
7
 
8
8
  .newspack-wizard {
9
9
  // Color
10
- --wp-admin-theme-color: #{colors.$primary-500};
11
- --wp-admin-theme-color--rgb: #{colors.$primary-500--rgb};
12
- --wp-admin-theme-color-darker-10: #{colors.$primary-600};
13
- --wp-admin-theme-color-darker-10--rgb: #{colors.$primary-600--rgb};
14
- --wp-admin-theme-color-darker-20: #{colors.$primary-700};
15
- --wp-admin-theme-color-darker-20--rgb: #{colors.$primary-700--rgb};
10
+ --wp-admin-theme-color: #{colors.$primary-600};
11
+ --wp-admin-theme-color--rgb: #{colors.$primary-600--rgb};
12
+ --wp-admin-theme-color-darker-10: #{colors.$primary-700};
13
+ --wp-admin-theme-color-darker-10--rgb: #{colors.$primary-700--rgb};
14
+ --wp-admin-theme-color-darker-20: #{colors.$primary-800};
15
+ --wp-admin-theme-color-darker-20--rgb: #{colors.$primary-800--rgb};
16
16
 
17
17
  color: wp-colors.$gray-900;
18
18
 
@@ -83,7 +83,7 @@
83
83
  }
84
84
 
85
85
  &:not(.newspack-icon) {
86
- background: colors.$primary-500;
86
+ background: var(--wp-admin-theme-color);
87
87
  left: 50%;
88
88
  margin: -28px 0 0 -28px !important;
89
89
  opacity: 0;
@@ -125,7 +125,7 @@
125
125
  padding: 0 16px;
126
126
 
127
127
  @media screen and ( min-width: 744px ) {
128
- padding: 32px 84px;
128
+ padding: 40px 84px;
129
129
  }
130
130
 
131
131
  // Typography
@@ -33,10 +33,7 @@ const WizardError = () => {
33
33
  if ( 'fatal' === level ) {
34
34
  const fallbackURL = typeof newspack_urls !== 'undefined' && newspack_urls.dashboard;
35
35
  return (
36
- <Modal
37
- title={ __( 'Unrecoverable error' ) }
38
- onRequestClose={ fallbackURL ? () => ( window.location = fallbackURL ) : undefined }
39
- >
36
+ <Modal title={ __( 'Unrecoverable error' ) } onRequestClose={ fallbackURL ? () => ( window.location = fallbackURL ) : undefined }>
40
37
  <Notice noticeText={ message } isError rawHTML />
41
38
  { fallbackURL && (
42
39
  <Card buttonsCard noBorder className="justify-end">
@@ -49,9 +46,7 @@ const WizardError = () => {
49
46
  );
50
47
  }
51
48
 
52
- return (
53
- <Notice isError className="newspack-wizard__above-header" noticeText={ message } rawHTML />
54
- );
49
+ return <Notice isError className="newspack-wizard__above-header" noticeText={ message } rawHTML />;
55
50
  };
56
51
 
57
52
  export default WizardError;
@@ -7,96 +7,107 @@ import classnames from 'classnames';
7
7
  * WordPress dependencies.
8
8
  */
9
9
  import { useSelect } from '@wordpress/data';
10
- import { useState } from '@wordpress/element';
10
+ import { useState, forwardRef } from '@wordpress/element';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { category } from '@wordpress/icons';
13
13
 
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import {
18
- Footer,
19
- Notice,
20
- Button,
21
- NewspackIcon,
22
- TabbedNavigation,
23
- PluginInstaller,
24
- HandoffMessage,
25
- } from '../';
17
+ import { Footer, Notice, Button, NewspackIcon, TabbedNavigation, PluginInstaller, HandoffMessage } from '../';
26
18
  import Router from '../proxied-imports/router';
27
19
  import registerStore, { WIZARD_STORE_NAMESPACE } from './store';
28
- import { useWizardData } from './store/utils';
29
20
  import WizardError from './components/WizardError';
30
21
 
31
22
  registerStore();
32
23
 
33
24
  const { HashRouter, Redirect, Route, Switch } = Router;
34
25
 
35
- const Wizard = ( {
36
- sections = [],
37
- apiSlug,
38
- headerText,
39
- subHeaderText,
40
- hasSimpleFooter,
41
- className,
42
- renderAboveSections,
43
- requiredPlugins = [],
44
- } ) => {
26
+ /**
27
+ * @typedef {Object} WizardProps
28
+ * @property {string} headerText The header text.
29
+ * @property {string} [subHeaderText] The sub-header text, optional.
30
+ * @property {string} [apiSlug] The API slug, optional.
31
+ * @property {string} [className] CSS classes, optional.
32
+ * @property {any[]} sections Array of sections.
33
+ * @property {boolean} [hasSimpleFooter] Indicates if a simple footer is used, optional.
34
+ * @property {() => void} [renderAboveSections] Function to render content above sections, optional.
35
+ * @property {string[]} [requiredPlugins] Array of required plugin strings, optional.
36
+ * @property {boolean} [isInitialFetchTriggered] Indicates if the initial fetch should be triggered, optional.
37
+ */
38
+
39
+ /**
40
+ * Wizard Component
41
+ *
42
+ * Provides a tabbed UI with history.
43
+ *
44
+ * @param {WizardProps} props
45
+ * @return {JSX.Element} Wizard component
46
+ */
47
+ const Wizard = (
48
+ {
49
+ sections = [],
50
+ headerText,
51
+ apiSlug,
52
+ subHeaderText,
53
+ hasSimpleFooter,
54
+ className,
55
+ renderAboveSections,
56
+ requiredPlugins = [],
57
+ isInitialFetchTriggered = true,
58
+ },
59
+ ref
60
+ ) => {
45
61
  const isLoading = useSelect( select => select( WIZARD_STORE_NAMESPACE ).isLoading() );
46
62
  const isQuietLoading = useSelect( select => select( WIZARD_STORE_NAMESPACE ).isQuietLoading() );
47
63
 
48
64
  // Trigger initial data fetch. Some sections might not use the wizard data,
49
65
  // but for consistency, fetching is triggered regardless of the section.
50
- useSelect( select => select( WIZARD_STORE_NAMESPACE ).getWizardAPIData( apiSlug ) );
66
+ useSelect( select => isInitialFetchTriggered && select( WIZARD_STORE_NAMESPACE ).getWizardAPIData( apiSlug ) );
51
67
 
52
68
  let displayedSections = sections.filter( section => ! section.isHidden );
53
69
 
54
- const [ pluginRequirementsSatisfied, setPluginRequirementsSatisfied ] = useState(
55
- requiredPlugins.length === 0
56
- );
70
+ const [ pluginRequirementsSatisfied, setPluginRequirementsSatisfied ] = useState( requiredPlugins.length === 0 );
57
71
  if ( ! pluginRequirementsSatisfied ) {
58
- headerText =
59
- requiredPlugins.length > 1
60
- ? __( 'Required plugins', 'newspack-plugin' )
61
- : __( 'Required plugin', 'newspack-plugin' );
72
+ headerText = requiredPlugins.length > 1 ? __( 'Required plugins', 'newspack-plugin' ) : __( 'Required plugin', 'newspack-plugin' );
62
73
  displayedSections = [
63
74
  {
64
75
  path: '/',
65
76
  render: () => (
66
- <PluginInstaller
67
- plugins={ requiredPlugins }
68
- onStatus={ ( { complete } ) => setPluginRequirementsSatisfied( complete ) }
69
- />
77
+ <PluginInstaller plugins={ requiredPlugins } onStatus={ ( { complete } ) => setPluginRequirementsSatisfied( complete ) } />
70
78
  ),
71
79
  },
72
80
  ];
73
81
  }
74
82
 
83
+ const urlWithoutHash = window.location.href.split( '#' )[ 0 ];
84
+
75
85
  return (
76
- <>
86
+ <div ref={ ref }>
77
87
  <div
78
- className={ classnames(
79
- isLoading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded',
80
- {
81
- 'newspack-wizard__is-loading-quiet': isQuietLoading,
82
- }
83
- ) }
88
+ className={ classnames( isLoading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded', {
89
+ 'newspack-wizard__is-loading-quiet': isQuietLoading,
90
+ } ) }
84
91
  >
85
92
  <HashRouter hashType="slash">
86
93
  { newspack_aux_data.is_debug_mode && <Notice debugMode /> }
87
94
  <div className="bg-white">
88
95
  <div className="newspack-wizard__header__inner">
89
96
  <div className="newspack-wizard__title">
90
- <Button
91
- isLink
92
- href={ newspack_urls.dashboard }
93
- label={ __( 'Return to Dashboard', 'newspack-plugin' ) }
94
- showTooltip={ true }
95
- icon={ category }
96
- iconSize={ 36 }
97
- >
97
+ { newspack_urls.dashboard !== urlWithoutHash ? (
98
+ <Button
99
+ isLink
100
+ href={ newspack_urls.dashboard }
101
+ label={ __( 'Return to Dashboard', 'newspack-plugin' ) }
102
+ showTooltip={ true }
103
+ icon={ category }
104
+ iconSize={ 36 }
105
+ >
106
+ <NewspackIcon size={ 36 } />
107
+ </Button>
108
+ ) : (
98
109
  <NewspackIcon size={ 36 } />
99
- </Button>
110
+ ) }
100
111
  <div>
101
112
  { headerText && <h2>{ headerText }</h2> }
102
113
  { subHeaderText && <span>{ subHeaderText }</span> }
@@ -116,13 +127,8 @@ const Wizard = ( {
116
127
  { displayedSections.map( ( section, index ) => {
117
128
  const SectionComponent = section.render;
118
129
  return (
119
- <Route key={ index } path={ section.path }>
120
- <div
121
- className={ classnames(
122
- 'newspack-wizard newspack-wizard__content',
123
- className
124
- ) }
125
- >
130
+ <Route key={ index } exact={ section.exact ?? false } path={ section.path }>
131
+ <div className={ classnames( 'newspack-wizard__content', className ) }>
126
132
  { 'function' === typeof renderAboveSections ? renderAboveSections() : null }
127
133
  <SectionComponent />
128
134
  </div>
@@ -134,12 +140,8 @@ const Wizard = ( {
134
140
  </HashRouter>
135
141
  </div>
136
142
  { ! isLoading && <Footer simple={ hasSimpleFooter } /> }
137
- </>
143
+ </div>
138
144
  );
139
145
  };
140
146
 
141
- Wizard.useWizardData = useWizardData;
142
-
143
- Wizard.STORE_NAMESPACE = WIZARD_STORE_NAMESPACE;
144
-
145
- export default Wizard;
147
+ export default forwardRef( Wizard );
@@ -16,7 +16,7 @@ import { createAction } from './utils.js';
16
16
  export const WIZARD_STORE_NAMESPACE = 'newspack/wizards';
17
17
 
18
18
  const DEFAULT_STATE = {
19
- isLoading: true,
19
+ isLoading: false,
20
20
  isQuietLoading: false,
21
21
  apiData: {},
22
22
  error: null,
@@ -59,13 +59,7 @@ const actions = {
59
59
  setError: createAction( 'SET_ERROR' ),
60
60
 
61
61
  // Async actions. These will not show up in Redux devtools.
62
- *saveWizardSettings( {
63
- slug,
64
- section = '',
65
- payloadPath = false,
66
- auxData = {},
67
- updatePayload = null,
68
- } ) {
62
+ *saveWizardSettings( { slug, section = '', payloadPath = false, auxData = {}, updatePayload = null } ) {
69
63
  // Optionally data can be updated before saving - an immediate update case
70
64
  // (without an explicit "save" action).
71
65
  if ( updatePayload ) {
@@ -94,6 +88,7 @@ const selectors = {
94
88
  isLoading: state => state.isLoading,
95
89
  isQuietLoading: state => state.isQuietLoading,
96
90
  getWizardAPIData: ( state, slug ) => state.apiData[ slug ] || {},
91
+ getWizardData: ( state, slug ) => state.apiData[ slug ] ?? {},
97
92
  getError: state => state.error,
98
93
  };
99
94
 
@@ -104,8 +99,9 @@ const store = createReduxStore( WIZARD_STORE_NAMESPACE, {
104
99
 
105
100
  controls: {
106
101
  FETCH_FROM_API: action => {
102
+ const { isLocalError = false, isQuietFetch = false } = action.payload;
107
103
  dispatch( WIZARD_STORE_NAMESPACE ).startLoadingData( {
108
- isQuietLoading: Boolean( action.payload.isQuietFetch ),
104
+ isQuietLoading: Boolean( isQuietFetch ),
109
105
  } );
110
106
  return apiFetch( action.payload )
111
107
  .then( data => {
@@ -113,8 +109,10 @@ const store = createReduxStore( WIZARD_STORE_NAMESPACE, {
113
109
  return data;
114
110
  } )
115
111
  .catch( error => {
112
+ if ( isLocalError ) {
113
+ throw error;
114
+ }
116
115
  dispatch( WIZARD_STORE_NAMESPACE ).setError( error );
117
- return { error };
118
116
  } )
119
117
  .finally( result => {
120
118
  dispatch( WIZARD_STORE_NAMESPACE ).finishLoadingData();
@@ -10,7 +10,6 @@ import { WIZARD_STORE_NAMESPACE } from '.';
10
10
 
11
11
  export const createAction = type => payload => ( { type, payload } );
12
12
 
13
- export const useWizardData = ( wizardName, defaultValue = {} ) =>
14
- useSelect( select =>
15
- select( WIZARD_STORE_NAMESPACE ).getWizardAPIData( `newspack-${ wizardName }-wizard` )
16
- ) || defaultValue;
13
+ export const useWizardData = ( wizardName, defaultValue = {} ) => {
14
+ return useSelect( select => select( WIZARD_STORE_NAMESPACE ).getWizardAPIData( wizardName ) ) || defaultValue;
15
+ };
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _reactDaterangePicker = _interopRequireDefault(require("react-daterange-picker"));
9
- var _moment = _interopRequireDefault(require("moment"));
10
- var _momentRange = require("moment-range");
11
- require("react-daterange-picker/dist/css/react-calendar.css");
12
- require("./style.scss");
13
- var _jsxRuntime = require("react/jsx-runtime");
14
- /**
15
- * External dependencies.
16
- */
17
-
18
- /**
19
- * Internal dependencies.
20
- */
21
-
22
- const moment = (0, _momentRange.extendMoment)(_moment.default);
23
- const DateRangePicker = ({
24
- start,
25
- end,
26
- onChange
27
- }) => {
28
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactDaterangePicker.default, {
29
- value: moment.range(moment(start), moment(end)),
30
- firstOfWeek: 1,
31
- onSelect: range => {
32
- onChange({
33
- start: range.start._d,
34
- end: range.end._d
35
- });
36
- }
37
- });
38
- };
39
- var _default = exports.default = DateRangePicker;
@@ -1,148 +0,0 @@
1
- @use "../../../shared/scss/colors";
2
- @use "~@wordpress/base-styles/colors" as wp-colors;
3
-
4
- .DateRangePicker {
5
- margin: 32px 0;
6
- max-width: 296px;
7
- width: 100%;
8
-
9
- &__PaginationArrow {
10
- background: transparent 50% 50% no-repeat;
11
- background-size: 24px 24px;
12
- border-radius: 3px;
13
- height: 36px;
14
- transition: background-image 125ms ease-in-out;
15
- width: 36px;
16
-
17
- &--previous {
18
- background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" fill="%231e1e1e"/%3E%3C/svg%3E');
19
- left: 0;
20
-
21
- &:hover {
22
- background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" fill="%2336f"/%3E%3C/svg%3E');
23
- }
24
- }
25
-
26
- &--next {
27
- background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" fill="%231e1e1e"/%3E%3C/svg%3E');
28
- right: 0;
29
-
30
- &:hover {
31
- background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" fill="%2336f"/%3E%3C/svg%3E');
32
- }
33
- }
34
-
35
- &:hover {
36
- background-color: transparent;
37
- }
38
- }
39
-
40
- &__PaginationArrowIcon {
41
- display: none;
42
- }
43
-
44
- &__Month {
45
- margin: 0;
46
- width: inherit;
47
- }
48
-
49
- &__MonthHeader {
50
- color: wp-colors.$gray-900;
51
- font-size: 17px;
52
- height: auto;
53
- line-height: 24px;
54
- padding: 6px 44px;
55
- }
56
-
57
- &__WeekdayHeading,
58
- &__Date {
59
- font-size: 14px;
60
- line-height: 24px;
61
- padding: 6px 0;
62
- }
63
-
64
- &__WeekdayHeading {
65
- border-bottom-color: wp-colors.$gray-300;
66
- color: wp-colors.$gray-900;
67
-
68
- abbr[title] {
69
- color: inherit;
70
- }
71
- }
72
-
73
- &__MonthDates {
74
- border: 0;
75
- border-spacing: 0;
76
- }
77
-
78
- &__Date {
79
- border-color: wp-colors.$gray-300;
80
- border-bottom-width: 1px;
81
-
82
- &--weekend {
83
- background-color: wp-colors.$gray-100;
84
- }
85
-
86
- &--otherMonth {
87
- color: wp-colors.$gray-200;
88
- opacity: 1;
89
- }
90
-
91
- &--is-disabled {
92
- color: wp-colors.$gray-100;
93
- cursor: not-allowed;
94
- }
95
-
96
- &--is-highlighted {
97
- color: white;
98
- }
99
- }
100
-
101
- &__CalendarSelection,
102
- &__CalendarHighlight {
103
- border-color: colors.$primary-500;
104
- bottom: 4px;
105
- top: 4px;
106
-
107
- &--inOtherMonth {
108
- opacity: 1;
109
- }
110
-
111
- &--start {
112
- border-bottom-left-radius: 3px;
113
- border-top-left-radius: 3px;
114
- left: 4px;
115
- }
116
-
117
- &--end {
118
- border-bottom-right-radius: 3px;
119
- border-top-right-radius: 3px;
120
- right: 4px;
121
- }
122
-
123
- &--single {
124
- border: none;
125
- border-radius: 3px;
126
- left: 4px;
127
- right: 4px;
128
- }
129
- }
130
-
131
- &__CalendarSelection {
132
- background-color: colors.$primary-500;
133
- }
134
-
135
- &__CalendarHighlight {
136
- background: colors.$primary-500;
137
- border: none;
138
- bottom: 0;
139
- top: 0;
140
-
141
- &--single {
142
- border: none;
143
- border-radius: 0;
144
- left: 0;
145
- right: 0;
146
- }
147
- }
148
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _element = require("@wordpress/element");
9
- var _components = require("@wordpress/components");
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- require("./style.scss");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- /**
14
- * Newspack Logo.
15
- */
16
-
17
- /**
18
- * WordPress dependencies.
19
- */
20
-
21
- /**
22
- * External dependencies.
23
- */
24
-
25
- /**
26
- * Internal dependencies.
27
- */
28
-
29
- class NewspackLogo extends _element.Component {
30
- /**
31
- * Render
32
- */
33
- render() {
34
- const {
35
- centered,
36
- className,
37
- height
38
- } = this.props;
39
- const classes = (0, _classnames.default)('newspack-logo__svg', centered && 'is-centered', className);
40
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SVG, {
41
- xmlns: "http://www.w3.org/2000/svg",
42
- height: height,
43
- viewBox: "0 0 221 64",
44
- className: classes,
45
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Path, {
46
- d: "M32 0c17.672 0 32 14.328 32 32S49.672 64 32 64C14.326 64 0 49.672 0 32S14.328 0 32 0zm130.57 27.247c3.611 0 6.475 2.521 6.475 7.974 0 5.417-3.134 8.995-8.314 8.995-1.262 0-2.248-.172-3.305-.376v8.551h-4.022V27.67h3.85v1.486c1.534-1.191 3.237-1.908 5.316-1.908zM18.023 17.755v28.49h6.902V34.287l11.733 11.958h9.319l-27.954-28.49zm178.552 9.495c2.009 0 3.219.34 4.581.784v3.407c-1.158-.444-2.878-.921-4.513-.921-2.453 0-4.532 1.294-4.532 5.076 0 4.156 2.077 5.383 4.736 5.387 1.262 0 2.676-.273 4.516-.99v3.34c-1.636.544-3.118.92-5.025.92-6.033 0-8.417-3.442-8.417-8.45 0-5.283 3.305-8.553 8.654-8.553zm-18.195-.003c3.919 0 6.44 1.567 6.435 6.235V43.84h-3.747v-1.771h-.103c-1.327 1.022-2.93 2.079-5.314 2.079-2.112 0-4.36-1.534-4.36-4.6 0-4.133 3.545-4.912 5.997-5.252l3.51-.477v-.47c0-2.181-.886-2.897-2.93-2.897-.989 0-3.338.305-5.28 1.09l-.341-3.237c1.738-.614 4.123-1.058 6.133-1.058zm-73.55-.12c5.145 0 6.951 3.579 6.951 6.987 0 .936-.047 1.518-.102 2.06l-.034.325h-10.358c.101 3.542 2.106 4.36 5.104 4.36 1.637 0 3.158-.372 4.845-.991v3.342c-2.093.644-3.89.921-5.968.921-5.141 0-8.308-2.556-8.308-8.586 0-4.398 2.69-8.417 7.87-8.417zm39.998 0c1.771 0 3.305.172 4.804.614v3.338s-2.188-.714-4.497-.714c-1.43 0-2.76.477-2.76 1.703 0 2.725 8.042 1.262 8.04 6.883 0 4.053-3.611 5.178-7.394 5.178-1.738 0-3.487-.467-4.736-.958v-3.305c1.5.52 3.578 1.026 4.873 1.026 1.84 0 3.1-.374 3.1-1.771 0-2.829-8.04-1.33-8.04-7.156 0-2.998 2.724-4.837 6.61-4.837zm64.01-6.114v13.63c.34-.376.615-.785 5.657-6.952h5.213l-6.543 7.666 7.156 8.485h-5.248l-6.235-7.665v7.665h-4.02v-22.83h4.02zm-127.634 0l8.633 15.263V21.013h4.022v22.83h-4.416L80.81 28.578v15.263h-4.021v-22.83h4.416zm36.758 6.678l2.476 11.469 2.801-11.469h3.572l2.438 11.469 2.75-11.469h4.038l-4.54 16.151h-4.83l-1.714-9.495-2.325 9.495h-4.814l-4.268-16.15h4.416zm62.836 8.616l-3.305.512c-.987.136-2.044.732-2.044 2.231 0 1.322.75 2.067 1.84 2.067 1.157 0 2.452-.716 3.509-1.466v-3.344zm-19.318-5.752c-1.193 0-2.657.545-4.054 1.771v8.415c.885.17 1.77.306 2.997.306 2.829 0 4.464-1.805 4.464-5.517 0-3.476-1.158-4.975-3.407-4.975zm-56.685-.394c-2.009 0-3.235 1.43-3.475 3.678h6.268c0-1.975-.646-3.678-2.793-3.678zm-58.818.836H40.33l2.205 2.248h3.442v-2.248zm0-6.621H33.833l2.205 2.248h9.939v-2.248zm0-6.621h-18.64l2.204 2.248h16.436v-2.248z"
47
- })
48
- });
49
- }
50
- }
51
- NewspackLogo.defaultProps = {
52
- height: 56
53
- };
54
- var _default = exports.default = NewspackLogo;