@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.
@@ -6,5 +6,5 @@ import "@charmland/gem/theme.js";
6
6
  import type { BootFlags } from "@charmland/gem-compiler/types";
7
7
  import type { ElmApp } from "./runtime.js";
8
8
  export declare function boot(flags: BootFlags, node?: HTMLElement): ElmApp;
9
- export { connectPorts, installLightbox, installTabs } from "./runtime.js";
9
+ export { connectPorts, installDrawerLock, installLightbox, installTabs } from "./runtime.js";
10
10
  export type { ElmApp, ElmProgram } from "./runtime.js";
@@ -11,4 +11,4 @@ export function boot(flags, node) {
11
11
  }
12
12
  return start(Elm.Gem.Main, flags, node);
13
13
  }
14
- export { connectPorts, installLightbox, installTabs } from "./runtime.js";
14
+ export { connectPorts, installDrawerLock, installLightbox, installTabs } from "./runtime.js";
@@ -0,0 +1 @@
1
+ export declare function installDrawerLock(root?: ParentNode): () => void;
@@ -0,0 +1,49 @@
1
+ // Pinning the body keeps the page still while the drawer is open, and
2
+ // restores the reader's offset when it closes.
3
+ const OPEN = "open";
4
+ export function installDrawerLock(root = document) {
5
+ const burger = root.querySelector(".burger");
6
+ if (!burger)
7
+ return () => { };
8
+ const body = document.body;
9
+ let locked = false;
10
+ let offset = 0;
11
+ const lock = () => {
12
+ offset = window.scrollY;
13
+ const gutter = window.innerWidth - document.documentElement.clientWidth;
14
+ body.style.position = "fixed";
15
+ body.style.top = `-${offset}px`;
16
+ body.style.left = "0";
17
+ body.style.right = "0";
18
+ body.style.overflow = "hidden";
19
+ if (gutter > 0)
20
+ body.style.paddingRight = `${gutter}px`;
21
+ };
22
+ const unlock = () => {
23
+ body.style.position = "";
24
+ body.style.top = "";
25
+ body.style.left = "";
26
+ body.style.right = "";
27
+ body.style.overflow = "";
28
+ body.style.paddingRight = "";
29
+ window.scrollTo(0, offset);
30
+ };
31
+ const apply = (open) => {
32
+ if (open === locked)
33
+ return;
34
+ locked = open;
35
+ if (open)
36
+ lock();
37
+ else
38
+ unlock();
39
+ };
40
+ const observer = new MutationObserver(() => apply(burger.classList.contains(OPEN)));
41
+ observer.observe(burger, { attributes: true, attributeFilter: ["class"] });
42
+ apply(burger.classList.contains(OPEN));
43
+ return () => {
44
+ observer.disconnect();
45
+ if (locked)
46
+ unlock();
47
+ locked = false;
48
+ };
49
+ }
@@ -10,5 +10,6 @@ export type { ElmApp, MetaFlags } from "./ports.js";
10
10
  export { connectPorts } from "./ports.js";
11
11
  export { installTabs } from "./tabs.js";
12
12
  export { installLightbox, upgradeImages } from "./lightbox.js";
13
+ export { installDrawerLock } from "./drawer.js";
13
14
  export type { Lightbox } from "./lightbox.js";
14
15
  export declare function start<App extends ElmApp>(program: ElmProgram<App>, flags: BootFlags, node?: HTMLElement): App;
@@ -1,4 +1,5 @@
1
1
  import { connectColorScheme, prepareColorScheme, watchSystem } from "./color-scheme.js";
2
+ import { installDrawerLock } from "./drawer.js";
2
3
  import { installLightbox } from "./lightbox.js";
3
4
  import { connectExternal, connectMeta, connectPorts, connectScroll } from "./ports.js";
4
5
  import { installLinkInterception } from "./router.js";
@@ -6,6 +7,7 @@ import { installTabs, observeTabs } from "./tabs.js";
6
7
  export { connectPorts } from "./ports.js";
7
8
  export { installTabs } from "./tabs.js";
8
9
  export { installLightbox, upgradeImages } from "./lightbox.js";
