@charmland/gem 0.2.0 → 0.2.2

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,8 +1,14 @@
1
1
  {
2
2
  "name": "@charmland/gem",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Gem's Elm sources, default application, browser runtime, UI kit, stylesheet and fonts.",
5
- "keywords": ["gem", "elm", "documentation", "theme", "ui"],
5
+ "keywords": [
6
+ "gem",
7
+ "elm",
8
+ "documentation",
9
+ "theme",
10
+ "ui"
11
+ ],
6
12
  "homepage": "https://github.com/charmbracelet/gem/tree/main/packages/gem",
7
13
  "bugs": {
8
14
  "url": "https://github.com/charmbracelet/gem/issues"
@@ -75,7 +81,7 @@
75
81
  "prepack": "bun run build"
76
82
  },
77
83
  "dependencies": {
78
- "@charmland/gem-compiler": "0.2.0"
84
+ "@charmland/gem-compiler": "0.2.2"
79
85
  },
80
86
  "devDependencies": {
81
87
  "@types/node": "^26.6.5",
@@ -100,6 +100,29 @@ app slots =
100
100
  }
101
101
 
102
102
 
103
+ {-| The groups a collection asks to start closed. The reader's own toggles
104
+ take over from here, so this is only read at init and never on navigation.
105
+ -}
106
+ initiallyCollapsed : List Page.NavItem -> List String
107
+ initiallyCollapsed items =
108
+ List.concatMap
109
+ (\item ->
110
+ case item of
111
+ Page.PageItem _ ->
112
+ []
113
+
114
+ Page.Category category ->
115
+ (if category.collapsed then
116
+ [ category.id ]
117
+
118
+ else
119
+ []
120
+ )
121
+ ++ initiallyCollapsed category.items
122
+ )
123
+ items
124
+
125
+
103
126
  init : Slots Msg -> D.Value -> Url -> Nav.Key -> ( Model, Cmd Msg )
104
127
  init slots flags url key =
105
128
  case D.decodeValue Page.site flags of
@@ -121,7 +144,7 @@ init slots flags url key =
121
144
  , burger = Ui.Burger.init
122
145
  , copy = Ui.CopyButton.init
123
146
  , pageCopied = False
124
- , collapsed = []
147
+ , collapsed = initiallyCollapsed doc.nav
125
148
  , key = key
126
149
  , error = Nothing
127
150
  , theme = site.theme
@@ -12,15 +12,12 @@
12
12
  // Gem's additions live in ./gem.scss and load after this file.
13
13
 
14
14
  // The shell: the whole docs site constrained to max-w-7xl and
15
- // centered; the navbar and the content column both span it. Its
16
- // hairlines run the full viewport height — down the left of the
17
- // sidebar and down the right of the ToC, the navbar included.
15
+ // centered; the navbar and the content column both span it. It carries
16
+ // no hairlines: the columns separate by their own padding alone.
18
17
  .shell {
19
18
  max-width: 88rem;
20
19
  min-height: 100vh;
21
20
  margin-inline: auto;
22
- border-left: 1px solid var(--frame);
23
- border-right: 1px solid var(--frame);
24
21
  }
25
22
 
26
23
  // The bar's height is the rail's sticky offset: they have to agree, or the
@@ -38,15 +35,19 @@ $toc-band-height: 2.3125rem;
38
35
  min-height: calc(100vh - #{$header-height});
39
36
  }
40
37
 
38
+ // The section starts 1.5rem below the navbar's border, not flush on it.
39
+ // The gap lives inside each column rather than on `.docs`: the rail is
40
+ // sticky at the bar's height, so a gap above it would be scrolled away
41
+ // over the first 1.5rem and the rail would creep up on its own.
42
+ $section-gap: 1.5rem;
43
+
41
44
  .docs-sidebar {
42
45
  position: sticky;
43
46
  top: $header-height;
44
47
  height: calc(100vh - #{$header-height});
45
- border-right: 1px solid var(--frame);
46
-
47
- .sidebar {
48
- height: 100%;
49
- }
48
+ // `.docs-sidebar` is the `.sidebar` itself, so its gap is its own
49
+ // padding, outside the scroller that carries the fade mask.
50
+ padding-top: $section-gap;
50
51
  }
51
52
 
52
53
  // The content column: the sidebar and the ToC rail separate it from
@@ -56,10 +57,11 @@ $toc-band-height: 2.3125rem;
56
57
  min-width: 0;
57
58
  display: flex;
58
59
  flex-direction: column;
60
+ padding-top: $section-gap;
59
61
  }
60
62
 
61
63
  .docs-content {
62
- padding: 3rem 5rem;
64
+ padding: 0.5rem 5rem 3rem;
63
65
  }
64
66
 
65
67
  .docs-header {
@@ -68,7 +70,6 @@ $toc-band-height: 2.3125rem;
68
70
  gap: 1.5rem;
69
71
  min-height: $header-height;
70
72
  padding: 0.75rem 1.5rem;
71
- border-bottom: 1px solid var(--frame);
72
73
  position: sticky;
73
74
  top: 0;
74
75
  background: var(--bg);
@@ -133,10 +134,11 @@ $toc-band-height: 2.3125rem;
133
134
  max-width: 60rem;
134
135
  }
135
136
 
136
- // The narrow layout is the one that hides the header on scroll: the ToC
137
- // band then owns the top edge, so something useful stays pinned. A wide
138
- // screen keeps its header, and its ToC rail is off to the side.
139
- @media (max-width: 1024px) {
137
+ // Only the phone layout hides the header on scroll: the ToC band then
138
+ // owns the top edge, so something useful stays pinned. Anywhere the
139
+ // desktop rail is still on screen (tablet and up) the header stays put,
140
+ // so the rail and the bar never move on their own while reading.
141
+ @media (max-width: 768px) {
140
142
  .docs-header.is-hidden {
141
143
  transform: translateY(-100%);
142
144
  }
@@ -146,21 +148,6 @@ $toc-band-height: 2.3125rem;
146
148
  .shell:has(.docs-header.is-hidden) .docs-toc {
147
149
  top: 0;
148
150
  }
149
-
150
- // Between the phone and wide layouts the rail is still on screen, so
151
- // it follows the bar up too, or it would hang a header's height below
152
- // the viewport edge with an empty strip above it. Same timing as the
153
- // bar's slide, so the two move as one.
154
- .docs-sidebar {
155
- transition:
156
- top 180ms ease,
157
- height 180ms ease;
158
- }
159
-
160
- .shell:has(.docs-header.is-hidden) .docs-sidebar {
161
- top: 0;
162
- height: 100vh;
163
- }
164
151
  }
165
152
 
166
153
  .docs-lede {
@@ -435,13 +422,6 @@ ul.rows {
435
422
  flex-direction: column;
436
423
  }
437
424
 
438
- // The frame's vertical hairlines don't read on a phone — the
439
- // viewport edges are the borders there.
440
- .shell {
441
- border-left: none;
442
- border-right: none;
443
- }
444
-
445
425
  // The desktop rail steps aside on mobile: the burger drawer carries
446
426
  // the docs nav instead.
447
427
  .docs-sidebar {
@@ -501,13 +481,9 @@ ul.rows {
501
481
  grid-row: 1;
502
482
  }
503
483
 
504
- // The ToC column stretches the full height of the content, so its
505
- // left hairline runs border to border; the sticky wrapper keeps the
506
- // nav pinned inside it. The title lines up with the item labels.
507
- .docs-toc {
508
- border-left: 1px solid var(--frame);
509
- }
510
-
484
+ // The sticky wrapper keeps the nav pinned inside the ToC column,
485
+ // which stretches the full height of the content. The title lines up
486
+ // with the item labels.
511
487
  .docs-toc-sticky {
512
488
  position: sticky;
513
489
  top: 4.75rem;
@@ -533,8 +509,6 @@ ul.rows {
533
509
  top: 3.8125rem;
534
510
  z-index: 25;
535
511
  margin: 0;
536
- border-left: none;
537
- border-bottom: 1px solid var(--frame);
538
512
  background: var(--plate);
539
513
  transition: top 180ms ease;
540
514
  }
@@ -659,7 +633,7 @@ ul.rows {
659
633
  padding-top: 1.5rem;
660
634
  font-size: 1.5rem;
661
635
  line-height: 1.3333333;
662
- font-variation-settings: "OPTK" -15;
636
+ font-variation-settings: "OPTK" -35;
663
637
  }
664
638
 
665
639
  .md-h3 {
@@ -720,10 +694,23 @@ ul.rows {
720
694
  // The app-global footer, following Hyper's footer: the brand on the page
721
695
  // surface, the configured link columns, and a quiet legal bar.
722
696
  .site-footer {
723
- border-top: 1px solid var(--frame);
697
+ position: relative;
724
698
  background: var(--bg);
725
699
  overflow: hidden;
726
700
 
701
+ // The edge above the footer is inset to its content padding rather than
702
+ // running the full width: a frame-to-frame line read as a second frame
703
+ // around the page, on desktop and on mobile alike.
704
+ &::before {
705
+ content: "";
706
+ position: absolute;
707
+ top: 0;
708
+ left: 2.5rem;
709
+ right: 2.5rem;
710
+ height: 1px;
711
+ background: var(--frame);
712
+ }
713
+
727
714
  .site-footer-inner {
728
715
  display: grid;
729
716
  grid-template-columns: 1.8fr 1fr 1fr 1fr;
@@ -825,7 +812,6 @@ ul.rows {
825
812
  justify-content: space-between;
826
813
  gap: 1rem;
827
814
  padding: 1.1rem 2.5rem;
828
- border-top: 1px solid var(--frame);
829
815
  font-size: 0.75rem;
830
816
  color: var(--tertiary);
831
817
  }
@@ -844,6 +830,10 @@ ul.rows {
844
830
  .site-footer .site-footer-inner {
845
831
  grid-template-columns: 1fr 1fr;
846
832
  }
833
+
834
+ .site-footer .site-footer-bar {
835
+ padding-right: 5.5rem;
836
+ }
847
837
  }
848
838
 
849
839
  // Icon-only theme tabs: square glyph tiles.
@@ -112,6 +112,7 @@ $row-inset: 1.5rem;
112
112
  padding: 5rem 0 0;
113
113
  transform: translateY(-100%);
114
114
  overflow-y: auto;
115
+ overscroll-behavior: contain;
115
116
  visibility: hidden;
116
117
  transition: visibility 0s 320ms;
117
118
  }
@@ -274,4 +275,3 @@ $row-inset: 1.5rem;
274
275
  display: block;
275
276
  }
276
277
  }
277
-
@@ -250,7 +250,7 @@
250
250
  h1 {
251
251
  font-size: 2.7rem;
252
252
  font-weight: 800;
253
- font-variation-settings: "OPTK" -15;
253
+ font-variation-settings: "OPTK" -45;
254
254
  margin: 0;
255
255
  }
256
256
 
@@ -153,7 +153,7 @@
153
153
  // Small screens: triggers often sit near the viewport's right edge
154
154
  // (toolbars), so the menu grows leftward — a left-anchored menu would
155
155
  // hang off-screen even while hidden and scroll the page.
156
- @media (max-width: 768px) {
156
+ @media (max-width: 1024px) {
157
157
  .dropdown .menu {
158
158
  left: auto;
159
159
  right: 0;
@@ -9,17 +9,22 @@
9
9
  .page-nav {
10
10
  display: flex;
11
11
  justify-content: space-between;
12
- gap: 1rem;
12
+ gap: 1.5rem;
13
13
  margin-top: 2.5rem;
14
14
  padding-top: 1.5rem;
15
- border-top: 1px solid var(--rule);
15
+ }
16
+
17
+ // A lone next link sits at the start with the rest of the row; two
18
+ // links split the row evenly.
19
+ .page-nav-link.next:only-child {
20
+ margin-left: auto;
16
21
  }
17
22
 
18
23
  .page-nav-link {
19
24
  display: flex;
25
+ flex: 1;
20
26
  flex-direction: column;
21
27
  gap: 0.25rem;
22
- max-width: 45%;
23
28
  min-width: 0;
24
29
  padding: 0.75rem 1rem;
25
30
  border: 1px solid var(--frame);
@@ -57,7 +62,6 @@
57
62
  }
58
63
 
59
64
  &.next {
60
- margin-left: auto;
61
65
  text-align: right;
62
66
  }
63
67
  }
@@ -30,7 +30,7 @@
30
30
  figcaption {
31
31
  margin: 0;
32
32
  padding: 0;
33
- font-weight: normal;
33
+ font-weight: inherit;
34
34
  font-style: normal;
35
35
  text-align: left;
36
36
  }
@@ -1,39 +1,46 @@
1
- @use "charmtone";
1
+ // One scrollbar recipe for every engine: a thin, flat thumb on an invisible
2
+ // track, the shape Firefox draws, mirrored into Chromium and Safari through
3
+ // the WebKit pseudo-elements. The thumb stays invisible until the pointer is
4
+ // over the scrolling element, so a page or a rail never wears a permanent bar.
2
5
 
3
- // Scrollbars drawn by the Meter's recipe: a rounded thumb carrying
4
- // the Meter's charple-to-dolly gradient over a recessed track, in both
5
- // themes. The light theme used to take the Meter's light stops
6
- // (zest-to-bok), but a yellow thumb reads as a stray highlight on salt;
7
- // the purple stays the brand mark either way. Two specs, both declared
8
- // — engines that don't know a property ignore it. Chromium/WebKit render
9
- // the gradient on the thumb directly; Firefox's scrollbar-color takes
10
- // flat colors only, so there the thumb is the gradient's charple start.
6
+ $thumb: color-mix(in srgb, var(--fg) 28%, transparent);
7
+ $thumb-hover: color-mix(in srgb, var(--fg) 45%, transparent);
11
8
 
12
9
  * {
13
10
  scrollbar-width: thin;
14
- scrollbar-color: charmtone.$charple var(--well);
11
+ scrollbar-color: transparent transparent;
12
+ }
13
+
14
+ *:hover {
15
+ scrollbar-color: $thumb transparent;
15
16
  }
16
17
 
17
18
  *::-webkit-scrollbar {
18
- width: 0.625rem;
19
- height: 0.625rem;
19
+ width: 0.5rem;
20
+ height: 0.5rem;
20
21
  }
21
22
 
22
23
  *::-webkit-scrollbar-track {
23
- border-radius: 9999px;
24
- background: var(--well);
24
+ background: transparent;
25
25
  }
26
26
 
27
27
  *::-webkit-scrollbar-thumb {
28
+ border: 1px solid transparent;
28
29
  border-radius: 9999px;
29
- background: linear-gradient(90deg, charmtone.$charple, charmtone.$dolly);
30
- border: 1px solid var(--bg);
30
+ background: transparent;
31
+ background-clip: content-box;
32
+ }
33
+
34
+ *:hover::-webkit-scrollbar-thumb {
35
+ background: $thumb;
36
+ background-clip: content-box;
37
+ }
31
38
 
32
- &:hover {
33
- background: linear-gradient(90deg, charmtone.$hazy, charmtone.$mauve);
34
- }
39
+ *::-webkit-scrollbar-thumb:hover {
40
+ background: $thumb-hover;
41
+ background-clip: content-box;
35
42
  }
36
43
 
37
44
  *::-webkit-scrollbar-corner {
38
- background: var(--well);
45
+ background: transparent;
39
46
  }
@@ -1,6 +1,22 @@
1
1
  @use "charmtone";
2
2
  @use "controls" as *;
3
3
 
4
+ // Height of the dissolve at each end of the scrolling list.
5
+ $sidebar-fade: 2.5rem;
6
+
7
+ // Registered so the scroll timelines can interpolate them as lengths.
8
+ @property --sidebar-fade-top {
9
+ syntax: "<length>";
10
+ inherits: false;
11
+ initial-value: 0px;
12
+ }
13
+
14
+ @property --sidebar-fade-bottom {
15
+ syntax: "<length>";
16
+ inherits: false;
17
+ initial-value: 0px;
18
+ }
19
+
4
20
  // The navigation rail, carried over from the Hyper dashboard: fixed
5
21
  // items with the house hover sweep — a charple fill with salt ink,
6
22
  // wiped in from the left via a two-cell mask position animation — and
@@ -16,35 +32,42 @@
16
32
  flex: 1;
17
33
  min-height: 0;
18
34
  overflow-y: auto;
35
+ scrollbar-gutter: stable;
36
+
37
+ // Scroll fades: rows that hide above or below the scrollport
38
+ // dissolve via a mask, which also fades the ink — background
39
+ // gradients paint behind the text, so they cannot do this. One
40
+ // gradient reads two registered lengths, and scroll timelines
41
+ // animate them: the top fade grows over the first stretch of
42
+ // scrolling, the bottom one shrinks over the last. Both ramp by
43
+ // distance, never by percentage, so the fades stay 2.5rem tall
44
+ // however long the list is. With no overflow the timeline is
45
+ // inactive and the lengths keep their initial 0, so no mask shows.
46
+ // Browsers without scroll timelines keep a plain list.
47
+ -webkit-mask-image: linear-gradient(
48
+ to bottom,
49
+ transparent 0,
50
+ #000 var(--sidebar-fade-top),
51
+ #000 calc(100% - var(--sidebar-fade-bottom)),
52
+ transparent 100%
53
+ );
54
+ mask-image: linear-gradient(
55
+ to bottom,
56
+ transparent 0,
57
+ #000 var(--sidebar-fade-top),
58
+ #000 calc(100% - var(--sidebar-fade-bottom)),
59
+ transparent 100%
60
+ );
19
61
 
20
- // Scroll shadows: a soft dark fade shows at the inner top edge
21
- // while content hides above, and at the inner bottom edge while
22
- // content hides below. Pure CSS (Lea Verou's scrolling shadows):
23
- // the two cover gradients ride the content (background-attachment:
24
- // local) and hide their shadow when scrolled to that edge, so a
25
- // short, unscrolled list shows neither.
26
- background:
27
- linear-gradient(var(--bg) 33%, rgb(255 255 255 / 0%)) local center top,
28
- linear-gradient(rgb(255 255 255 / 0%), var(--bg) 67%) local center bottom,
29
- radial-gradient(
30
- farthest-side at 50% 0%,
31
- rgb(0 0 0 / 30%),
32
- rgb(0 0 0 / 0%)
33
- )
34
- scroll center top,
35
- radial-gradient(
36
- farthest-side at 50% 100%,
37
- rgb(0 0 0 / 30%),
38
- rgb(0 0 0 / 0%)
39
- )
40
- scroll center bottom;
41
- background-repeat: no-repeat;
42
- background-size:
43
- 100% 4rem,
44
- 100% 4rem,
45
- 100% 1rem,
46
- 100% 1rem;
47
- background-attachment: local, local, scroll, scroll;
62
+ @supports (animation-timeline: scroll()) {
63
+ animation:
64
+ sidebar-fade-top linear both,
65
+ sidebar-fade-bottom linear both;
66
+ animation-timeline: scroll(self block), scroll(self block);
67
+ animation-range:
68
+ 0 $sidebar-fade,
69
+ calc(100% - #{$sidebar-fade}) 100%;
70
+ }
48
71
  }
49
72
 
50
73
  ul {
@@ -72,8 +95,8 @@
72
95
  // size and in full-strength ink, so the sections read as the structure
73
96
  // and the pages as their contents.
74
97
  .section-label {
75
- padding: 0.35rem 1.5rem;
76
- font-weight: 620;
98
+ padding: 0.35rem 1rem 0.35rem 1.5rem;
99
+ font-weight: 735;
77
100
  letter-spacing: -0.01em;
78
101
  color: var(--fg);
79
102
  }
@@ -87,7 +110,7 @@
87
110
  align-items: center;
88
111
  justify-content: space-between;
89
112
  width: 100%;
90
- padding: 0.35rem 1.5rem;
113
+ padding: 0.35rem 1rem 0.35rem 1.5rem;
91
114
  border: none;
92
115
  background: none;
93
116
  cursor: pointer;
@@ -123,11 +146,11 @@
123
146
  display: flex;
124
147
  align-items: center;
125
148
  gap: 0.5rem;
126
- padding: 0.5rem 1.5rem;
149
+ padding: 0.5rem 1rem 0.5rem 1.5rem;
127
150
  text-decoration: none;
128
151
  color: var(--muted);
129
152
  font-size: 0.9375rem;
130
- font-weight: 520;
153
+ font-weight: 560;
131
154
  cursor: pointer;
132
155
  --active-border: 0.375rem;
133
156
 
@@ -187,7 +210,7 @@
187
210
  border-left: var(--active-border) solid charmtone.$blush;
188
211
  padding-left: calc(1.5rem - var(--active-border));
189
212
  color: var(--fg);
190
- font-weight: 620;
213
+ font-weight: 660;
191
214
  }
192
215
 
193
216
  ul > li.section ~ li.active > a {
@@ -227,3 +250,21 @@
227
250
  }
228
251
  }
229
252
  }
253
+
254
+ @keyframes sidebar-fade-top {
255
+ from {
256
+ --sidebar-fade-top: 0rem;
257
+ }
258
+ to {
259
+ --sidebar-fade-top: #{$sidebar-fade};
260
+ }
261
+ }
262
+
263
+ @keyframes sidebar-fade-bottom {
264
+ from {
265
+ --sidebar-fade-bottom: #{$sidebar-fade};
266
+ }
267
+ to {
268
+ --sidebar-fade-bottom: 0rem;
269
+ }
270
+ }
@@ -113,7 +113,7 @@ body {
113
113
  // rendered outside the page (the mobile drawer, toasts, dialogs)
114
114
  // inherit it too.
115
115
  font-family: $sans;
116
- font-weight: 500;
116
+ font-weight: 460;
117
117
  color: var(--fg);
118
118
  background: var(--bg);
119
119
  -webkit-font-smoothing: antialiased;
@@ -2,7 +2,8 @@
2
2
  @use "controls" as *;
3
3
 
4
4
  // The table of contents: a centered header, items on a flat list.
5
- // No rail — the blush edge on the active item is the only marker.
5
+ // No rail — the active section reads as accent-colored, bolder text,
6
+ // not the sidebar's blush edge.
6
7
 
7
8
  .toc {
8
9
  font-size: 0.8125rem;
@@ -25,21 +26,16 @@
25
26
  }
26
27
 
27
28
  ul ul {
28
- // Children keep the highlight rail in the same column as the
29
- // parent; only the label indents, never the border.
30
29
  margin-left: 0;
31
30
  }
32
31
 
33
32
  li a {
34
33
  display: block;
35
34
  padding: 0.3rem 0.9rem;
36
- border-left: 2px solid transparent;
37
35
  color: var(--muted);
38
36
  text-decoration: none;
39
37
  line-height: 1.4;
40
- transition:
41
- color 125ms ease,
42
- border-color 125ms ease;
38
+ transition: color 125ms ease;
43
39
 
44
40
  &:hover {
45
41
  color: var(--fg);
@@ -50,9 +46,10 @@
50
46
  padding-left: 1.6rem;
51
47
  }
52
48
 
53
- li.active a {
54
- border-left-color: charmtone.$blush;
55
- color: var(--fg);
49
+ // Only the entry's own anchor: children render inside the active
50
+ // parent's li, so a descendant selector would tint the whole branch.
51
+ li.active > a {
52
+ color: charmtone.$blush;
56
53
  font-weight: 620;
57
54
  }
58
55
 
@@ -75,10 +72,10 @@
75
72
  width: 100%;
76
73
  // The .toc-title margins don't apply to the button: the collapsed
77
74
  // band centers it instead. Its label starts where the item labels
78
- // do (rail + item padding), folded or open, at every width.
75
+ // do (item padding), folded or open, at every width.
79
76
  margin: 0;
80
77
  padding: 0;
81
- padding-left: calc(0.9rem + 2px);
78
+ padding-left: 0.9rem;
82
79
  border: none;
83
80
  background: none;
84
81
  cursor: pointer;