newspack-components 4.8.0 → 4.9.0-alpha.1
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.
- package/CHANGELOG.md +10 -0
- package/DEVELOPMENT.md +18 -17
- package/dist/cjs/action-card/index.js +85 -18
- package/dist/cjs/action-card/index.test.js +192 -5
- package/dist/cjs/action-card/style.scss +3 -9
- package/dist/cjs/card-feature/index.js +28 -3
- package/dist/cjs/card-feature/index.test.js +100 -45
- package/dist/cjs/card-feature/style.scss +1 -5
- package/dist/cjs/debug-badge/index.js +44 -0
- package/dist/cjs/debug-badge/index.test.js +50 -0
- package/dist/cjs/debug-badge/style.scss +26 -0
- package/dist/cjs/empty-state/index.test.js +37 -24
- package/dist/cjs/empty-state/root.js +2 -1
- package/dist/cjs/footer/index.js +52 -16
- package/dist/cjs/footer/index.test.js +208 -0
- package/dist/cjs/footer/style.scss +17 -1
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/integration-icon/index.js +4 -4
- package/dist/cjs/integration-icon/style.scss +18 -2
- package/dist/cjs/integration-icons/active-campaign.js +4 -7
- package/dist/cjs/integration-icons/beehiiv.js +19 -0
- package/dist/cjs/integration-icons/gravity-forms.js +19 -0
- package/dist/cjs/integration-icons/index.js +26 -6
- package/dist/cjs/integration-icons/salesforce.js +5 -3
- package/dist/cjs/notice/index.js +1 -4
- package/dist/cjs/notice/style.scss +0 -19
- package/dist/cjs/plugin-toggle/index.js +1 -1
- package/dist/cjs/with-wizard-screen/index.js +1 -3
- package/dist/cjs/with-wizard-screen/index.test.js +0 -3
- package/dist/cjs/wizard/breadcrumbs-select.js +17 -4
- package/dist/cjs/wizard/breadcrumbs-select.test.js +17 -0
- package/dist/cjs/wizard/index.js +50 -13
- package/dist/cjs/wizard/index.test.js +304 -5
- package/dist/cjs/wizard/store/index.js +2 -0
- package/dist/esm/action-card/index.js +86 -21
- package/dist/esm/action-card/index.test.js +192 -1
- package/dist/esm/action-card/style.scss +3 -9
- package/dist/esm/card-feature/index.js +29 -4
- package/dist/esm/card-feature/index.test.js +100 -45
- package/dist/esm/card-feature/style.scss +1 -5
- package/dist/esm/debug-badge/index.js +39 -0
- package/dist/esm/debug-badge/index.test.js +46 -0
- package/dist/esm/debug-badge/style.scss +26 -0
- package/dist/esm/empty-state/index.test.js +37 -24
- package/dist/esm/empty-state/root.js +2 -1
- package/dist/esm/footer/index.js +52 -17
- package/dist/esm/footer/index.test.js +210 -0
- package/dist/esm/footer/style.scss +17 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/integration-icon/index.js +5 -5
- package/dist/esm/integration-icon/style.scss +18 -2
- package/dist/esm/integration-icons/active-campaign.js +5 -8
- package/dist/esm/integration-icons/beehiiv.js +13 -0
- package/dist/esm/integration-icons/gravity-forms.js +13 -0
- package/dist/esm/integration-icons/index.js +15 -4
- package/dist/esm/integration-icons/salesforce.js +5 -3
- package/dist/esm/notice/index.js +2 -5
- package/dist/esm/notice/style.scss +0 -19
- package/dist/esm/plugin-toggle/index.js +1 -1
- package/dist/esm/with-wizard-screen/index.js +2 -4
- package/dist/esm/with-wizard-screen/index.test.js +0 -3
- package/dist/esm/wizard/breadcrumbs-select.js +16 -3
- package/dist/esm/wizard/breadcrumbs-select.test.js +18 -1
- package/dist/esm/wizard/index.js +53 -16
- package/dist/esm/wizard/index.test.js +304 -5
- package/dist/esm/wizard/store/index.js +2 -0
- package/package.json +1 -1
- package/src/action-card/action-card.d.ts +3 -2
- package/src/action-card/index.js +81 -8
- package/src/action-card/index.test.js +159 -0
- package/src/action-card/style.scss +3 -9
- package/src/card-feature/README.md +10 -11
- package/src/card-feature/index.test.js +45 -15
- package/src/card-feature/index.tsx +43 -24
- package/src/card-feature/style.scss +1 -5
- package/src/debug-badge/index.js +36 -0
- package/src/debug-badge/index.test.js +39 -0
- package/src/debug-badge/style.scss +26 -0
- package/src/empty-state/README.md +11 -10
- package/src/empty-state/index.test.js +10 -0
- package/src/empty-state/root.tsx +2 -1
- package/src/empty-state/types.ts +1 -1
- package/src/footer/index.js +47 -2
- package/src/footer/index.test.js +114 -0
- package/src/footer/style.scss +17 -1
- package/src/index.js +1 -0
- package/src/integration-icon/index.tsx +5 -5
- package/src/integration-icon/style.scss +18 -2
- package/src/integration-icons/active-campaign.js +1 -5
- package/src/integration-icons/beehiiv.js +10 -0
- package/src/integration-icons/gravity-forms.js +10 -0
- package/src/integration-icons/index.js +14 -3
- package/src/integration-icons/salesforce.js +3 -3
- package/src/notice/index.js +2 -17
- package/src/notice/style.scss +0 -19
- package/src/plugin-toggle/index.js +1 -1
- package/src/with-wizard-screen/index.js +2 -2
- package/src/with-wizard-screen/index.test.js +0 -2
- package/src/wizard/breadcrumbs-select.js +12 -4
- package/src/wizard/breadcrumbs-select.test.js +15 -1
- package/src/wizard/index.js +45 -14
- package/src/wizard/index.test.js +169 -3
- package/src/wizard/store/index.js +2 -0
|
@@ -95,7 +95,8 @@ describe('CardFeature', function () {
|
|
|
95
95
|
it('names the feature in the configure state too', function () {
|
|
96
96
|
render(/*#__PURE__*/_jsx(CardFeature, {
|
|
97
97
|
title: "Content Gifting",
|
|
98
|
-
enabled: true
|
|
98
|
+
enabled: true,
|
|
99
|
+
onConfigure: function onConfigure() {}
|
|
99
100
|
}));
|
|
100
101
|
expect(screen.getByRole('button', {
|
|
101
102
|
name: 'Configure Content Gifting'
|
|
@@ -164,6 +165,72 @@ describe('CardFeature', function () {
|
|
|
164
165
|
expect(onConfigure).toHaveBeenCalledTimes(1);
|
|
165
166
|
expect(onEnable).not.toHaveBeenCalled();
|
|
166
167
|
});
|
|
168
|
+
|
|
169
|
+
// A button reading Configure with nothing behind it would click to nowhere.
|
|
170
|
+
it('drops the primary button once enabled when there is nothing to configure', function () {
|
|
171
|
+
render(/*#__PURE__*/_jsx(CardFeature, {
|
|
172
|
+
title: "Content gifting",
|
|
173
|
+
enabled: true,
|
|
174
|
+
onEnable: jest.fn(),
|
|
175
|
+
moreControls: [{
|
|
176
|
+
title: 'Disable',
|
|
177
|
+
onClick: jest.fn()
|
|
178
|
+
}]
|
|
179
|
+
}));
|
|
180
|
+
expect(screen.queryByRole('button', {
|
|
181
|
+
name: /Configure/
|
|
182
|
+
})).toBeNull();
|
|
183
|
+
expect(moreMenu()).toBeInTheDocument();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Enabling removes the button that was just used; without a hand-off,
|
|
187
|
+
// keyboard focus falls to the page.
|
|
188
|
+
it('hands focus to the More menu when enabling removes the focused button', function () {
|
|
189
|
+
var props = {
|
|
190
|
+
title: 'Content gifting',
|
|
191
|
+
onEnable: jest.fn(),
|
|
192
|
+
moreControls: [{
|
|
193
|
+
title: 'Disable',
|
|
194
|
+
onClick: jest.fn()
|
|
195
|
+
}]
|
|
196
|
+
};
|
|
197
|
+
var _render2 = render(/*#__PURE__*/_jsx(CardFeature, _objectSpread({}, props))),
|
|
198
|
+
rerender = _render2.rerender;
|
|
199
|
+
primaryButton().focus();
|
|
200
|
+
rerender(/*#__PURE__*/_jsx(CardFeature, _objectSpread(_objectSpread({}, props), {}, {
|
|
201
|
+
enabled: true
|
|
202
|
+
})));
|
|
203
|
+
expect(moreMenu()).toHaveFocus();
|
|
204
|
+
});
|
|
205
|
+
it('leaves focus alone when the removed button did not have it', function () {
|
|
206
|
+
var props = {
|
|
207
|
+
title: 'Content gifting',
|
|
208
|
+
onEnable: jest.fn(),
|
|
209
|
+
moreControls: [{
|
|
210
|
+
title: 'Disable',
|
|
211
|
+
onClick: jest.fn()
|
|
212
|
+
}]
|
|
213
|
+
};
|
|
214
|
+
var _render3 = render(/*#__PURE__*/_jsxs(_Fragment, {
|
|
215
|
+
children: [/*#__PURE__*/_jsx(CardFeature, _objectSpread({}, props)), /*#__PURE__*/_jsx("button", {
|
|
216
|
+
children: "Elsewhere"
|
|
217
|
+
})]
|
|
218
|
+
})),
|
|
219
|
+
rerender = _render3.rerender;
|
|
220
|
+
screen.getByRole('button', {
|
|
221
|
+
name: 'Elsewhere'
|
|
222
|
+
}).focus();
|
|
223
|
+
rerender(/*#__PURE__*/_jsxs(_Fragment, {
|
|
224
|
+
children: [/*#__PURE__*/_jsx(CardFeature, _objectSpread(_objectSpread({}, props), {}, {
|
|
225
|
+
enabled: true
|
|
226
|
+
})), /*#__PURE__*/_jsx("button", {
|
|
227
|
+
children: "Elsewhere"
|
|
228
|
+
})]
|
|
229
|
+
}));
|
|
230
|
+
expect(screen.getByRole('button', {
|
|
231
|
+
name: 'Elsewhere'
|
|
232
|
+
})).toHaveFocus();
|
|
233
|
+
});
|
|
167
234
|
it('still routes to onEnable when enabled with an unmet requirement, since the button reads Enable', function () {
|
|
168
235
|
var onEnable = jest.fn();
|
|
169
236
|
var onConfigure = jest.fn();
|
|
@@ -221,18 +288,19 @@ describe('CardFeature', function () {
|
|
|
221
288
|
it('leaves the enabled badge unlinked, since it explains nothing about the button', function () {
|
|
222
289
|
render(/*#__PURE__*/_jsx(CardFeature, {
|
|
223
290
|
title: "Content gifting",
|
|
224
|
-
enabled: true
|
|
291
|
+
enabled: true,
|
|
292
|
+
onConfigure: function onConfigure() {}
|
|
225
293
|
}));
|
|
226
294
|
expect(primaryButton()).not.toHaveAttribute('aria-describedby');
|
|
227
295
|
});
|
|
228
296
|
it('disables the button while an action is in flight, even with an actionable requirement', function () {
|
|
229
297
|
var onEnable = jest.fn();
|
|
230
|
-
var
|
|
298
|
+
var _render4 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
231
299
|
title: "Content gifting",
|
|
232
300
|
busy: true,
|
|
233
301
|
onEnable: onEnable
|
|
234
302
|
})),
|
|
235
|
-
rerender =
|
|
303
|
+
rerender = _render4.rerender;
|
|
236
304
|
expect(primaryButton()).toHaveAttribute('aria-disabled', 'true');
|
|
237
305
|
fireEvent.click(primaryButton());
|
|
238
306
|
expect(onEnable).not.toHaveBeenCalled();
|
|
@@ -246,12 +314,12 @@ describe('CardFeature', function () {
|
|
|
246
314
|
expect(primaryButton()).toHaveAttribute('aria-disabled', 'true');
|
|
247
315
|
});
|
|
248
316
|
it('accepts custom labels for both states', function () {
|
|
249
|
-
var
|
|
317
|
+
var _render5 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
250
318
|
title: "Apple News",
|
|
251
319
|
enableLabel: "Connect",
|
|
252
320
|
configureLabel: "Manage connection"
|
|
253
321
|
})),
|
|
254
|
-
rerender =
|
|
322
|
+
rerender = _render5.rerender;
|
|
255
323
|
expect(screen.getByRole('button', {
|
|
256
324
|
name: 'Connect Apple News'
|
|
257
325
|
})).toBeInTheDocument();
|
|
@@ -259,7 +327,8 @@ describe('CardFeature', function () {
|
|
|
259
327
|
title: "Apple News",
|
|
260
328
|
enabled: true,
|
|
261
329
|
enableLabel: "Connect",
|
|
262
|
-
configureLabel: "Manage connection"
|
|
330
|
+
configureLabel: "Manage connection",
|
|
331
|
+
onConfigure: function onConfigure() {}
|
|
263
332
|
}));
|
|
264
333
|
expect(screen.getByRole('button', {
|
|
265
334
|
name: 'Manage connection Apple News'
|
|
@@ -268,10 +337,10 @@ describe('CardFeature', function () {
|
|
|
268
337
|
});
|
|
269
338
|
describe('badge', function () {
|
|
270
339
|
it('shows nothing when off, and the enabled badge when on', function () {
|
|
271
|
-
var
|
|
340
|
+
var _render6 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
272
341
|
title: "Content gifting"
|
|
273
342
|
})),
|
|
274
|
-
rerender =
|
|
343
|
+
rerender = _render6.rerender;
|
|
275
344
|
expect(screen.queryByText('Enabled')).not.toBeInTheDocument();
|
|
276
345
|
rerender(/*#__PURE__*/_jsx(CardFeature, {
|
|
277
346
|
title: "Content gifting",
|
|
@@ -306,11 +375,11 @@ describe('CardFeature', function () {
|
|
|
306
375
|
onClick: jest.fn()
|
|
307
376
|
}];
|
|
308
377
|
it('appears only when enabled and controls are supplied', function () {
|
|
309
|
-
var
|
|
378
|
+
var _render7 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
310
379
|
title: "Content gifting",
|
|
311
380
|
moreControls: controls
|
|
312
381
|
})),
|
|
313
|
-
rerender =
|
|
382
|
+
rerender = _render7.rerender;
|
|
314
383
|
expect(moreMenu()).not.toBeInTheDocument();
|
|
315
384
|
rerender(/*#__PURE__*/_jsx(CardFeature, {
|
|
316
385
|
title: "Content gifting",
|
|
@@ -325,14 +394,14 @@ describe('CardFeature', function () {
|
|
|
325
394
|
expect(moreMenu()).toBeInTheDocument();
|
|
326
395
|
});
|
|
327
396
|
it('stays available on an actionable requirement and hides on a locked one', function () {
|
|
328
|
-
var
|
|
397
|
+
var _render8 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
329
398
|
title: "Content gifting",
|
|
330
399
|
enabled: true,
|
|
331
400
|
requirements: "Requires metering",
|
|
332
401
|
requirementsActionable: true,
|
|
333
402
|
moreControls: controls
|
|
334
403
|
})),
|
|
335
|
-
rerender =
|
|
404
|
+
rerender = _render8.rerender;
|
|
336
405
|
expect(moreMenu()).toBeInTheDocument();
|
|
337
406
|
rerender(/*#__PURE__*/_jsx(CardFeature, {
|
|
338
407
|
title: "Content gifting",
|
|
@@ -345,88 +414,74 @@ describe('CardFeature', function () {
|
|
|
345
414
|
});
|
|
346
415
|
describe('icon', function () {
|
|
347
416
|
it('renders a ready element as-is, without the descriptor container', function () {
|
|
348
|
-
var
|
|
417
|
+
var _render9 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
349
418
|
title: "Content gifting",
|
|
350
419
|
icon: /*#__PURE__*/_jsx("span", {
|
|
351
420
|
"data-testid": "ready-icon"
|
|
352
421
|
})
|
|
353
422
|
})),
|
|
354
|
-
container =
|
|
423
|
+
container = _render9.container;
|
|
355
424
|
expect(screen.getByTestId('ready-icon')).toBeInTheDocument();
|
|
356
425
|
expect(container.querySelector('.newspack-card-feature__icon')).toBeNull();
|
|
357
426
|
});
|
|
358
|
-
it('applies the descriptor colours inline and rounds
|
|
359
|
-
var
|
|
427
|
+
it('applies the descriptor colours inline and rounds a backed icon', function () {
|
|
428
|
+
var _render0 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
360
429
|
title: "Content gifting",
|
|
361
430
|
icon: {
|
|
362
431
|
node: /*#__PURE__*/_jsx("span", {
|
|
363
432
|
"data-testid": "descriptor-icon"
|
|
364
433
|
}),
|
|
365
434
|
fill: '#003da5',
|
|
366
|
-
backgroundColor: '#dfe7f4'
|
|
367
|
-
radius: 'full'
|
|
435
|
+
backgroundColor: '#dfe7f4'
|
|
368
436
|
}
|
|
369
437
|
})),
|
|
370
|
-
container =
|
|
438
|
+
container = _render0.container;
|
|
371
439
|
var iconContainer = container.querySelector('.newspack-card-feature__icon');
|
|
372
440
|
expect(screen.getByTestId('descriptor-icon')).toBeInTheDocument();
|
|
373
|
-
expect(iconContainer).toHaveClass('newspack-card-feature__icon--
|
|
441
|
+
expect(iconContainer).toHaveClass('newspack-card-feature__icon--has-background');
|
|
374
442
|
expect(iconContainer).toHaveStyle({
|
|
375
443
|
backgroundColor: '#dfe7f4',
|
|
376
444
|
color: '#003da5'
|
|
377
445
|
});
|
|
378
446
|
});
|
|
379
447
|
it('hides the descriptor container from assistive tech, since the title already names the feature', function () {
|
|
380
|
-
var
|
|
448
|
+
var _render1 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
381
449
|
title: "Content gifting",
|
|
382
450
|
icon: {
|
|
383
451
|
node: /*#__PURE__*/_jsx("svg", {})
|
|
384
452
|
}
|
|
385
453
|
})),
|
|
386
|
-
container =
|
|
454
|
+
container = _render1.container;
|
|
387
455
|
expect(container.querySelector('.newspack-card-feature__icon')).toHaveAttribute('aria-hidden', 'true');
|
|
388
456
|
});
|
|
389
|
-
it('
|
|
390
|
-
var
|
|
391
|
-
title: "Content gifting",
|
|
392
|
-
icon: {
|
|
393
|
-
node: /*#__PURE__*/_jsx("span", {}),
|
|
394
|
-
backgroundColor: '#dfe7f4'
|
|
395
|
-
}
|
|
396
|
-
})),
|
|
397
|
-
container = _render0.container;
|
|
398
|
-
var iconContainer = container.querySelector('.newspack-card-feature__icon');
|
|
399
|
-
expect(iconContainer).toHaveClass('newspack-card-feature__icon--radius-small');
|
|
400
|
-
expect(iconContainer).not.toHaveClass('newspack-card-feature__icon--radius-full');
|
|
401
|
-
});
|
|
402
|
-
it('leaves an unbacked descriptor icon without a radius class', function () {
|
|
403
|
-
var _render1 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
457
|
+
it('leaves an unbacked descriptor icon without the background class', function () {
|
|
458
|
+
var _render10 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
404
459
|
title: "Content gifting",
|
|
405
460
|
icon: {
|
|
406
461
|
node: /*#__PURE__*/_jsx("span", {}),
|
|
407
462
|
fill: '#003da5'
|
|
408
463
|
}
|
|
409
464
|
})),
|
|
410
|
-
container =
|
|
465
|
+
container = _render10.container;
|
|
411
466
|
var iconContainer = container.querySelector('.newspack-card-feature__icon');
|
|
412
|
-
expect(iconContainer).not.toHaveClass('newspack-card-feature__icon--
|
|
467
|
+
expect(iconContainer).not.toHaveClass('newspack-card-feature__icon--has-background');
|
|
413
468
|
});
|
|
414
469
|
});
|
|
415
470
|
it('passes className through to the card element', function () {
|
|
416
|
-
var
|
|
471
|
+
var _render11 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
417
472
|
title: "Content gifting",
|
|
418
473
|
className: "newspack-subscribers__card"
|
|
419
474
|
})),
|
|
420
|
-
container =
|
|
475
|
+
container = _render11.container;
|
|
421
476
|
expect(container.querySelector('.newspack-card-feature')).toHaveClass('newspack-subscribers__card');
|
|
422
477
|
});
|
|
423
478
|
it('marks the card as muted only when requirements are set', function () {
|
|
424
|
-
var
|
|
479
|
+
var _render12 = render(/*#__PURE__*/_jsx(CardFeature, {
|
|
425
480
|
title: "Content gifting",
|
|
426
481
|
enabled: true
|
|
427
482
|
})),
|
|
428
|
-
container =
|
|
429
|
-
rerender =
|
|
483
|
+
container = _render12.container,
|
|
484
|
+
rerender = _render12.rerender;
|
|
430
485
|
expect(container.querySelector('.newspack-card-feature--muted')).toBeNull();
|
|
431
486
|
rerender(/*#__PURE__*/_jsx(CardFeature, {
|
|
432
487
|
title: "Content gifting",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug Badge
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies.
|
|
7
|
+
*/
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { Icon, bug } from '@wordpress/icons';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies.
|
|
13
|
+
*/
|
|
14
|
+
import './style.scss';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Debug Badge component.
|
|
18
|
+
*
|
|
19
|
+
* Gates itself on `window.newspack_aux_data.is_debug_mode`, so consumers render
|
|
20
|
+
* it unconditionally and it stays absent outside debug mode.
|
|
21
|
+
*
|
|
22
|
+
* @return {JSX.Element|null} Debug Badge component, or nothing outside debug mode.
|
|
23
|
+
*/
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
+
var DebugBadge = function DebugBadge() {
|
|
26
|
+
var _window$newspack_aux_;
|
|
27
|
+
if (!((_window$newspack_aux_ = window.newspack_aux_data) !== null && _window$newspack_aux_ !== void 0 && _window$newspack_aux_.is_debug_mode)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return /*#__PURE__*/_jsx("div", {
|
|
31
|
+
className: "newspack-debug-badge",
|
|
32
|
+
role: "img",
|
|
33
|
+
"aria-label": __('Debug mode', 'newspack-plugin'),
|
|
34
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
35
|
+
icon: bug
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export default DebugBadge;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import DebugBadge from '.';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
describe('DebugBadge', function () {
|
|
12
|
+
afterEach(function () {
|
|
13
|
+
delete window.newspack_aux_data;
|
|
14
|
+
});
|
|
15
|
+
it('renders the badge and its glyph in debug mode', function () {
|
|
16
|
+
window.newspack_aux_data = {
|
|
17
|
+
is_debug_mode: true
|
|
18
|
+
};
|
|
19
|
+
var _render = render(/*#__PURE__*/_jsx(DebugBadge, {})),
|
|
20
|
+
container = _render.container;
|
|
21
|
+
expect(container.querySelector('.newspack-debug-badge')).toBeInTheDocument();
|
|
22
|
+
expect(container.querySelector('.newspack-debug-badge > svg')).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
it('names itself for assistive tech', function () {
|
|
25
|
+
window.newspack_aux_data = {
|
|
26
|
+
is_debug_mode: true
|
|
27
|
+
};
|
|
28
|
+
render(/*#__PURE__*/_jsx(DebugBadge, {}));
|
|
29
|
+
expect(screen.getByRole('img', {
|
|
30
|
+
name: 'Debug mode'
|
|
31
|
+
})).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
it('renders nothing outside debug mode', function () {
|
|
34
|
+
window.newspack_aux_data = {
|
|
35
|
+
is_debug_mode: false
|
|
36
|
+
};
|
|
37
|
+
var _render2 = render(/*#__PURE__*/_jsx(DebugBadge, {})),
|
|
38
|
+
container = _render2.container;
|
|
39
|
+
expect(container).toBeEmptyDOMElement();
|
|
40
|
+
});
|
|
41
|
+
it('renders nothing when the global is absent', function () {
|
|
42
|
+
var _render3 = render(/*#__PURE__*/_jsx(DebugBadge, {})),
|
|
43
|
+
container = _render3.container;
|
|
44
|
+
expect(container).toBeEmptyDOMElement();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug Badge
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
@use "~@wordpress/base-styles/variables" as wp-vars;
|
|
7
|
+
@use "../../../colors/colors.module" as np-colors;
|
|
8
|
+
|
|
9
|
+
.newspack-debug-badge {
|
|
10
|
+
background: np-colors.$primary-600;
|
|
11
|
+
border-radius: wp-vars.$radius-round;
|
|
12
|
+
bottom: 0;
|
|
13
|
+
box-shadow: var(--wpds-elevation-sm, #{wp-vars.$elevation-small});
|
|
14
|
+
display: grid;
|
|
15
|
+
height: wp-vars.$button-size;
|
|
16
|
+
margin: 0 wp-vars.$grid-unit-30 wp-vars.$grid-unit-30;
|
|
17
|
+
place-items: center;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
position: fixed;
|
|
20
|
+
width: wp-vars.$button-size;
|
|
21
|
+
z-index: 9997;
|
|
22
|
+
|
|
23
|
+
> svg {
|
|
24
|
+
fill: wp-colors.$white;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -49,17 +49,30 @@ describe('EmptyState.Root', function () {
|
|
|
49
49
|
gap: 'var(--wpds-dimension-gap-2xl, 32px)'
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
it('tightens the stack gap when small', function () {
|
|
53
|
+
var _render4 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
54
|
+
size: "small",
|
|
55
|
+
children: /*#__PURE__*/_jsx("p", {
|
|
56
|
+
children: "body"
|
|
57
|
+
})
|
|
58
|
+
})),
|
|
59
|
+
container = _render4.container;
|
|
60
|
+
var stack = container.querySelector('.newspack-empty-state').firstElementChild;
|
|
61
|
+
expect(stack).toHaveStyle({
|
|
62
|
+
gap: 'var(--wpds-dimension-gap-xl, 24px)'
|
|
63
|
+
});
|
|
64
|
+
});
|
|
52
65
|
|
|
53
66
|
// Consumers key `:has()` selectors off this class, so losing it changes their
|
|
54
67
|
// layout without failing anything.
|
|
55
68
|
it('merges className onto the grid', function () {
|
|
56
|
-
var
|
|
69
|
+
var _render5 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
57
70
|
className: "consumer-empty-state",
|
|
58
71
|
children: /*#__PURE__*/_jsx("p", {
|
|
59
72
|
children: "body"
|
|
60
73
|
})
|
|
61
74
|
})),
|
|
62
|
-
container =
|
|
75
|
+
container = _render5.container;
|
|
63
76
|
expect(container.querySelector('.newspack-empty-state')).toHaveClass('consumer-empty-state');
|
|
64
77
|
});
|
|
65
78
|
|
|
@@ -76,13 +89,13 @@ describe('EmptyState.Root', function () {
|
|
|
76
89
|
});
|
|
77
90
|
describe('EmptyState.Header', function () {
|
|
78
91
|
it('renders the title and description in the header', function () {
|
|
79
|
-
var
|
|
92
|
+
var _render6 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
80
93
|
children: /*#__PURE__*/_jsx(EmptyState.Header, {
|
|
81
94
|
title: "Get started with newsletters",
|
|
82
95
|
description: "Compose and send."
|
|
83
96
|
})
|
|
84
97
|
})),
|
|
85
|
-
container =
|
|
98
|
+
container = _render6.container;
|
|
86
99
|
expect(container.querySelector('.newspack-empty-state__title')).toHaveTextContent('Get started with newsletters');
|
|
87
100
|
expect(container.querySelector('.newspack-empty-state__description')).toHaveTextContent('Compose and send.');
|
|
88
101
|
});
|
|
@@ -90,13 +103,13 @@ describe('EmptyState.Header', function () {
|
|
|
90
103
|
// Spacing comes from the stacks, so a margin creeping back onto the heading or
|
|
91
104
|
// paragraph would silently widen every gap.
|
|
92
105
|
it('spaces the header from its stacks rather than from margins', function () {
|
|
93
|
-
var
|
|
106
|
+
var _render7 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
94
107
|
children: /*#__PURE__*/_jsx(EmptyState.Header, {
|
|
95
108
|
title: "Get started with newsletters",
|
|
96
109
|
description: "Compose and send."
|
|
97
110
|
})
|
|
98
111
|
})),
|
|
99
|
-
container =
|
|
112
|
+
container = _render7.container;
|
|
100
113
|
var header = container.querySelector('.newspack-empty-state__header');
|
|
101
114
|
expect(header).toHaveStyle({
|
|
102
115
|
flexDirection: 'column',
|
|
@@ -110,33 +123,33 @@ describe('EmptyState.Header', function () {
|
|
|
110
123
|
});
|
|
111
124
|
});
|
|
112
125
|
it('wraps the icon in the disc', function () {
|
|
113
|
-
var
|
|
126
|
+
var _render8 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
114
127
|
children: /*#__PURE__*/_jsx(EmptyState.Header, {
|
|
115
128
|
title: "Get started with newsletters",
|
|
116
129
|
icon: /*#__PURE__*/_jsx("svg", {})
|
|
117
130
|
})
|
|
118
131
|
})),
|
|
119
|
-
container =
|
|
132
|
+
container = _render8.container;
|
|
120
133
|
expect(container.querySelector('.newspack-empty-state__icon svg')).toBeInTheDocument();
|
|
121
134
|
});
|
|
122
135
|
it('omits the description and the icon when they are not given', function () {
|
|
123
|
-
var
|
|
136
|
+
var _render9 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
124
137
|
children: /*#__PURE__*/_jsx(EmptyState.Header, {
|
|
125
138
|
title: "Get started with newsletters"
|
|
126
139
|
})
|
|
127
140
|
})),
|
|
128
|
-
container =
|
|
141
|
+
container = _render9.container;
|
|
129
142
|
expect(container.querySelector('.newspack-empty-state__description')).not.toBeInTheDocument();
|
|
130
143
|
expect(container.querySelector('.newspack-empty-state__icon')).not.toBeInTheDocument();
|
|
131
144
|
});
|
|
132
145
|
it('renders an h2 and a 48px icon at the default size', function () {
|
|
133
|
-
var
|
|
146
|
+
var _render0 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
134
147
|
children: /*#__PURE__*/_jsx(EmptyState.Header, {
|
|
135
148
|
title: "Get started with newsletters",
|
|
136
149
|
icon: /*#__PURE__*/_jsx("svg", {})
|
|
137
150
|
})
|
|
138
151
|
})),
|
|
139
|
-
container =
|
|
152
|
+
container = _render0.container;
|
|
140
153
|
expect(screen.getByRole('heading', {
|
|
141
154
|
level: 2,
|
|
142
155
|
name: 'Get started with newsletters'
|
|
@@ -145,14 +158,14 @@ describe('EmptyState.Header', function () {
|
|
|
145
158
|
expect(container.querySelector('.newspack-empty-state__icon svg')).toHaveAttribute('width', '48');
|
|
146
159
|
});
|
|
147
160
|
it('drops to an h3, the small modifier and a 24px icon when the root is small', function () {
|
|
148
|
-
var
|
|
161
|
+
var _render1 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
149
162
|
size: "small",
|
|
150
163
|
children: /*#__PURE__*/_jsx(EmptyState.Header, {
|
|
151
164
|
title: "No products match this rule",
|
|
152
165
|
icon: /*#__PURE__*/_jsx("svg", {})
|
|
153
166
|
})
|
|
154
167
|
})),
|
|
155
|
-
container =
|
|
168
|
+
container = _render1.container;
|
|
156
169
|
expect(container.querySelector('.newspack-empty-state__header--small')).toBeInTheDocument();
|
|
157
170
|
expect(screen.getByRole('heading', {
|
|
158
171
|
level: 3,
|
|
@@ -177,13 +190,13 @@ describe('EmptyState.Header', function () {
|
|
|
177
190
|
})).toBeInTheDocument();
|
|
178
191
|
});
|
|
179
192
|
it('carries its own class hook alongside any className', function () {
|
|
180
|
-
var
|
|
193
|
+
var _render10 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
181
194
|
children: /*#__PURE__*/_jsx(EmptyState.Header, {
|
|
182
195
|
title: "Get started with newsletters",
|
|
183
196
|
className: "consumer-header"
|
|
184
197
|
})
|
|
185
198
|
})),
|
|
186
|
-
container =
|
|
199
|
+
container = _render10.container;
|
|
187
200
|
var header = container.querySelector('.newspack-empty-state__header');
|
|
188
201
|
expect(header).toBeInTheDocument();
|
|
189
202
|
expect(header).toHaveClass('consumer-header');
|
|
@@ -207,11 +220,11 @@ describe('EmptyState.Header', function () {
|
|
|
207
220
|
var previous = process.env.NODE_ENV;
|
|
208
221
|
process.env.NODE_ENV = 'production';
|
|
209
222
|
try {
|
|
210
|
-
var
|
|
223
|
+
var _render11 = render(/*#__PURE__*/_jsx(EmptyState.Header, {
|
|
211
224
|
title: "Orphan",
|
|
212
225
|
icon: /*#__PURE__*/_jsx("svg", {})
|
|
213
226
|
})),
|
|
214
|
-
container =
|
|
227
|
+
container = _render11.container;
|
|
215
228
|
expect(screen.getByRole('heading', {
|
|
216
229
|
level: 2,
|
|
217
230
|
name: 'Orphan'
|
|
@@ -225,7 +238,7 @@ describe('EmptyState.Header', function () {
|
|
|
225
238
|
});
|
|
226
239
|
describe('EmptyState.Actions', function () {
|
|
227
240
|
it('renders its children in a centred row', function () {
|
|
228
|
-
var
|
|
241
|
+
var _render12 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
229
242
|
children: /*#__PURE__*/_jsx(EmptyState.Actions, {
|
|
230
243
|
children: /*#__PURE__*/_jsx("button", {
|
|
231
244
|
type: "button",
|
|
@@ -233,7 +246,7 @@ describe('EmptyState.Actions', function () {
|
|
|
233
246
|
})
|
|
234
247
|
})
|
|
235
248
|
})),
|
|
236
|
-
container =
|
|
249
|
+
container = _render12.container;
|
|
237
250
|
expect(container.querySelector('.newspack-empty-state__actions')).toBeInTheDocument();
|
|
238
251
|
expect(container.querySelector('.newspack-empty-state__actions')).toHaveStyle({
|
|
239
252
|
justifyContent: 'center',
|
|
@@ -244,7 +257,7 @@ describe('EmptyState.Actions', function () {
|
|
|
244
257
|
})).toBeInTheDocument();
|
|
245
258
|
});
|
|
246
259
|
it('stacks into a column while keeping the hook class', function () {
|
|
247
|
-
var
|
|
260
|
+
var _render13 = render(/*#__PURE__*/_jsx(EmptyState.Root, {
|
|
248
261
|
children: /*#__PURE__*/_jsxs(EmptyState.Actions, {
|
|
249
262
|
orientation: "column",
|
|
250
263
|
children: [/*#__PURE__*/_jsx("button", {
|
|
@@ -256,7 +269,7 @@ describe('EmptyState.Actions', function () {
|
|
|
256
269
|
})]
|
|
257
270
|
})
|
|
258
271
|
})),
|
|
259
|
-
container =
|
|
272
|
+
container = _render13.container;
|
|
260
273
|
var actions = container.querySelector('.newspack-empty-state__actions');
|
|
261
274
|
expect(actions).toBeInTheDocument();
|
|
262
275
|
expect(actions).toHaveStyle({
|
|
@@ -287,10 +300,10 @@ describe('EmptyState.Actions', function () {
|
|
|
287
300
|
var previous = process.env.NODE_ENV;
|
|
288
301
|
process.env.NODE_ENV = 'production';
|
|
289
302
|
try {
|
|
290
|
-
var
|
|
303
|
+
var _render14 = render(/*#__PURE__*/_jsx(EmptyState.Actions, {
|
|
291
304
|
children: "x"
|
|
292
305
|
})),
|
|
293
|
-
container =
|
|
306
|
+
container = _render14.container;
|
|
294
307
|
expect(container.querySelector('.newspack-empty-state__actions')).toBeInTheDocument();
|
|
295
308
|
} finally {
|
|
296
309
|
process.env.NODE_ENV = previous;
|
|
@@ -37,6 +37,7 @@ var Root = function Root(_ref) {
|
|
|
37
37
|
size: size
|
|
38
38
|
};
|
|
39
39
|
}, [size]);
|
|
40
|
+
var isSmall = size === 'small';
|
|
40
41
|
return /*#__PURE__*/_jsx(EmptyStateContext.Provider, {
|
|
41
42
|
value: context,
|
|
42
43
|
children: /*#__PURE__*/_jsx(Grid, {
|
|
@@ -46,7 +47,7 @@ var Root = function Root(_ref) {
|
|
|
46
47
|
children: /*#__PURE__*/_jsx(Stack, _objectSpread(_objectSpread({
|
|
47
48
|
className: "newspack-empty-state__stack",
|
|
48
49
|
direction: "column",
|
|
49
|
-
gap:
|
|
50
|
+
gap: isSmall ? 'xl' : '2xl'
|
|
50
51
|
}, gridColumn), {}, {
|
|
51
52
|
children: children
|
|
52
53
|
}))
|