newspack-components 2.0.3 → 2.2.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 (315) hide show
  1. package/copy-styles.js +1 -1
  2. package/dist/cjs/accordion/index.js +46 -0
  3. package/dist/cjs/accordion/style.scss +27 -0
  4. package/dist/cjs/action-card/index.js +72 -40
  5. package/dist/cjs/action-card/style.scss +143 -41
  6. package/dist/cjs/autocomplete-tokenfield/index.js +13 -41
  7. package/dist/cjs/autocomplete-tokenfield/style.scss +6 -6
  8. package/dist/cjs/autocomplete-with-suggestions/index.js +33 -53
  9. package/dist/cjs/autocomplete-with-suggestions/style.scss +27 -27
  10. package/dist/cjs/button/index.js +1 -20
  11. package/dist/cjs/button/style.scss +3 -344
  12. package/dist/cjs/button-card/index.js +11 -15
  13. package/dist/cjs/button-card/style.scss +65 -35
  14. package/dist/cjs/card/index.js +4 -9
  15. package/dist/cjs/card/style.scss +47 -63
  16. package/dist/cjs/category-autocomplete/index.js +66 -47
  17. package/dist/cjs/category-autocomplete/style.scss +20 -24
  18. package/dist/cjs/color-picker/index.js +16 -48
  19. package/dist/cjs/color-picker/style.scss +20 -163
  20. package/dist/cjs/consts.js +5 -3
  21. package/dist/cjs/custom-select-control/index.js +1 -9
  22. package/dist/cjs/custom-select-control/style.scss +14 -45
  23. package/dist/cjs/date-range-picker/index.js +1 -10
  24. package/dist/cjs/date-range-picker/style.scss +12 -12
  25. package/dist/cjs/footer/index.js +24 -22
  26. package/dist/cjs/footer/style.scss +13 -14
  27. package/dist/cjs/form-token-field/index.js +3 -11
  28. package/dist/cjs/form-token-field/style.scss +9 -105
  29. package/dist/cjs/global-notices/index.js +3 -9
  30. package/dist/cjs/grid/index.js +1 -8
  31. package/dist/cjs/grid/style.scss +19 -6
  32. package/dist/cjs/handoff/index.js +15 -24
  33. package/dist/cjs/handoff-message/index.js +50 -0
  34. package/dist/cjs/hooks/index.js +1 -7
  35. package/dist/cjs/hooks/useObjectState.js +7 -13
  36. package/dist/cjs/hooks/useObjectState.test.js +0 -14
  37. package/dist/cjs/hooks/useOnClickOutside.js +3 -6
  38. package/dist/cjs/hooks/usePrompt.js +1 -13
  39. package/dist/cjs/image-upload/index.js +22 -20
  40. package/dist/cjs/image-upload/index.test.js +0 -5
  41. package/dist/cjs/image-upload/style.scss +12 -17
  42. package/dist/cjs/index.js +31 -93
  43. package/dist/cjs/info-button/index.js +3 -11
  44. package/dist/cjs/info-button/style.scss +1 -3
  45. package/dist/cjs/modal/index.js +1 -12
  46. package/dist/cjs/modal/style.scss +20 -132
  47. package/dist/cjs/newspack-icon/index.js +5 -11
  48. package/dist/cjs/newspack-icon/style.scss +17 -2
  49. package/dist/cjs/newspack-logo/index.js +1 -9
  50. package/dist/cjs/newspack-logo/style.scss +3 -3
  51. package/dist/cjs/notice/index.js +8 -16
  52. package/dist/cjs/notice/style.scss +60 -19
  53. package/dist/cjs/patrons-logo/index.js +3 -11
  54. package/dist/cjs/plugin-installer/index.js +37 -37
  55. package/dist/cjs/plugin-installer/style.scss +5 -5
  56. package/dist/cjs/plugin-settings/SettingsSection.js +71 -59
  57. package/dist/cjs/plugin-settings/index.js +71 -50
  58. package/dist/cjs/plugin-settings/style.scss +7 -0
  59. package/dist/cjs/plugin-toggle/index.js +60 -32
  60. package/dist/cjs/plugin-toggle/style.scss +2 -2
  61. package/dist/cjs/popover/index.js +1 -11
  62. package/dist/cjs/popover/style.scss +20 -17
  63. package/dist/cjs/position-control/index.js +113 -0
  64. package/dist/cjs/position-control/style.scss +66 -0
  65. package/dist/cjs/progress-bar/index.js +2 -9
  66. package/dist/cjs/progress-bar/index.test.js +2 -7
  67. package/dist/cjs/progress-bar/style.scss +4 -4
  68. package/dist/cjs/proxied-imports/router.js +0 -3
  69. package/dist/cjs/radio-control/index.js +1 -11
  70. package/dist/cjs/radio-control/style.scss +10 -11
  71. package/dist/cjs/section-header/index.js +47 -19
  72. package/dist/cjs/section-header/style.scss +22 -1
  73. package/dist/cjs/select-control/ButtonGroupControl.js +11 -20
  74. package/dist/cjs/select-control/GroupedSelectControl.js +42 -45
  75. package/dist/cjs/select-control/index.js +6 -14
  76. package/dist/cjs/select-control/style.scss +47 -88
  77. package/dist/cjs/settings/MinMaxSetting.js +6 -8
  78. package/dist/cjs/settings/SettingsCard.js +9 -8
  79. package/dist/cjs/settings/SettingsSection.js +5 -8
  80. package/dist/cjs/settings/index.js +0 -6
  81. package/dist/cjs/settings/style.scss +32 -4
  82. package/dist/cjs/steps-list/index.js +52 -0
  83. package/dist/cjs/steps-list/style.scss +11 -0
  84. package/dist/cjs/steps-list-item/index.js +56 -0
  85. package/dist/cjs/steps-list-item/style.scss +47 -0
  86. package/dist/cjs/style-card/index.js +15 -18
  87. package/dist/cjs/style-card/style.scss +19 -18
  88. package/dist/cjs/style.scss +43 -0
  89. package/dist/cjs/tabbed-navigation/index.js +27 -31
  90. package/dist/cjs/tabbed-navigation/style.scss +58 -37
  91. package/dist/cjs/text-control/index.js +6 -19
  92. package/dist/cjs/text-control/style.scss +0 -126
  93. package/dist/cjs/utils/index.js +10 -5
  94. package/dist/cjs/waiting/index.js +9 -33
  95. package/dist/cjs/waiting/style.scss +9 -20
  96. package/dist/cjs/web-preview/index.js +30 -57
  97. package/dist/cjs/web-preview/style.scss +41 -34
  98. package/dist/cjs/with-wizard/index.js +55 -33
  99. package/dist/cjs/with-wizard/style.scss +77 -124
  100. package/dist/cjs/with-wizard-screen/index.js +28 -38
  101. package/dist/cjs/with-wizard-screen/style.scss +75 -125
  102. package/dist/cjs/wizard/components/WizardError.js +74 -0
  103. package/dist/cjs/wizard/index.js +131 -0
  104. package/dist/cjs/wizard/store/index.js +165 -0
  105. package/dist/cjs/wizard/store/utils.js +26 -0
  106. package/dist/cjs/wizard/style.scss +148 -0
  107. package/dist/esm/accordion/index.js +38 -0
  108. package/dist/esm/accordion/style.scss +27 -0
  109. package/dist/esm/action-card/index.js +75 -37
  110. package/dist/esm/action-card/style.scss +143 -41
  111. package/dist/esm/autocomplete-tokenfield/index.js +14 -37
  112. package/dist/esm/autocomplete-tokenfield/style.scss +6 -6
  113. package/dist/esm/autocomplete-with-suggestions/index.js +31 -43
  114. package/dist/esm/autocomplete-with-suggestions/style.scss +27 -27
  115. package/dist/esm/button/index.js +2 -14
  116. package/dist/esm/button/style.scss +3 -344
  117. package/dist/esm/button-card/index.js +12 -11
  118. package/dist/esm/button-card/style.scss +65 -35
  119. package/dist/esm/card/index.js +5 -6
  120. package/dist/esm/card/style.scss +47 -63
  121. package/dist/esm/category-autocomplete/index.js +68 -41
  122. package/dist/esm/category-autocomplete/style.scss +20 -24
  123. package/dist/esm/color-picker/index.js +17 -38
  124. package/dist/esm/color-picker/style.scss +20 -163
  125. package/dist/esm/consts.js +3 -2
  126. package/dist/esm/custom-select-control/index.js +2 -5
  127. package/dist/esm/custom-select-control/style.scss +14 -45
  128. package/dist/esm/date-range-picker/index.js +1 -3
  129. package/dist/esm/date-range-picker/style.scss +12 -12
  130. package/dist/esm/footer/index.js +22 -16
  131. package/dist/esm/footer/style.scss +13 -14
  132. package/dist/esm/form-token-field/index.js +4 -7
  133. package/dist/esm/form-token-field/style.scss +9 -105
  134. package/dist/esm/global-notices/index.js +3 -7
  135. package/dist/esm/grid/index.js +2 -5
  136. package/dist/esm/grid/style.scss +19 -6
  137. package/dist/esm/handoff/index.js +10 -21
  138. package/dist/esm/handoff-message/index.js +45 -0
  139. package/dist/esm/hooks/index.js +0 -2
  140. package/dist/esm/hooks/useObjectState.js +3 -8
  141. package/dist/esm/hooks/useObjectState.test.js +0 -3
  142. package/dist/esm/hooks/useOnClickOutside.js +2 -5
  143. package/dist/esm/hooks/usePrompt.js +1 -8
  144. package/dist/esm/image-upload/index.js +18 -17
  145. package/dist/esm/image-upload/style.scss +12 -17
  146. package/dist/esm/index.js +7 -8
  147. package/dist/esm/info-button/index.js +4 -6
  148. package/dist/esm/info-button/style.scss +1 -3
  149. package/dist/esm/modal/index.js +2 -8
  150. package/dist/esm/modal/style.scss +20 -132
  151. package/dist/esm/newspack-icon/index.js +6 -7
  152. package/dist/esm/newspack-icon/style.scss +17 -2
  153. package/dist/esm/newspack-logo/index.js +2 -5
  154. package/dist/esm/newspack-logo/style.scss +3 -3
  155. package/dist/esm/notice/index.js +11 -10
  156. package/dist/esm/notice/style.scss +60 -19
  157. package/dist/esm/patrons-logo/index.js +3 -5
  158. package/dist/esm/plugin-installer/index.js +37 -40
  159. package/dist/esm/plugin-installer/style.scss +5 -5
  160. package/dist/esm/plugin-settings/SettingsSection.js +71 -56
  161. package/dist/esm/plugin-settings/index.js +70 -52
  162. package/dist/esm/plugin-settings/style.scss +7 -0
  163. package/dist/esm/plugin-toggle/index.js +59 -34
  164. package/dist/esm/plugin-toggle/style.scss +2 -2
  165. package/dist/esm/popover/index.js +3 -6
  166. package/dist/esm/popover/style.scss +20 -17
  167. package/dist/esm/position-control/index.js +109 -0
  168. package/dist/esm/position-control/style.scss +66 -0
  169. package/dist/esm/progress-bar/index.js +2 -7
  170. package/dist/esm/progress-bar/index.test.js +2 -1
  171. package/dist/esm/progress-bar/style.scss +4 -4
  172. package/dist/esm/proxied-imports/router.js +1 -0
  173. package/dist/esm/radio-control/index.js +3 -6
  174. package/dist/esm/radio-control/style.scss +10 -11
  175. package/dist/esm/section-header/index.js +47 -16
  176. package/dist/esm/section-header/style.scss +22 -1
  177. package/dist/esm/select-control/ButtonGroupControl.js +12 -14
  178. package/dist/esm/select-control/GroupedSelectControl.js +38 -36
  179. package/dist/esm/select-control/index.js +7 -8
  180. package/dist/esm/select-control/style.scss +47 -88
  181. package/dist/esm/settings/MinMaxSetting.js +4 -5
  182. package/dist/esm/settings/SettingsCard.js +9 -5
  183. package/dist/esm/settings/SettingsSection.js +5 -7
  184. package/dist/esm/settings/style.scss +32 -4
  185. package/dist/esm/steps-list/index.js +43 -0
  186. package/dist/esm/steps-list/style.scss +11 -0
  187. package/dist/esm/steps-list-item/index.js +48 -0
  188. package/dist/esm/steps-list-item/style.scss +47 -0
  189. package/dist/esm/style-card/index.js +13 -13
  190. package/dist/esm/style-card/style.scss +19 -18
  191. package/dist/esm/style.scss +43 -0
  192. package/dist/esm/tabbed-navigation/index.js +30 -28
  193. package/dist/esm/tabbed-navigation/style.scss +58 -37
  194. package/dist/esm/text-control/index.js +2 -12
  195. package/dist/esm/text-control/style.scss +0 -126
  196. package/dist/esm/utils/index.js +9 -3
  197. package/dist/esm/waiting/index.js +11 -27
  198. package/dist/esm/waiting/style.scss +9 -20
  199. package/dist/esm/web-preview/index.js +21 -49
  200. package/dist/esm/web-preview/style.scss +41 -34
  201. package/dist/esm/with-wizard/index.js +53 -36
  202. package/dist/esm/with-wizard/style.scss +77 -124
  203. package/dist/esm/with-wizard-screen/index.js +26 -32
  204. package/dist/esm/with-wizard-screen/style.scss +75 -125
  205. package/dist/esm/wizard/components/WizardError.js +69 -0
  206. package/dist/esm/wizard/index.js +126 -0
  207. package/dist/esm/wizard/store/index.js +155 -0
  208. package/dist/esm/wizard/store/utils.js +17 -0
  209. package/dist/esm/wizard/style.scss +148 -0
  210. package/package.json +4 -4
  211. package/src/accordion/index.js +32 -0
  212. package/src/accordion/style.scss +27 -0
  213. package/src/action-card/index.js +70 -25
  214. package/src/action-card/style.scss +143 -41
  215. package/src/autocomplete-tokenfield/index.js +1 -1
  216. package/src/autocomplete-tokenfield/style.scss +6 -6
  217. package/src/autocomplete-with-suggestions/index.js +4 -2
  218. package/src/autocomplete-with-suggestions/style.scss +27 -27
  219. package/src/button/index.js +2 -9
  220. package/src/button/style.scss +3 -344
  221. package/src/button-card/index.js +19 -5
  222. package/src/button-card/style.scss +65 -35
  223. package/src/card/index.js +4 -0
  224. package/src/card/style.scss +47 -63
  225. package/src/category-autocomplete/index.js +53 -18
  226. package/src/category-autocomplete/style.scss +20 -24
  227. package/src/color-picker/index.js +16 -22
  228. package/src/color-picker/style.scss +20 -163
  229. package/src/consts.js +2 -1
  230. package/src/custom-select-control/style.scss +14 -45
  231. package/src/date-range-picker/style.scss +12 -12
  232. package/src/footer/index.js +20 -9
  233. package/src/footer/style.scss +13 -14
  234. package/src/form-token-field/index.js +3 -8
  235. package/src/form-token-field/style.scss +9 -105
  236. package/src/global-notices/index.js +1 -1
  237. package/src/grid/style.scss +19 -6
  238. package/src/handoff/index.js +10 -15
  239. package/src/handoff-message/index.js +39 -0
  240. package/src/hooks/useObjectState.js +2 -1
  241. package/src/image-upload/index.js +9 -3
  242. package/src/image-upload/style.scss +12 -17
  243. package/src/index.js +7 -7
  244. package/src/info-button/style.scss +1 -3
  245. package/src/modal/index.js +2 -5
  246. package/src/modal/style.scss +20 -132
  247. package/src/newspack-icon/index.js +7 -2
  248. package/src/newspack-icon/style.scss +17 -2
  249. package/src/newspack-logo/style.scss +3 -3
  250. package/src/notice/index.js +9 -1
  251. package/src/notice/style.scss +60 -19
  252. package/src/plugin-installer/index.js +17 -4
  253. package/src/plugin-installer/style.scss +5 -5
  254. package/src/plugin-settings/SettingsSection.js +59 -27
  255. package/src/plugin-settings/index.js +29 -8
  256. package/src/plugin-settings/style.scss +7 -0
  257. package/src/plugin-toggle/index.js +37 -12
  258. package/src/plugin-toggle/style.scss +2 -2
  259. package/src/popover/style.scss +20 -17
  260. package/src/position-control/index.js +122 -0
  261. package/src/position-control/style.scss +66 -0
  262. package/src/progress-bar/style.scss +4 -4
  263. package/src/radio-control/style.scss +10 -11
  264. package/src/section-header/index.js +41 -5
  265. package/src/section-header/style.scss +22 -1
  266. package/src/select-control/ButtonGroupControl.js +15 -5
  267. package/src/select-control/GroupedSelectControl.js +28 -25
  268. package/src/select-control/index.js +6 -3
  269. package/src/select-control/style.scss +47 -88
  270. package/src/settings/MinMaxSetting.js +2 -1
  271. package/src/settings/SettingsCard.js +9 -7
  272. package/src/settings/SettingsSection.js +4 -4
  273. package/src/settings/style.scss +32 -4
  274. package/src/steps-list/index.js +39 -0
  275. package/src/steps-list/style.scss +11 -0
  276. package/src/steps-list-item/index.js +40 -0
  277. package/src/steps-list-item/style.scss +47 -0
  278. package/src/style-card/index.js +16 -27
  279. package/src/style-card/style.scss +19 -18
  280. package/src/style.scss +43 -0
  281. package/src/tabbed-navigation/index.js +20 -24
  282. package/src/tabbed-navigation/style.scss +58 -37
  283. package/src/text-control/index.js +1 -2
  284. package/src/text-control/style.scss +0 -126
  285. package/src/utils/index.js +9 -0
  286. package/src/waiting/index.js +7 -18
  287. package/src/waiting/style.scss +9 -20
  288. package/src/web-preview/index.js +13 -34
  289. package/src/web-preview/style.scss +41 -34
  290. package/src/with-wizard/index.js +7 -5
  291. package/src/with-wizard/style.scss +77 -124
  292. package/src/with-wizard-screen/index.js +17 -17
  293. package/src/with-wizard-screen/style.scss +75 -125
  294. package/src/wizard/components/WizardError.js +57 -0
  295. package/src/wizard/index.js +145 -0
  296. package/src/wizard/store/index.js +132 -0
  297. package/src/wizard/store/utils.js +16 -0
  298. package/dist/cjs/wizard-pagination/index.js +0 -71
  299. package/dist/cjs/wizard-pagination/style.scss +0 -74
  300. package/dist/esm/wizard-pagination/index.js +0 -57
  301. package/dist/esm/wizard-pagination/style.scss +0 -74
  302. package/src/button-group/index.js +0 -35
  303. package/src/button-group/style.scss +0 -73
  304. package/src/checkbox-control/index.js +0 -38
  305. package/src/checkbox-control/style.scss +0 -78
  306. package/src/preview-box/index.js +0 -18
  307. package/src/preview-box/style.scss +0 -18
  308. package/src/textarea-control/index.js +0 -32
  309. package/src/textarea-control/style.scss +0 -76
  310. package/src/toggle-control/index.js +0 -38
  311. package/src/toggle-control/style.scss +0 -74
  312. package/src/toggle-group/index.js +0 -43
  313. package/src/toggle-group/style.scss +0 -28
  314. package/src/wizard-pagination/index.js +0 -59
  315. package/src/wizard-pagination/style.scss +0 -74
