newspack-components 2.0.3 → 2.1.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 (248) hide show
  1. package/copy-styles.js +1 -1
  2. package/dist/cjs/action-card/index.js +29 -20
  3. package/dist/cjs/action-card/style.scss +52 -27
  4. package/dist/cjs/autocomplete-tokenfield/style.scss +4 -4
  5. package/dist/cjs/autocomplete-with-suggestions/index.js +3 -2
  6. package/dist/cjs/autocomplete-with-suggestions/style.scss +19 -20
  7. package/dist/cjs/button/index.js +2 -13
  8. package/dist/cjs/button/style.scss +3 -344
  9. package/dist/cjs/button-card/index.js +11 -6
  10. package/dist/cjs/button-card/style.scss +60 -30
  11. package/dist/cjs/card/index.js +3 -1
  12. package/dist/cjs/card/style.scss +29 -62
  13. package/dist/cjs/category-autocomplete/index.js +52 -13
  14. package/dist/cjs/category-autocomplete/style.scss +20 -22
  15. package/dist/cjs/color-picker/index.js +17 -35
  16. package/dist/cjs/color-picker/style.scss +20 -160
  17. package/dist/cjs/custom-select-control/style.scss +12 -42
  18. package/dist/cjs/footer/index.js +21 -7
  19. package/dist/cjs/footer/style.scss +9 -10
  20. package/dist/cjs/form-token-field/index.js +2 -2
  21. package/dist/cjs/form-token-field/style.scss +8 -103
  22. package/dist/cjs/global-notices/index.js +2 -1
  23. package/dist/cjs/grid/style.scss +14 -1
  24. package/dist/cjs/handoff/index.js +7 -7
  25. package/dist/cjs/image-upload/index.js +1 -1
  26. package/dist/cjs/image-upload/style.scss +10 -11
  27. package/dist/cjs/index.js +7 -53
  28. package/dist/cjs/modal/index.js +0 -3
  29. package/dist/cjs/modal/style.scss +19 -131
  30. package/dist/cjs/newspack-icon/index.js +4 -2
  31. package/dist/cjs/newspack-icon/style.scss +15 -0
  32. package/dist/cjs/notice/index.js +8 -9
  33. package/dist/cjs/notice/style.scss +38 -10
  34. package/dist/cjs/plugin-installer/index.js +1 -1
  35. package/dist/cjs/plugin-settings/SettingsSection.js +74 -43
  36. package/dist/cjs/plugin-settings/index.js +34 -30
  37. package/dist/cjs/plugin-settings/style.scss +7 -0
  38. package/dist/cjs/plugin-toggle/index.js +22 -1
  39. package/dist/cjs/popover/style.scss +2 -2
  40. package/dist/cjs/radio-control/style.scss +1 -2
  41. package/dist/cjs/section-header/index.js +18 -5
  42. package/dist/cjs/section-header/style.scss +22 -1
  43. package/dist/cjs/select-control/ButtonGroupControl.js +8 -8
  44. package/dist/cjs/select-control/GroupedSelectControl.js +33 -30
  45. package/dist/cjs/select-control/index.js +1 -2
  46. package/dist/cjs/select-control/style.scss +46 -87
  47. package/dist/cjs/settings/MinMaxSetting.js +4 -2
  48. package/dist/cjs/settings/SettingsCard.js +6 -1
  49. package/dist/cjs/settings/SettingsSection.js +4 -4
  50. package/dist/cjs/settings/style.scss +32 -4
  51. package/dist/cjs/style-card/index.js +10 -6
  52. package/dist/cjs/style-card/style.scss +12 -8
  53. package/dist/cjs/style.scss +44 -0
  54. package/dist/cjs/tabbed-navigation/index.js +13 -20
  55. package/dist/cjs/tabbed-navigation/style.scss +56 -34
  56. package/dist/cjs/text-control/index.js +0 -3
  57. package/dist/cjs/text-control/style.scss +0 -126
  58. package/dist/cjs/waiting/index.js +9 -25
  59. package/dist/cjs/waiting/style.scss +9 -20
  60. package/dist/cjs/web-preview/index.js +18 -30
  61. package/dist/cjs/web-preview/style.scss +33 -26
  62. package/dist/cjs/with-wizard/index.js +4 -2
  63. package/dist/cjs/with-wizard/style.scss +44 -89
  64. package/dist/cjs/with-wizard-screen/index.js +17 -21
  65. package/dist/cjs/with-wizard-screen/style.scss +74 -121
  66. package/dist/cjs/wizard/components/WizardError.js +86 -0
  67. package/dist/cjs/wizard/index.js +145 -0
  68. package/dist/cjs/wizard/store/index.js +178 -0
  69. package/dist/cjs/wizard/store/utils.js +31 -0
  70. package/dist/esm/action-card/index.js +30 -21
  71. package/dist/esm/action-card/style.scss +52 -27
  72. package/dist/esm/autocomplete-tokenfield/style.scss +4 -4
  73. package/dist/esm/autocomplete-with-suggestions/index.js +3 -2
  74. package/dist/esm/autocomplete-with-suggestions/style.scss +19 -20
  75. package/dist/esm/button/index.js +2 -12
  76. package/dist/esm/button/style.scss +3 -344
  77. package/dist/esm/button-card/index.js +10 -6
  78. package/dist/esm/button-card/style.scss +60 -30
  79. package/dist/esm/card/index.js +3 -1
  80. package/dist/esm/card/style.scss +29 -62
  81. package/dist/esm/category-autocomplete/index.js +54 -14
  82. package/dist/esm/category-autocomplete/style.scss +20 -22
  83. package/dist/esm/color-picker/index.js +15 -34
  84. package/dist/esm/color-picker/style.scss +20 -160
  85. package/dist/esm/custom-select-control/style.scss +12 -42
  86. package/dist/esm/footer/index.js +21 -7
  87. package/dist/esm/footer/style.scss +9 -10
  88. package/dist/esm/form-token-field/index.js +2 -2
  89. package/dist/esm/form-token-field/style.scss +8 -103
  90. package/dist/esm/global-notices/index.js +2 -1
  91. package/dist/esm/grid/style.scss +14 -1
  92. package/dist/esm/handoff/index.js +7 -7
  93. package/dist/esm/image-upload/index.js +1 -1
  94. package/dist/esm/image-upload/style.scss +10 -11
  95. package/dist/esm/index.js +3 -8
  96. package/dist/esm/modal/index.js +0 -3
  97. package/dist/esm/modal/style.scss +19 -131
  98. package/dist/esm/newspack-icon/index.js +4 -2
  99. package/dist/esm/newspack-icon/style.scss +15 -0
  100. package/dist/esm/notice/index.js +8 -3
  101. package/dist/esm/notice/style.scss +38 -10
  102. package/dist/esm/plugin-installer/index.js +2 -1
  103. package/dist/esm/plugin-settings/SettingsSection.js +72 -44
  104. package/dist/esm/plugin-settings/index.js +34 -30
  105. package/dist/esm/plugin-settings/style.scss +7 -0
  106. package/dist/esm/plugin-toggle/index.js +23 -1
  107. package/dist/esm/popover/style.scss +2 -2
  108. package/dist/esm/radio-control/style.scss +1 -2
  109. package/dist/esm/section-header/index.js +17 -5
  110. package/dist/esm/section-header/style.scss +22 -1
  111. package/dist/esm/select-control/ButtonGroupControl.js +8 -8
  112. package/dist/esm/select-control/GroupedSelectControl.js +33 -30
  113. package/dist/esm/select-control/index.js +1 -2
  114. package/dist/esm/select-control/style.scss +46 -87
  115. package/dist/esm/settings/MinMaxSetting.js +3 -2
  116. package/dist/esm/settings/SettingsCard.js +6 -1
  117. package/dist/esm/settings/SettingsSection.js +5 -5
  118. package/dist/esm/settings/style.scss +32 -4
  119. package/dist/esm/style-card/index.js +11 -8
  120. package/dist/esm/style-card/style.scss +12 -8
  121. package/dist/esm/style.scss +44 -0
  122. package/dist/esm/tabbed-navigation/index.js +14 -22
  123. package/dist/esm/tabbed-navigation/style.scss +56 -34
  124. package/dist/esm/text-control/index.js +0 -3
  125. package/dist/esm/text-control/style.scss +0 -126
  126. package/dist/esm/waiting/index.js +9 -22
  127. package/dist/esm/waiting/style.scss +9 -20
  128. package/dist/esm/web-preview/index.js +12 -25
  129. package/dist/esm/web-preview/style.scss +33 -26
  130. package/dist/esm/with-wizard/index.js +4 -2
  131. package/dist/esm/with-wizard/style.scss +44 -89
  132. package/dist/esm/with-wizard-screen/index.js +18 -22
  133. package/dist/esm/with-wizard-screen/style.scss +74 -121
  134. package/dist/esm/wizard/components/WizardError.js +78 -0
  135. package/dist/esm/wizard/index.js +128 -0
  136. package/dist/esm/wizard/store/index.js +161 -0
  137. package/dist/esm/wizard/store/utils.js +17 -0
  138. package/package.json +1 -1
  139. package/shared/scss/_colors.scss +15 -0
  140. package/src/action-card/index.js +28 -18
  141. package/src/action-card/style.scss +52 -27
  142. package/src/autocomplete-tokenfield/style.scss +4 -4
  143. package/src/autocomplete-with-suggestions/index.js +4 -2
  144. package/src/autocomplete-with-suggestions/style.scss +19 -20
  145. package/src/button/index.js +2 -9
  146. package/src/button/style.scss +3 -344
  147. package/src/button-card/index.js +19 -5
  148. package/src/button-card/style.scss +60 -30
  149. package/src/card/index.js +4 -0
  150. package/src/card/style.scss +29 -62
  151. package/src/category-autocomplete/index.js +51 -18
  152. package/src/category-autocomplete/style.scss +20 -22
  153. package/src/color-picker/index.js +16 -22
  154. package/src/color-picker/style.scss +20 -160
  155. package/src/custom-select-control/style.scss +12 -42
  156. package/src/footer/index.js +19 -8
  157. package/src/footer/style.scss +9 -10
  158. package/src/form-token-field/index.js +1 -1
  159. package/src/form-token-field/style.scss +8 -103
  160. package/src/global-notices/index.js +1 -1
  161. package/src/grid/style.scss +14 -1
  162. package/src/handoff/index.js +7 -7
  163. package/src/image-upload/style.scss +10 -11
  164. package/src/index.js +3 -7
  165. package/src/modal/index.js +2 -5
  166. package/src/modal/style.scss +19 -131
  167. package/src/newspack-icon/index.js +7 -2
  168. package/src/newspack-icon/style.scss +15 -0
  169. package/src/notice/index.js +7 -1
  170. package/src/notice/style.scss +38 -10
  171. package/src/plugin-installer/index.js +2 -2
  172. package/src/plugin-settings/SettingsSection.js +64 -26
  173. package/src/plugin-settings/index.js +23 -7
  174. package/src/plugin-settings/style.scss +7 -0
  175. package/src/plugin-toggle/index.js +35 -9
  176. package/src/popover/style.scss +2 -2
  177. package/src/radio-control/style.scss +1 -2
  178. package/src/section-header/index.js +25 -6
  179. package/src/section-header/style.scss +22 -1
  180. package/src/select-control/ButtonGroupControl.js +13 -6
  181. package/src/select-control/GroupedSelectControl.js +26 -24
  182. package/src/select-control/index.js +1 -2
  183. package/src/select-control/style.scss +46 -87
  184. package/src/settings/MinMaxSetting.js +2 -1
  185. package/src/settings/SettingsCard.js +9 -7
  186. package/src/settings/SettingsSection.js +4 -4
  187. package/src/settings/style.scss +32 -4
  188. package/src/style-card/index.js +14 -16
  189. package/src/style-card/style.scss +12 -8
  190. package/src/style.scss +44 -0
  191. package/src/tabbed-navigation/index.js +12 -24
  192. package/src/tabbed-navigation/style.scss +56 -34
  193. package/src/text-control/index.js +1 -2
  194. package/src/text-control/style.scss +0 -126
  195. package/src/waiting/index.js +7 -18
  196. package/src/waiting/style.scss +9 -20
  197. package/src/web-preview/index.js +12 -33
  198. package/src/web-preview/style.scss +33 -26
  199. package/src/with-wizard/index.js +7 -5
  200. package/src/with-wizard/style.scss +44 -89
  201. package/src/with-wizard-screen/index.js +14 -17
  202. package/src/with-wizard-screen/style.scss +74 -121
  203. package/src/wizard/components/WizardError.js +57 -0
  204. package/src/wizard/index.js +133 -0
  205. package/src/wizard/store/index.js +126 -0
  206. package/src/wizard/store/utils.js +16 -0
  207. package/dist/cjs/button-group/index.js +0 -57
  208. package/dist/cjs/button-group/style.scss +0 -73
  209. package/dist/cjs/checkbox-control/index.js +0 -63
  210. package/dist/cjs/checkbox-control/style.scss +0 -78
  211. package/dist/cjs/preview-box/index.js +0 -36
  212. package/dist/cjs/preview-box/style.scss +0 -18
  213. package/dist/cjs/textarea-control/index.js +0 -54
  214. package/dist/cjs/textarea-control/style.scss +0 -76
  215. package/dist/cjs/toggle-control/index.js +0 -58
  216. package/dist/cjs/toggle-control/style.scss +0 -74
  217. package/dist/cjs/toggle-group/index.js +0 -71
  218. package/dist/cjs/toggle-group/style.scss +0 -28
  219. package/dist/cjs/wizard-pagination/index.js +0 -71
  220. package/dist/cjs/wizard-pagination/style.scss +0 -74
  221. package/dist/esm/button-group/index.js +0 -43
  222. package/dist/esm/button-group/style.scss +0 -73
  223. package/dist/esm/checkbox-control/index.js +0 -49
  224. package/dist/esm/checkbox-control/style.scss +0 -78
  225. package/dist/esm/preview-box/index.js +0 -30
  226. package/dist/esm/preview-box/style.scss +0 -18
  227. package/dist/esm/textarea-control/index.js +0 -40
  228. package/dist/esm/textarea-control/style.scss +0 -76
  229. package/dist/esm/toggle-control/index.js +0 -44
  230. package/dist/esm/toggle-control/style.scss +0 -74
  231. package/dist/esm/toggle-group/index.js +0 -58
  232. package/dist/esm/toggle-group/style.scss +0 -28
  233. package/dist/esm/wizard-pagination/index.js +0 -57
  234. package/dist/esm/wizard-pagination/style.scss +0 -74
  235. package/src/button-group/index.js +0 -35
  236. package/src/button-group/style.scss +0 -73
  237. package/src/checkbox-control/index.js +0 -38
  238. package/src/checkbox-control/style.scss +0 -78
  239. package/src/preview-box/index.js +0 -18
  240. package/src/preview-box/style.scss +0 -18
  241. package/src/textarea-control/index.js +0 -32
  242. package/src/textarea-control/style.scss +0 -76
  243. package/src/toggle-control/index.js +0 -38
  244. package/src/toggle-control/style.scss +0 -74
  245. package/src/toggle-group/index.js +0 -43
  246. package/src/toggle-group/style.scss +0 -28
  247. package/src/wizard-pagination/index.js +0 -59
  248. package/src/wizard-pagination/style.scss +0 -74
