@charmland/gem 0.1.1 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charmland/gem",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Gem's Elm sources, default application, browser runtime, UI kit, stylesheet and fonts.",
5
5
  "keywords": ["gem", "elm", "documentation", "theme", "ui"],
6
6
  "homepage": "https://github.com/charmbracelet/gem/tree/main/packages/gem",
@@ -52,7 +52,6 @@
52
52
  "./source/ui/*": "./src/ui/*",
53
53
  "./source/styles/*": "./src/styles/*",
54
54
  "./source/elm.json": "./elm.json",
55
- "./fonts/*": "./assets/fonts/*",
56
55
  "./package.json": "./package.json"
57
56
  },
58
57
  "files": [
@@ -63,7 +62,6 @@
63
62
  "src/app",
64
63
  "src/ui",
65
64
  "src/styles",
66
- "assets/fonts",
67
65
  "elm.json",
68
66
  "LICENSE",
69
67
  "NOTICE"
@@ -77,7 +75,7 @@
77
75
  "prepack": "bun run build"
78
76
  },
79
77
  "dependencies": {
80
- "@charmland/gem-compiler": "0.1.1"
78
+ "@charmland/gem-compiler": "0.2.0"
81
79
  },
82
80
  "devDependencies": {
83
81
  "@types/node": "^26.6.5",
@@ -85,7 +85,6 @@ type Msg
85
85
  | TocToggled
86
86
  | AnchorsMeasured Measurements
87
87
  | SearchShortcut
88
- | ScrolledTo (Result Dom.Error ())
89
88
  | Noop
90
89
 
91
90
 
@@ -148,8 +147,7 @@ init slots flags url key =
148
147
  in
149
148
  ( model
150
149
  , Cmd.batch
151
- [ scrollTo url
152
- , measureAnchors (pageAnchors page)
150
+ [ measureAnchors (pageAnchors page)
153
151
  , setMeta model
154
152
  ]
155
153
  )
@@ -242,8 +240,7 @@ update msg model =
242
240
  in
243
241
  ( next
244
242
  , Cmd.batch
245
- [ scrollTo url
246
- , measureAnchors (pageAnchors page)
243
+ [ measureAnchors (pageAnchors page)
247
244
  , setMeta next
248
245
  ]
249
246
  )
@@ -504,22 +501,29 @@ update msg model =
504
501
  else
505
502
  ( model, Cmd.none )
506
503
 
507
- ScrolledTo _ ->
508
- ( model, Cmd.none )
509
-
510
504
  Noop ->
511
505
  ( model, Cmd.none )
512
506
 
513
507
 
514
508
  subscriptions : Model -> Sub Msg
515
509
  subscriptions model =
510
+ let
511
+ header =
512
+ model.site.chrome.header
513
+
514
+ shell =
515
+ model.error == Nothing
516
+
517
+ docsSwitcher =
518
+ shell && header.docs && List.length model.site.docs > 1
519
+ in
516
520
  Sub.batch
517
521
  [ Sub.map SearchMsg (Ui.Search.subscriptions model.search)
518
522
  , Sub.map BurgerMsg (Ui.Burger.subscriptions model.burger)
519
- , Sub.map DocsTabsMsg (Ui.Tabs.subscriptions True model.docsTabs)
520
- , Sub.map MenuDocsTabsMsg (Ui.Tabs.subscriptions model.burger.open model.menuDocsTabs)
521
- , Sub.map ThemeTabsMsg (Ui.Tabs.subscriptions True model.themeTabs)
522
- , Sub.map MenuTabsMsg (Ui.Tabs.subscriptions model.burger.open model.menuTabs)
523
+ , Sub.map DocsTabsMsg (Ui.Tabs.subscriptions docsSwitcher model.docsTabs)
524
+ , Sub.map MenuDocsTabsMsg (Ui.Tabs.subscriptions (model.burger.open && docsSwitcher) model.menuDocsTabs)
525
+ , Sub.map ThemeTabsMsg (Ui.Tabs.subscriptions (shell && header.theme) model.themeTabs)
526
+ , Sub.map MenuTabsMsg (Ui.Tabs.subscriptions (model.burger.open && shell && header.theme) model.menuTabs)
523
527
  , Ui.Dropdown.subscriptions "ai-dropdown" model.aiOpen AiToggled
524
528
  , Ports.onScroll Scrolled
525
529
  , Browser.Events.onKeyDown searchShortcutKey
@@ -1222,18 +1226,6 @@ closeBurger burger =
1222
1226
  burger
1223
1227
 
1224
1228
 
1225
- scrollTo : Url -> Cmd Msg
1226
- scrollTo url =
1227
- case url.fragment of
1228
- Just id ->
1229
- Dom.getElement id
1230
- |> Task.andThen (\element -> Dom.setViewport 0 element.element.y)
1231
- |> Task.attempt ScrolledTo
1232
-
1233
- Nothing ->
1234
- Dom.setViewport 0 0 |> Task.attempt ScrolledTo
1235
-
1236
-
1237
1229
  emptySite : Site
1238
1230
  emptySite =
1239
1231
  { meta =
@@ -192,7 +192,7 @@ header config =
192
192
  ]
193
193
  ([ if chrome.logo then
194
194
  Html.a [ A.class "docs-header-title", A.href (Page.href config.site config.doc.root) ]
195
- [ logoView config.site.meta.logo config ]
195
+ [ logoView config ]
196
196
 
197
197
  else
198
198
  Html.text ""
@@ -256,15 +256,34 @@ headerAction config action =
256
256
  (Page.href config.site action.href)
257
257
 
258
258
 
259
- {-| A site brand: its configured logo image when it has one, otherwise the
260
- text label. The image is the same node in the bar, the drawer and the
261
- footer; each context sizes it.
259
+ {-| A site brand: its configured logo image, its configured logo text, or
260
+ both. The image and the wordmark are the same nodes in the bar and the
261
+ drawer; each context sizes them.
262
262
  -}
263
- logoView : String -> Config msg -> Html msg
264
- logoView label config =
263
+ logoView : Config msg -> Html msg
264
+ logoView config =
265
+ let
266
+ logo =
267
+ config.site.meta.logo
268
+
269
+ label =
270
+ if String.isEmpty logo then
271
+ config.site.meta.title
272
+
273
+ else
274
+ logo
275
+
276
+ wordmark =
277
+ if String.isEmpty logo then
278
+ []
279
+
280
+ else
281
+ [ Html.span [ A.class "site-brand-text" ] [ Html.text logo ] ]
282
+ in
265
283
  case config.site.meta.logoImage of
266
284
  Just src ->
267
- Html.node "img" [ A.class "site-logo", A.src (Page.href config.site src), A.alt label ] []
285
+ Html.span [ A.class "site-brand" ]
286
+ (Html.node "img" [ A.class "site-logo", A.src (Page.href config.site src), A.alt label ] [] :: wordmark)
268
287
 
269
288
  Nothing ->
270
289
  Html.text label
@@ -903,7 +922,7 @@ drawer config =
903
922
  Ui.Burger.view
904
923
  { label = "Menu"
905
924
  , logo =
906
- Just (Html.span [ A.class "burger-wordmark" ] [ logoView config.site.meta.logo config ])
925
+ Just (Html.span [ A.class "burger-wordmark" ] [ logoView config ])
907
926
  , header =
908
927
  Just
909
928
  (Html.div [ A.class "burger-panel" ]
@@ -28,6 +28,10 @@
28
28
  // One value, used by the bar, the rail and the layout's min-height.
29
29
  $header-height: 3.8125rem;
30
30
 
31
+ // The sticky ToC band on the narrow layout: it and the headings' scroll
32
+ // margin share the value, so a fragment jump clears both.
33
+ $toc-band-height: 2.3125rem;
34
+
31
35
  .docs {
32
36
  display: flex;
33
37
  align-items: stretch;
@@ -75,17 +79,13 @@ $header-height: 3.8125rem;
75
79
  display: inline-flex;
76
80
  align-items: center;
77
81
  gap: 0.45rem;
78
- font-family: "Hypography Web", "Charmform Web", system-ui, sans-serif;
82
+ font-family: "Charmform Web", system-ui, sans-serif;
79
83
  font-size: 1.35rem;
84
+ font-weight: 800;
80
85
  color: var(--fg);
81
86
  text-decoration: none;
82
87
  flex-shrink: 0;
83
88
 
84
- // The wordmark wears the house pink, same as the footer's.
85
- span {
86
- color: charmtone.$blush;
87
- }
88
-
89
89
  .sprout-mark {
90
90
  // Sits a touch high so the leaves read level with the x-height.
91
91
  margin-top: -0.1rem;
@@ -122,6 +122,12 @@ $header-height: 3.8125rem;
122
122
  }
123
123
  }
124
124
 
125
+ .site-brand {
126
+ display: inline-flex;
127
+ align-items: center;
128
+ gap: 0.45rem;
129
+ }
130
+
125
131
  .docs-page {
126
132
  position: relative;
127
133
  max-width: 60rem;
@@ -231,7 +237,7 @@ $header-height: 3.8125rem;
231
237
 
232
238
  .docs-eof-mark {
233
239
  display: block;
234
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
240
+ font-family: "JetBrains Mono", ui-monospace, monospace;
235
241
  font-size: 0.875rem;
236
242
  font-weight: 640;
237
243
  letter-spacing: 0.16em;
@@ -266,7 +272,7 @@ $header-height: 3.8125rem;
266
272
  border-radius: calc(0.4rem * var(--squircle-scale, 1));
267
273
  background: var(--well);
268
274
  color: var(--fg);
269
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
275
+ font-family: "JetBrains Mono", ui-monospace, monospace;
270
276
  font-size: 0.8125rem;
271
277
  overflow-wrap: anywhere;
272
278
  }
@@ -385,13 +391,13 @@ $header-height: 3.8125rem;
385
391
  }
386
392
 
387
393
  .swatch-name {
388
- font-family: "JetBrains Mono Variable", ui-monospace, monospace;
394
+ font-family: "JetBrains Mono", ui-monospace, monospace;
389
395
  font-size: 0.75rem;
390
396
  font-weight: 620;
391
397
  }
392
398
 
393
399
  .swatch-hex {
394
- font-family: "JetBrains Mono Variable", ui-monospace, monospace;
400
+ font-family: "JetBrains Mono", ui-monospace, monospace;
395
401
  font-size: 0.6875rem;
396
402
  color: var(--muted);
397
403
  }
@@ -536,6 +542,7 @@ ul.rows {
536
542
  .docs-toc-sticky {
537
543
  display: flex;
538
544
  align-items: center;
545
+ min-height: $toc-band-height;
539
546
  padding: 0.55rem 0.9rem;
540
547
 
541
548
  // The nav is a flex item and would shrink to its content;
@@ -627,6 +634,11 @@ ul.rows {
627
634
  font-weight: 800;
628
635
  font-variation-settings: "OPTK" -10;
629
636
  outline: none;
637
+ scroll-margin-top: calc(#{$header-height} + 0.5rem);
638
+
639
+ @media (max-width: 1024px) {
640
+ scroll-margin-top: calc(#{$header-height} + #{$toc-band-height} + 0.5rem);
641
+ }
630
642
  }
631
643
 
632
644
  .md-h1 {
@@ -737,7 +749,7 @@ ul.rows {
737
749
  }
738
750
 
739
751
  .site-footer-wordmark {
740
- font-family: "Hypography Web", "Charmform Web", system-ui, sans-serif;
752
+ font-family: "Charmform Web", system-ui, sans-serif;
741
753
  font-size: 2.25rem;
742
754
  letter-spacing: -0.03em;
743
755
  color: charmtone.$blush;
@@ -1031,7 +1043,7 @@ ul.rows {
1031
1043
 
1032
1044
  .detail {
1033
1045
  color: var(--tertiary);
1034
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
1046
+ font-family: "JetBrains Mono", ui-monospace, monospace;
1035
1047
  font-size: 0.65rem;
1036
1048
  letter-spacing: 0.06em;
1037
1049
  text-transform: uppercase;
@@ -1,51 +1,53 @@
1
- @import url("https://stuff.charm.land/fonts/charmform/charmform.css");
2
-
3
1
  @font-face {
4
- font-family: "Fraktion Mono Web";
5
- src: url("../../assets/fonts/PPFraktionMono-Variable.ttf") format("truetype-variations");
6
- font-weight: 200 800;
2
+ font-family: "JetBrains Mono";
3
+ src: url("https://stuff.charm.land/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2")
4
+ format("woff2");
5
+ font-weight: 400;
7
6
  font-style: normal;
8
7
  font-display: swap;
9
8
  }
10
9
 
11
10
  @font-face {
12
- font-family: "Fraktion Mono Web";
13
- src: url("../../assets/fonts/PPFraktionMonoItalic-Variable.ttf")
14
- format("truetype-variations");
15
- font-weight: 200 800;
11
+ font-family: "JetBrains Mono";
12
+ src: url("https://stuff.charm.land/fonts/jetbrains-mono/JetBrainsMono-Italic.woff2")
13
+ format("woff2");
14
+ font-weight: 400;
16
15
  font-style: italic;
17
16
  font-display: swap;
18
17
  }
19
18
 
20
19
  @font-face {
21
- font-family: "Fraktion Sans Web";
22
- src: url("../../assets/fonts/PPFraktionSans-Variable.ttf") format("truetype-variations");
23
- font-weight: 200 800;
20
+ font-family: "JetBrains Mono";
21
+ src: url("https://stuff.charm.land/fonts/jetbrains-mono/JetBrainsMono-Medium.woff2")
22
+ format("woff2");
23
+ font-weight: 500;
24
24
  font-style: normal;
25
25
  font-display: swap;
26
26
  }
27
27
 
28
28
  @font-face {
29
- font-family: "Fraktion Sans Web";
30
- src: url("../../assets/fonts/PPFraktionSansItalic-Variable.ttf")
31
- format("truetype-variations");
32
- font-weight: 200 800;
29
+ font-family: "JetBrains Mono";
30
+ src: url("https://stuff.charm.land/fonts/jetbrains-mono/JetBrainsMono-Medium-Italic.woff2")
31
+ format("woff2");
32
+ font-weight: 500;
33
33
  font-style: italic;
34
34
  font-display: swap;
35
35
  }
36
36
 
37
37
  @font-face {
38
- font-family: "Hypography Web";
39
- src: url("../../assets/fonts/Hypography-Regular.woff2") format("woff2");
40
- font-weight: 400;
38
+ font-family: "JetBrains Mono";
39
+ src: url("https://stuff.charm.land/fonts/jetbrains-mono/JetBrainsMono-Bold.woff2")
40
+ format("woff2");
41
+ font-weight: 700;
41
42
  font-style: normal;
42
43
  font-display: swap;
43
44
  }
44
45
 
45
46
  @font-face {
46
- font-family: "Hypography Web";
47
- src: url("../../assets/fonts/Hypography-Italic.woff2") format("woff2");
48
- font-weight: 400;
47
+ font-family: "JetBrains Mono";
48
+ src: url("https://stuff.charm.land/fonts/jetbrains-mono/JetBrainsMono-Bold-Italic.woff2")
49
+ format("woff2");
50
+ font-weight: 700;
49
51
  font-style: italic;
50
52
  font-display: swap;
51
53
  }
@@ -34,6 +34,73 @@
34
34
  border-radius: 0.5rem;
35
35
  }
36
36
 
37
+ .md-image[role="button"] {
38
+ cursor: zoom-in;
39
+ }
40
+
41
+ // The module measures the scrollbar into --gem-lightbox-gap.
42
+ :root.gem-lightbox-open {
43
+ overflow: hidden;
44
+ padding-right: var(--gem-lightbox-gap, 0px);
45
+ }
46
+
47
+ // The image is a child, so the backdrop fades on a pseudo element.
48
+ .gem-lightbox {
49
+ position: fixed;
50
+ inset: 0;
51
+ z-index: 240;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: center;
55
+ padding: clamp(0.5rem, 2vw, 1.5rem);
56
+
57
+ &[hidden] {
58
+ display: none;
59
+ }
60
+
61
+ &:focus {
62
+ outline: none;
63
+ }
64
+
65
+ &::before {
66
+ content: "";
67
+ position: absolute;
68
+ inset: 0;
69
+ background: color-mix(in srgb, var(--bg) 55%, transparent);
70
+ backdrop-filter: blur(0.75rem);
71
+ -webkit-backdrop-filter: blur(0.75rem);
72
+ opacity: 0;
73
+ // Matches DURATION in lightbox.ts.
74
+ transition: opacity 300ms ease;
75
+ }
76
+
77
+ &.open::before {
78
+ opacity: 1;
79
+ }
80
+ }
81
+
82
+ .gem-lightbox-image {
83
+ position: relative;
84
+ max-width: min(94vw, 1600px);
85
+ max-height: 90vh;
86
+ border-radius: calc(0.75rem * var(--squircle-scale, 1));
87
+ box-shadow: 0 1.5rem 4rem rgba(charmtone.$char, 0.45);
88
+ cursor: zoom-out;
89
+ }
90
+
91
+ // Matches NARROW in lightbox.ts.
92
+ @media (max-width: 768px) {
93
+ .gem-lightbox {
94
+ padding: 0;
95
+ }
96
+
97
+ .gem-lightbox-image {
98
+ max-width: 100vw;
99
+ max-height: 100vh;
100
+ border-radius: 0;
101
+ }
102
+ }
103
+
37
104
  .md-quote {
38
105
  margin: 1rem 0;
39
106
  padding-left: 1rem;
@@ -152,7 +219,7 @@
152
219
 
153
220
  .code-title {
154
221
  overflow: hidden;
155
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
222
+ font-family: "JetBrains Mono", ui-monospace, monospace;
156
223
  font-size: 0.72rem;
157
224
  font-weight: 600;
158
225
  color: var(--fg);
@@ -171,7 +238,7 @@
171
238
  border-color: transparent;
172
239
  background: transparent;
173
240
  color: var(--tertiary);
174
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
241
+ font-family: "JetBrains Mono", ui-monospace, monospace;
175
242
  font-size: 0.6875rem;
176
243
  font-weight: 520;
177
244
  letter-spacing: 0.06em;
@@ -208,7 +275,7 @@
208
275
  .code-block pre {
209
276
  margin: 0;
210
277
  padding: 0.9rem 1.15rem 1rem 0.5rem;
211
- font-family: "JetBrains Mono Variable", ui-monospace, monospace;
278
+ font-family: "JetBrains Mono", ui-monospace, monospace;
212
279
  font-size: 0.8125rem;
213
280
  line-height: 1.7;
214
281
  color: var(--fg);
@@ -294,14 +361,14 @@
294
361
  background: color-mix(in srgb, var(--fg) 6%, transparent);
295
362
  border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
296
363
  border-radius: calc(0.3rem * var(--squircle-scale, 1));
297
- font-family: "JetBrains Mono Variable", ui-monospace, monospace;
364
+ font-family: "JetBrains Mono", ui-monospace, monospace;
298
365
  font-size: 0.82em;
299
366
  color: var(--fg);
300
367
  white-space: nowrap;
301
368
  }
302
369
 
303
370
  .gem-raw {
304
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
371
+ font-family: "JetBrains Mono", ui-monospace, monospace;
305
372
  font-size: 0.8125rem;
306
373
  color: var(--tertiary);
307
374
  }
@@ -318,7 +385,7 @@
318
385
  content: "unregistered component: " attr(data-component);
319
386
  display: block;
320
387
  margin-bottom: 0.35rem;
321
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
388
+ font-family: "JetBrains Mono", ui-monospace, monospace;
322
389
  font-size: 0.7rem;
323
390
  color: var(--tertiary);
324
391
  }
@@ -327,7 +394,7 @@
327
394
  .gem-error {
328
395
  margin: 2rem;
329
396
  padding: 1rem;
330
- font-family: "Fraktion Mono Web", ui-monospace, monospace;
397
+ font-family: "JetBrains Mono", ui-monospace, monospace;
331
398
  font-size: 0.8125rem;
332
399
  white-space: pre-wrap;
333
400
  color: var(--fg);
@@ -146,7 +146,7 @@ $row-inset: 1.5rem;
146
146
  gap: 0.5rem;
147
147
  text-decoration: none;
148
148
  color: var(--fg);
149
- font-family: "Hypography Web", "Charmform Web", system-ui, sans-serif;
149
+ font-family: "Charmform Web", system-ui, sans-serif;
150
150
  font-size: 1.5rem;
151
151
  letter-spacing: -0.02em;
152
152
 
@@ -156,6 +156,11 @@ $row-inset: 1.5rem;
156
156
  max-width: 60vw;
157
157
  height: auto;
158
158
  }
159
+
160
+ .site-brand:has(.site-brand-text) .site-logo {
161
+ width: auto;
162
+ height: 2.5rem;
163
+ }
159
164
  }
160
165
 
161
166
  svg.logo {
@@ -105,6 +105,7 @@
105
105
  // button paints its own background instead.
106
106
  .tabs {
107
107
  --tabs-pad: 0.25rem;
108
+ --tabs-radius: calc(0.5rem * var(--squircle-scale, 1));
108
109
  position: relative;
109
110
  display: inline-flex;
110
111
  align-self: flex-start;
@@ -120,7 +121,7 @@
120
121
  bottom: var(--tabs-pad);
121
122
  left: 0;
122
123
  z-index: 0;
123
- border-radius: calc(0.5rem * var(--squircle-scale, 1));
124
+ border-radius: var(--tabs-radius);
124
125
  background: charmtone.$charple;
125
126
  transition:
126
127
  transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1),
@@ -140,10 +141,7 @@
140
141
  background: transparent;
141
142
  color: var(--muted);
142
143
  font-size: 0.875rem;
143
- transition:
144
- background 125ms ease,
145
- border-color 125ms ease,
146
- color 125ms ease;
144
+ transition: border-color 125ms ease;
147
145
 
148
146
  // Icon tabs (the models layout switcher): the glyph follows the
149
147
  // button's color states via currentColor.
@@ -170,14 +168,6 @@
170
168
  }
171
169
  }
172
170
 
173
- // Before the first measurement lands there is no thumb; the active
174
- // button paints its own fill so the selection is visible
175
- // immediately. Once the thumb exists it takes over. The underline
176
- // variant never paints a pill — its selection is the slide alone.
177
- &:not(.measured):not(.underline) button.active {
178
- background: charmtone.$charple;
179
- }
180
-
181
171
  // The dense switcher used next to compact controls and tables.
182
172
  &.compact {
183
173
  height: $control-height-sm;
@@ -189,6 +179,11 @@
189
179
  }
190
180
  }
191
181
 
182
+ &:not(.measured):not(.underline) button.active {
183
+ background: charmtone.$charple;
184
+ border-radius: var(--tabs-radius);
185
+ }
186
+
192
187
  // The underline variant: bare text tabs sitting on a hairline, the
193
188
  // selection a sliding two-pixel charple bar. Same geometry as the
194
189
  // reference site's section navs: the buttons hang 1px past the row so
@@ -15,7 +15,7 @@ $control-radius: 0.75rem;
15
15
  $control-fill: var(--well);
16
16
  // JetBrains Mono is the house mono; hosts that don't load it fall
17
17
  // back to the system mono.
18
- $mono: "JetBrains Mono Variable", ui-monospace, monospace;
18
+ $mono: "JetBrains Mono", ui-monospace, monospace;
19
19
 
20
20
  // The app face: Charmform, the Charm house typeface. Hosts that don't
21
21
  // load it fall back to the system sans.