10
+ export { installDrawerLock } from "./drawer.js";
9
11
  export function start(program, flags, node) {
10
12
  const app = program.init({
11
13
  flags: prepareColorScheme(flags),
@@ -21,5 +23,6 @@ export function start(program, flags, node) {
21
23
  installTabs();
22
24
  observeTabs();
23
25
  installLightbox();
26
+ installDrawerLock();
24
27
  return app;
25
28
  }
@@ -71,7 +71,7 @@
71
71
  figcaption {
72
72
  margin: 0;
73
73
  padding: 0;
74
- font-weight: normal;
74
+ font-weight: inherit;
75
75
  font-style: normal;
76
76
  text-align: left;
77
77
  }
@@ -197,7 +197,7 @@ html,
197
197
  body {
198
198
  height: 100%;
199
199
  font-family: "Charmform Web", system-ui, -apple-system, sans-serif;
200
- font-weight: 500;
200
+ font-weight: 460;
201
201
  color: var(--fg);
202
202
  background: var(--bg);
203
203
  -webkit-font-smoothing: antialiased;
@@ -217,30 +217,41 @@ textarea {
217
217
 
218
218
  * {
219
219
  scrollbar-width: thin;
220
- scrollbar-color: #6b50ff var(--well);
220
+ scrollbar-color: transparent transparent;
221
+ }
222
+
223
+ *:hover {
224
+ scrollbar-color: color-mix(in srgb, var(--fg) 28%, transparent) transparent;
221
225
  }
222
226
 
223
227
  *::-webkit-scrollbar {
224
- width: 0.625rem;
225
- height: 0.625rem;
228
+ width: 0.5rem;
229
+ height: 0.5rem;
226
230
  }
227
231
 
228
232
  *::-webkit-scrollbar-track {
229
- border-radius: 9999px;
230
- background: var(--well);
233
+ background: transparent;
231
234
  }
232
235
 
233
236
  *::-webkit-scrollbar-thumb {
237
+ border: 1px solid transparent;
234
238
  border-radius: 9999px;
235
- background: linear-gradient(90deg, #6b50ff, #ff60ff);
236
- border: 1px solid var(--bg);
239
+ background: transparent;
240
+ background-clip: content-box;
241
+ }
242
+
243
+ *:hover::-webkit-scrollbar-thumb {
244
+ background: color-mix(in srgb, var(--fg) 28%, transparent);
245
+ background-clip: content-box;
237
246
  }
247
+
238
248
  *::-webkit-scrollbar-thumb:hover {
239
- background: linear-gradient(90deg, #8b75ff, #d46eff);
249
+ background: color-mix(in srgb, var(--fg) 45%, transparent);
250
+ background-clip: content-box;
240
251
  }
241
252
 
242
253
  *::-webkit-scrollbar-corner {
243
- background: var(--well);
254
+ background: transparent;
244
255
  }
245
256
 
246
257
  @supports (corner-shape: squircle) {
@@ -1135,7 +1146,7 @@ table a:hover {
1135
1146
  .toolbar h1 {
1136
1147
  font-size: 2.7rem;
1137
1148
  font-weight: 800;
1138
- font-variation-settings: "OPTK" -15;
1149
+ font-variation-settings: "OPTK" -45;
1139
1150
  margin: 0;
1140
1151
  }
1141
1152
  .toolbar .actions {
@@ -1581,7 +1592,7 @@ button.copy.done {
1581
1592
  transition: opacity 150ms ease, visibility 150ms ease;
1582
1593
  }
1583
1594
 
1584
- @media (max-width: 768px) {
1595
+ @media (max-width: 1024px) {
1585
1596
  .dropdown .menu {
1586
1597
  left: auto;
1587
1598
  right: 0;
@@ -3035,6 +3046,16 @@ a.social.disabled {
3035
3046
  border-top: 1px solid rgba(247, 246, 251, 0.2);
3036
3047
  }
3037
3048
 
3049
+ @property --sidebar-fade-top {
3050
+ syntax: "<length>";
3051
+ inherits: false;
3052
+ initial-value: 0px;
3053
+ }
3054
+ @property --sidebar-fade-bottom {
3055
+ syntax: "<length>";
3056
+ inherits: false;
3057
+ initial-value: 0px;
3058
+ }
3038
3059
  .sidebar {
3039
3060
  display: flex;
3040
3061
  flex-direction: column;
@@ -3045,10 +3066,16 @@ a.social.disabled {
3045
3066
  flex: 1;
3046
3067
  min-height: 0;
3047
3068
  overflow-y: auto;
3048
- background: linear-gradient(var(--bg) 33%, rgba(255, 255, 255, 0)) local center top, linear-gradient(rgba(255, 255, 255, 0), var(--bg) 67%) local center bottom, radial-gradient(farthest-side at 50% 0%, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0)) scroll center top, radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0)) scroll center bottom;
3049
- background-repeat: no-repeat;
3050
- background-size: 100% 4rem, 100% 4rem, 100% 1rem, 100% 1rem;
3051
- background-attachment: local, local, scroll, scroll;
3069
+ scrollbar-gutter: stable;
3070
+ -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--sidebar-fade-top), #000 calc(100% - var(--sidebar-fade-bottom)), transparent 100%);
3071
+ mask-image: linear-gradient(to bottom, transparent 0, #000 var(--sidebar-fade-top), #000 calc(100% - var(--sidebar-fade-bottom)), transparent 100%);
3072
+ }
3073
+ @supports (animation-timeline: scroll()) {
3074
+ .sidebar .sidebar-items {
3075
+ animation: sidebar-fade-top linear both, sidebar-fade-bottom linear both;
3076
+ animation-timeline: scroll(self block), scroll(self block);
3077
+ animation-range: 0 2.5rem, calc(100% - 2.5rem) 100%;
3078
+ }
3052
3079
  }
3053
3080
  .sidebar ul {
3054
3081
  list-style: none;
@@ -3068,8 +3095,8 @@ a.social.disabled {
3068
3095
  margin-top: 0;
3069
3096
  }
3070
3097
  .sidebar li.section .section-label {
3071
- padding: 0.35rem 1.5rem;
3072
- font-weight: 620;
3098
+ padding: 0.35rem 1rem 0.35rem 1.5rem;
3099
+ font-weight: 735;
3073
3100
  letter-spacing: -0.01em;
3074
3101
  color: var(--fg);
3075
3102
  }
@@ -3078,7 +3105,7 @@ a.social.disabled {
3078
3105
  align-items: center;
3079
3106
  justify-content: space-between;
3080
3107
  width: 100%;
3081
- padding: 0.35rem 1.5rem;
3108
+ padding: 0.35rem 1rem 0.35rem 1.5rem;
3082
3109
  border: none;
3083
3110
  background: none;
3084
3111
  cursor: pointer;
@@ -3107,11 +3134,11 @@ a.social.disabled {
3107
3134
  display: flex;
3108
3135
  align-items: center;
3109
3136
  gap: 0.5rem;
3110
- padding: 0.5rem 1.5rem;
3137
+ padding: 0.5rem 1rem 0.5rem 1.5rem;
3111
3138
  text-decoration: none;
3112
3139
  color: var(--muted);
3113
3140
  font-size: 0.9375rem;
3114
- font-weight: 520;
3141
+ font-weight: 560;
3115
3142
  cursor: pointer;
3116
3143
  --active-border: 0.375rem;
3117
3144
  }
@@ -3156,7 +3183,7 @@ a.social.disabled {
3156
3183
  border-left: var(--active-border) solid #ff84ff;
3157
3184
  padding-left: calc(1.5rem - var(--active-border));
3158
3185
  color: var(--fg);
3159
- font-weight: 620;
3186
+ font-weight: 660;
3160
3187
  }
3161
3188
  .sidebar ul > li.section ~ li.active > a {
3162
3189
  padding-left: calc(2.25rem - var(--active-border));
@@ -3187,6 +3214,22 @@ a.social.disabled {
3187
3214
  padding-right: 0.6rem;
3188
3215
  }
3189
3216
 
3217
+ @keyframes sidebar-fade-top {
3218
+ from {
3219
+ --sidebar-fade-top: 0rem;
3220
+ }
3221
+ to {
3222
+ --sidebar-fade-top: 2.5rem;
3223
+ }
3224
+ }
3225
+ @keyframes sidebar-fade-bottom {
3226
+ from {
3227
+ --sidebar-fade-bottom: 2.5rem;
3228
+ }
3229
+ to {
3230
+ --sidebar-fade-bottom: 0rem;
3231
+ }
3232
+ }
3190
3233
  .toc {
3191
3234
  font-size: 0.8125rem;
3192
3235
  }
@@ -3211,11 +3254,10 @@ a.social.disabled {
3211
3254
  .toc li a {
3212
3255
  display: block;
3213
3256
  padding: 0.3rem 0.9rem;
3214
- border-left: 2px solid transparent;
3215
3257
  color: var(--muted);
3216
3258
  text-decoration: none;
3217
3259
  line-height: 1.4;
3218
- transition: color 125ms ease, border-color 125ms ease;
3260
+ transition: color 125ms ease;
3219
3261
  }
3220
3262
  .toc li a:hover {
3221
3263
  color: var(--fg);
@@ -3223,9 +3265,8 @@ a.social.disabled {
3223
3265
  .toc li li a {
3224
3266
  padding-left: 1.6rem;
3225
3267
  }
3226
- .toc li.active a {
3227
- border-left-color: #ff84ff;
3228
- color: var(--fg);
3268
+ .toc li.active > a {
3269
+ color: #ff84ff;
3229
3270
  font-weight: 620;
3230
3271
  }
3231
3272
  .toc.collapsible ul {
@@ -3241,7 +3282,7 @@ a.social.disabled {
3241
3282
  width: 100%;
3242
3283
  margin: 0;
3243
3284
  padding: 0;
3244
- padding-left: calc(0.9rem + 2px);
3285
+ padding-left: 0.9rem;
3245
3286
  border: none;
3246
3287
  background: none;
3247
3288
  cursor: pointer;
@@ -3282,17 +3323,20 @@ a.social.disabled {
3282
3323
  .page-nav {
3283
3324
  display: flex;
3284
3325
  justify-content: space-between;
3285
- gap: 1rem;
3326
+ gap: 1.5rem;
3286
3327
  margin-top: 2.5rem;
3287
3328
  padding-top: 1.5rem;
3288
- border-top: 1px solid var(--rule);
3329
+ }
3330
+
3331
+ .page-nav-link.next:only-child {
3332
+ margin-left: auto;
3289
3333
  }
3290
3334
 
3291
3335
  .page-nav-link {
3292
3336
  display: flex;
3337
+ flex: 1;
3293
3338
  flex-direction: column;
3294
3339
  gap: 0.25rem;
3295
- max-width: 45%;
3296
3340
  min-width: 0;
3297
3341
  padding: 0.75rem 1rem;
3298
3342
  border: 1px solid var(--frame);
@@ -3325,7 +3369,6 @@ a.social.disabled {
3325
3369
  color: #ff84ff;
3326
3370
  }
3327
3371
  .page-nav-link.next {
3328
- margin-left: auto;
3329
3372
  text-align: right;
3330
3373
  }
3331
3374
 
@@ -3409,6 +3452,7 @@ a.social.disabled {
3409
3452
  padding: 5rem 0 0;
3410
3453
  transform: translateY(-100%);
3411
3454
  overflow-y: auto;
3455
+ overscroll-behavior: contain;
3412
3456
  visibility: hidden;
3413
3457
  transition: visibility 0s 320ms;
3414
3458
  }
@@ -3530,8 +3574,6 @@ a.social.disabled {
3530
3574
  max-width: 88rem;
3531
3575
  min-height: 100vh;
3532
3576
  margin-inline: auto;
3533
- border-left: 1px solid var(--frame);
3534
- border-right: 1px solid var(--frame);
3535
3577
  }
3536
3578
 
3537
3579
  .docs {
@@ -3544,10 +3586,7 @@ a.social.disabled {
3544
3586
  position: sticky;
3545
3587
  top: 3.8125rem;
3546
3588
  height: calc(100vh - 3.8125rem);
3547
- border-right: 1px solid var(--frame);
3548
- }
3549
- .docs-sidebar .sidebar {
3550
- height: 100%;
3589
+ padding-top: 1.5rem;
3551
3590
  }
3552
3591
 
3553
3592
  .docs-main {
@@ -3555,10 +3594,11 @@ a.social.disabled {
3555
3594
  min-width: 0;
3556
3595
  display: flex;
3557
3596
  flex-direction: column;
3597
+ padding-top: 1.5rem;
3558
3598
  }
3559
3599
 
3560
3600
  .docs-content {
3561
- padding: 3rem 5rem;
3601
+ padding: 0.5rem 5rem 3rem;
3562
3602
  }
3563
3603
 
3564
3604
  .docs-header {
@@ -3567,7 +3607,6 @@ a.social.disabled {
3567
3607
  gap: 1.5rem;
3568
3608
  min-height: 3.8125rem;
3569
3609
  padding: 0.75rem 1.5rem;
3570
- border-bottom: 1px solid var(--frame);
3571
3610
  position: sticky;
3572
3611
  top: 0;
3573
3612
  background: var(--bg);
@@ -3622,20 +3661,13 @@ a.social.disabled {
3622
3661
  max-width: 60rem;
3623
3662
  }
3624
3663
 
3625
- @media (max-width: 1024px) {
3664
+ @media (max-width: 768px) {
3626
3665
  .docs-header.is-hidden {
3627
3666
  transform: translateY(-100%);
3628
3667
  }
3629
3668
  .shell:has(.docs-header.is-hidden) .docs-toc {
3630
3669
  top: 0;
3631
3670
  }
3632
- .docs-sidebar {
3633
- transition: top 180ms ease, height 180ms ease;
3634
- }
3635
- .shell:has(.docs-header.is-hidden) .docs-sidebar {
3636
- top: 0;
3637
- height: 100vh;
3638
- }
3639
3671
  }
3640
3672
  .docs-lede {
3641
3673
  margin: 0 0 1rem;
@@ -3865,10 +3897,6 @@ ul.rows .list-row + .list-row {
3865
3897
  .docs {
3866
3898
  flex-direction: column;
3867
3899
  }
3868
- .shell {
3869
- border-left: none;
3870
- border-right: none;
3871
- }
3872
3900
  .docs-sidebar {
3873
3901
  display: none;
3874
3902
  }
@@ -3910,9 +3938,6 @@ ul.rows .list-row + .list-row {
3910
3938
  grid-column: 2;
3911
3939
  grid-row: 1;
3912
3940
  }
3913
- .docs-with-toc .docs-toc {
3914
- border-left: 1px solid var(--frame);
3915
- }
3916
3941
  .docs-with-toc .docs-toc-sticky {
3917
3942
  position: sticky;
3918
3943
  top: 4.75rem;
@@ -3929,8 +3954,6 @@ ul.rows .list-row + .list-row {
3929
3954
  top: 3.8125rem;
3930
3955
  z-index: 25;
3931
3956
  margin: 0;
3932
- border-left: none;
3933
- border-bottom: 1px solid var(--frame);
3934
3957
  background: var(--plate);
3935
3958
  transition: top 180ms ease;
3936
3959
  }
@@ -4030,7 +4053,7 @@ ul.rows .list-row + .list-row {
4030
4053
  padding-top: 1.5rem;
4031
4054
  font-size: 1.5rem;
4032
4055
  line-height: 1.3333333;
4033
- font-variation-settings: "OPTK" -15;
4056
+ font-variation-settings: "OPTK" -35;
4034
4057
  }
4035
4058
  .md .md-h3 {
4036
4059
  margin: 2rem 0 0;
@@ -4074,10 +4097,19 @@ ul.rows .list-row + .list-row {
4074
4097
  }
4075
4098
 
4076
4099
  .site-footer {
4077
- border-top: 1px solid var(--frame);
4100
+ position: relative;
4078
4101
  background: var(--bg);
4079
4102
  overflow: hidden;
4080
4103
  }
4104
+ .site-footer::before {
4105
+ content: "";
4106
+ position: absolute;
4107
+ top: 0;
4108
+ left: 2.5rem;
4109
+ right: 2.5rem;
4110
+ height: 1px;
4111
+ background: var(--frame);
4112
+ }
4081
4113
  .site-footer .site-footer-inner {
4082
4114
  display: grid;
4083
4115
  grid-template-columns: 1.8fr 1fr 1fr 1fr;
@@ -4163,7 +4195,6 @@ ul.rows .list-row + .list-row {
4163
4195
  justify-content: space-between;
4164
4196
  gap: 1rem;
4165
4197
  padding: 1.1rem 2.5rem;
4166
- border-top: 1px solid var(--frame);
4167
4198
  font-size: 0.75rem;
4168
4199
  color: var(--tertiary);
4169
4200
  }
@@ -4179,6 +4210,9 @@ ul.rows .list-row + .list-row {
4179
4210
  .site-footer .site-footer-inner {
4180
4211
  grid-template-columns: 1fr 1fr;
4181
4212
  }
4213
+ .site-footer .site-footer-bar {
4214
+ padding-right: 5.5rem;
4215
+ }
4182
4216
  }
4183
4217
  .tabs button .theme-icon {
4184
4218
  width: 1.1rem;