@@ -23,18 +23,15 @@ class Modal extends Component {
23
23
  * Render.
24
24
  */
25
25
  render() {
26
- const { className, overlayClassName, isWide, isNarrow, ...otherProps } = this.props;
26
+ const { className, isWide, isNarrow, ...otherProps } = this.props;
27
27
  const classes = classnames(
28
28
  'newspack-modal',
29
29
  isWide && 'newspack-modal--wide',
30
30
  isNarrow && 'newspack-modal--narrow',
31
31
  className
32
32
  );
33
- const overlayClasses = classnames( 'newspack-modal__overlay', overlayClassName );
34
33
 
35
- return (
36
- <BaseComponent className={ classes } overlayClassName={ overlayClasses } { ...otherProps } />
37
- );
34
+ return <BaseComponent className={ classes } { ...otherProps } />;
38
35
  }
39
36
  }
40
37
 
@@ -3,166 +3,54 @@
3
3
  */
4
4
 
5
5
  @import '../../../shared/scss/colors';
6
- @import '~@wordpress/base-styles/colors';
7
6
 
8
7
  .newspack-modal {
9
- background: white;
10
- border: 0;
11
- color: $gray-700;
12
- font-size: 14px;
13
- line-height: 24px;
14
- margin: auto;
15
- max-height: 100%;
16
- width: 100%;
17
-
18
- @media screen and ( min-width: 600px ) {
19
- border-radius: 3px;
20
- max-width: 80%;
21
- max-width: calc( 100% - 64px );
22
- }
8
+ // Color
9
+ --wp-admin-theme-color: #{$primary-500};
10
+ --wp-admin-theme-color--rgb: #{$primary-500--rgb};
11
+ --wp-admin-theme-color-darker-10: #{$primary-600};
12
+ --wp-admin-theme-color-darker-10--rgb: #{$primary-600--rgb};
13
+ --wp-admin-theme-color-darker-20: #{$primary-700};
14
+ --wp-admin-theme-color-darker-20--rgb: #{$primary-700--rgb};
23
15
 
24
16
  @media screen and ( min-width: 744px ) {
25
17
  max-width: 680px;
18
+ width: 680px;
26
19
 
27
20
  &--wide {
28
21
  max-width: 1168px;
22
+ width: 1168px;
29
23
  }
30
24
  }
31
25
 
32
26
  &--narrow {
33
27
  max-width: 360px;
28
+ width: 360px;
34
29
  }
35
30
 
36
- // Header
37
-
38
- .components-modal__header {
39
- align-items: flex-start;
40
- background: white;
41
- border: 0;
42
- height: auto;
43
- justify-content: flex-end;
44
- margin: 0 -32px 0;
45
- padding: 32px 32px 0;
46
- position: relative;
47
-
48
- .components-modal__header-heading-container {
49
- display: block;
50
- margin-right: 16px;
51
- }
52
-
53
- .components-button.has-icon {
54
- flex: 0 0 36px;
55
- left: 0;
56
- margin: -2px 0;
57
-
58
- &:hover,
59
- &[aria-expended='true'] {
60
- color: $primary-500;
61
- }
62
-
63
- &:focus:not( :disabled ) {
64
- box-shadow: 0 0 0 2px $primary-500;
65
- }
66
-
67
- svg {
68
- width: 24px;
69
- height: 24px;
70
-
71
- + span {
72
- display: none;
73
- }
74
- }
75
- }
76
-
77
- .components-modal__header-heading {
78
- color: $gray-900;
79
- font-size: 21px;
80
- font-weight: bold;
81
- line-height: 32px;
82
- }
83
- }
84
-
85
- // Content
86
-
87
- .components-modal__content {
88
- padding: 0 32px;
89
- margin: 0;
90
-
91
- &::before {
92
- display: none;
93
- }
94
- }
95
-
96
- // Typography
97
-
98
- h2,
99
- p {
100
- line-height: 24px;
101
- margin: 32px 0;
102
- padding: 0;
103
- }
104
-
105
- h2 {
106
- color: $gray-900;
107
- font-size: 17px;
108
- font-weight: bold;
109
- }
110
-
111
- p {
112
- font-size: 14px;
113
-
114
- &.is-dark {
115
- color: $gray-900;
116
- }
117
- }
118
-
119
- // Thematic Break
120
-
121
- hr {
122
- background: $gray-300;
123
- border: 0;
124
- height: 1px;
125
- margin: 48px -48px;
126
-
127
- @media screen and ( min-width: 744px ) {
128
- margin: 64px -64px;
129
- }
31
+ @media screen and ( min-width: 960px ) {
32
+ max-height: calc( 100% - 128px );
130
33
  }
131
34
 
132
35
  // Links
133
-
134
36
  a {
135
- color: $primary-500;
37
+ color: var( --wp-admin-theme-color );
136
38
 
137
39
  &:active,
138
40
  &:focus,
139
41
  &:hover {
140
- color: $primary-600;
141
- text-decoration: none;
42
+ color: var( --wp-admin-theme-color-darker-10 );
142
43
  }
143
44
 
144
45
  &:focus {
145
- box-shadow: none;
146
- outline: 2px solid $primary-500;
147
- outline-offset: 2px;
46
+ box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) var( --wp-admin-theme-color );
47
+ outline: 3px solid transparent;
148
48
  }
149
49
  }
150
- }
151
-
152
- // Overlay
153
50
 
