astryx-dracula 0.3.1 → 0.5.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 (59) hide show
  1. package/USAGE.md +25 -0
  2. package/astryx-dracula.d.ts +2 -2
  3. package/astryx-dracula.js +384 -3
  4. package/astryx-dracula.variants.d.ts +2 -14
  5. package/icons.mjs +125 -0
  6. package/package.json +21 -9
  7. package/shared/auth-chrome.tsx +156 -6
  8. package/shared/chaptered-doc.tsx +3 -4
  9. package/shared/chart-hues.ts +0 -5
  10. package/shared/chart-legend.tsx +2 -3
  11. package/shared/data-bar.tsx +5 -5
  12. package/shared/format-money.ts +3 -0
  13. package/shared/metric-card.tsx +127 -0
  14. package/shared/revenue-chart.tsx +63 -7
  15. package/shared/scene-hues.ts +0 -8
  16. package/shared/scene-tile.tsx +3 -11
  17. package/shared/settings-data.ts +71 -1
  18. package/shared/settings-rows.tsx +76 -30
  19. package/shared/stars.tsx +28 -0
  20. package/templates/ai-chat-landing.tsx +105 -67
  21. package/templates/ai-chat.tsx +67 -80
  22. package/templates/centered-hero.tsx +2 -2
  23. package/templates/contact-form.tsx +11 -10
  24. package/templates/dashboard-portfolio.tsx +77 -155
  25. package/templates/dashboard.tsx +24 -137
  26. package/templates/detail-page.tsx +25 -22
  27. package/templates/documentation-design.tsx +39 -478
  28. package/templates/documentation-technical.tsx +13 -31
  29. package/templates/editor.tsx +168 -185
  30. package/templates/file-explorer.tsx +91 -93
  31. package/templates/form-two-column.tsx +1 -1
  32. package/templates/ide.tsx +18 -24
  33. package/templates/incident-console.tsx +67 -42
  34. package/templates/kanban-board.tsx +36 -85
  35. package/templates/library.tsx +42 -66
  36. package/templates/login-card.tsx +33 -123
  37. package/templates/login-split.tsx +96 -119
  38. package/templates/login-sso.tsx +69 -74
  39. package/templates/login.tsx +21 -118
  40. package/templates/messaging-shell.tsx +162 -168
  41. package/templates/payment-form.tsx +63 -71
  42. package/templates/product-detail.tsx +11 -46
  43. package/templates/product-tour.tsx +38 -60
  44. package/templates/settings-dialog.tsx +93 -118
  45. package/templates/settings-sidebar.tsx +122 -143
  46. package/templates/settings.tsx +208 -121
  47. package/templates/shell-nav.tsx +20 -75
  48. package/templates/shell-side-nav.tsx +16 -90
  49. package/templates/shell-top-nav.tsx +20 -53
  50. package/templates/side-gallery.tsx +19 -19
  51. package/templates/table-grouped.tsx +86 -136
  52. package/templates/table-page-chart.tsx +12 -11
  53. package/templates/table-page-heatmap-status.tsx +0 -17
  54. package/templates/table-page-shoe-store-heatmap.tsx +12 -12
  55. package/templates/table-page.tsx +4 -31
  56. package/templates/table.tsx +18 -2
  57. package/templates/tech-report.tsx +59 -73
  58. package/templates/theme-showcase.tsx +124 -415
  59. package/theme.css +211 -119
@@ -11,21 +11,23 @@ import {VStack, HStack, Layout, LayoutContent} from '@astryxdesign/core/Layout';
11
11
  import {Text, Heading} from '@astryxdesign/core/Text';
12
12
  import {Card} from '@astryxdesign/core/Card';
13
13
  import {Button} from '@astryxdesign/core/Button';
14
- import {ProgressBar} from '@astryxdesign/core/ProgressBar';
15
14
  import {Grid} from '@astryxdesign/core/Grid';
16
- import {Table, proportional, pixel} from '@astryxdesign/core/Table';
15
+ import {proportional, pixel} from '@astryxdesign/core/Table';
17
16
  import type {TableColumn} from '@astryxdesign/core/Table';
18
17
  import {Divider} from '@astryxdesign/core/Divider';
19
- import {Link} from '@astryxdesign/core/Link';
20
18
  import {Icon} from '@astryxdesign/core/Icon';
21
19
 
