@smwb/ui-styles 2.6.0 → 2.8.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.
package/README.md CHANGED
@@ -117,6 +117,23 @@ value for both modes, so a theme that makes `@warningColor` lighter, or any of t
117
117
  changes the numbers: re-check them there. `color="secondary"` is the one name that falls short in the default dark
118
118
  theme (2.65:1): use a status for state.
119
119
 
120
+ #### IdentityBadge colours
121
+
122
+ `IdentityBadge` is a frame with no fill, so its colour is a border, an icon and 11px of text. It reads one custom
123
+ property, `--smwb-identity-badge-accent`, which the component sets from its `accent` prop; without it (or with an empty
124
+ one) the badge resolves `--smwb-identity-badge-color` to `@identityBadgeColor`, `var(--smui-onSurfaceVariant)` —
125
+ neutral, following the dark theme. No status token (`infoColor`, `successColor`, `warningColor`, `errorColor`) appears
126
+ in the badge's rules: the marker must not read as a state the way `StatusDot` does. An accent is any CSS colour, so its
127
+ contrast is the caller's problem: at `@identityBadgeFontSize` (11px) pick one that reaches 4.5:1 against the surface it
128
+ sits on.
129
+
130
+ The box comes from `@identityBadgeHeight` (18px), `@identityBadgePaddingX` (4px), `@identityBadgeGap` (2px, icon to
131
+ text), `@identityBadgeIconSize` (12px), `@identityBadgeBorderWidth` and `@identityBadgeRadius`; the text from
132
+ `@identityBadgeFontFamily` (a monospace stack), `@identityBadgeFontSize` and `@identityBadgeFontWeight`; the row of a
133
+ group from `@identityBadgeGroupGap` (4px). All are `theme.config` variables, and the colour is the only one that reads a
134
+ `--smui-*` runtime token. Under forced colours the frame and the text draw in `CanvasText`, and a clickable "+N" in
135
+ `ButtonText`.
136
+
120
137
  #### QrCode colours
121
138
 
122
139
  `QrCode` never reads theme tokens for the code itself: the modules are always `@qrCodeDarkColor`
@@ -127,6 +144,26 @@ so a copied or printed svg scans without the library CSS). Only the caption is t
127
144
  (`--smui-onSurfaceVariant`). The corner rounding is `@qrCodeRadius` (`@smui-radius-sm`); the svg clips to
128
145
  it, and the quiet zone keeps the modules clear of the rounding.
129
146
 
147
+ #### Markdown
148
+
149
+ `Markdown` (issue and PR descriptions and comments) takes its text styles from `@markdown*` variables and
150
+ its colours from runtime tokens, so the dark theme follows without extra settings: the link is
151
+ `@markdownLinkColor` (`--smui-primaryColor`), the code and table-head surfaces are
152
+ `@markdownCodeBackground` / `@markdownTableHeadBackground` (`--smui-surfaceVariant`), the quote border and
153
+ text are `@markdownQuoteBorderColor` / `@markdownQuoteColor` (`--smui-outlineColor` /
154
+ `--smui-onSurfaceVariant`), the table borders are `@markdownTableBorderColor` (`--smui-tableBorderColor`)
155
+ and the rule is `@markdownRuleColor` (`--smui-dividerColor`). The type scale lives in
156
+ `@markdownFontSize` / `@markdownLineHeight` (body2), the six `@markdownHeading*Size` steps, sized in `em`
157
+ off the prose, `@markdownHeadingWeight`, `@markdownListIndent`, the code measures (`@markdownCodeFontFamily`,
158
+ `@markdownCodeFontSize`, `@markdownCodeRadius`, `@markdownCodeBlockPadding`, `@markdownInlineCodePadding`),
159
+ the quote's `@markdownQuoteBorderWidth` and the table's `@markdownTableCellPadding`.
160
+
161
+ Two layout promises are part of the theme contract: the prose wraps long words and addresses itself
162
+ (`overflow-wrap: anywhere` on the root), and the code blocks and tables scroll sideways _inside
163
+ themselves_ (`overflow-x: auto` with `contain: inline-size`), so a long line or a wide table never widens
164
+ the page — not even inside a flex or grid parent that does not set `min-width: 0`. Override the variables
165
+ in `theme.config`; an app needs no rules of its own on the `smwb-markdown` classes.
166
+
130
167
  #### DagView colours