package/copy-styles.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /* eslint-disable import/no-nodejs-modules,no-console */
3
+ /* eslint-disable import/no-nodejs-modules,no-console,@typescript-eslint/no-var-requires */
4
4
 
5
5
  // find all the packages
6
6
  const path = require( 'path' );
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _element = require("@wordpress/element");
9
+ var _icons = require("@wordpress/icons");
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ require("./style.scss");
12
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
13
+ /**
14
+ * WordPress dependencies
15
+ */
16
+
17
+ /**
18
+ * External dependencies
19
+ */
20
+
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+
25
+ const Accordion = _ref => {
26
+ let {
27
+ children,
28
+ title
29
+ } = _ref;
30
+ const [isOpen, setIsOpen] = (0, _element.useState)(false);
31
+ return (0, _jsxRuntime.jsxs)("details", {
32
+ className: (0, _classnames.default)('newspack-accordion', {
33
+ 'newspack-accordion--is-open': isOpen
34
+ }),
35
+ children: [(0, _jsxRuntime.jsxs)("summary", {
36
+ onClick: () => setIsOpen(!isOpen),
37
+ children: [title, (0, _jsxRuntime.jsx)(_icons.Icon, {
38
+ className: "newspack-accordion__icon",
39
+ icon: _icons.chevronRight,
40
+ size: 24
41
+ })]
42
+ }), children]
43
+ });
44
+ };
45
+ var _default = Accordion;
46
+ exports.default = _default;
@@ -0,0 +1,27 @@
1
+ @use '~@wordpress/base-styles/colors' as wp-colors;
2
+
3
+ .newspack-accordion {
4
+ border: 1px solid wp-colors.$gray-300;
5
+
6
+ &__icon {
7
+ transition: transform 200ms ease-out;
8
+ transform: rotate( 90deg );
9
+ }
10
+
11
+ &--is-open {
12
+ .newspack-accordion {
13
+ &__icon {
14
+ transform: rotate( -90deg );
15
+ }
16
+ }
17
+ }
18
+ summary {
19
+ padding: 16px 32px;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: space-between;
23
+ cursor: pointer;
24
+ font-size: 14px;
25
+ font-weight: bold;
26
+ }
27
+ }
@@ -1,28 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _element = require("@wordpress/element");
13
-
14
10
  var _components = require("@wordpress/components");