20
+ // Same-route hash: demo links stay focusable anchors without escaping the
21
+ // template through the hash router (bare "#" would drop back to the home page).
22
+ const SELF_HASH = '#/templates/dashboard';
23
+
22
24
  // ============= ICONS =============
23
25
 
24
26
  import {RefreshCw, Square} from 'lucide-react';
25
27
  import {ChartLegend} from 'astryx-dracula/shared/chart-legend';
26
28
  import {CHART_HUES} from 'astryx-dracula/shared/chart-hues';
27
- import {MetricDelta} from 'astryx-dracula/shared/metric-delta';
28
- import {Sparkline, type SparkPoint} from 'astryx-dracula/shared/sparkline';
29
+ import type {SparkPoint} from 'astryx-dracula/shared/sparkline';
30
+ import {MetricCard, TableCard, BarCell, CountCell} from 'astryx-dracula/shared/metric-card';
29
31
  import {CHART_PANEL_STYLE} from 'astryx-dracula/shared/chart-panel-style';
30
32
 
31
33
  // ============= DATA =============
@@ -348,38 +350,22 @@ const topPagesColumns: TableColumn<PageRow>[] = [
348
350
  header: 'Views',
349
351
  width: proportional(1),
350
352
  renderCell: (item: PageRow) => (
351
- <VStack gap={1}>
352
- <ProgressBar
353
- value={item.views}
354
- max={topPagesMaxViews}
355
- label={`${item.page} views`}
356
- isLabelHidden
357
- />
358
- <Text type="body" hasTabularNumbers maxLines={1}>
359
- {formatCount(item.views)}
360
- </Text>
361
- </VStack>
353
+ <BarCell label={`${item.page} views`} value={item.views} max={topPagesMaxViews}>
354
+ {formatCount(item.views)}
355
+ </BarCell>
362
356
  ),
363
357
  },
364
358
  {
365
359
  key: 'newUsers',
366
360
  header: 'New Users',
367
361
  width: pixel(104),
368
- renderCell: (item: PageRow) => (
369
- <Text hasTabularNumbers maxLines={1}>
370
- {item.newUsers}
371
- </Text>
372
- ),
362
+ renderCell: (item: PageRow) => <CountCell>{item.newUsers}</CountCell>,
373
363
  },
374
364
  {
375
365
  key: 'avgTime',
376
366
  header: 'Avg. Time',
377
367
  width: pixel(104),
378
- renderCell: (item: PageRow) => (
379
- <Text hasTabularNumbers maxLines={1}>
380
- {item.avgTime}
381
- </Text>
382
- ),
368
+ renderCell: (item: PageRow) => <CountCell>{item.avgTime}</CountCell>,
383
369
  },
384
370
  ];
385
371
 
@@ -414,50 +400,27 @@ const topEventsColumns: TableColumn<EventRow>[] = [
414
400
  header: 'Count',
415
401
  width: proportional(1),
416
402
  renderCell: (item: EventRow) => (
417
- <VStack gap={1}>
418
- <ProgressBar
419
- value={item.count}
420
- max={topEventsMaxCount}
421
- label={`${item.count}`}
422
- isLabelHidden
423
- />
424
- <Text type="body" hasTabularNumbers maxLines={1}>
425
- {formatCount(item.count)}
426
- </Text>
427
- </VStack>
403
+ <BarCell label={`${item.count}`} value={item.count} max={topEventsMaxCount}>
404
+ {formatCount(item.count)}
405
+ </BarCell>
428
406
  ),
429
407
  },
430
408
  {
431
409
  key: 'users',
432
410
  header: 'Users',
433
411
  width: pixel(72),
434
- renderCell: (item: EventRow) => (
435
- <Text hasTabularNumbers maxLines={1}>
436
- {formatCount(item.users)}
437
- </Text>
438
- ),
412
+ renderCell: (item: EventRow) => <CountCell>{formatCount(item.users)}</CountCell>,
439
413
  },
440
414
  {
441
415
  key: 'newUsers',
442
416
  header: 'New Users',
443
417
  width: pixel(104),
444
- renderCell: (item: EventRow) => (
445
- <Text hasTabularNumbers maxLines={1}>
446
- {formatCount(item.newUsers)}
447
- </Text>
448
- ),
418
+ renderCell: (item: EventRow) => <CountCell>{formatCount(item.newUsers)}</CountCell>,
449
419
  },
450
420
  ];
451
421
 
452
422
  // ============= CHART COMPONENTS =============