131
168
 
132
169
  The dependency graph (`DagView` in `@smwb/ui-solid` and `@smwb/ui-react`) takes its colours from theme variables that default to the
@@ -0,0 +1,2 @@
1
+ @import (reference) "../../_prelude.less";
2
+ @import "./identityBadge.less";
@@ -0,0 +1,110 @@
1
+ // A compact identity marker: an outlined frame with no fill, a glyph on the left and a
2
+ // short monospace text on the right. It must not read as a status, so its colour is the
3
+ // caller's accent or the theme's neutral — never a status token — and the frame, not a
4
+ // fill, carries it. One size, one look: no modifier classes.
5
+ .smwb-identity-badge {
6
+ --smwb-identity-badge-color: var(--smwb-identity-badge-accent, @identityBadgeColor);
7
+ display: inline-flex;
8
+ align-items: center;
9
+ gap: @identityBadgeGap;
10
+ flex: none;
11
+ box-sizing: border-box;
12
+ height: @identityBadgeHeight;
13
+ padding: 0 @identityBadgePaddingX;
14
+ vertical-align: middle;
15
+ white-space: nowrap;
16
+ border: @identityBadgeBorderWidth solid var(--smwb-identity-badge-color);
17
+ border-radius: @identityBadgeRadius;
18
+ background-color: transparent;
19
+ color: var(--smwb-identity-badge-color);
20
+ font-family: @identityBadgeFontFamily;
21
+ font-size: @identityBadgeFontSize;
22
+ font-weight: @identityBadgeFontWeight;
23
+ line-height: 1;
24
+
25
+ &__icon {
26
+ display: inline-flex;
27
+ flex: none;
28
+ align-items: center;
29
+ justify-content: center;
30
+ width: @identityBadgeIconSize;
31
+ height: @identityBadgeIconSize;
32
+ overflow: hidden;
33
+
34
+ // The caller picks the icon's own size, so the box clamps it: an <Icon size={20}> is scaled
35
+ // into the 12px slot instead of stretching the badge's fixed height. The Icon's wrapper
36
+ // takes the whole box, so that its glyph has a definite size to be clamped to.
37
+ > .smwb-icon__wrapper {
38
+ width: 100%;
39
+ height: 100%;
40
+ }
41
+
42
+ svg,
43
+ img {
44
+ max-width: 100%;
45
+ max-height: 100%;
46
+ }
47
+
48
+ // A font glyph sizes itself with an inline font-size, which only !important can take over.
49
+ .material-symbols-outlined {
50
+ font-size: @identityBadgeIconSize !important;
51
+ }
52
+ }
53
+ }
54
+
55
+ .smwb-identity-badge-group {
56
+ display: inline-flex;
57
+ align-items: center;
58
+ gap: @identityBadgeGroupGap;
59
+ vertical-align: middle;
60
+
61
+ // The children past `max` are drawn for hydration and hidden: a server that left them
62
+ // out would leave the browser without nodes to hydrate them from.
63
+ &__hidden {
64
+ display: none;
65
+ }
66
+
67
+ // A clickable "+N" is a real button, so a keyboard reaches it. normalize.css strips a
68
+ // button's looks and its outline, so both come back here.
69
+ button&__surplus {
70
+ position: relative; // holds the coarse-pointer hit area
71
+ margin: 0;
72
+ appearance: none;
73
+ background-color: transparent;
74
+ cursor: pointer;
75
+
76
+ &:focus-visible {
77
+ outline: 2px solid var(--smui-primaryColor);
78
+ outline-offset: 2px;
79
+ }
80
+
81
+ // A finger needs a 44px target and the badge must keep its 18px row, so the hit area
82
+ // hangs off a pseudo-element, centred over the button: the row does not grow
83
+ // (SelectField's chip-delete precedent).
84
+ @media (pointer: coarse) {
85
+ &::after {
86
+ content: "";
87
+ position: absolute;
88
+ top: 50%;
89
+ left: 50%;
90
+ width: var(--smui-control-h-sm, @smui-control-h-sm-coarse);
91
+ height: var(--smui-control-h-sm, @smui-control-h-sm-coarse);
92
+ transform: translate(-50%, -50%);
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ // Forced colours drop the accent: draw the frame and the text in the text colour, and a
99
+ // clickable "+N" in the button colour.
100
+ @media (forced-colors: active) {
101
+ .smwb-identity-badge {
102
+ border-color: CanvasText;
103
+ color: CanvasText;
104
+ }
105
+
106
+ button.smwb-identity-badge-group__surplus {
107
+ border-color: ButtonText;
108
+ color: ButtonText;
109
+ }
110
+ }
@@ -0,0 +1,2 @@
1
+ @import (reference) "../../_prelude.less";
2
+ @import "./markdown.less";
@@ -0,0 +1,265 @@
1
+ // Markdown prose: an issue or PR description or comment rendered from a parsed tree.
2
+ // Text styles follow the @markdown* theme variables; colours are runtime tokens, so the
3
+ // dark theme follows without extra settings. Long words and addresses wrap in the prose
4
+ // itself; the wide blocks (code and tables) scroll sideways inside themselves instead
5
+ // of widening the page — `contain: inline-size` takes their min-content contribution out
6
+ // of flex and grid parents that do not set min-width: 0.
7
+ .smwb-markdown {
8
+ min-width: 0;
9
+ max-width: 100%;
10
+ overflow-wrap: anywhere;
11
+ font-size: @markdownFontSize;
12
+ line-height: @markdownLineHeight;
13
+
14
+ // Blocks stack with a gap; the first and the last child carry no outer margin.
15
+ > * {
16
+ margin-block: 0;
17
+ }
18
+ > * + * {
19
+ margin-block-start: @markdownBlockGap;
20
+ }
21
+
22
+ // Over the maxLength cap, and for raw HTML that survived as a block, the text is pre-wrapped prose.
23
+ &__plain,
24
+ &__raw {
25
+ white-space: pre-wrap;
26
+ }
27
+
28
+ // The look follows the Markdown level (the class), not the tag: `headingOffset` shifts
29
+ // the tag for the document outline, not the size.
30
+ &__heading {
31
+ font-weight: @markdownHeadingWeight;
32
+ line-height: 1.3;
33
+
34
+ &_level-1 {
35
+ font-size: @markdownHeading1Size;
36
+ }
37
+ &_level-2 {
38
+ font-size: @markdownHeading2Size;
39
+ }
40
+ &_level-3 {
41
+ font-size: @markdownHeading3Size;
42
+ }
43
+ &_level-4 {
44
+ font-size: @markdownHeading4Size;
45
+ }
46
+ &_level-5 {
47
+ font-size: @markdownHeading5Size;
48
+ }
49
+ &_level-6 {
50
+ font-size: @markdownHeading6Size;
51
+ }
52
+ }
53
+
54
+ &__rule {
55
+ height: 0;
56
+ border: 0;
57
+ border-block-start: 1px solid @markdownRuleColor;
58
+ }
59
+
60
+ &__quote {
61
+ margin-inline: 0;
62
+ padding-inline-start: @markdownBlockGap;
63
+ border-inline-start: @markdownQuoteBorderWidth solid @markdownQuoteBorderColor;
64
+ color: @markdownQuoteColor;
65
+
66
+ > * + * {
67
+ margin-block-start: @markdownBlockGap;
68
+ }
69
+ }
70
+
71
+ // Deep nesting stops widening the text: from the fourth occurrence of the same container on,
72
+ // a quote, a list or a footnote indents only a little, so the deepest text that still draws as
73
+ // Markdown (31 levels of quotes, lists and footnotes, alone or mixed) fits a phone-width column.
74
+ &__quote &__quote &__quote &__quote,
75
+ &__footnote &__footnote &__footnote &__footnote {
76
+ padding-inline-start: ~"calc(@{markdownBlockGap} / 3)";
77
+ }
78
+ &__list &__list &__list &__list {
79
+ padding-inline-start: ~"calc(@{markdownListIndent} * 2 / 3)";
80
+ }
81
+
82
+ // The marker kind lives on the list…
83
+ &__list {
84
+ padding-inline-start: @markdownListIndent;
85
+ list-style: disc;
86
+
87
+ &_ordered {
88
+ list-style: decimal;
89
+ }
90
+
91
+ // A nested list hangs closer to its parent item than a top-level block gap.
92
+ .smwb-markdown__list {
93
+ margin-block-start: ~"calc(@{markdownBlockGap} / 2)";
94
+ }
95
+ }
96
+
97
+ // …and reaches each item through `inherit`: normalize.css sets `list-style: none` on every
98
+ // `ul li` (0,0,2), and this class (0,1,0) wins over it.
99
+ &__item {
100
+ list-style: inherit;
101
+
102
+ // Loose list items stack their paragraphs like the root's blocks.
103
+ > * + * {
104
+ margin-block-start: ~"calc(@{markdownBlockGap} / 2)";
105
+ }
106
+
107
+ // A task item drops its marker, the checkbox leads it instead; plain items in the same list
108
+ // keep theirs. In a loose item the first paragraph runs on after the checkbox.
109
+ &_task {
110
+ list-style: none;
111
+
112
+ > .smwb-markdown__checkbox + .smwb-markdown__paragraph {
113
+ display: inline;
114
+ }
115
+ }
116
+ }
117
+
118
+ // normalize.css stretches every `input` to the full width and height of its parent; the
119
+ // checkbox keeps its own size so the item's text runs on beside it.
120
+ &__checkbox {
121
+ width: auto;
122
+ height: auto;
123
+ margin-block: 0;
124
+ margin-inline-end: 0.5em;
125
+ vertical-align: middle;
126
+ accent-color: var(--smui-primaryColor);
127
+ }
128
+
129
+ // A focusable scroll container: it keeps long lines inside itself, never the page.
130
+ &__code-block {
131
+ max-width: 100%;
132
+ overflow-x: auto;
133
+ contain: inline-size;
134
+ padding: @markdownCodeBlockPadding;
135
+ border-radius: @markdownCodeRadius;
136
+ background-color: @markdownCodeBackground;
137
+ white-space: pre;
138
+ overflow-wrap: normal;
139
+ tab-size: 4;
140
+
141
+ @supports not (contain: inline-size) {
142
+ width: 0;
143
+ min-width: 100%;
144
+ }
145
+
146
+ &:focus-visible {
147
+ outline: 2px solid var(--smui-primaryColor);
148
+ outline-offset: 2px;
149
+ }
150
+ }
151
+
152
+ &__code,
153
+ &__inline-code {
154
+ font-family: @markdownCodeFontFamily;
155
+ font-size: @markdownCodeFontSize;
156
+ }
157
+
158
+ &__code {
159
+ padding: 0;
160
+ border-radius: 0;
161
+ background-color: transparent;
162
+ }
163
+
164
+ &__inline-code {
165
+ padding: @markdownInlineCodePadding;
166
+ border-radius: @markdownCodeRadius;
167
+ background-color: @markdownCodeBackground;
168
+ // The background (and padding), not the font, tells inline code apart: an app's own
169
+ // UI font may already be monospace, so a different family alone would read as plain text.
170
+ }
171
+
172
+ &__table-wrap {
173
+ max-width: 100%;
174
+ overflow-x: auto;
175
+ contain: inline-size;
176
+
177
+ @supports not (contain: inline-size) {
178
+ width: 0;
179
+ min-width: 100%;
180
+ }
181
+
182
+ &:focus-visible {
183
+ outline: 2px solid var(--smui-primaryColor);
184
+ outline-offset: 2px;
185
+ }
186
+ }
187
+
188
+ // The cells carry the borders, so the grid reads both when the table fills the wrap
189
+ // and when the wrap scrolls sideways over a wider table.
190
+ &__table {
191
+ width: 100%;
192
+ border-collapse: collapse;
193
+ }
194
+
195
+ // Cells wrap at spaces only: with the root's `overflow-wrap: anywhere` every character would
196
+ // be a break, the table's min-content width would drop to nothing and a wide table would squeeze
197
+ // into the wrap instead of scrolling inside it. Prose in a cell still wraps.
198
+ &__cell {
199
+ overflow-wrap: normal;
200
+ padding: @markdownTableCellPadding;
201
+ border: 1px solid @markdownTableBorderColor;
202
+ text-align: left;
203
+
204
+ &_head {
205
+ background-color: @markdownTableHeadBackground;
206
+ font-weight: @markdownHeadingWeight;
207
+ }
208
+
209
+ &_align-left {
210
+ text-align: left;
211
+ }
212
+ &_align-center {
213
+ text-align: center;
214
+ }
215
+ &_align-right {
216
+ text-align: right;
217
+ }
218
+ }
219
+
220
+ &__link {
221
+ color: @markdownLinkColor;
222
+ text-decoration: underline;
223
+ text-underline-offset: 0.15em;
224
+
225
+ &:hover,
226
+ &:focus-visible {
227
+ text-decoration-thickness: 2px;
228
+ }
229
+ }
230
+
231
+ &__image {
232
+ max-width: 100%;
233
+ height: auto;
234
+ }
235
+
236
+ // Footnotes render where their definitions stand, with no ids or back-links.
237
+ &__footnote {
238
+ margin-inline: 0;
239
+ padding-inline-start: @markdownListIndent;
240
+
241
+ > * + * {
242
+ margin-block-start: @markdownBlockGap;
243
+ }
244
+ }
245
+
246
+ // The label leads the definition's first paragraph on its line.
247
+ &__footnote-label {
248
+ margin-inline-end: 0.5em;
249
+ font-weight: @markdownHeadingWeight;
250
+
251
+ + .smwb-markdown__paragraph {
252
+ display: inline;
253
+ }
254
+ }
255
+ }
256
+
257
+ // Forced colours drop background colours: the code surfaces become frames so they stay visible.
258
+ @media (forced-colors: active) {
259
+ .smwb-markdown {
260
+ &__code-block,
261
+ &__inline-code {
262
+ border: 1px solid CanvasText;
263
+ }
264
+ }
265
+ }
@@ -15,6 +15,7 @@
15
15
  @import "./components/meter/meter.less";
16
16
  @import "./components/diffStat/diffStat.less";
17
17
  @import "./components/statusDot/statusDot.less";
18
+ @import "./components/identityBadge/identityBadge.less";
18
19
  @import "./components/qrCode/qrCode.less";
19
20
  @import "./components/radioButton/radioButton.less";
20
21
  @import "./components/sidebar/sidebar.less";
@@ -41,6 +42,7 @@
41
42
  @import "./components/grid/grid.less";
42
43
  @import "./components/tooltip/tooltip.less";
43
44
  @import "./components/kbd/kbd.less";
45
+ @import "./components/markdown/markdown.less";
44
46
  @import "./components/commandPalette/commandPalette.less";
45
47
  @import "./components/sheet/sheet.less";
46
48
  @import "./components/floatingWindow/floatingWindow.less";
@@ -204,6 +204,20 @@
204
204
  @statusDotDiamondRotation: 45deg; // corner-up, the diamond of the onreel thread marker
205
205
  @statusDotDiamondRadius: @smui-radius-none; // sharp corners; the dot's are a circle
206
206
 
207
+ // A compact identity marker sits inside a dense row, so its height is off-grid and below
208
+ // the control scale on purpose: one 14px line at the DagView node's line-height 1.3.
209
+ @identityBadgeHeight: 18px;
210
+ @identityBadgePaddingX: @smui-space-xs; // 4px
211
+ @identityBadgeGap: @smui-space-xxs; // 2px, icon to text
212
+ @identityBadgeIconSize: 12px; // @smui-space-3
213
+ @identityBadgeBorderWidth: 1px;
214
+ @identityBadgeRadius: @smui-radius-sm;
215
+ @identityBadgeFontFamily: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
216
+ @identityBadgeFontSize: 11px; // off-grid
217
+ @identityBadgeFontWeight: 500;
218
+ @identityBadgeColor: ~"var(--smui-onSurfaceVariant)"; // neutral, follows the dark theme; never a status token
219
+ @identityBadgeGroupGap: @smui-space-xs; // 4px between badges
220
+
207
221
  // A QR code is always dark modules on a white square — never theme tokens, so no
208
222
  // theme (or forced-colours mode, see the component's print/forced-color-adjust) can
209
223
  // invert it.
@@ -215,6 +229,35 @@
215
229
  @kbdKeyMinSize: 1.5em; // a key cap is square at one character
216
230
  @kbdKeyPaddingX: 0.375em;
217
231
  @kbdKeyRadius: @smui-radius-sm;
232
+
233
+ // ---- Markdown ----
234
+ // Prose of Markdown descriptions and comments. The colours are runtime tokens, so the
235
+ // dark theme follows without a Dark set here.
236
+ @markdownFontSize: @smui-font-body2-size; // 14px
237
+ @markdownLineHeight: @smui-font-body2-lh; // 1.5
238
+ @markdownBlockGap: @smui-space-md; // 12px between blocks
239
+ @markdownHeadingWeight: 600;
240
+ @markdownHeading1Size: 1.5em;
241
+ @markdownHeading2Size: 1.3em;
242
+ @markdownHeading3Size: 1.15em;
243
+ @markdownHeading4Size: 1em;
244
+ @markdownHeading5Size: 0.925em;
245
+ @markdownHeading6Size: 0.85em;
246
+ @markdownListIndent: 1.5em;
247
+ @markdownLinkColor: ~"var(--smui-primaryColor)";
248
+ @markdownCodeFontFamily: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
249
+ @markdownCodeFontSize: 0.9em;
250
+ @markdownCodeBackground: ~"var(--smui-surfaceVariant)";
251
+ @markdownCodeRadius: @smui-radius-sm;
252
+ @markdownCodeBlockPadding: @smui-space-sm @smui-space-md;
253
+ @markdownInlineCodePadding: 0.1em 0.35em;
254
+ @markdownQuoteBorderWidth: 3px;
255
+ @markdownQuoteBorderColor: ~"var(--smui-outlineColor)";
256
+ @markdownQuoteColor: ~"var(--smui-onSurfaceVariant)";
257
+ @markdownTableBorderColor: ~"var(--smui-tableBorderColor)";
258
+ @markdownTableCellPadding: @smui-space-xs @smui-space-sm;
259
+ @markdownTableHeadBackground: ~"var(--smui-surfaceVariant)";
260
+ @markdownRuleColor: ~"var(--smui-dividerColor)";
218
261
  // ---- DiffStat ----
219
262
  @diffStatFontSize: 0.875rem;
220
263
  @diffStatCompactFontSize: 0.75rem; // a tab label
@@ -35,6 +35,8 @@
35
35
  // - ProgressIndicator: indicator diameter (28px), not a control box
36
36
  // - StatusDot: decorative dot (@statusDotSizeSm/Md); also uses the
37
37
  // _size-sm suffix, a different class convention
38
+ // - IdentityBadge: compact identity marker (@identityBadgeHeight 18px),
39
+ // not a control — it must fit a dense TreeView row and a DagView node
38
40
  // - Slider: size scales track thickness and thumb diameter, not a
39
41
  // control height
40
42
  // - Modal: size selects dialog width, not control height
@@ -53,7 +55,8 @@
53
55
  // Menu dense items, List dense rows, and the targets the controls above do not
54
56
  // cover: Composer icon buttons, Breadcrumbs "..." button, DagView zoom buttons,
55
57
  // Slider rail and thumb zones, SelectField clear button and chip delete zones, Sheet
56
- // header buttons, Table sort control, DatePicker adornment button). A mouse keeps the sizes above.
58
+ // header buttons, Table sort control, DatePicker adornment button, IdentityBadgeGroup's
59
+ // clickable "+N"). A mouse keeps the sizes above.
57
60
  // Still exempt on touch: the --filled and --inline fields, the compact Toggle
58
61
  // (capped at @toggleCompactMaxHeight) and a small Chip that is neither a button
59
62
  // nor a link.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smwb/ui-styles",
3
- "version": "2.6.0",
3
+ "version": "2.8.0",
4
4
  "description": "Framework-agnostic LESS design tokens and component styles (smwb-*) shared by the @smwb UI libraries. Prebuilt aggregate CSS lives in @smwb/ui-css.",
5
5
  "license": "MIT",
6
6
  "sideEffects": [