@mdbase-dev/ui 0.1.0-beta.166 → 0.1.0-beta.167

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/README.md CHANGED
@@ -37,7 +37,8 @@ applyThemePreference(loadThemePreference());
37
37
  - `apps` lists the mdbase apps and builds links that open the current
38
38
  collection in another app. Every deployment passes its own URLs to
39
39
  `withAppUrls` (or `AppSwitcher`'s `urls` prop). Apps without a configured URL
40
- are omitted; shared metadata never falls back to production origins.
40
+ are omitted; shared metadata never falls back to production origins. The
41
+ switcher's menu ends with a "Build your own" link to the SDK guide.
41
42
 
42
43
  ## Icon-button tooltips
43
44
 
@@ -0,0 +1,175 @@
1
+ /* Comments: threads beside a record (CommentsPanel), and their anchors and
2
+ tracked changes in a CodeMirror editor (comment-anchors). */
3
+ .mdbase-comments {
4
+ display: grid;
5
+ grid-template-columns: minmax(0, 1fr);
6
+ align-content: start;
7
+ gap: 12px;
8
+ color: var(--color-text);
9
+ font-family: var(--sans);
10
+ font-size: var(--font-size-ui);
11
+ }
12
+
13
+ .mdbase-comments-bar {
14
+ display: flex;
15
+ flex-wrap: wrap;
16
+ align-items: center;
17
+ justify-content: space-between;
18
+ gap: 8px;
19
+ }
20
+
21
+ .mdbase-comments-filter {
22
+ display: inline-flex;
23
+ gap: 2px;
24
+ }
25
+
26
+ .mdbase-comments-filter button {
27
+ min-height: 28px;
28
+ padding: 0 8px;
29
+ border: 0;
30
+ border-radius: var(--radius-sm);
31
+ color: var(--color-text-muted);
32
+ background: none;
33
+ font: inherit;
34
+ cursor: pointer;
35
+ }
36
+
37
+ .mdbase-comments-filter button:hover { color: var(--color-text); }
38
+ .mdbase-comments-filter button[aria-pressed="true"] { color: var(--color-text); background: var(--color-selected); }
39
+ .mdbase-comments-filter button:focus-visible,
40
+ .mdbase-thread-anchor:focus-visible,
41
+ .mdbase-thread-action:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
42
+ .mdbase-comments-count { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
43
+
44
+ .mdbase-comments-note,
45
+ .mdbase-comments-empty p,
46
+ .mdbase-comments-error { margin: 0; }
47
+ .mdbase-comments-note,
48
+ .mdbase-comments-empty { color: var(--color-text-muted); }
49
+ .mdbase-comments-empty { display: grid; gap: 4px; padding: 8px 0; }
50
+ .mdbase-comments-empty strong { color: var(--color-text); font-weight: 600; }
51
+ .mdbase-comments-empty kbd { font-family: var(--mono); font-size: 0.92em; }
52
+ .mdbase-comments-error { color: var(--color-danger); }
53
+
54
+ /* Why new comments are unsigned, and where to put that right. */
55
+ .mdbase-comments-signing {
56
+ display: grid;
57
+ gap: 6px;
58
+ margin: 0;
59
+ padding: 10px 12px;
60
+ border: 1px solid var(--color-warning-border);
61
+ border-radius: var(--radius-sm);
62
+ color: var(--color-warning-text);
63
+ background: var(--color-warning-surface);
64
+ }
65
+ .mdbase-comments-signing p { margin: 0; }
66
+ .mdbase-comments-signing strong { color: var(--color-warning-strong); }
67
+
68
+ /* Threads are rows ruled apart; the one selected in the editor is the selected surface. */
69
+ .mdbase-threads {
70
+ display: grid;
71
+ grid-template-columns: minmax(0, 1fr);
72
+ margin: 0;
73
+ padding: 0;
74
+ list-style: none;
75
+ }
76
+
77
+ .mdbase-thread {
78
+ display: grid;
79
+ grid-template-columns: minmax(0, 1fr);
80
+ gap: 8px;
81
+ padding: 12px 8px;
82
+ border-radius: var(--radius-sm);
83
+ }
84
+
85
+ .mdbase-threads > .mdbase-thread + .mdbase-thread { border-top: 1px solid var(--color-border); }
86
+ .mdbase-thread.is-active { background: var(--color-selected); }
87
+ .mdbase-threads > .mdbase-thread.is-active,
88
+ .mdbase-threads > .mdbase-thread.is-active + .mdbase-thread { border-top-color: transparent; }
89
+ .mdbase-thread.mdbase-comment-composer { margin: 0; padding: 12px; border: 1px solid var(--color-border-strong); }
90
+
91
+ .mdbase-thread-anchor {
92
+ display: grid;
93
+ gap: 4px;
94
+ padding: 0;
95
+ border: 0;
96
+ color: inherit;
97
+ background: none;
98
+ font: inherit;
99
+ text-align: left;
100
+ cursor: pointer;
101
+ }
102
+
103
+ .mdbase-thread-quote {
104
+ display: -webkit-box;
105
+ margin: 0;
106
+ overflow: hidden;
107
+ color: var(--color-text-soft);
108
+ font-style: italic;
109
+ line-height: 1.5;
110
+ white-space: pre-wrap;
111
+ -webkit-box-orient: vertical;
112
+ -webkit-line-clamp: 3;
113
+ }
114
+ blockquote.mdbase-thread-quote::before { content: "“"; }
115
+ blockquote.mdbase-thread-quote::after { content: "”"; }
116
+ .mdbase-thread-whole,
117
+ .mdbase-thread-detached { margin: 0; color: var(--color-text-muted); font-style: italic; }
118
+ .mdbase-thread-resolved { margin: 0; color: var(--color-text-muted); }
119
+
120
+ .mdbase-thread-suggestion { line-height: 1.5; }
121
+ .mdbase-thread-suggestion del,
122
+ .cm-suggest-delete { color: var(--color-danger); text-decoration: line-through; text-decoration-thickness: 1.5px; }
123
+ .mdbase-thread-suggestion ins,
124
+ .cm-suggest-insert { color: var(--color-success); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
125
+ .mdbase-thread-suggestion :is(del, ins) { padding: 0 2px; border-radius: var(--radius-sm); }
126
+ .mdbase-thread-suggestion del { background: color-mix(in oklch, var(--color-danger) 10%, transparent); }
127
+ .mdbase-thread-suggestion ins { background: color-mix(in oklch, var(--color-success) 12%, transparent); }
128
+
129
+ .mdbase-thread-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
130
+ .mdbase-thread-reply { display: grid; gap: 6px; }
131
+ .mdbase-thread textarea.mdbase-field { width: 100%; resize: vertical; }
132
+
133
+ /* A quiet text action: reply, resolve, withdraw. */
134
+ .mdbase-thread-action {
135
+ min-height: 24px;
136
+ padding: 0;
137
+ border: 0;
138
+ color: var(--color-accent);
139
+ background: none;
140
+ font: inherit;
141
+ cursor: pointer;
142
+ }
143
+ .mdbase-thread-action:hover:not(:disabled) { text-decoration: underline; }
144
+ .mdbase-thread-action:disabled { color: var(--color-text-faint); cursor: default; }
145
+ .mdbase-thread-action.is-quiet { color: var(--color-text-muted); }
146
+
147
+ .mdbase-comment-composer-title { display: flex; align-items: baseline; gap: 6px; margin: 0; }
148
+ .mdbase-comment-composer-title span { overflow: hidden; color: var(--color-text-muted); text-overflow: ellipsis; white-space: nowrap; }
149
+
150
+ /* A comment: who and when, the text beneath; replies are indented under the first. */
151
+ .mdbase-comment { display: grid; gap: 2px; }
152
+ .mdbase-comment.is-reply { margin-left: 12px; }
153
+ .mdbase-comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; margin: 0; color: var(--color-text-muted); }
154
+ .mdbase-comment-meta strong { overflow: hidden; color: var(--color-text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
155
+ .mdbase-comment-meta .mdbase-thread-action { margin-left: auto; }
156
+ .mdbase-comment-text { margin: 0; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
157
+ .mdbase-comment-text code { padding: 0 3px; border-radius: var(--radius-sm); background: var(--color-surface-subtle); font-family: var(--mono); font-size: 0.92em; }
158
+ .mdbase-comment-text a { color: var(--color-accent); }
159
+ .mdbase-comment-withdrawn { margin: 0; color: var(--color-text-muted); font-style: italic; }
160
+
161
+ /* In the editor: a commented passage is a quiet fill, stronger while its thread is selected. */
162
+ .cm-comment { border-radius: var(--radius-sm); background: color-mix(in oklch, var(--color-warning) 20%, transparent); }
163
+ .cm-comment.is-active { background: color-mix(in oklch, var(--color-warning) 42%, transparent); }
164
+ .cm-comment-point {
165
+ display: inline-block;
166
+ width: 0;
167
+ height: 1.1em;
168
+ margin: 0 1px;
169
+ border-left: 2px solid var(--color-warning);
170
+ vertical-align: text-bottom;
171
+ }
172
+ :is(.cm-suggest-delete, .cm-suggest-insert).is-active { border-radius: var(--radius-sm); background: var(--color-selected); }
173
+ .cm-tooltip .cm-comment-tip { display: grid; gap: 2px; max-width: 320px; padding: 8px 10px; font-size: var(--font-size-ui); }
174
+ .cm-comment-who { color: var(--color-text-muted); font-size: var(--font-size-caption); }
175
+ .cm-comment-said { line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
package/css/controls.css CHANGED
@@ -429,6 +429,30 @@ textarea.mdbase-field {
429
429
  margin-inline: 3px;
430
430
  }
431
431
 
432
+ /* The app menu's last line: the new-tab note, and a quiet link to the SDK guide. */
433
+ .mdbase-app-menu-footer {
434
+ display: flex;
435
+ flex-wrap: wrap;
436
+ align-items: center;
437
+ justify-content: space-between;
438
+ gap: 2px 12px;
439
+ }
440
+
441
+ .mdbase-app-menu-build {
442
+ margin: -2px -6px;
443
+ padding: 2px 6px;
444
+ border-radius: var(--control-radius);
445
+ color: var(--color-text-soft);
446
+ text-decoration: none;
447
+ }
448
+
449
+ .mdbase-app-menu-build:hover,
450
+ .mdbase-menu .mdbase-app-menu-build:focus-visible {
451
+ outline: 0;
452
+ color: var(--color-text);
453
+ background: var(--color-accent-soft);
454
+ }
455
+
432
456
  .mdbase-app-menu-external {
433
457
  width: 15px;
434
458
  height: 15px;
@@ -6,6 +6,8 @@ import { mdbaseAppHref, withAppUrls } from "./apps.js";
6
6
  import { MdbaseAppMark, Wordmark } from "./brand.js";
7
7
  import { useMdbaseMarkActivity } from "./mark-activity.js";
8
8
  import { Menu } from "./Menu.js";
9
+ /** Where the menu's "Build your own" link goes: the same SDK guide in every environment. */
10
+ const sdkDocumentationUrl = "https://mdbase.dev/sdk/";
9
11
  /**
10
12
  * The product wordmark as a menu for opening the current collection in the other mdbase apps.
11
13
  * Each opens in a new tab so the current app stays where it is.
@@ -109,14 +111,37 @@ function AppMenu({
109
111
  current: app.id === current,
110
112
  onOpen: () => onClose(false)
111
113
  }, app.id))
112
- }), _jsx("p", {
113
- className: "mdbase-menu-note",
114
- children: _i18n._(
115
- /** i18n */
116
- {
117
- id: "XDzAnp",
118
- message: "Opens in a new tab"
119
- })
114
+ }), _jsxs("div", {
115
+ className: "mdbase-menu-note mdbase-app-menu-footer",
116
+ children: [_jsx("span", {
117
+ children: _i18n._(
118
+ /** i18n */
119
+ {
120
+ id: "XDzAnp",
121
+ message: "Opens in a new tab"
122
+ })
123
+ }), _jsxs("a", {
124
+ className: "mdbase-app-menu-build",
125
+ role: "menuitem",
126
+ href: sdkDocumentationUrl,
127
+ target: "_blank",
128
+ rel: "noopener",
129
+ onClick: () => onClose(false),
130
+ children: [_i18n._(
131
+ /** i18n */
132
+ {
133
+ id: "vWeG-x",
134
+ message: "Build your own"
135
+ }), _jsxs("span", {
136
+ className: "mdbase-visually-hidden",
137
+ children: [" ", _i18n._(
138
+ /** i18n */
139
+ {
140
+ id: "75iTY6",
141
+ message: "(opens in a new tab)"
142
+ })]
143
+ })]
144
+ })]
120
145
  })]
121
146
  });
122
147
  }