15
-
16
11
  var _icons = require("@wordpress/icons");
17
-
18
12
  var _ = require("../");
19
-
20
13
  require("./style.scss");
21
-
22
14
  var _classnames = _interopRequireDefault(require("classnames"));
23
-
24
15
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
25
-
26
16
  /**
27
17
  * Action Card
28
18
  */
@@ -38,18 +28,27 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
38
28
  /**
39
29
  * External dependencies
40
30
  */
31
+
41
32
  class ActionCard extends _element.Component {
42
33
  constructor() {
43
34
  super(...arguments);
44
- (0, _defineProperty2.default)(this, "backgroundImageStyles", url => {
45
- return url ? {
46
- backgroundImage: `url(${url})`
47
- } : {};
35
+ (0, _defineProperty2.default)(this, "state", {
36
+ expanded: false
48
37
  });
49
38
  }
39
+ /**
40
+ * When the collapse prop is updated to true, collapse the card if already expanded.
41
+ */
42
+ componentDidUpdate(prevProps) {
43
+ if (!prevProps.collapse && this.props.collapse && this.state.expanded) {
44
+ this.setState({
45
+ expanded: false
46
+ });
47
+ }
48
+ }
50
49
 
51
50
  /**
52
- * Render
51
+ * Render.
53
52
  */
54
53
  render() {
55
54
  const {
@@ -69,8 +68,10 @@ class ActionCard extends _element.Component {
69
68
  actionContent,
70
69
  actionText,
71
70
  secondaryActionText,
71
+ secondaryDestructive,
72
72
  image,
73
73
  imageLink,
74
+ indent,
74
75
  isSmall,
75
76
  isMedium,
76
77
  simple,
@@ -80,10 +81,21 @@ class ActionCard extends _element.Component {
80
81
  titleLink,
81
82
  toggleChecked,
82
83
  toggleOnChange,
83
- hasGreyHeader
84
+ hasGreyHeader,
85
+ hasWhiteHeader,
86
+ isPending,
87
+ expandable = false
84
88
  } = this.props;
89
+ const {
90
+ expanded
91
+ } = this.state;
85
92
  const hasChildren = notification || children;
86
- const classes = (0, _classnames.default)('newspack-action-card', simple && 'newspack-card--is-clickable', hasGreyHeader && 'newspack-card--has-grey-header', hasChildren && 'newspack-card--has-children', isSmall && 'is-small', isMedium && 'is-medium', className);
93
+ const classes = (0, _classnames.default)('newspack-action-card', simple && 'newspack-card--is-clickable', hasGreyHeader && 'newspack-card--has-grey-header', hasWhiteHeader && 'newspack-card--has-white-header', hasChildren && 'newspack-card--has-children', indent && 'newspack-card--indent', isSmall && 'is-small', isMedium && 'is-medium', checkbox && 'has-checkbox', expandable && 'is-expandable', actionContent && 'has-action-content', className);
94
+ const backgroundImageStyles = url => {
95
+ return url ? {
96
+ backgroundImage: `url(${url})`
97
+ } : {};
98
+ };
87
99
  const titleProps = toggleOnChange && !titleLink && !disabled ? {
88
100
  onClick: () => toggleOnChange(!toggleChecked),
89
101
  tabIndex: '0'
@@ -96,7 +108,7 @@ class ActionCard extends _element.Component {
96
108
  onClick: simple && onClick,
97
109
  children: [(0, _jsxRuntime.jsxs)("div", {
98
110
  className: "newspack-action-card__region newspack-action-card__region-top",
99
- children: [toggleOnChange && (0, _jsxRuntime.jsx)(_.ToggleControl, {
111
+ children: [toggleOnChange && (0, _jsxRuntime.jsx)(_components.ToggleControl, {
100
112
  checked: toggleChecked,
101
113
  onChange: toggleOnChange,
102
114
  disabled: disabled
@@ -106,35 +118,46 @@ class ActionCard extends _element.Component {
106
118
  href: imageLink,
107
119
  children: (0, _jsxRuntime.jsx)("div", {
108
120
  className: "newspack-action-card__image",
109
- style: this.backgroundImageStyles(image)
121
+ style: backgroundImageStyles(image)
110
122
  })
111
123
  })
112
124
  }), checkbox && !toggleOnChange && (0, _jsxRuntime.jsx)("div", {
113
125
  className: "newspack-action-card__region newspack-action-card__region-left",
114
126
  children: (0, _jsxRuntime.jsx)("span", {
115
- className: (0, _classnames.default)('newspack-checkbox-icon', 'is-primary', 'checked' === checkbox && 'newspack-checkbox-icon--checked'),
127
+ className: (0, _classnames.default)('newspack-checkbox-icon', 'is-primary', 'checked' === checkbox && 'newspack-checkbox-icon--checked', isPending && 'newspack-checkbox-icon--pending'),
116
128
  children: 'checked' === checkbox && (0, _jsxRuntime.jsx)(_icons.Icon, {
117
129
  icon: _icons.check
118
130
  })
119
131
  })
120
- }), (0, _jsxRuntime.jsxs)("div", {
132
+ }), (0, _jsxRuntime.jsx)("div", {
121
133
  className: "newspack-action-card__region newspack-action-card__region-center",
122
- children: [(0, _jsxRuntime.jsxs)("h2", {
123
- children: [(0, _jsxRuntime.jsx)("span", {
124
- className: "newspack-action-card__title",
125
- ...titleProps,
126
- children: titleLink ? (0, _jsxRuntime.jsx)("a", {
127
- href: titleLink,
128
- children: title
129
- }) : title
130
- }), (badges === null || badges === void 0 ? void 0 : badges.length) && badges.map((badgeText, i) => (0, _jsxRuntime.jsx)("span", {
131
- className: "newspack-action-card__badge",
132
- children: badgeText
133
- }, `badge-${i}`))]
134
- }), (0, _jsxRuntime.jsxs)("p", {
135
- children: [typeof description === 'string' && description, typeof description === 'function' && description()]
136
- })]
137
- }), (actionText || isDisplayingSecondaryAction || actionContent) && (0, _jsxRuntime.jsxs)("div", {
134
+ children: (0, _jsxRuntime.jsxs)(_.Grid, {
135
+ columns: 1,
136
+ gutter: 8,
137
+ noMargin: true,
138
+ children: [(0, _jsxRuntime.jsxs)("h2", {
139
+ children: [(0, _jsxRuntime.jsxs)("span", {
140
+ className: "newspack-action-card__title",
141
+ ...titleProps,
142
+ children: [titleLink && (0, _jsxRuntime.jsx)("a", {
143
+ href: titleLink,
144
+ children: title
145
+ }), !titleLink && expandable && (0, _jsxRuntime.jsx)(_.Button, {
146
+ isLink: true,
147
+ onClick: () => this.setState({
148
+ expanded: !expanded
149
+ }),
150
+ children: title
151
+ }), !titleLink && !expandable && title]
152
+ }), badges?.length && badges.map((badgeText, i) => (0, _jsxRuntime.jsx)("span", {
153
+ className: "newspack-action-card__badge",
154
+ children: badgeText
155
+ }, `badge-${i}`))]
156
+ }), description && (0, _jsxRuntime.jsxs)("p", {
157
+ children: [typeof description === 'string' && description, typeof description === 'function' && description()]
158
+ })]
159
+ })
160
+ }), !expandable && (actionText || isDisplayingSecondaryAction || actionContent) && (0, _jsxRuntime.jsxs)("div", {
138
161
  className: "newspack-action-card__region newspack-action-card__region-right",
139
162
  children: [actionContent && actionContent, actionText && (handoff ? (0, _jsxRuntime.jsx)(_.Handoff, {
140
163
  plugin: handoff,
@@ -143,6 +166,7 @@ class ActionCard extends _element.Component {
143
166
  isLink: true,
144
167
  children: actionText
145
168
  }) : onClick || hasInternalLink ? (0, _jsxRuntime.jsx)(_.Button, {
169
+ disabled: disabled,
146
170
  isLink: true,
147
171
  href: href,
148
172
  onClick: onClick,
@@ -161,8 +185,18 @@ class ActionCard extends _element.Component {
161
185
  isLink: true,
162
186
  onClick: onSecondaryActionClick,
163
187
  className: "newspack-action-card__secondary_button",
188
+ isDestructive: secondaryDestructive,
164
189
  children: secondaryActionText
165
190
  })]
191
+ }), expandable && (0, _jsxRuntime.jsx)(_.Button, {
192
+ onClick: () => this.setState({
193
+ expanded: !expanded
194
+ }),
195
+ children: (0, _jsxRuntime.jsx)(_icons.Icon, {
196
+ icon: expanded ? _icons.chevronUp : _icons.chevronDown,
197
+ height: 24,
198
+ width: 24
199
+ })
166
200
  })]
167
201
  }), notification && (0, _jsxRuntime.jsxs)("div", {
168
202
  className: "newspack-action-card__notification newspack-action-card__region-children",
@@ -182,15 +216,13 @@ class ActionCard extends _element.Component {
182
216
  isWarning: true,
183
217
  rawHTML: notificationHTML
184
218
  })]
185
- }), children && (0, _jsxRuntime.jsx)("div", {
219
+ }), children && (expandable && expanded || !expandable) && (0, _jsxRuntime.jsx)("div", {
186
220
  className: "newspack-action-card__region-children",
187
221
  children: children
188
222
  })]
189
223
  });
190
224
  }
191
-
192
225
  }
193
-
194
226
  ActionCard.defaultProps = {
195
227
  toggleChecked: false
196
228
  };
@@ -2,12 +2,12 @@
2
2
  * Action Card
3
3
  */
4
4
 
5
- @import '~@wordpress/base-styles/colors';
6
- @import '../../../shared/scss/colors';
5
+ @use 'sass:color';
6
+ @use '~@wordpress/base-styles/colors' as wp-colors;
7
7
 
8
8
  .newspack-card.newspack-action-card {
9
9
  padding: 0;
10
- border-color: $gray-300;
10
+ border-color: wp-colors.$gray-300;
11
11
 
12
12
  // Clickable
13
13
 
@@ -26,7 +26,7 @@
26
26
  &.newspack-card__is-secondary,
27
27
  &.newspack-card__is-supported,
28
28
  &.newspack-card__is-unsupported {
29
- box-shadow: inset 4px 0 0 $gray-100;
29
+ box-shadow: inset 4px 0 0 wp-colors.$gray-100;
30
30
 
31
31
  .newspack-action-card__region-top {
32
32
  padding-left: 28px;
@@ -34,19 +34,19 @@
34
34
  }
35
35
 
36
36
  &.newspack-card__is-primary {
37
- box-shadow: inset 4px 0 0 $primary-500;
37
+ box-shadow: inset 4px 0 0 var( --wp-admin-theme-color );
38
38
  }
39
39
 
40
40
  &.newspack-card__is-secondary {
41
- box-shadow: inset 4px 0 0 $alert-yellow;
41
+ box-shadow: inset 4px 0 0 wp-colors.$alert-yellow;
42
42
  }
43
43
 
44
44
  &.newspack-card__is-supported {
45
- box-shadow: inset 4px 0 0 $alert-green;
45
+ box-shadow: inset 4px 0 0 wp-colors.$alert-green;
46
46
  }
47
47
 
48
48
  &.newspack-card__is-unsupported {
49
- box-shadow: inset 4px 0 0 $alert-red;
49
+ box-shadow: inset 4px 0 0 wp-colors.$alert-red;
50
50
  }
51
51
 
52
52
  // Small
@@ -84,18 +84,18 @@
84
84
  }
85
85
 
86
86
  &.mv0 {
87
- border-left-color: $gray-300;
87
+ border-left-color: wp-colors.$gray-300;
88
88
  border-radius: 0;
89
- border-right-color: $gray-300;
89
+ border-right-color: wp-colors.$gray-300;
90
90
 
91
91
  &:first-of-type {
92
- border-top-color: $gray-300;
92
+ border-top-color: wp-colors.$gray-300;
93
93
  border-top-left-radius: 3px;
94
94
  border-top-right-radius: 3px;
95
95
  }
96
96
 
97
97
  &:last-of-type {
98
- border-bottom-color: $gray-300;
98
+ border-bottom-color: wp-colors.$gray-300;
99
99
  border-bottom-left-radius: 3px;
100
100
  border-bottom-right-radius: 3px;
101
101
  }
@@ -142,7 +142,25 @@
142
142
  }
143
143
 
144
144
  .newspack-action-card__region-children {
145
- padding: 0 32px 32px 32px;
145
+ padding: 0 32px 32px;
146
+ }
147
+ }
148
+
149
+ // Nested children
150
+
151
+ &.newspack-card--has-children {
152
+ .newspack-action-card {
153
+ &:first-child {
154
+ margin-top: 32px;
155
+ }
156
+
157
+ + .newspack-action-card {
158
+ margin-top: 16px !important;
159
+ }
160
+
161
+ &:last-child {
162
+ margin-bottom: 0;
163
+ }
146
164
  }
147
165
  }
148
166
 
@@ -150,20 +168,58 @@
150
168
 
151
169
  &.newspack-card--has-grey-header {
152
170
  overflow: hidden;
171
+
153
172
  &.newspack-card--has-children {
154
173
  .newspack-action-card__region-top {
155
- border-bottom: 1px solid $gray-300;
174
+ border-bottom: 1px solid wp-colors.$gray-300;
175
+ }
176
+
177
+ .is-small > .newspack-action-card__region-top {
178
+ padding-bottom: 8px;
179
+ padding-top: 8px;
156
180
  }
157
181
  }
182
+
158
183
  .newspack-action-card__region-top {
159
- background-color: $gray-100;
184
+ background-color: rgba( black, 0.025 );
185
+ }
186
+
187
+ .newspack-action-card__region-center {
188
+ p {
189
+ color: color.adjust( wp-colors.$gray-700, $lightness: -0.75% );
190
+ }
191
+ }
192
+ }
193
+
194
+ &.newspack-card--has-white-header {
195
+ .newspack-action-card__region-top {
196
+ background-color: transparent;
197
+ border: none !important;
198
+ }
199
+ }
200
+
201
+ // Indent
202
+
203
+ &.newspack-card--indent {
204
+ margin-left: 56px;
205
+ position: relative;
206
+
207
+ &::before {
208
+ border: 0 solid wp-colors.$gray-300;
209
+ border-left-width: 1px;
210
+ border-bottom-width: 1px;
211
+ border-radius: 0 0 0 2px;
212
+ content: '';
213
+ display: block;
214
+ position: absolute;
215
+ inset: -17px 100% 50% -28px;
160
216
  }
161
217
  }
162
218
 
163
219
  // Typography
164
220
 
165
221
  h2,
166
- p {
222
+ p:not( [class*='components-base-control'] ) {
167
223
  margin: 0;
168
224
  max-width: 100%;
169
225
  width: 100%;
@@ -186,7 +242,7 @@
186
242
  &:active,
187
243
  &:focus,
188
244
  &:hover {
189
- color: $primary-500;
245
+ color: var( --wp-admin-theme-color );
190
246
  }
191
247
  }
192
248
  }
@@ -230,7 +286,7 @@
230
286
  }
231
287
 
232
288
  .newspack-action-card__region-children {
233
- padding: 0 24px 24px 24px;
289
+ padding: 0 24px 24px;
234
290
 
235
291
  &__inner {
236
292
  padding-top: 32px;
@@ -270,6 +326,14 @@
270
326
  align-items: flex-start;
271
327
  flex: 1 1 auto;
272
328
  flex-wrap: wrap;
329
+
330
+ .newspack-grid {
331
+ width: 100%;
332
+ }
333
+
334
+ p {
335
+ color: wp-colors.$gray-700;
336
+ }
273
337
  }
274
338
 
275
339
  .newspack-action-card__region-right {
@@ -289,6 +353,10 @@
289
353
  > * {
290
354
  text-align: inherit;
291
355
  }
356
+
357
+ .newspack-action-card__secondary_button {
358
+ margin-top: 8px;
359
+ }
292
360
  }
293
361
 
294
362
  // Waiting
@@ -307,6 +375,12 @@
307
375
  margin-top: 0;
308
376
  }
309
377
  }
378
+
379
+ &.newspack-action-card__region-children {
380
+ .newspack-notice {
381
+ margin-top: 32px;
382
+ }
383
+ }
310
384
  }
311
385
 
312
386
  // Image
@@ -326,34 +400,19 @@
326
400
  margin: 0;
327
401
  }
328
402
 
329
- // Buttons
330
-
331
- .newspack-button {
332
- &.newspack-action-card__secondary_button {
333
- &.is-link {
334
- color: $alert-red;
335
-
336
- &:active,
337
- &:focus,
338
- &:hover {
339
- color: darken( $alert-red, 20% );
340
- }
341
- }
342
- }
343
- }
344
-
345
403
  // Badge
346
404
 
347
405
  .newspack-action-card__badge {
348
- border: 1px solid $gray-300;
349
- border-radius: 12px;
406
+ background: wp-colors.$gray-100;
407
+ border-radius: 2px;
408
+ color: wp-colors.$gray-900;
350
409
  display: block;
351
410
  flex: 0 0 auto;
352
- font-size: 12px;
411
+ font-size: 10px;
353
412
  font-weight: bold;
354
- line-height: 16px;
355
- margin: 3px 8px 3px 0;
356
- padding: 0 8px;
413
+ line-height: 1.4;
414
+ margin: 0 8px 0 0;
415
+ padding: 2px 8px;
357
416
  text-transform: uppercase;
358
417
 
359
418
  + .newspack-action-card__badge {
@@ -367,6 +426,49 @@
367
426
  font-style: italic;
368
427
  }
369
428
 
429
+ // Expandable card children
430
+
431
+ &.is-expandable {
432
+ .newspack-action-card__title .components-button.is-link {
433
+ color: inherit;
434
+ font-size: inherit;
435
+ font-weight: inherit;
436
+ text-decoration: inherit;
437
+ }
438
+
439
+ .newspack-action-card__region-children {
440
+ border-top: 1px solid wp-colors.$gray-100;
441
+ padding-top: 24px;
442
+ }
443
+
444
+ &.is-medium .newspack-action-card__region-children {
445
+ padding-top: 32px;
446
+ }
447
+
448
+ &.has-checkbox {
449
+ .newspack-action-card__region-children {
450
+ padding-left: 72px;
451
+ }
452
+
453
+ &.is-small .newspack-action-card__region-children {
454
+ padding-left: 64px;
455
+ }
456
+
457
+ &.is-medium .newspack-action-card__region-children {
458
+ padding-left: 56px;
459
+ }
460
+ }
461
+ }
462
+
463
+ // Action content with multiple buttons
464
+ &.has-action-content .newspack-action-card__region-right {
465
+ flex-direction: row;
466
+
467
+ .components-button + .components-button {
468
+ margin-left: 8px;
469
+ }
470
+ }
471
+
370
472
  // Multiple Cards
371
473
 
372
474
  & + & {
@@ -376,6 +478,6 @@
376
478
 
377
479
  .newspack-card {
378
480
  .newspack-card.newspack-action-card {
379
- border: 1px solid $gray-200;
481
+ border: 1px solid wp-colors.$gray-200;
380
482
  }
381
483
  }