154
- .newspack-modal__overlay {
155
- background: rgba( black, 0.7 );
156
- }
157
-
158
- // Small Screens
159
-
160
- @media ( max-width: 599px ) {
161
- .newspack-modal {
162
- top: auto;
163
-
164
- .components-modal__content {
165
- height: auto;
51
+ .components-modal__content {
52
+ > *:last-child {
53
+ margin-bottom: 8px;
166
54
  }
167
55
  }
168
56
  }
@@ -23,8 +23,13 @@ class NewspackIcon extends Component {
23
23
  * Render
24
24
  */
25
25
  render() {
26
- const { className, size } = this.props;
27
- const classes = classnames( 'newspack-icon', className );
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
+ );
28
33
  return (
29
34
  <SVG
30
35
  xmlns="http://www.w3.org/2000/svg"
@@ -8,4 +8,19 @@
8
8
  background: $primary-500;
9
9
  fill: white;
10
10
  padding: 12px;
11
+
12
+ &--white {
13
+ background: white;
14
+ fill: $primary-500;
15
+ }
16
+
17
+ &--simple {
18
+ background: none;
19
+ fill: $primary-500;
20
+ padding: 0;
21
+ }
22
+
23
+ &#{&}--simple#{&}--white {
24
+ fill: white;
25
+ }
11
26
  }
@@ -6,7 +6,8 @@
6
6
  * WordPress dependencies.
7
7
  */
8
8
  import { Component, RawHTML } from '@wordpress/element';
9
- import { Icon, check, help, info } from '@wordpress/icons';
9
+ import { Icon, bug, check, help, info } from '@wordpress/icons';
10
+ import { __ } from '@wordpress/i18n';
10
11
 
11
12
  /**
12
13
  * Internal dependencies.
@@ -25,6 +26,7 @@ class Notice extends Component {
25
26
  render() {
26
27
  const {
27
28
  className,
29
+ debugMode,
28
30
  isError,
29
31
  isHelp,
30
32
  isSuccess,
@@ -37,6 +39,7 @@ class Notice extends Component {
37
39
  const classes = classnames(
38
40
  'newspack-notice',
39
41
  className,
42
+ debugMode && 'newspack-notice__is-debug',
40
43
  isError && 'newspack-notice__is-error',
41
44
  isHelp && 'newspack-notice__is-help',
42
45
  isSuccess && 'newspack-notice__is-success',
@@ -47,6 +50,8 @@ class Notice extends Component {
47
50
  noticeIcon = help;
48
51
  } else if ( isSuccess ) {
49
52
  noticeIcon = check;
53
+ } else if ( debugMode ) {
54
+ noticeIcon = bug;
50
55
  } else {
51
56
  noticeIcon = info;
52
57
  }
@@ -55,6 +60,7 @@ class Notice extends Component {
55
60
  { <Icon icon={ noticeIcon } /> }
56
61
  <div className="newspack-notice__content">
57
62
  { rawHTML ? <RawHTML>{ noticeText }</RawHTML> : noticeText }
63
+ { debugMode && __( 'Debug Mode', 'newspack' ) }
58
64
  { children || null }
59
65
  </div>
60
66
  </div>
@@ -6,14 +6,11 @@
6
6
  @import '../../../shared/scss/colors';
7
7
 
8
8
  .newspack-notice {
9
- align-items: flex-start;
9
+ align-items: center;
10
10
  background: $gray-100;
11
- border-radius: 3px;
12
11
  color: $gray-900;
13
12
  display: flex;
14
- font-size: 14px;
15
13
  justify-content: flex-start;
16
- line-height: 24px;
17
14
  margin: 32px 0;
18
15
  padding: 6px 8px;
19
16
 
@@ -24,8 +21,25 @@
24
21
  margin-right: 4px;
25
22
  }
26
23
 
24
+ &__is-debug {
25
+ background: $primary-700;
26
+ border-radius: 2px;
27
+ bottom: 16px;
28
+ box-shadow: 0 0 8px 4px rgba( black, 0.08 );
29
+ color: white;
30
+ font-weight: bold;
31
+ margin: 0 16px;
32
+ position: fixed;
33
+ text-transform: uppercase;
34
+ z-index: 9997;
35
+
36
+ > svg {
37
+ fill: white;
38
+ }
39
+ }
40
+
27
41
  &__is-error {
28
- background: lighten( $alert-red, 54% );
42
+ background: lighten( $alert-red, 51% );
29
43
 
30
44
  > svg {
31
45
  fill: $alert-red;
@@ -34,7 +48,7 @@
34
48
  }
35
49
 
36
50
  &__is-help {
37
- background: $primary-000;
51
+ background: $primary-050;
38
52
 
39
53
  > svg {
40
54
  fill: $primary-500;
@@ -42,7 +56,7 @@
42
56
  }
43
57
 
44
58
  &__is-success {
45
- background: lighten( $alert-green, 47% );
59
+ background: lighten( $alert-green, 42% );
46
60
 
47
61
  > svg {
48
62
  fill: $alert-green;
@@ -50,7 +64,7 @@
50
64
  }
51
65
 
52
66
  &__is-warning {
53
- background: lighten( $alert-yellow, 36% );
67
+ background: lighten( $alert-yellow, 30% );
54
68
 
55
69
  > svg {
56
70
  fill: $alert-yellow;
@@ -58,9 +72,23 @@
58
72
  }
59
73
  }
60
74
 
61
- &__content {
75
+ & &__content {
62
76
  > div > * {
63
- margin: 0;
77
+ margin: 0 !important;
78
+ }
79
+
80
+ a {
81
+ color: inherit;
82
+
83
+ &:active,
84
+ &:focus,
85
+ &:hover {
86
+ color: inherit;
87
+ }
88
+
89
+ &:focus {
90
+ box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) currentColor;
91
+ }
64
92
  }
65
93
  }
66
94
 
@@ -178,7 +178,7 @@ class PluginInstaller extends Component {
178
178
  } );
179
179
 
180
180
  return (
181
- <div>
181
+ <>
182
182
  { ( ! pluginInfo || ! Object.keys( pluginInfo ).length ) && (
183
183
  <div className="newspack-plugin-installer_is-waiting">
184
184
  <Waiting isLeft />
@@ -248,7 +248,7 @@ class PluginInstaller extends Component {
248
248
  </Button>
249
249
  </div>
250
250
  ) }
251
- </div>
251
+ </>
252
252
  );
253
253
  }
254
254
  }
@@ -6,15 +6,21 @@
6
6
  * WordPress dependencies
7
7
  */
8
8
  import { Fragment } from '@wordpress/element';
9
+ import { applyFilters } from '@wordpress/hooks';
9
10
  import { __ } from '@wordpress/i18n';
11
+ import { CheckboxControl } from '@wordpress/components';
10
12
 
11
13
  /**
12
14
  * Internal dependencies
13
15
  */
14
- import { ActionCard, Grid, Button, TextControl, CheckboxControl, SelectControl } from '../';
16
+ import { ActionCard, Button, Grid, Notice, SelectControl, TextControl } from '../';
17
+ import './style.scss';
15
18
 
19
+ const isSelectControl = setting => {
20
+ return Array.isArray( setting.options ) && setting.options.length;
21
+ };
16
22
  const getControlComponent = setting => {
17
- if ( Array.isArray( setting.options ) && setting.options.length ) {
23
+ if ( isSelectControl( setting ) ) {
18
24
  return SelectControl;
19
25
  }
20
26
  switch ( setting.type ) {
@@ -35,20 +41,28 @@ const getControlType = setting => {
35
41
  case 'string':
36
42
  case 'text':
37
43
  return 'text';
44
+ case 'password':
45
+ return 'password';
46
+ case 'boolean':
47
+ case 'checkbox':
48
+ return 'checkbox';
38
49
  default:
39
50
  return null;
40
51
  }
41
52
  };
42
53
 
43
- const SettingsSection = ( {
44
- active,
45
- title,
46
- description,
47
- fields,
48
- disabled,
49
- onChange,
50
- onUpdate,
51
- } ) => {
54
+ const SettingsSection = props => {
55
+ const {
56
+ error,
57
+ sectionKey,
58
+ active,
59
+ title,
60
+ description,
61
+ fields,
62
+ disabled,
63
+ onChange,
64
+ onUpdate,
65
+ } = props;
52
66
  const getControlProps = setting => ( {
53
67
  disabled,
54
68
  name: `${ setting.section }_${ setting.key }`,
@@ -58,14 +72,28 @@ const SettingsSection = ( {
58
72
  options:
59
73
  setting.options?.map( option => ( {
60
74
  value: option.value,
61
- label: option.name,
75
+ label: option.name || option.label,
62
76
  } ) ) || null,
63
77
  value: setting.value,
78
+ multiple: isSelectControl( setting ) && setting.multiple ? true : null,
64
79
  checked: setting.type === 'boolean' ? !! setting.value : null,
65
80
  onChange: value => {
66
81
  onChange( setting.key, value );
67
82
  },
68
83
  } );
84
+ const createFilter = ( name, defaultComponent = null ) => {
85
+ return applyFilters(
86
+ `newspack.settingSection.${ sectionKey }.${ name }`,
87
+ defaultComponent,
88
+ props
89
+ );
90
+ };
91
+ let columns = 2;
92
+ if ( fields.length % 3 === 0 ) {
93
+ columns = 3;
94
+ } else if ( fields.length === 1 ) {
95
+ columns = 1;
96
+ }
69
97
  return (
70
98
  <ActionCard
71
99
  isMedium
@@ -73,28 +101,38 @@ const SettingsSection = ( {
73
101
  title={ title }
74
102
  description={ description }
75
103
  toggleChecked={ active }
76
- hasGreyHeader={ true }
104
+ hasGreyHeader={ active || null === active }
77
105
  toggleOnChange={ active !== null ? value => onUpdate( { active: value } ) : null }
106
+ actionContent={
107
+ ( active || null === active ) &&
108
+ createFilter(
109
+ 'buttons',
110
+ <Button
111
+ variant="primary"
112
+ disabled={ disabled }
113
+ onClick={ () => {
114
+ onUpdate();
115
+ } }
116
+ >
117
+ { __( 'Save Settings', 'newspack' ) }
118
+ </Button>
119
+ )
120
+ }
78
121
  >
79
122
  { ( active || active === null ) && (
80
123
  <Fragment>
81
- <Grid columns={ fields.length % 3 === 0 ? 3 : 2 } gutter={ 32 }>
124
+ { error?.message && <Notice noticeText={ error.message } isError /> }
125
+ { createFilter( 'beforeControls' ) }
126
+ <Grid columns={ columns } gutter={ 32 }>
82
127
  { fields.map( setting => {
83
128
  const Control = getControlComponent( setting ); // eslint-disable-line @wordpress/no-unused-vars-before-return, no-unused-vars
84
- return <Control key={ setting.key } { ...getControlProps( setting ) } />;
129
+ return applyFilters(
130
+ `newspack.settingsSection.${ sectionKey }.control`,
131
+ <Control key={ setting.key } { ...getControlProps( setting ) } />,
132
+ { sectionKey, setting, onChange }
133
+ );
85
134
  } ) }
86
135
  </Grid>
87
- <div className="newspack-buttons-card" style={ { margin: '32px 0 0' } }>
88
- <Button
89
- isPrimary
90
- disabled={ disabled }
91
- onClick={ () => {
92
- onUpdate();
93
- } }
94
- >
95
- { __( 'Save settings', 'newspack' ) }
96
- </Button>
97
- </div>
98
136
  </Fragment>
99
137
  ) }
100
138
  </ActionCard>
@@ -27,11 +27,18 @@ class PluginSettings extends Component {
27
27
  }
28
28
 
29
29
  fetchSettings = () => {
30
- const { pluginSlug } = this.props;
30
+ const { afterFetch, pluginSlug, isWizard } = this.props;
31
31
  this.setState( { inFlight: true } );
32
- apiFetch( { path: `/${ pluginSlug }/v1/settings` } )
32
+ apiFetch( {
33
+ path: isWizard
34
+ ? `/newspack/v1/wizard/${ pluginSlug }/settings`
35
+ : `/${ pluginSlug }/v1/settings`,
36
+ } )
33
37
  .then( settings => {
34
38
  this.setState( { settings, error: null } );
39
+ if ( 'function' === typeof afterFetch ) {
40
+ afterFetch( settings );
41
+ }
35
42
  } )
36
43
  .catch( error => {
37
44
  this.setState( { error } );
@@ -70,10 +77,12 @@ class PluginSettings extends Component {
70
77
  };
71
78
 
72
79
  handleSectionUpdate = sectionKey => data => {
73
- const { pluginSlug } = this.props;
80
+ const { afterUpdate, pluginSlug, isWizard } = this.props;
74
81
  this.setState( { inFlight: true } );
75
82
  apiFetch( {
76
- path: `/${ pluginSlug }/v1/settings`,
83
+ path: isWizard
84
+ ? `/newspack/v1/wizard/${ pluginSlug }/settings`
85
+ : `/${ pluginSlug }/v1/settings`,
77
86
  method: 'POST',
78
87
  data: {
79
88
  section: sectionKey,
@@ -82,6 +91,10 @@ class PluginSettings extends Component {
82
91
  } )
83
92
  .then( settings => {
84
93
  this.setState( { settings, error: null } );
94
+
95
+ if ( 'function' === typeof afterUpdate ) {
96
+ afterUpdate( settings );
97
+ }
85
98
  } )
86
99
  .catch( error => {
87
100
  this.setState( { error } );
@@ -154,14 +167,14 @@ class PluginSettings extends Component {
154
167
  * Render.
155
168
  */
156
169
  render() {
157
- const { title, description } = this.props;
170
+ const { title, description, hasGreyHeader, children } = this.props;
158
171
  const { settings, inFlight, error } = this.state;
159
172
  return (
160
173
  <Fragment>
161
- <SectionHeader title={ title } description={ description } />
174
+ { title && <SectionHeader title={ title } description={ description } /> }
162
175
  { error && <Notice isError noticeText={ error.message } /> }
163
176
  <div
164
- className={ classnames( {
177
+ className={ classnames( 'newspack-plugin-settings', {
165
178
  'newspack-wizard-section__is-loading': inFlight && ! Object.keys( settings ).length,
166
179
  } ) }
167
180
  >
@@ -169,14 +182,17 @@ class PluginSettings extends Component {
169
182
  <SettingsSection
170
183
  key={ sectionKey }
171
184
  disabled={ inFlight }
185
+ sectionKey={ sectionKey }
172
186
  title={ this.getSectionTitle( sectionKey ) }
173
187
  description={ this.getSectionDescription( sectionKey ) }
174
188
  active={ this.isSectionActive( sectionKey ) }
175
189
  fields={ this.getSectionFields( sectionKey ) }
176
190
  onChange={ this.handleSettingChange( sectionKey ) }
177
191
  onUpdate={ this.handleSectionUpdate( sectionKey ) }
192
+ hasGreyHeader={ hasGreyHeader }
178
193
  />
179
194
  ) ) }
195
+ { children }
180
196
  </div>
181
197
  </Fragment>
182
198
  );
@@ -0,0 +1,7 @@
1
+ .newspack-card:not( .newspack-settings__no-border ) {
2
+ .newspack-action-card__region-children {
3
+ > .newspack-grid {
4
+ margin: 32px 0 0 !important;
5
+ }
6
+ }
7
+ }
@@ -51,15 +51,27 @@ class PluginToggle extends Component {
51
51
  pluginInfo: { ...pluginInfo, [ plugin ]: { ...pluginInfo[ plugin ], inFlight: action } },
52
52
  },
53
53
  () => {
54
- apiFetch( params ).then( response => {
55
- const { shouldRefreshAfterUpdate } = plugins[ plugin ];
56
- this.setState(
57
- ( { pluginInfo: currentPluginInfo } ) => ( {
58
- pluginInfo: { ...currentPluginInfo, [ plugin ]: response },
59
- } ),
60
- () => shouldRefreshAfterUpdate && location.reload()
61
- );
62
- } );
54
+ apiFetch( params )
55
+ .then( response => {
56
+ const { shouldRefreshAfterUpdate } = plugins[ plugin ];
57
+ this.setState(
58
+ ( { pluginInfo: currentPluginInfo } ) => ( {
59
+ pluginInfo: { ...currentPluginInfo, [ plugin ]: response },
60
+ } ),
61
+ () => shouldRefreshAfterUpdate && location.reload()
62
+ );
63
+ } )
64
+ .catch( e => {
65
+ this.setState( {
66
+ pluginInfo: {
67
+ ...pluginInfo,
68
+ [ plugin ]: {
69
+ ...pluginInfo[ plugin ],
70
+ error: e.message || __( 'There was an error managing this plugin.', 'newspack' ),
71
+ },
72
+ },
73
+ } );
74
+ } );
63
75
  }
64
76
  );
65
77
  };
@@ -74,6 +86,7 @@ class PluginToggle extends Component {
74
86
  const { name, description, href, slug, editPath } = plugin;
75
87
  const pluginStatus = this.isPluginInstalledAndActive( plugin );
76
88
  const handoff = ! href && pluginStatus && editPath ? slug : null;
89
+ const error = this.errorForPlugin( plugin );
77
90
  return (
78
91
  <ActionCard
79
92
  key={ index }
@@ -86,6 +99,9 @@ class PluginToggle extends Component {
86
99
  toggle
87
100
  toggleChecked={ this.isPluginInstalledAndActive( plugin ) }
88
101
  toggleOnChange={ value => this.managePlugin( slug, value ) }
102
+ notification={ error }
103
+ notificationHTML={ error }
104
+ notificationLevel="error"
89
105
  />
90
106
  );
91
107
  } );
@@ -160,6 +176,16 @@ class PluginToggle extends Component {
160
176
  }
161
177
  };
162
178
 
179
+ /**
180
+ * Get error message for this plugin.
181
+ */
182
+ errorForPlugin = plugin => {
183
+ const { slug } = plugin;
184
+ const { pluginInfo } = this.state;
185
+
186
+ return pluginInfo[ slug ]?.error || null;
187
+ };
188
+
163
189
  /**
164
190
  * Get installation/activation status for a plugin.
165
191
  */