@bridgebrew/design-system 0.1.11-next.94 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridgebrew/design-system",
3
- "version": "0.1.11-next.94",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "description": "A storyboard of the @bridge/ui kit: every component's variants, sizes and states, live, in the page's theme.",
6
6
  "keywords": [
@@ -58,14 +58,14 @@
58
58
  }
59
59
  },
60
60
  "peerDependencies": {
61
- "@bridge/ui": ">=0.1.11-next.94",
61
+ "@bridge/ui": ">=0.1.12",
62
62
  "react": "19.3.0"
63
63
  },
64
64
  "dependencies": {
65
65
  "shiki": "4.4.3"
66
66
  },
67
67
  "devDependencies": {
68
- "@bridge/ui": "npm:@bridgebrew/ui@0.1.11-next.94"
68
+ "@bridge/ui": "npm:@bridgebrew/ui@0.1.12"
69
69
  },
70
70
  "scripts": {
71
71
  "test": "node --test model.test.ts",
@@ -1,12 +1,13 @@
1
1
  // Data display: marks, chips, rows and tables.
2
2
  import * as React from 'react';
3
3
  import {
4
- Avatar, Badge, Button, Collapsible, CollapsiblePanel, CollapsibleTrigger, CollapsibleRows, FilterChip, Kbd, TagDot, TagList, TagPill, ExpandToggle, GroupHeader, Icon, ICON_NAMES, Input, Label, List, ListGroup,
4
+ Avatar, Badge, Button, DiffView, SegmentGroup, Toggle, Collapsible, CollapsiblePanel, CollapsibleTrigger, CollapsibleRows, FilterChip, Kbd, TagDot, TagList, TagPill, ExpandToggle, GroupHeader, Icon, ICON_NAMES, Input, Label, List, ListGroup,
5
5
  ListItem, Picker, Properties, PropertyRow, StatusIcon, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader,
6
6
  TableRow, type StatusIconStatus,
7
7
  Thumbnail,
8
8
  } from '@bridge/ui';
9
9
  import { Code, Group, Sample, Wide, organizations, people } from './parts.tsx';
10
+ import { tokensOf } from '../highlight.ts';
10
11
 
11
12
  const avatarSizes = ['xs', 'sm', 'default', 'lg', 'xl', '2xl', '3xl'] as const;
12
13
 
@@ -364,7 +365,73 @@ function CodeBlockStory() {
364
365
  );
365
366
  }
366
367
 