@@ -0,0 +1,44 @@
1
+ import { type JSX, type ReactNode } from "react";
2
+ import { type CommentChange, type CommentPeople, type CommentRecord, type CommentThread, type PlacedThread } from "./comments.js";
3
+ /** What a write came to; a failure's message is shown beside the action that made it. */
4
+ export type CommentResult = {
5
+ readonly ok: true;
6
+ } | {
7
+ readonly ok: false;
8
+ readonly message: string;
9
+ };
10
+ /** A comment being written: on `quote`, at a point in the text (an empty quote), or on the whole record. */
11
+ export interface PendingComment {
12
+ readonly quote?: string;
13
+ }
14
+ interface CommentsPanelProps {
15
+ readonly threads: readonly PlacedThread[];
16
+ readonly people: CommentPeople;
17
+ /** Threads are still being read. */
18
+ readonly loading?: boolean;
19
+ /** Why comments could not be read. */
20
+ readonly problem?: string | undefined;
21
+ readonly onRetry?: (() => void) | undefined;
22
+ /** The selected thread (its first comment's path). */
23
+ readonly active: string | null;
24
+ readonly pending: PendingComment | null;
25
+ /** Absent when this person cannot write comments here. */
26
+ readonly onStart?: (() => void) | undefined;
27
+ /** Said when there is nothing open: how to begin a comment in this app. */
28
+ readonly hint?: ReactNode;
29
+ /** Shown above the threads, such as why new comments will not be signed. */
30
+ readonly notice?: ReactNode;
31
+ readonly onSelect: (placed: PlacedThread) => void;
32
+ readonly onSubmit: (text: string) => Promise<CommentResult>;
33
+ readonly onCancel: () => void;
34
+ readonly onReply?: ((thread: CommentThread, text: string) => Promise<CommentResult>) | undefined;
35
+ readonly onChange?: ((comment: CommentRecord, change: CommentChange) => Promise<CommentResult>) | undefined;
36
+ /** Makes a suggested edit and resolves its thread. */
37
+ readonly onAccept?: ((placed: PlacedThread) => Promise<CommentResult>) | undefined;
38
+ /** Opens a comment's own record. */
39
+ readonly onOpenRecord?: ((path: string) => void) | undefined;
40
+ }
41
+ export declare function CommentsPanel({ threads, people, loading, problem, onRetry, active, pending, onStart, hint, notice, onSelect, onSubmit, onCancel, onReply, onChange, onAccept, onOpenRecord }: CommentsPanelProps): JSX.Element;
42
+ /** "3 open comments", for a control that opens them. */
43
+ export declare function openCommentCount(threads: readonly PlacedThread[]): string;
44
+ export {};