453
423
 
454
- // Chart series colors: desktop glows orange, mobile glows cyan. Sourced from
455
- // the shared categorical hues so data encoding can never reach for purple.
456
- const chartColors = {
457
- desktop: CHART_HUES.orange,
458
- mobile: CHART_HUES.cyan,
459
- };
460
-
461
424
  // Legend rows go through shared/chart-legend.tsx, which makes `label` a
462
425
  // REQUIRED field so a hue can never ship without the word that names it.
463
426
 
@@ -492,7 +455,7 @@ function ActiveUsersChart() {
492
455
  width={14}
493
456
  height={hAll - hDesktop}
494
457
  rx={4}
495
- fill={chartColors.mobile}
458
+ fill={CHART_HUES.cyan}
496
459
  />
497
460
  <rect
498
461
  x={x}
@@ -500,7 +463,7 @@ function ActiveUsersChart() {
500
463
  width={14}
501
464
  height={hDesktop}
502
465
  rx={4}
503
- fill={chartColors.desktop}
466
+ fill={CHART_HUES.orange}
504
467
  />
505
468
  {(i % 6 === 0 || i === bars.length - 1) && (
506
469
  <text
@@ -531,8 +494,8 @@ function ActiveUsersChart() {
531
494
  </Card>
532
495
  <ChartLegend
533
496
  entries={[
534
- {label: 'Desktop', color: chartColors.desktop},
535
- {label: 'Mobile', color: chartColors.mobile},
497
+ {label: 'Desktop', color: CHART_HUES.orange},
498
+ {label: 'Mobile', color: CHART_HUES.cyan},
536
499
  ]}
537
500
  gap={4}
538
501
  caption={
@@ -547,44 +510,6 @@ function ActiveUsersChart() {
547
510
 
548
511
  // ============= CARD COMPONENTS =============
549
512
 
550
- function MetricCard({
551
- label,
552
- value,
553
- change,
554
- positive,
555
- sparkline,
556
- }: {
557
- label: string;
558
- value: string;
559
- change: string;
560
- positive: boolean;
561
- sparkline: SparkPoint[];
562
- }) {
563
- return (
564
- <Card>
565
- <VStack gap={2}>
566
- <Text type="supporting" color="secondary">
567
- {label}
568
- </Text>
569
- <HStack gap={2} vAlign="center">
570
- <Text type="display-3" weight="semibold" hasTabularNumbers>
571
- {value}
572
- </Text>
573
- <MetricDelta value={change} positive={positive} />
574
- </HStack>
575
- <Text type="supporting" color="secondary">
576
- Last 30 days vs. Previous
577
- </Text>
578
- <Sparkline
579
- data={sparkline}
580
- label={`${label} thirty-day trend`}
581
- positive={positive}
582
- />
583
- </VStack>
584
- </Card>
585
- );
586
- }
587
-
588
513
  function StackedBarCard({
589
514
  title,
590
515
  data,
@@ -632,7 +557,7 @@ function StackedBarCard({
632
557
  {/* Legend */}
633
558
  <HStack gap={4} wrap="wrap">
634
559
  {data.map(d => (
635
- <VStack key={d.label} gap={0}>
560
+ <VStack key={d.label} gap={1}>
636
561
  <HStack gap={2} vAlign="center">
637
562
  <Icon icon={Square} size="xsm" style={{color: d.color}} />
638
563
  <Text type="supporting" color="secondary">{d.label}</Text>
@@ -648,44 +573,6 @@ function StackedBarCard({
648
573
  );
649
574
  }
650
575
 
651
- // ============= TABLE COMPONENTS =============
652
-
653
- function TableCard<T extends {id: string}>({
654
- title,
655
- linkLabel,
656
- linkHref,
657
- data,
658
- columns,
659
- }: {
660
- title: string;
661
- linkLabel: string;
662
- linkHref: string;
663
- data: T[];
664
- columns: TableColumn<T>[];
665
- }) {
666
- return (
667
- <Card>
668
- <VStack gap={6}>
669
- <HStack hAlign="between" vAlign="center">
670
- <Heading level={3}>{title}</Heading>
671
- <Link href={linkHref}>{linkLabel}</Link>
672
- </HStack>
673
- <Table<T>
674
- data={data}
675
- columns={columns}
676
- idKey="id"
677
- density="compact"
678
- dividers="rows"
679
- textOverflow="truncate"
680
- hasHover
681
- />
682
- </VStack>
683
- </Card>
684
- );
685
- }
686
-
687
- // ============= SIDENAV =============
688
-
689
576
  // ============= MAIN COMPONENT =============
690
577
 
691
578
  // A definite ancestor, so `Layout height="fill"` (Layout.tsx:58-63, height:
@@ -756,14 +643,14 @@ export default function DashboardTemplate() {
756
643
  <TableCard
757
644
  title="Top pages"
758
645
  linkLabel="All pages"
759
- linkHref="#"
646
+ linkHref={SELF_HASH}
760
647
  data={topPagesData}
761
648
  columns={topPagesColumns}
762
649
  />
763
650
  <TableCard
764
651
  title="Top events"
765
652
  linkLabel="All events"
766
- linkHref="#"
653
+ linkHref={SELF_HASH}
767
654
  data={topEventsData}
768
655
  columns={topEventsColumns}
769
656
  />
@@ -12,7 +12,6 @@ import {
12
12
  VStack,
13
13
  HStack,
14
14
  StackItem,
15
- Card,
16
15
  Section,
17
16
  } from '@astryxdesign/core/Layout';
18
17
  import {Text, Heading} from '@astryxdesign/core/Text';
@@ -29,6 +28,8 @@ import {Collapsible} from '@astryxdesign/core/Collapsible';
29
28
  import {Icon} from '@astryxdesign/core/Icon';
30
29
  import {Dialog, DialogHeader} from '@astryxdesign/core/Dialog';
31
30
  import type {SceneHue} from 'astryx-dracula/shared/scene-hues';
31
+ import {SceneFrame} from 'astryx-dracula/shared/scene-frame';
32
+ import {formatMoney} from 'astryx-dracula/shared/format-money';
32
33
  import {
33
34
  Calendar,
34
35
  Flag,
@@ -121,12 +122,8 @@ const sigilClip: CSSProperties = {
121
122
  function ProductSigil({index}: {name: string; index: number}) {
122
123
  const hue = PRODUCT_HUES[index % PRODUCT_HUES.length];
123
124
  return (
124
- <Card padding={0} style={sigilClip}>
125
- <svg
126
- viewBox="0 0 40 40"
127
- width={40}
128
- height={40}
129
- aria-hidden="true">
125
+ <div style={sigilClip}>
126
+ <SceneFrame label={`${PRODUCTS[index % PRODUCTS.length].name} sigil`} viewBox="0 0 40 40" hasBackdrop={false}>
130
127
  <rect width="40" height="40" fill="var(--dracula-bg-light)" />
131
128
  <circle cx={28} cy={11} r={7} fill={hue} />
132
129
  <circle
@@ -140,8 +137,8 @@ function ProductSigil({index}: {name: string; index: number}) {
140
137
  d="M0 28 Q10 22 20 26 T40 24 V40 H0 Z"
141
138
  fill="var(--dracula-current-line)"
142
139
  />
143
- </svg>
144
- </Card>
140
+ </SceneFrame>
141
+ </div>
145
142
  );
146
143
  }
147
144
 
@@ -151,7 +148,6 @@ const SHIPPING = 0;
151
148
  const TAX_RATE = 0.0825;
152
149
  const TAX = Math.round((SUBTOTAL - DISCOUNT) * TAX_RATE * 100) / 100;
153
150
  const TOTAL = SUBTOTAL - DISCOUNT + SHIPPING + TAX;
154
- const fmt = (n: number) => `$${n.toFixed(2)}`;
155
151
 
156
152
  // ─── Activity data ──────────────────────────────────────────────────────────
157
153
  const ACTIVITY = [
@@ -216,7 +212,9 @@ function PageHeader({
216
212
  <VStack gap={3}>
217
213
  <HStack gap={4} vAlign="start">
218
214
  <StackItem size="fill">
219
- <VStack gap={0}>
215
+ {/* gap={2}: the breadcrumb is a control, not a text-baseline
216
+ pairing, so it needs separation from the H1 rather than 0. */}
217
+ <VStack gap={2}>
220
218
  <Link href="#/templates/detail-page">
221
219
  <HStack gap={1} vAlign="center">
222
220
  <Icon icon={ArrowLeft} size="sm" color="inherit" />
@@ -379,14 +377,14 @@ function ItemsCard() {
379
377
  weight="semibold"
380
378
  maxLines={1}
381
379
  hasTabularNumbers>
382
- {fmt(product.price * product.qty)}
380
+ {formatMoney(product.price * product.qty)}
383
381
  </Text>
384
382
  <Text
385
383
  type="supporting"
386
384
  color="secondary"
387
385
  maxLines={1}
388
386
  hasTabularNumbers>
389
- {fmt(product.price)} {'×'} {product.qty}
387
+ {formatMoney(product.price)} {'×'} {product.qty}
390
388
  </Text>
391
389
  </VStack>
392
390
  }
@@ -428,7 +426,7 @@ function InvoiceCard() {
428
426
  </Text>
429
427
  </StackItem>
430
428
  <Text type="body" hasTabularNumbers>
431
- {fmt(SUBTOTAL)}
429
+ {formatMoney(SUBTOTAL)}
432
430
  </Text>
433
431
  </HStack>
434
432
  </MetadataListItem>
@@ -438,7 +436,7 @@ function InvoiceCard() {
438
436
  <Text type="body">New customer code: NEW15</Text>
439
437
  </StackItem>
440
438
  <Text type="body" hasTabularNumbers>
441
- – {fmt(DISCOUNT)}
439
+ – {formatMoney(DISCOUNT)}
442
440
  </Text>
443
441
  </HStack>
444
442
  </MetadataListItem>
@@ -450,7 +448,7 @@ function InvoiceCard() {
450
448
  </Text>
451
449
  </StackItem>
452
450
  <Text type="body" hasTabularNumbers>
453
- {fmt(SHIPPING)}
451
+ {formatMoney(SHIPPING)}
454
452
  </Text>
455
453
  </HStack>
456
454
  </MetadataListItem>
@@ -462,7 +460,7 @@ function InvoiceCard() {
462
460
  </Text>
463
461
  </StackItem>
464
462
  <Text type="body" hasTabularNumbers>
465
- {fmt(TAX)}
463
+ {formatMoney(TAX)}
466
464
  </Text>
467
465
  </HStack>
468
466
  </MetadataListItem>
@@ -470,7 +468,7 @@ function InvoiceCard() {
470
468
  <HStack>
471
469
  <StackItem size="fill" />
472
470
  <Text type="body" weight="semibold" hasTabularNumbers>
473
- {fmt(TOTAL)}
471
+ {formatMoney(TOTAL)}
474
472
  </Text>
475
473
  </HStack>
476
474
  </MetadataListItem>
@@ -487,7 +485,7 @@ function InvoiceCard() {
487
485
  </Text>
488
486
  </StackItem>
489
487
  <Text type="body" hasTabularNumbers>
490
- {fmt(TOTAL)}
488
+ {formatMoney(TOTAL)}
491
489
  </Text>
492
490
  </HStack>
493
491
  </MetadataListItem>
@@ -502,8 +500,8 @@ function TimelineSection() {
502
500
  return (
503
501
  <Section>
504
502
  <VStack gap={4}>
505
- {/* gap={2}, matching the byte-identical header rows at :338 and
506
- :407. Core's Stack has no default gap (Stack.tsx:211, pass-through
503
+ {/* gap={2}, matching the byte-identical header rows at :340 and
504
+ :408. Core's Stack has no default gap (Stack.tsx:211, pass-through
507
505
  at :255/:285), so this rendered 0px -- the heading and the Filters
508
506
  button touched -- while both siblings render 8px. */}
509
507
  <HStack gap={2} vAlign="center">
@@ -582,11 +580,16 @@ function PanelContent() {
582
580
  return (
583
581
  <VStack gap={4}>
584
582
  <Collapsible trigger={<Heading level={3}>Notes</Heading>}>
583
+ {/* "Show more" closes the sentence inside the Text below, so it is
584
+ prose and asks for `hasUnderline` — colour alone is not a
585
+ sufficient cue inline (1.4.1 / F73). `type="inherit"` adopts the
586
+ paragraph's size and leading. The two links in the header are
587
+ navigation, so they pass neither. */}
585
588
  <Text type="body">
586
589
  Customer is a repeat buyer, 3rd order this quarter. Prefers
587
590
  moonlight and sage glazes. Requested gift wrapping for the mug set.
588
591
  Ships to a residential address in CA.{' '}
589
- <Link href="#/templates/detail-page">
592
+ <Link href="#/templates/detail-page" hasUnderline type="inherit">
590
593
  Show more
591
594
  </Link>
592
595
  </Text>