367
- export const dataDisplay = { thumbnail: ThumbnailStory, collapsible: CollapsibleStory, 'code-block': CodeBlockStory,
368
+
369
+ const diffSample = `diff --git a/src/lib/format.js b/src/lib/format.js
370
+ --- a/src/lib/format.js
371
+ +++ b/src/lib/format.js
372
+ @@ -12,5 +12,5 @@ export function pad(value, size) {
373
+ export function money(amount, currency) {
374
+ - return amount.toFixed(2) + ' ' + currency;
375
+ + return amount.toFixed(currency === 'JPY' ? 0 : 2) + ' ' + currency;
376
+ }
377
+
378
+ export function percent(ratio) {
379
+ @@ -58,3 +58,8 @@ export function percent(ratio) {
380
+ export function initials(name) {
381
+ - return name.split(' ').map((part) => part[0]).join('');
382
+ + // Initials of a person's name as shown on their avatar: the first letter of each word, upper case, blank words skipped, so that " ada lovelace " gives "AL" and an empty name gives an empty string rather than "undefined".
383
+ + return name
384
+ + .split(/\\s+/)
385
+ + .filter(Boolean)
386
+ + .map((part) => part[0].toUpperCase())
387
+ + .join('');
388
+ }
389
+ `;
390
+ const diffLock = `@@ -1,3 +1,4 @@
391
+ lockfileVersion: '9.0'
392
+ +settings: { autoInstallPeers: true }
393
+ importers:
394
+ .: {}
395
+ `;
396
+ /** The sample file's new text: what the folds read. */
397
+ const sampleLines = (from: number, to: number) =>
398
+ Promise.resolve(Array.from({ length: Math.max(0, Math.min(to, 72) - from + 1) }, (_, at) => `// line ${from + at} of format.js`));
399
+ /** The stories' highlighter for a file's extension (tsx covers js). */
400
+ const highlightDiff = (code: string, language: string) => tokensOf(code, ['js', 'jsx', 'ts'].includes(language) ? 'tsx' : language);
401
+
402
+ function DiffViewStory() {
403
+ const [mode, setMode] = React.useState<'unified' | 'split'>('unified');
404
+ const [wrap, setWrap] = React.useState(false);
405
+ const [reviewed, setReviewed] = React.useState<ReadonlySet<string>>(new Set());
406
+ const files = [
407
+ { path: 'src/lib/format.js', patch: diffSample },
408
+ { path: 'pnpm-lock.yaml', patch: diffLock, generated: true },
409
+ ];
410
+ return (
411
+ <>
412
+ <Group title="Unified and split" description="One number column (the new one, − on a removed line), or both sides; the changed words marked; colours from the caller's Shiki; the arrows of a fold read 20 more lines." layout="fill"
413
+ code={`<DiffView\n mode="${mode}"\n wrap={${wrap}}\n files={[{ path: 'src/lib/format.js', patch }, { path: 'pnpm-lock.yaml', patch: lock, generated: true }]}\n highlight={tokensOf}\n loadLines={(path, from, to) => linesOf(path, from, to)}\n/>`}>
414
+ <div className="flex min-w-0 flex-col gap-3">
415
+ <div className="flex items-center justify-end gap-3 text-sm">
416
+ <SegmentGroup aria-label="Layout" value={mode} onValueChange={(value: string) => setMode(value === 'split' ? 'split' : 'unified')} items={[{ value: 'unified', label: 'Unified' }, { value: 'split', label: 'Split' }]} />
417
+ <label className="flex items-center gap-2"><Toggle aria-label="Wrap lines" checked={wrap} onCheckedChange={setWrap} />Wrap lines</label>
418
+ </div>
419
+ <DiffView mode={mode} wrap={wrap} files={files} highlight={highlightDiff} loadLines={(_path, from, to) => sampleLines(from, to)} />
420
+ </div>
421
+ </Group>
422
+ <Group title="Read one by one" description="A file without its patch says it is read; one that failed says why; one with no text diff says so." layout="fill"
423
+ code={`<DiffView files={[{ path: 'a.ts', patch: { loading: true }, added: 12 }, { path: 'b.ts', patch: { error: 'Could not read b.ts.' } }, { path: 'logo.png', patch: binary }]} />`}>
424
+ <DiffView files={[{ path: 'src/a.ts', patch: { loading: true }, added: 12, removed: 3 }, { path: 'src/b.ts', patch: { error: 'Could not read src/b.ts.' } }, { path: 'assets/logo.png', patch: 'diff --git a/assets/logo.png b/assets/logo.png\nBinary files a/assets/logo.png and b/assets/logo.png differ' }]} />
425
+ </Group>
426
+ <Group title="Review mode" description="A Reviewed checkbox in each header (for review plugins); a reviewed file folds to its header." layout="fill"
427
+ code={`<DiffView files={files} review={{ reviewed, onReviewedChange: (path, value) => … }} />`}>
428
+ <DiffView files={files.slice(0, 1)} highlight={highlightDiff} review={{ reviewed, onReviewedChange: (path, value) => setReviewed((was) => { const next = new Set(was); if (value) next.add(path); else next.delete(path); return next; }) }} />
429
+ </Group>
430
+ </>
431
+ );
432
+ }
433
+
434
+ export const dataDisplay = { 'diff-view': DiffViewStory, thumbnail: ThumbnailStory, collapsible: CollapsibleStory, 'code-block': CodeBlockStory,
368
435
  kbd: KbdStory, 'tag-pill': TagPillStory,
369
436
  avatar: AvatarStory, badge: BadgeStory, icon: IconStory, label: LabelStory, list: ListStory, properties: PropertiesStory,
370
437
  'status-icon': StatusIconStory, table: TableStory,
@@ -273,6 +273,9 @@ function MultiPaneStory() {
273
273
  {(device) => device === 'desktop' ? (
274
274
  <>
275
275
  {shapes.map(([title, description, panes]) => <Group key={title} title={title} description={description} layout="bleed" code={codeOf(panes)}><Screen device="desktop"><MultiPane {...panes} main={main} /></Screen></Group>)}
276
+ <Group title="Floating aside" description="asideVariant='floating': the aside a card inset from the edges, as tall as its content, scrolling inside it; no line drawn before it, its edge still dragged." layout="bleed" code={codeOf({ nav, aside }).replace('/>', ' asideVariant="floating"\n/>')}>
277
+ <Screen device="desktop"><MultiPane nav={nav} main={main} aside={<div className="ds-block" style={{ height: 160 }}>aside</div>} asideVariant="floating" /></Screen>
278
+ </Group>
276
279
  </>
277
280
  ) : (
278
281
  shapes.map(([title, , panes]) => {
package/stories.ts CHANGED
@@ -95,6 +95,7 @@ export const stories = [
95
95
  { id: 'snooze-menu', title: 'Snooze menu', layer: 'composite', description: 'Puts an item away until a preset or chosen time.' },
96
96
  { id: 'wizard', title: 'Wizard', layer: 'composite', description: 'A dialog in steps, where a first choice decides the next.' },
97
97
  { id: 'draft-bar', title: 'Draft bar', layer: 'composite', description: 'Under a record not created yet: kept, or what stops Create, then Cancel and Create.' },
98
+ { id: 'diff-view', title: 'Diff view', layer: 'composite', description: 'A git diff file by file: unified or split, changed words, colours, folds that expand.' },
98
99
 
99
100
  { id: 'address-book-template', title: 'Address book', layer: 'template', description: 'Sample people: MultiPane, a searchable list, a record.' },
100
101
  { id: 'mail-template', title: 'Mail', layer: 'template', description: 'Sample mails: MultiPane, an inbox grouped by day (sender, subject, the text\'s start; unread, a dot), the mail open, its actions.' },