@prenta/admin 2.16.2 → 2.16.3
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 +6 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.d.ts +2 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.js +157 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.js.map +1 -0
- package/dist/components/BreakpointPicker.d.ts.map +1 -1
- package/dist/components/BreakpointPicker.js +2 -2
- package/dist/components/BreakpointPicker.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/views/page-editor/EditorTopBar.d.ts.map +1 -1
- package/dist/views/page-editor/EditorTopBar.js +28 -17
- package/dist/views/page-editor/EditorTopBar.js.map +1 -1
- package/package.json +6 -6
- package/src/__tests__/views/editor-top-bar-layout.render.test.tsx +198 -0
- package/src/components/BreakpointPicker.tsx +7 -6
- package/src/styles/responsive.css +44 -18
- package/src/views/page-editor/EditorTopBar.tsx +109 -65
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
ExternalLink,
|
|
10
10
|
History,
|
|
11
11
|
Loader2,
|
|
12
|
+
MessageSquareWarning,
|
|
12
13
|
Redo2,
|
|
13
14
|
Settings2,
|
|
14
15
|
Share2,
|
|
15
16
|
TriangleAlert,
|
|
16
17
|
Undo2,
|
|
17
18
|
} from 'lucide-react'
|
|
19
|
+
import { Button } from '../../components/ui/Button.js'
|
|
18
20
|
import { EditorSeoScoreBadge } from '../../components/seo/EditorSeoScoreBadge.js'
|
|
19
21
|
import { BreakpointPicker } from '../../components/BreakpointPicker.js'
|
|
20
22
|
import { RequestChangesDialog } from '../../components/RequestChangesDialog.js'
|
|
@@ -35,6 +37,17 @@ import { type ViewportId } from './viewports.js'
|
|
|
35
37
|
import type { ThemeChromeMode } from '../../lib/theme-chrome.js'
|
|
36
38
|
import { ThemeChromeModeToggle } from './theme-chrome/ThemeChromeModeToggle.js'
|
|
37
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The shared Button stops pointer events while disabled, which also stops the
|
|
42
|
+
* browser showing its title. These actions use the title to say why they are
|
|
43
|
+
* disabled (not ready to publish, no site URL), so they keep the pointer.
|
|
44
|
+
*/
|
|
45
|
+
const DISABLED_WITH_REASON =
|
|
46
|
+
'disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:hover:border-bdr! disabled:hover:text-txt!'
|
|
47
|
+
/** The same for the filled primary action, whose hover is a brightness lift. */
|
|
48
|
+
const DISABLED_PRIMARY_WITH_REASON =
|
|
49
|
+
'disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:hover:brightness-100!'
|
|
50
|
+
|
|
38
51
|
export type SaveState = 'idle' | 'saving' | 'saved' | 'error'
|
|
39
52
|
|
|
40
53
|
interface EditorTopBarProps {
|
|
@@ -219,37 +232,43 @@ export function EditorTopBar({
|
|
|
219
232
|
switch (workflow.primary) {
|
|
220
233
|
case 'submit':
|
|
221
234
|
primaryAction = (
|
|
222
|
-
<
|
|
235
|
+
<Button
|
|
223
236
|
type="button"
|
|
237
|
+
variant="primary"
|
|
224
238
|
onClick={onSubmitForReview}
|
|
239
|
+
className={DISABLED_PRIMARY_WITH_REASON}
|
|
225
240
|
disabled={submitBlocked}
|
|
226
241
|
title={submitTitle}
|
|
227
242
|
aria-disabled={submitBlocked}
|
|
228
|
-
|
|
243
|
+
leftIcon={
|
|
244
|
+
publishing ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden /> : undefined
|
|
245
|
+
}
|
|
229
246
|
>
|
|
230
|
-
{publishing && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}
|
|
231
247
|
{SUBMIT_FOR_REVIEW_LABEL}
|
|
232
|
-
</
|
|
248
|
+
</Button>
|
|
233
249
|
)
|
|
234
250
|
break
|
|
235
251
|
case 'approve':
|
|
236
252
|
primaryAction = (
|
|
237
|
-
<
|
|
253
|
+
<Button
|
|
238
254
|
type="button"
|
|
255
|
+
variant="primary"
|
|
239
256
|
onClick={onApprove}
|
|
257
|
+
className={DISABLED_PRIMARY_WITH_REASON}
|
|
240
258
|
disabled={approveBlocked}
|
|
241
259
|
title={approveTitle}
|
|
242
260
|
aria-disabled={approveBlocked}
|
|
243
|
-
|
|
261
|
+
leftIcon={
|
|
262
|
+
publishing ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden /> : undefined
|
|
263
|
+
}
|
|
244
264
|
>
|
|
245
|
-
{publishing && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}
|
|
246
265
|
{APPROVE_LABEL}
|
|
247
|
-
</
|
|
266
|
+
</Button>
|
|
248
267
|
)
|
|
249
268
|
break
|
|
250
269
|
case 'waiting':
|
|
251
270
|
primaryAction = (
|
|
252
|
-
<span className="text-muted-foreground text-sm" aria-live="polite">
|
|
271
|
+
<span className="text-muted-foreground text-sm whitespace-nowrap" aria-live="polite">
|
|
253
272
|
{workflow.waitingLabel}
|
|
254
273
|
</span>
|
|
255
274
|
)
|
|
@@ -264,10 +283,18 @@ export function EditorTopBar({
|
|
|
264
283
|
}
|
|
265
284
|
|
|
266
285
|
return (
|
|
267
|
-
|
|
286
|
+
// The bar is a size container (responsive.css): its secondary actions drop
|
|
287
|
+
// their labels by the bar's own width, which the sidebar and the rail
|
|
288
|
+
// change independently of the viewport. When it is still too narrow the
|
|
289
|
+
// actions wrap to a second line: the left group's minimum width is its
|
|
290
|
+
// fixed parts plus a 5rem title, so the title is never squeezed to nothing.
|
|
291
|
+
<header className="prenta-editor-header bg-card border-border flex min-h-14 shrink-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 border-b px-4 py-2">
|
|
268
292
|
{/* Breadcrumb + status */}
|
|
269
|
-
<div className="flex min-w-
|
|
270
|
-
<nav
|
|
293
|
+
<div className="flex min-w-min flex-[1_1_0%] items-center gap-2">
|
|
294
|
+
<nav
|
|
295
|
+
aria-label="Breadcrumb"
|
|
296
|
+
className="flex min-w-[5rem] flex-[0_1_auto] items-center gap-1.5 overflow-hidden text-sm"
|
|
297
|
+
>
|
|
271
298
|
<button
|
|
272
299
|
type="button"
|
|
273
300
|
onClick={onBack}
|
|
@@ -287,7 +314,10 @@ export function EditorTopBar({
|
|
|
287
314
|
{workflow.statusLabel}
|
|
288
315
|
</span>
|
|
289
316
|
{reviewNote ? (
|
|
290
|
-
<span
|
|
317
|
+
<span
|
|
318
|
+
className="text-muted-foreground max-w-[16rem] min-w-0 shrink truncate text-xs"
|
|
319
|
+
title={`${REVIEWER_NOTE_PREFIX} ${reviewNote}`}
|
|
320
|
+
>
|
|
291
321
|
{REVIEWER_NOTE_PREFIX} {reviewNote}
|
|
292
322
|
</span>
|
|
293
323
|
) : null}
|
|
@@ -306,33 +336,37 @@ export function EditorTopBar({
|
|
|
306
336
|
<SaveStatus state={saveState} dirty={dirty} />
|
|
307
337
|
{onUndo && onRedo && (
|
|
308
338
|
<span className="ml-1 inline-flex shrink-0 items-center">
|
|
309
|
-
<
|
|
339
|
+
<Button
|
|
310
340
|
type="button"
|
|
341
|
+
variant="icon"
|
|
342
|
+
size="icon-lg"
|
|
311
343
|
onClick={onUndo}
|
|
312
344
|
disabled={!canUndo}
|
|
313
345
|
aria-label="Undo"
|
|
314
346
|
title="Undo the last edit (Ctrl+Z or ⌘Z). Text fields keep their own undo."
|
|
315
|
-
className="prenta-touch-target
|
|
347
|
+
className="prenta-touch-target"
|
|
316
348
|
>
|
|
317
349
|
<Undo2 className="h-4 w-4" aria-hidden />
|
|
318
|
-
</
|
|
319
|
-
<
|
|
350
|
+
</Button>
|
|
351
|
+
<Button
|
|
320
352
|
type="button"
|
|
353
|
+
variant="icon"
|
|
354
|
+
size="icon-lg"
|
|
321
355
|
onClick={onRedo}
|
|
322
356
|
disabled={!canRedo}
|
|
323
357
|
aria-label="Redo"
|
|
324
358
|
title="Redo (Ctrl+Shift+Z, Ctrl+Y, or ⌘⇧Z)."
|
|
325
|
-
className="prenta-touch-target
|
|
359
|
+
className="prenta-touch-target"
|
|
326
360
|
>
|
|
327
361
|
<Redo2 className="h-4 w-4" aria-hidden />
|
|
328
|
-
</
|
|
362
|
+
</Button>
|
|
329
363
|
</span>
|
|
330
364
|
)}
|
|
331
365
|
{localeControl ? <span className="ml-1 inline-flex shrink-0">{localeControl}</span> : null}
|
|
332
366
|
</div>
|
|
333
367
|
|
|
334
368
|
{/* Right controls */}
|
|
335
|
-
<div className="flex items-center gap-2">
|
|
369
|
+
<div className="ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-2">
|
|
336
370
|
<div className="hidden items-center gap-1.5 md:flex">
|
|
337
371
|
<BreakpointPicker value={viewport} onChange={onViewport} />
|
|
338
372
|
{zoom !== undefined && onZoom && (
|
|
@@ -343,19 +377,22 @@ export function EditorTopBar({
|
|
|
343
377
|
) : null}
|
|
344
378
|
</div>
|
|
345
379
|
|
|
346
|
-
<
|
|
380
|
+
<Button
|
|
347
381
|
type="button"
|
|
382
|
+
variant="icon"
|
|
383
|
+
size="icon-lg"
|
|
348
384
|
onClick={onOpenSettings}
|
|
349
385
|
aria-label={backLabel === 'Posts' ? 'Post settings' : 'Page settings'}
|
|
350
386
|
title={backLabel === 'Posts' ? 'Post settings' : 'Page settings'}
|
|
351
|
-
className="prenta-touch-target
|
|
387
|
+
className="prenta-touch-target"
|
|
352
388
|
>
|
|
353
389
|
<Settings2 className="h-4 w-4" aria-hidden />
|
|
354
|
-
</
|
|
390
|
+
</Button>
|
|
355
391
|
|
|
356
392
|
{onOpenSeo && (
|
|
357
|
-
<
|
|
393
|
+
<Button
|
|
358
394
|
type="button"
|
|
395
|
+
variant={seoOpen ? 'primary' : 'ghost'}
|
|
359
396
|
onClick={onOpenSeo}
|
|
360
397
|
aria-pressed={seoOpen}
|
|
361
398
|
aria-label={seoScore === undefined ? 'SEO' : `SEO, score ${seoScore} out of 100`}
|
|
@@ -364,40 +401,35 @@ export function EditorTopBar({
|
|
|
364
401
|
? 'SEO — meta tags, social preview, schema, and analysis.'
|
|
365
402
|
: `SEO — score ${seoScore}/100. Meta tags, social preview, schema, and analysis.`
|
|
366
403
|
}
|
|
367
|
-
className=
|
|
368
|
-
seoOpen
|
|
369
|
-
? 'bg-primary text-primary-foreground'
|
|
370
|
-
: 'text-muted-foreground hover:text-foreground hover:bg-accent'
|
|
371
|
-
}`}
|
|
404
|
+
className="px-2!"
|
|
372
405
|
>
|
|
373
406
|
{seoScore !== undefined && (
|
|
374
407
|
<EditorSeoScoreBadge score={seoScore} band={seoScoreBand} inverted={seoOpen} />
|
|
375
408
|
)}
|
|
376
409
|
<span className="hidden sm:inline">SEO</span>
|
|
377
|
-
</
|
|
410
|
+
</Button>
|
|
378
411
|
)}
|
|
379
412
|
|
|
380
413
|
{onHistory && (
|
|
381
|
-
<
|
|
414
|
+
<Button
|
|
382
415
|
type="button"
|
|
416
|
+
variant={historyOpen ? 'primary' : 'icon'}
|
|
417
|
+
size="icon-lg"
|
|
383
418
|
onClick={onHistory}
|
|
384
419
|
aria-pressed={historyOpen}
|
|
385
420
|
aria-label="Version history"
|
|
386
421
|
title={historyOpen ? 'Close version history' : 'Version history'}
|
|
387
|
-
className=
|
|
388
|
-
historyOpen
|
|
389
|
-
? 'bg-primary text-primary-foreground'
|
|
390
|
-
: 'text-muted-foreground hover:text-foreground hover:bg-accent'
|
|
391
|
-
}`}
|
|
422
|
+
className="prenta-touch-target"
|
|
392
423
|
>
|
|
393
424
|
<History className="h-4 w-4" aria-hidden />
|
|
394
|
-
</
|
|
425
|
+
</Button>
|
|
395
426
|
)}
|
|
396
427
|
|
|
397
428
|
{chrome && (
|
|
398
429
|
<>
|
|
399
|
-
<
|
|
430
|
+
<Button
|
|
400
431
|
type="button"
|
|
432
|
+
variant="secondary"
|
|
401
433
|
onClick={() => onViewOnSite?.(chrome.primaryIntent)}
|
|
402
434
|
disabled={!chrome.viewEnabled}
|
|
403
435
|
title={
|
|
@@ -406,22 +438,24 @@ export function EditorTopBar({
|
|
|
406
438
|
? 'Open the published page in a new tab.'
|
|
407
439
|
: 'Open the draft on your site in a new tab.')
|
|
408
440
|
}
|
|
409
|
-
className=
|
|
441
|
+
className={DISABLED_WITH_REASON}
|
|
442
|
+
leftIcon={<ExternalLink className="h-3.5 w-3.5" aria-hidden />}
|
|
410
443
|
>
|
|
411
|
-
<ExternalLink className="h-3.5 w-3.5" aria-hidden />
|
|
412
444
|
{chrome.primaryIntent === 'view-live' ? 'View live' : 'View site'}
|
|
413
|
-
</
|
|
445
|
+
</Button>
|
|
414
446
|
{chrome.showViewLive && (
|
|
415
447
|
<DropdownMenu.Root>
|
|
416
448
|
<DropdownMenu.Trigger asChild>
|
|
417
|
-
<
|
|
449
|
+
<Button
|
|
418
450
|
type="button"
|
|
451
|
+
variant="secondary"
|
|
452
|
+
size="icon-lg"
|
|
419
453
|
disabled={!chrome.viewEnabled}
|
|
420
454
|
aria-label="More view options"
|
|
421
|
-
className="prenta-touch-target
|
|
455
|
+
className="prenta-touch-target"
|
|
422
456
|
>
|
|
423
457
|
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
|
|
424
|
-
</
|
|
458
|
+
</Button>
|
|
425
459
|
</DropdownMenu.Trigger>
|
|
426
460
|
<DropdownMenu.Portal container={adminPortalContainer()}>
|
|
427
461
|
<DropdownMenu.Content
|
|
@@ -440,57 +474,64 @@ export function EditorTopBar({
|
|
|
440
474
|
</DropdownMenu.Root>
|
|
441
475
|
)}
|
|
442
476
|
{chrome.shareVisible && onShare && (
|
|
443
|
-
<
|
|
477
|
+
<Button
|
|
444
478
|
type="button"
|
|
479
|
+
variant="secondary"
|
|
445
480
|
onClick={onShare}
|
|
446
481
|
disabled={!chrome.viewEnabled}
|
|
482
|
+
aria-label="Share"
|
|
447
483
|
title={
|
|
448
484
|
chrome.viewDisabledReason ??
|
|
449
485
|
'Copy a link so someone can view this draft without signing in.'
|
|
450
486
|
}
|
|
451
|
-
className=
|
|
487
|
+
className={`prenta-editor-collapsible prenta-touch-target ${DISABLED_WITH_REASON}`}
|
|
488
|
+
leftIcon={<Share2 className="h-3.5 w-3.5" aria-hidden />}
|
|
452
489
|
>
|
|
453
|
-
<
|
|
454
|
-
|
|
455
|
-
</button>
|
|
490
|
+
<span className="prenta-editor-label">Share</span>
|
|
491
|
+
</Button>
|
|
456
492
|
)}
|
|
457
493
|
</>
|
|
458
494
|
)}
|
|
459
495
|
|
|
460
|
-
<
|
|
496
|
+
<Button
|
|
461
497
|
type="button"
|
|
498
|
+
variant="secondary"
|
|
462
499
|
onClick={onSaveDraft}
|
|
463
500
|
disabled={!canEdit || saveState === 'saving' || (!dirty && saveState !== 'error')}
|
|
464
|
-
className="border-border text-foreground hover:bg-accent rounded-lg border px-3 py-1.5 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
|
465
501
|
>
|
|
466
502
|
{saveState === 'saving' ? 'Saving…' : workflow.saveLabel}
|
|
467
|
-
</
|
|
503
|
+
</Button>
|
|
468
504
|
|
|
469
505
|
{onSchedule && workflow.showSchedule && (
|
|
470
|
-
<
|
|
506
|
+
<Button
|
|
471
507
|
type="button"
|
|
508
|
+
variant="secondary"
|
|
472
509
|
onClick={onSchedule}
|
|
473
510
|
disabled={scheduleBlocked}
|
|
474
511
|
title={scheduleTitle}
|
|
475
512
|
aria-label={scheduledAt ? 'Reschedule publish' : 'Schedule publish'}
|
|
476
|
-
className=
|
|
513
|
+
className={`prenta-editor-collapsible prenta-touch-target ${DISABLED_WITH_REASON}`}
|
|
514
|
+
leftIcon={<Calendar className="h-3.5 w-3.5" aria-hidden />}
|
|
477
515
|
>
|
|
478
|
-
<
|
|
479
|
-
|
|
480
|
-
</button>
|
|
516
|
+
<span className="prenta-editor-label">{scheduledAt ? 'Reschedule' : 'Schedule'}</span>
|
|
517
|
+
</Button>
|
|
481
518
|
)}
|
|
482
519
|
|
|
483
520
|
{primaryAction}
|
|
484
521
|
|
|
485
522
|
{workflow.showRequestChanges && (
|
|
486
|
-
<
|
|
523
|
+
<Button
|
|
487
524
|
type="button"
|
|
525
|
+
variant="secondary"
|
|
488
526
|
onClick={() => setRequestChangesOpen(true)}
|
|
489
527
|
disabled={requestChangesBlocked}
|
|
490
|
-
|
|
528
|
+
aria-label={REQUEST_CHANGES_LABEL}
|
|
529
|
+
title={REQUEST_CHANGES_LABEL}
|
|
530
|
+
className="prenta-editor-collapsible prenta-touch-target"
|
|
531
|
+
leftIcon={<MessageSquareWarning className="h-3.5 w-3.5" aria-hidden />}
|
|
491
532
|
>
|
|
492
|
-
{REQUEST_CHANGES_LABEL}
|
|
493
|
-
</
|
|
533
|
+
<span className="prenta-editor-label">{REQUEST_CHANGES_LABEL}</span>
|
|
534
|
+
</Button>
|
|
494
535
|
)}
|
|
495
536
|
|
|
496
537
|
<RequestChangesDialog
|
|
@@ -507,7 +548,7 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
507
548
|
if (state === 'saving') {
|
|
508
549
|
return (
|
|
509
550
|
<span
|
|
510
|
-
className="text-muted-foreground ml-2 inline-flex items-center gap-1 text-xs"
|
|
551
|
+
className="text-muted-foreground ml-2 inline-flex min-w-0 shrink items-center gap-1 overflow-hidden text-xs whitespace-nowrap"
|
|
511
552
|
aria-live="polite"
|
|
512
553
|
>
|
|
513
554
|
<Loader2 className="h-3 w-3 animate-spin" aria-hidden />
|
|
@@ -518,7 +559,7 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
518
559
|
if (state === 'error') {
|
|
519
560
|
return (
|
|
520
561
|
<span
|
|
521
|
-
className="text-destructive ml-2 inline-flex items-center gap-1 text-xs"
|
|
562
|
+
className="text-destructive ml-2 inline-flex min-w-0 shrink items-center gap-1 overflow-hidden text-xs whitespace-nowrap"
|
|
522
563
|
aria-live="polite"
|
|
523
564
|
>
|
|
524
565
|
<TriangleAlert className="h-3 w-3" aria-hidden />
|
|
@@ -528,7 +569,10 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
528
569
|
}
|
|
529
570
|
if (dirty) {
|
|
530
571
|
return (
|
|
531
|
-
<span
|
|
572
|
+
<span
|
|
573
|
+
className="text-muted-foreground ml-2 min-w-0 shrink truncate text-xs"
|
|
574
|
+
aria-live="polite"
|
|
575
|
+
>
|
|
532
576
|
Unsaved changes
|
|
533
577
|
</span>
|
|
534
578
|
)
|
|
@@ -536,7 +580,7 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
536
580
|
if (state === 'saved') {
|
|
537
581
|
return (
|
|
538
582
|
<span
|
|
539
|
-
className="text-muted-foreground ml-2 inline-flex items-center gap-1 text-xs"
|
|
583
|
+
className="text-muted-foreground ml-2 inline-flex min-w-0 shrink items-center gap-1 overflow-hidden text-xs whitespace-nowrap"
|
|
540
584
|
aria-live="polite"
|
|
541
585
|
>
|
|
542
586
|
<Check className="h-3 w-3" aria-hidden />
|