ab-nextjs-components 0.1.14 → 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/CHANGELOG.md +35 -0
- package/README.md +5 -0
- package/ab-app-bar/index.tsx +16 -5
- package/ab-app-bar/styles.module.css +27 -2
- package/ab-bottom-drawer/styles.module.css +1 -1
- package/ab-breadcrumbs/index.tsx +1 -1
- package/ab-drawer/gestures.ts +134 -0
- package/ab-drawer/index.tsx +163 -12
- package/ab-drawer/kit.module.css +204 -0
- package/ab-drawer/styles.module.css +39 -0
- package/ab-drawer/use-ab-edge-swipe.ts +155 -0
- package/ab-icon-button/index.tsx +1 -1
- package/ab-locale-switcher/index.tsx +64 -3
- package/ab-locale-switcher/styles.module.css +20 -0
- package/ab-mobile-header/index.tsx +100 -0
- package/ab-nav-drawer/index.tsx +158 -0
- package/ab-navbar/index.tsx +1 -1
- package/ab-search-drawer/index.tsx +279 -0
- package/ab-search-trigger/index.tsx +8 -3
- package/ab-search-trigger/styles.module.css +3 -0
- package/ab-settings-drawer/index.tsx +160 -0
- package/ab-sidebar/index.tsx +1 -1
- package/ab-sidebar/styles.module.css +5 -0
- package/ab-sidebar/view.tsx +4 -0
- package/ab-toc-drawer/index.tsx +129 -0
- package/ab-version-switcher/index.tsx +5 -5
- package/index.ts +23 -0
- package/package.json +13 -3
- package/types/index.d.ts +18 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-components
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-components
|
|
27
|
+
* @name: Drawers v2 kit styles
|
|
28
|
+
* @file: ab-drawer/kit.module.css
|
|
29
|
+
* @type: CSS module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more 😜!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/* 🧰 drawers v2 (John's frames, God 01:22): the shared look of AbSettingsDrawer, AbNavDrawer, AbTocDrawer and
|
|
41
|
+
AbSearchDrawer. Values are the mock's (drawer.css), read through the theme tokens where theme 0.3.5+ has them.
|
|
42
|
+
Doubled classes beat AbDrawer's own rules without !important. */
|
|
43
|
+
|
|
44
|
+
/* 🎨 local tokens: light, then dark (CSS modules need :global for the theme classes) */
|
|
45
|
+
.sheet {
|
|
46
|
+
--ab-dr-bg: var(--ab-color-bg, #fff8f5); /* 🎨 --bg */
|
|
47
|
+
--ab-dr-card: var(--ab-color-card, #fff); /* 🃏 --card */
|
|
48
|
+
--ab-dr-card2: #fbf3ec; /* 🃏 --card2 (segmented track) */
|
|
49
|
+
--ab-dr-on: #f7ede4; /* 🎯 the active row (mock .light .row.on) */
|
|
50
|
+
--ab-dr-on-ring: inset 0 0 0 1px rgb(166 124 82 / 0.3); /* 🎯 its 1px ring */
|
|
51
|
+
--ab-dr-seg-on: var(--ab-color-card, #fff); /* 🎚️ the raised segment */
|
|
52
|
+
--ab-dr-faint: #9c8c80; /* ➖ the handle bar (--faint) */
|
|
53
|
+
}
|
|
54
|
+
:global(.dark) .sheet, :global([data-theme='dark']) .sheet {
|
|
55
|
+
--ab-dr-bg: var(--ab-color-pane-main, #1d150f); /* 🌙 the sheet is #1D150F */
|
|
56
|
+
--ab-dr-card2: #2c2118;
|
|
57
|
+
--ab-dr-on: var(--ab-color-tint, rgb(166 124 82 / 0.2)); /* 🌙 tint, no ring */
|
|
58
|
+
--ab-dr-on-ring: none;
|
|
59
|
+
--ab-dr-seg-on: #3a2b1e;
|
|
60
|
+
--ab-dr-faint: #86776b;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* 🗄️ every v2 sheet: --bg, a 1px --border edge, the mock shadow */
|
|
64
|
+
.sheet.sheet {
|
|
65
|
+
background: var(--ab-dr-bg); color: var(--ab-color-text, #211a16); /* 🎨 */
|
|
66
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); /* ➖ */
|
|
67
|
+
box-shadow: 0 -8px 32px rgb(25 18 12 / 0.22); /* 🌗 */
|
|
68
|
+
outline: none; /* 🎯 */
|
|
69
|
+
}
|
|
70
|
+
/* ⬆️ bottom: 16px top radius, no bottom edge; 16px + home indicator below (24px on laptop) */
|
|
71
|
+
.sheet.sheet[data-side='bottom'] { border-bottom: 0; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
|
|
72
|
+
.sheet.sheet[data-side='bottom'][data-center='main'] { padding-bottom: 24px; }
|
|
73
|
+
/* ⬅️ left: 320px, 0 16 16 0; ➡️ right: 296px, 16 0 0 16 (widths come from `size`) */
|
|
74
|
+
.sheet.sheet:is([data-side='left'], [data-side='start']) { border-inline-start: 0; border-radius: 0 16px 16px 0; box-shadow: 8px 0 32px rgb(25 18 12 / 0.22); padding-top: env(safe-area-inset-top, 0px); }
|
|
75
|
+
.sheet.sheet:is([data-side='right'], [data-side='end']) { border-inline-end: 0; border-radius: 16px 0 0 16px; box-shadow: -8px 0 32px rgb(25 18 12 / 0.22); padding-top: env(safe-area-inset-top, 0px); }
|
|
76
|
+
.sheet.sheet:is([data-side='left'], [data-side='start'], [data-side='right'], [data-side='end']) { max-width: 100%; }
|
|
77
|
+
|
|
78
|
+
/* ➖ the handle bar: 40×4 in --faint */
|
|
79
|
+
.sheet [data-ab-part='drawer-handle']::before { background: var(--ab-dr-faint); }
|
|
80
|
+
/* 🔝 header: 56px, 24px start inset; the title is Mulish 800 22px (20px on the right drawer) */
|
|
81
|
+
.sheet [data-ab-part='drawer-header'] { block-size: 56px; box-sizing: border-box; padding: 0 8px 0 24px; gap: 8px; }
|
|
82
|
+
.sheet [data-ab-part='drawer-header'] > :first-child { font-family: var(--ab-font-title, 'Mulish', inherit); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; line-height: 1.2; }
|
|
83
|
+
.titleSm [data-ab-part='drawer-header'] > :first-child { font-size: 20px; }
|
|
84
|
+
/* ✕ close: 44px, 8px radius, --muted, 24px glyph */
|
|
85
|
+
.sheet [data-ab-part='drawer-close'] { inline-size: 44px; block-size: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--ab-color-muted, #6b5b50); }
|
|
86
|
+
.sheet [data-ab-part='drawer-close']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
87
|
+
.sheet [data-ab-part='drawer-close']:focus { outline: none; }
|
|
88
|
+
.sheet [data-ab-part='drawer-close']:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; }
|
|
89
|
+
/* 📜 body: 16px sides */
|
|
90
|
+
.sheet [data-ab-part='drawer-body'] { padding: 0 16px; display: flex; flex-direction: column; }
|
|
91
|
+
|
|
92
|
+
/* 🏷️ section label: Inter 700 12/16 uppercase +0.08em, --muted */
|
|
93
|
+
.lbl { margin: 0; padding: 16px 16px 8px; font: 700 12px/16px var(--ab-font-body, 'Inter', inherit); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ab-color-muted, #6b5b50); }
|
|
94
|
+
/* ▭ a 48px row (settings, footer links) */
|
|
95
|
+
.row {
|
|
96
|
+
box-sizing: border-box; display: flex; align-items: center; gap: 16px; flex: none; /* 📐 */
|
|
97
|
+
block-size: 48px; padding: 0 16px; border: 0; border-radius: 8px; margin: 0; inline-size: 100%; /* 📏 */
|
|
98
|
+
background: transparent; color: var(--ab-color-text, #211a16); font: 500 16px/1.2 var(--ab-font-body, 'Inter', inherit); /* 🔤 */
|
|
99
|
+
text-align: start; text-decoration: none; cursor: pointer; /* 🖱️ */
|
|
100
|
+
}
|
|
101
|
+
.row > svg, .row > .ic { flex: none; inline-size: 24px; block-size: 24px; color: var(--ab-color-muted, #6b5b50); }
|
|
102
|
+
.row:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
103
|
+
.row:focus { outline: none; }
|
|
104
|
+
.row:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
105
|
+
.row[aria-checked='true'], .row[aria-current='page'] { background: var(--ab-dr-on); box-shadow: var(--ab-dr-on-ring); color: var(--ab-color-accent-text, #8b6340); font-weight: 700; } /* 🎯 */
|
|
106
|
+
.row[aria-checked='true'] > svg, .row[aria-current='page'] > svg { color: var(--ab-color-accent-text, #8b6340); }
|
|
107
|
+
.ck { margin-inline-start: auto; color: var(--ab-color-accent-text, #8b6340); } /* ✓ 24px check */
|
|
108
|
+
.row > .ck { color: var(--ab-color-accent-text, #8b6340); }
|
|
109
|
+
.chev { margin-inline-start: 0; } /* › right after the label (mock: "Settings ›") */
|
|
110
|
+
.hr { block-size: 1px; margin: 8px 16px; border: 0; background: var(--ab-color-div, rgb(92 64 48 / 0.11)); flex: none; }
|
|
111
|
+
|
|
112
|
+
/* 🎚️ segmented control: 48px, 4px track padding, 3 equal segments, 14px 600 */
|
|
113
|
+
.seg { box-sizing: border-box; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; block-size: 48px; padding: 4px; margin: 0 0 8px; border-radius: 8px; background: var(--ab-dr-card2); border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); }
|
|
114
|
+
.segBtn { display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 6px; background: transparent; color: var(--ab-color-muted, #6b5b50); font: 600 14px/1 var(--ab-font-body, 'Inter', inherit); cursor: pointer; padding: 0; }
|
|
115
|
+
.segBtn > svg { inline-size: 18px; block-size: 18px; }
|
|
116
|
+
.segBtn[aria-checked='true'] { background: var(--ab-dr-seg-on); color: var(--ab-color-accent-text, #8b6340); box-shadow: 0 1px 3px rgb(25 18 12 / 0.12); outline: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); }
|
|
117
|
+
.segBtn:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 1px; }
|
|
118
|
+
|
|
119
|
+
/* ⬅️ the nav drawer: logo header, the version chip, a scrolling nav (44px rows, 15px) with a 72px fade, a pinned footer */
|
|
120
|
+
.logoRow { display: flex; align-items: center; min-inline-size: 0; }
|
|
121
|
+
.logoRow a { display: flex; align-items: center; color: inherit; }
|
|
122
|
+
.ver { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; block-size: 32px; padding: 0 8px 0 10px; margin: 0 0 8px 8px; box-sizing: border-box; border-radius: 8px; border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); background: var(--ab-dr-card); color: var(--ab-color-muted, #6b5b50); font: 500 13px/1 var(--ab-font-body, 'Inter', inherit); }
|
|
123
|
+
.ver b { font-family: var(--ab-font-mono, 'Roboto Mono', monospace); color: var(--ab-color-accent-text, #8b6340); font-weight: 600; }
|
|
124
|
+
.ver > svg { inline-size: 18px; block-size: 18px; }
|
|
125
|
+
.navWrap { position: relative; flex: 1 1 auto; min-block-size: 0; display: flex; flex-direction: column; }
|
|
126
|
+
.nav { flex: 1 1 auto; min-block-size: 0; overflow: hidden auto; overscroll-behavior: contain; padding-bottom: 72px; }
|
|
127
|
+
.fade { position: absolute; inset: auto 0 0; block-size: 72px; pointer-events: none; background: linear-gradient(transparent, var(--ab-dr-bg)); } /* 🌫️ marks the scroll */
|
|
128
|
+
.grp { margin: 0; padding: 16px 12px 8px; font: 700 12px/16px var(--ab-font-body, 'Inter', inherit); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ab-color-muted, #6b5b50); }
|
|
129
|
+
.list { list-style: none; margin: 0; padding: 0; }
|
|
130
|
+
.nv { box-sizing: border-box; display: flex; align-items: center; gap: 12px; block-size: 44px; padding: 0 12px; border-radius: 8px; color: var(--ab-color-text, #211a16); font: 500 15px/1.2 var(--ab-font-body, 'Inter', inherit); text-decoration: none; }
|
|
131
|
+
.nv > svg { flex: none; inline-size: 22px; block-size: 22px; color: var(--ab-color-muted, #6b5b50); }
|
|
132
|
+
.nv:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
133
|
+
.nv:focus { outline: none; }
|
|
134
|
+
.nv:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
135
|
+
.nv[aria-current='page'] { background: var(--ab-dr-on); box-shadow: var(--ab-dr-on-ring); color: var(--ab-color-accent-text, #8b6340); font-weight: 700; }
|
|
136
|
+
.nv[aria-current='page'] > svg { color: var(--ab-color-accent-text, #8b6340); }
|
|
137
|
+
.mini { margin-inline-start: auto; font: 400 12px/1 var(--ab-font-mono, 'Roboto Mono', monospace); color: var(--ab-color-muted, #6b5b50); }
|
|
138
|
+
.navFoot { flex: none; border-top: 1px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); margin: 0 -16px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px)); } /* 📌 pinned, full-width rule */
|
|
139
|
+
|
|
140
|
+
/* ➡️ the outline: 44px rows on a 2px rail, level 3 indented 16px, the active one bronze */
|
|
141
|
+
.toc { list-style: none; margin: 0 0 0 8px; padding: 0; }
|
|
142
|
+
.tocLink { box-sizing: border-box; display: flex; align-items: center; block-size: 44px; padding: 0 16px; border-inline-start: 2px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); color: var(--ab-color-muted, #6b5b50); font: 400 15px/1.2 var(--ab-font-body, 'Inter', inherit); text-decoration: none; }
|
|
143
|
+
.tocLink[data-level='3'] { padding-inline-start: 32px; font-size: 14px; }
|
|
144
|
+
.tocLink[data-level='4'] { padding-inline-start: 48px; font-size: 14px; }
|
|
145
|
+
.tocLink[aria-current='location'] { border-inline-start-color: var(--ab-color-accent, #a67c52); color: var(--ab-color-accent-text, #8b6340); font-weight: 700; background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
146
|
+
.tocLink:focus { outline: none; }
|
|
147
|
+
.tocLink:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
148
|
+
.tocHr { margin: 16px 8px; }
|
|
149
|
+
.tocRow { font-size: 15px; margin: 0 -8px; inline-size: calc(100% + 16px); }
|
|
150
|
+
|
|
151
|
+
/* 🔎 search: a 48px field with a 2px accent border, then the results (they scroll) */
|
|
152
|
+
.searchBody { flex: 1 1 auto; min-block-size: 0; display: flex; flex-direction: column; }
|
|
153
|
+
.field { box-sizing: border-box; flex: none; display: flex; align-items: center; gap: 12px; block-size: 48px; padding: 0 4px 0 16px; margin: 0 0 8px; border-radius: 8px; border: 2px solid var(--ab-color-accent, #a67c52); background: var(--ab-dr-card); }
|
|
154
|
+
.field > svg { flex: none; inline-size: 22px; block-size: 22px; color: var(--ab-color-muted, #6b5b50); }
|
|
155
|
+
.input { flex: 1 1 auto; min-inline-size: 0; border: 0; outline: none; background: transparent; color: var(--ab-color-text, #211a16); font: 500 16px/1.2 var(--ab-font-body, 'Inter', inherit); caret-color: var(--ab-color-accent-text, #8b6340); padding: 0; }
|
|
156
|
+
.input::placeholder { color: var(--ab-color-muted, #6b5b50); font-weight: 400; }
|
|
157
|
+
.input::-webkit-search-cancel-button { display: none; }
|
|
158
|
+
.iconSm { flex: none; inline-size: 40px; block-size: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--ab-color-muted, #6b5b50); cursor: pointer; padding: 0; }
|
|
159
|
+
.iconSm > svg { inline-size: 20px; block-size: 20px; }
|
|
160
|
+
.iconSm:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
161
|
+
.iconSm:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
162
|
+
.results { flex: 1 1 auto; min-block-size: 0; overflow: hidden auto; overscroll-behavior: contain; }
|
|
163
|
+
.recent { gap: 12px; padding-inline-end: 0; font-size: 15px; cursor: default; }
|
|
164
|
+
.recent:hover { background: transparent; }
|
|
165
|
+
.recentGo { flex: 1 1 auto; min-inline-size: 0; border: 0; background: none; padding: 0; text-align: start; color: inherit; font: inherit; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
166
|
+
.recentGo:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; }
|
|
167
|
+
.grp2 { display: flex; align-items: baseline; gap: 8px; padding: 12px 16px 4px; margin: 0; }
|
|
168
|
+
.grp2 > span { font: 700 12px/16px var(--ab-font-body, 'Inter', inherit); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ab-color-muted, #6b5b50); }
|
|
169
|
+
.grp2 > code { font: 400 12px/16px var(--ab-font-mono, 'Roboto Mono', monospace); color: var(--ab-color-muted, #6b5b50); }
|
|
170
|
+
.sr { box-sizing: border-box; display: flex; align-items: center; gap: 12px; min-block-size: 56px; padding: 4px 12px; border-radius: 8px; color: inherit; text-decoration: none; }
|
|
171
|
+
.sr[aria-selected='true'] { background: var(--ab-dr-on); box-shadow: var(--ab-dr-on-ring); }
|
|
172
|
+
.sr:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
173
|
+
.sr[aria-selected='true']:hover { background: var(--ab-dr-on); }
|
|
174
|
+
.pkgIc { flex: none; inline-size: 32px; block-size: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--ab-dr-card2); color: var(--ab-color-accent-text, #8b6340); }
|
|
175
|
+
.pkgIc > svg { inline-size: 20px; block-size: 20px; }
|
|
176
|
+
.srText { flex: 1 1 auto; min-inline-size: 0; }
|
|
177
|
+
.srText > b { display: block; font: 600 15px/1.3 var(--ab-font-body, 'Inter', inherit); color: var(--ab-color-text, #211a16); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
178
|
+
.srText > small { display: block; font: 400 13px/1.35 var(--ab-font-body, 'Inter', inherit); color: var(--ab-color-muted, #6b5b50); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
179
|
+
.srMeta { flex: none; font: 400 12px/1 var(--ab-font-mono, 'Roboto Mono', monospace); color: var(--ab-color-muted, #6b5b50); }
|
|
180
|
+
.mark { background: none; color: var(--ab-color-accent-text, #8b6340); font-weight: 700; } /* 🖍️ the matched part */
|
|
181
|
+
.nores { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; }
|
|
182
|
+
.nores > .pkgIc { inline-size: 56px; block-size: 56px; border-radius: 16px; }
|
|
183
|
+
.nores > .pkgIc > svg { inline-size: 28px; block-size: 28px; }
|
|
184
|
+
.nores > b { margin-top: 8px; font: 800 20px/1.2 var(--ab-font-title, 'Mulish', inherit); }
|
|
185
|
+
.nores > p { margin: 0; max-inline-size: 300px; font: 400 15px/1.5 var(--ab-font-body, 'Inter', inherit); color: var(--ab-color-muted, #6b5b50); }
|
|
186
|
+
.srOnly { position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
187
|
+
|
|
188
|
+
/* 📱 the mobile main header: 56px row, logo left, 44px globe + theme buttons right */
|
|
189
|
+
.mh { box-sizing: border-box; display: flex; align-items: center; block-size: 100%; min-block-size: 56px; padding: 0 4px 0 16px; gap: 0; background: transparent; }
|
|
190
|
+
.mh > .logoRow { flex: 1 1 auto; }
|
|
191
|
+
.ibtn { flex: none; inline-size: 44px; block-size: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--ab-color-text, #211a16); cursor: pointer; padding: 0; }
|
|
192
|
+
.ibtn > svg { inline-size: 24px; block-size: 24px; }
|
|
193
|
+
.ibtn:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
194
|
+
.ibtn:focus { outline: none; }
|
|
195
|
+
.ibtn:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
196
|
+
.verRow { display: flex; flex: none; } /* 🏷️ keeps the chip its own size */
|
|
197
|
+
|
|
198
|
+
/* 🔎 the search sheet: laptop = a fixed 70% (567px at 810) with the results scrolling inside under a 48px fade */
|
|
199
|
+
.searchSheet.searchSheet[data-center='main'] { block-size: 70%; }
|
|
200
|
+
.resWrap { position: relative; flex: 1 1 auto; min-block-size: 0; display: flex; flex-direction: column; }
|
|
201
|
+
.resFade { display: none; position: absolute; inset: auto 0 0; block-size: 48px; pointer-events: none; background: linear-gradient(transparent, var(--ab-dr-bg)); }
|
|
202
|
+
.searchSheet[data-center='main'] .resFade { display: block; }
|
|
203
|
+
.didYouMean { justify-content: center; gap: 0; margin-top: 8px; font-size: 15px; }
|
|
204
|
+
.nores code { font-family: var(--ab-font-mono, 'Roboto Mono', monospace); }
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
inset: 0; /* 📐 the whole scope */
|
|
48
48
|
z-index: 60; /* ⬆️ above the panes and the aside sheet (30) */
|
|
49
49
|
overflow: hidden; /* ✂️ a sliding panel never leaks out */
|
|
50
|
+
overflow: clip; /* ✂️ 0.2.0: clip, so nothing (focus, scrollIntoView) can scroll the layer itself */
|
|
50
51
|
pointer-events: none; /* 🖱️ idle layer = transparent to clicks */
|
|
51
52
|
contain: layout paint; /* 🚀 */
|
|
52
53
|
}
|
|
@@ -113,6 +114,44 @@
|
|
|
113
114
|
|
|
114
115
|
/* ♿ reduced motion: no slide, no fade (handled by ab-nextjs-animations .ab-motion-*) */
|
|
115
116
|
|
|
117
|
+
/* ===== 🆕 0.2.0 drawers v2 (John's frames, God 01:22) ===== */
|
|
118
|
+
/* 🥞 stacking tiers (spec z-order): right drawer < left drawer < bottom sheet. The layers are siblings in the host,
|
|
119
|
+
so the tier sits on the layer (z 60 / 61 / 62 keeps all three above the panes and bars, like before) */
|
|
120
|
+
.abDrawerLayer:has(> .abDrawerFrame[data-tier='nav']) { z-index: 61; } /* ⬅️ the left drawer is in front of the right one */
|
|
121
|
+
.abDrawerLayer:has(> .abDrawerFrame[data-tier='sheet']) { z-index: 62; } /* ⬆️ the bottom sheet is on top */
|
|
122
|
+
/* 🎞️ side drawers slide in 200ms and out 160ms, cubic-bezier(.2,0,0,1) (the ab-nextjs-animations tokens) */
|
|
123
|
+
.abDrawerFrame[data-tier] > .abDrawer:is([data-side='left'], [data-side='right'], [data-side='start'], [data-side='end']) { --ab-motion-duration: var(--ab-drawer-duration, 200ms); }
|
|
124
|
+
.abDrawerFrame[data-tier][data-state='closed'] > .abDrawer:is([data-side='left'], [data-side='right'], [data-side='start'], [data-side='end']) { --ab-motion-duration: var(--ab-drawer-close-duration, 160ms); }
|
|
125
|
+
/* 🫳 while a finger leads, the sheet follows it 1:1 (no transition); on release CSS takes over again */
|
|
126
|
+
.abDrawer.abDrawer[data-dragging] { --ab-motion-duration: 0ms; } /* ⏱️ the ab-nextjs-animations token at 0 */
|
|
127
|
+
.abDrawer[data-swipe='true']:not([data-side='bottom']) { touch-action: pan-y; } /* ↔️ sideways drags reach us, vertical scroll stays native */
|
|
128
|
+
|
|
129
|
+
/* ➖ the handle: a 40×4 bar in a 24px strip at the very top; its touch zone reaches 44px (over the header) */
|
|
130
|
+
.abDrawerHandle {
|
|
131
|
+
flex: none; position: relative; z-index: 1; display: block; box-sizing: border-box; /* 📐 */
|
|
132
|
+
inline-size: 100%; block-size: 24px; margin: 0; padding: 0; border: 0; /* 📏 */
|
|
133
|
+
background: transparent; cursor: grab; touch-action: none; /* 🤏 the drag is ours */
|
|
134
|
+
}
|
|
135
|
+
.abDrawerHandle::before { content: ''; position: absolute; inset-block-start: 10px; inset-inline-start: calc(50% - 20px); inline-size: 40px; block-size: 4px; border-radius: 2px; background: var(--ab-color-handle, rgb(25 18 12 / 0.18)); } /* ➖ the bar */
|
|
136
|
+
.abDrawerHandle::after { content: ''; position: absolute; inset: 0 0 -20px; } /* 🖐️ 24 + 20 = 44px touch zone */
|
|
137
|
+
.abDrawerHandle:focus { outline: none; }
|
|
138
|
+
.abDrawerHandle:focus-visible::before { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 4px; } /* ♿ */
|
|
139
|
+
.abDrawer[data-snap] > .abDrawerHeader { touch-action: none; } /* 🤏 the header drags the sheet too */
|
|
140
|
+
|
|
141
|
+
/* 🧲 snap points (bottom, below 768px): the sheet is full height (top at the safe-area top) and slides:
|
|
142
|
+
closed = off-screen, S1 = 70% of the app visible (JS measures --ab-drawer-partial-offset), S2 = all of it */
|
|
143
|
+
.abDrawer[data-side='bottom'][data-snap] { inset: env(safe-area-inset-top, 0px) 0 0 0; max-height: none; transform: translateY(100%); }
|
|
144
|
+
.abDrawerFrame[data-state='open'] > .abDrawer[data-snap='partial'] { transform: translateY(var(--ab-drawer-partial-offset, 30%)); } /* 🧲 S1 */
|
|
145
|
+
.abDrawerFrame[data-state='open'] > .abDrawer[data-snap='full'] { transform: none; } /* 🧲 S2 */
|
|
146
|
+
|
|
147
|
+
/* 💻 laptop (768px and up): centred in the main pane, min(640px, main width), at most 70% of the app height */
|
|
148
|
+
.abDrawer[data-side='bottom'][data-center='main'] {
|
|
149
|
+
--ab-drawer-w: min(var(--ab-drawer-max-width, 640px), var(--ab-drawer-main-width, 100%)); /* 📏 never wider than main */
|
|
150
|
+
inset: auto auto 0 calc(var(--ab-drawer-main-left, 0px) + (var(--ab-drawer-main-width, 100%) - var(--ab-drawer-w)) / 2); /* 🎯 centred */
|
|
151
|
+
inline-size: var(--ab-drawer-w); max-inline-size: none; margin: 0; /* 📏 */
|
|
152
|
+
max-block-size: 70%; /* 📏 ≤ 70% of the app (567px at 810) */
|
|
153
|
+
}
|
|
154
|
+
|
|
116
155
|
/* 🧩 D41 no-JS fallback: an in-flow section; hidden as soon as scripting runs (hydration swaps in the drawer) */
|
|
117
156
|
.abDrawerFallback { display: block; margin-block: 16px; border: var(--ab-divider-hairline, 1px solid rgb(0 0 0 / 0.12)); border-radius: 12px; }
|
|
118
157
|
.abDrawerFallback .abDrawerTitle { padding: 12px 20px 0; }
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-components
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-components
|
|
27
|
+
* @name: useAbEdgeSwipe
|
|
28
|
+
* @file: ab-drawer/use-ab-edge-swipe.ts
|
|
29
|
+
* @type: Client hook
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more 😜!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
'use client';
|
|
40
|
+
|
|
41
|
+
// ⚛️ React
|
|
42
|
+
import { useEffect, useRef } from 'react';
|
|
43
|
+
// 🤏 the pure rules
|
|
44
|
+
import { AB_SWIPE, createAbVelocityTracker, isInAbEdgeZone, isInAbHorizontalScroller, resolveAbSideRelease } from './gestures';
|
|
45
|
+
// 🗺️ the app box (same lookup AbDrawer uses)
|
|
46
|
+
import { getAbDrawerHost } from './index';
|
|
47
|
+
|
|
48
|
+
/** ⚙️ options */
|
|
49
|
+
export interface UseAbEdgeSwipeOptions {
|
|
50
|
+
edge: 'left' | 'right'; // 🧱 which edge the swipe starts from (left = left-to-right, opens the left drawer)
|
|
51
|
+
onOpen: () => void; // 🚪 called when the swipe commits
|
|
52
|
+
enabled?: boolean; // 🎚️ e.g. false while that drawer is open, or when the page has no aside (default true)
|
|
53
|
+
width?: number; // 📏 the drawer width the 30% rule uses (default 320)
|
|
54
|
+
pointerTypes?: readonly string[]; // 🖐️ default touch + pen (a mouse never edge-swipes)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 📱 iOS home-screen web app (the zone starts 16px in there)
|
|
58
|
+
const standalone = (): boolean => typeof navigator !== 'undefined' && (navigator as Navigator & { standalone?: boolean }).standalone === true;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 🤏 useAbEdgeSwipe — open a side drawer with an edge swipe (drawer spec §2 / §3):
|
|
62
|
+
* - 🧱 the press starts in a 24px zone on that edge of the app box (16px in on iOS standalone)
|
|
63
|
+
* - ↔️ it commits past 30% of the drawer width or above 0.5px/ms toward the middle; slower or shorter does nothing
|
|
64
|
+
* - 🎠 ignored inside things that scroll sideways (code blocks, carousels) and `[data-ab-no-edge-swipe]`
|
|
65
|
+
* - 🧭 a mostly vertical move is a scroll, not a swipe
|
|
66
|
+
* - 📱 iOS Safari's own back gesture starts at the very screen edge and takes the touch before the page sees it,
|
|
67
|
+
* so the two don't fight; in standalone mode the 16px inset leaves that edge to the system
|
|
68
|
+
*
|
|
69
|
+
* - 👆 touch uses touch events (non-passive touchmove only during an edge press, preventDefault only once it's
|
|
70
|
+
* sideways), so Android Chrome's pointercancel-on-pan can't swallow it
|
|
71
|
+
*
|
|
72
|
+
* The drawer opens on release (it doesn't follow the finger), then slides in with its normal 200ms motion.
|
|
73
|
+
*/
|
|
74
|
+
export function useAbEdgeSwipe({ edge, onOpen, enabled = true, width = 320, pointerTypes = ['touch', 'pen'] }: UseAbEdgeSwipeOptions): void {
|
|
75
|
+
const latest = useRef(onOpen); // 🔁 latest callback for the listener
|
|
76
|
+
useEffect(() => { latest.current = onOpen; }, [onOpen]);
|
|
77
|
+
const types = pointerTypes.join(','); // 🧮 a stable dep
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!enabled) return;
|
|
80
|
+
let d: { x: number; y: number; axis: 0 | 1 | 2; v: ReturnType<typeof createAbVelocityTracker> } | null = null; // 🫳 the current press
|
|
81
|
+
const sign = edge === 'left' ? 1 : -1; // ➡️ / ⬅️ toward the middle
|
|
82
|
+
const allow = types.split(','); // 🖐️
|
|
83
|
+
// 🧱 shared start rule (pointer or touch): from the edge zone, not in a sideways scroller / opt-out / open drawer
|
|
84
|
+
const start = (x: number, y: number, t: number, target: Element): boolean => {
|
|
85
|
+
const host = getAbDrawerHost('app', target); // 🗺️ the app box
|
|
86
|
+
const box = host === document.body ? { left: 0, right: window.innerWidth } : host.getBoundingClientRect();
|
|
87
|
+
if (!isInAbEdgeZone(x, edge, box, standalone())) return false; // 🧱 not from the edge
|
|
88
|
+
if (isInAbHorizontalScroller(target)) return false; // 🎠 (also [data-ab-no-edge-swipe])
|
|
89
|
+
if (target.closest?.('[data-ab-part="drawer"]')) return false; // 🗄️ a drawer is already up there
|
|
90
|
+
const v = createAbVelocityTracker(); v.add(x, t);
|
|
91
|
+
d = { x, y, axis: 0, v }; return true;
|
|
92
|
+
};
|
|
93
|
+
// 🧭 shared move rule; returns true while the gesture is ours (sideways)
|
|
94
|
+
const step = (x: number, y: number, t: number): boolean => {
|
|
95
|
+
if (!d || d.axis === 2) return false;
|
|
96
|
+
const dx = x - d.x; const dy = y - d.y;
|
|
97
|
+
if (d.axis === 0) {
|
|
98
|
+
if (Math.max(Math.abs(dx), Math.abs(dy)) < AB_SWIPE.slop) return false; // 🫳
|
|
99
|
+
d.axis = Math.abs(dx) > Math.abs(dy) ? 1 : 2; // 🧭 sideways = ours, vertical = the page's scroll
|
|
100
|
+
}
|
|
101
|
+
if (d.axis === 1) { d.v.add(x, t); return true; } // ⚡
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
const finish = (x: number) => {
|
|
105
|
+
const cur = d; d = null;
|
|
106
|
+
if (!cur || cur.axis !== 1) return;
|
|
107
|
+
if (resolveAbSideRelease({ distance: (x - cur.x) * sign, velocity: cur.v.velocity() * sign, width })) latest.current(); // ✅
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// 🖊️ pointer path: pen (and touch only where there are no touch events)
|
|
111
|
+
const touchy = typeof window !== 'undefined' && 'ontouchstart' in window;
|
|
112
|
+
const byPointer = (e: PointerEvent) => allow.includes(e.pointerType) && !(touchy && e.pointerType === 'touch');
|
|
113
|
+
const down = (e: PointerEvent) => { if (byPointer(e)) start(e.clientX, e.clientY, e.timeStamp, e.target as Element); };
|
|
114
|
+
const move = (e: PointerEvent) => { if (byPointer(e)) step(e.clientX, e.clientY, e.timeStamp); };
|
|
115
|
+
const up = (e: PointerEvent) => { if (byPointer(e)) finish(e.clientX); };
|
|
116
|
+
const cancel = (e: PointerEvent) => { if (byPointer(e)) d = null; }; // 🧹 the browser took it (scroll)
|
|
117
|
+
|
|
118
|
+
// 👆 touch path (Android Chrome fix): Chromium fires pointercancel as soon as it starts a native pan, so a
|
|
119
|
+
// touch swipe is read from touch events instead. A NON-passive touchmove listener is attached only while a
|
|
120
|
+
// touch that started in the edge zone is down (no scroll jank elsewhere), and it calls preventDefault only
|
|
121
|
+
// once the move is sideways. Vertical moves are never prevented, so the page still scrolls from the strip.
|
|
122
|
+
const tmove = (e: TouchEvent) => {
|
|
123
|
+
const t = e.touches[0]; if (!t) return;
|
|
124
|
+
if (step(t.clientX, t.clientY, e.timeStamp) && e.cancelable) e.preventDefault(); // 🛑 ours: keep the browser out
|
|
125
|
+
if (d?.axis === 2) detach(); // 🧭 a scroll: let go early
|
|
126
|
+
};
|
|
127
|
+
const tend = (e: TouchEvent) => { const t = e.changedTouches[0]; detach(); if (t && e.type === 'touchend') finish(t.clientX); else d = null; };
|
|
128
|
+
const attach = () => { document.addEventListener('touchmove', tmove, { capture: true, passive: false }); document.addEventListener('touchend', tend, true); document.addEventListener('touchcancel', tend, true); };
|
|
129
|
+
const detach = () => { document.removeEventListener('touchmove', tmove, true); document.removeEventListener('touchend', tend, true); document.removeEventListener('touchcancel', tend, true); };
|
|
130
|
+
const tstart = (e: TouchEvent) => {
|
|
131
|
+
if (!allow.includes('touch')) return;
|
|
132
|
+
detach(); d = null;
|
|
133
|
+
if (e.touches.length !== 1) return; // ✌️ pinch etc. are not swipes
|
|
134
|
+
const t = e.touches[0];
|
|
135
|
+
if (start(t.clientX, t.clientY, e.timeStamp, e.target as Element)) attach();
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
document.addEventListener('pointerdown', down, true); // 🎧 capture: before anything stops it
|
|
139
|
+
document.addEventListener('pointermove', move, true);
|
|
140
|
+
document.addEventListener('pointerup', up, true);
|
|
141
|
+
document.addEventListener('pointercancel', cancel, true);
|
|
142
|
+
document.addEventListener('touchstart', tstart, { capture: true, passive: true }); // 👆 passive: never delays a tap or scroll
|
|
143
|
+
return () => {
|
|
144
|
+
document.removeEventListener('pointerdown', down, true);
|
|
145
|
+
document.removeEventListener('pointermove', move, true);
|
|
146
|
+
document.removeEventListener('pointerup', up, true);
|
|
147
|
+
document.removeEventListener('pointercancel', cancel, true);
|
|
148
|
+
document.removeEventListener('touchstart', tstart, true);
|
|
149
|
+
detach();
|
|
150
|
+
};
|
|
151
|
+
}, [edge, enabled, width, types]);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 📦 default export
|
|
155
|
+
export default useAbEdgeSwipe;
|
package/ab-icon-button/index.tsx
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
*
|
|
32
32
|
* Example usage:
|
|
33
33
|
* 1+|> <AbIconButton icon="arrow_back" label={t('back')} onClick={prev} />
|
|
34
|
-
* -|> <AbIconButton icon="open_in_new" href="/
|
|
34
|
+
* -|> <AbIconButton icon="open_in_new" href="/packages" label="Open packages" /> // 🔗 link variant is named too
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
/*
|
|
@@ -32,6 +32,19 @@
|
|
|
32
32
|
* Example usage:
|
|
33
33
|
* 1+|> const { switchLocale } = useAbLocaleSwitch() // 🌍 from ab-nextjs-i18n/navigation
|
|
34
34
|
* -|> <AbLocaleSwitcher label={t('language')} current={locale} locales={[{ code: 'en', label: 'English' }, { code: 'fr', label: 'Français' }]} onSelect={switchLocale} />
|
|
35
|
+
*
|
|
36
|
+
* 🧩 0.1.15 inline, inside the mobile app drawer (John):
|
|
37
|
+
* 2+|> // a) mixed drawer: nav + theme first, LANGUAGE last under a 1px rule
|
|
38
|
+
* -|> <AbBottomDrawer open={open} onClose={close} title={t('menu')}>
|
|
39
|
+
* -|> <AbDrawerList … />{themeRow}
|
|
40
|
+
* -|> <AbLocaleSwitcher presentation="inline" divider label={t('language')} current={locale} locales={LOCALES} onSelect={switchLocale} />
|
|
41
|
+
* -|> </AbBottomDrawer>
|
|
42
|
+
* 🔁 Switching `presentation` at runtime (e.g. inline in the drawer, menu on desktop) is safe: inline and popover
|
|
43
|
+
* are separate components, so React remounts instead of reordering hooks. `AbLocaleSwitcherInline` is also exported.
|
|
44
|
+
* 3+|> // b) language only: the drawer title says it, so no uppercase label
|
|
45
|
+
* -|> <AbBottomDrawer open={open} onClose={close} title={t('language')}>
|
|
46
|
+
* -|> <AbLocaleSwitcher presentation="inline" showLabel={false} label={t('language')} current={locale} locales={LOCALES} onSelect={switchLocale} />
|
|
47
|
+
* -|> </AbBottomDrawer>
|
|
35
48
|
*/
|
|
36
49
|
|
|
37
50
|
/*
|
|
@@ -80,8 +93,17 @@ export interface AbLocaleSwitcherProps {
|
|
|
80
93
|
icon?: ReactNode; // 🖼️ override the globe
|
|
81
94
|
className?: string; // 🏷️
|
|
82
95
|
style?: CSSProperties; // 🎨
|
|
83
|
-
/** 🗄️ 0.1.14 (G56, D40): `menu` (default) = popover menu; `drawer` = AbDrawerList; `auto` = drawer below 768px, menu above
|
|
84
|
-
|
|
96
|
+
/** 🗄️ 0.1.14 (G56, D40): `menu` (default) = popover menu; `drawer` = AbDrawerList; `auto` = drawer below 768px, menu above.
|
|
97
|
+
* 🧩 0.1.15 (God 00:08): `inline` = no trigger; a labelled list of rows rendered in place, e.g. inside the app drawer on mobile */
|
|
98
|
+
presentation?: AbPresentation | 'inline';
|
|
99
|
+
/** 🏷️ 0.1.15 (John): inline only. Show the small uppercase group label (default true). Set false when the language
|
|
100
|
+
* list is the drawer's only content and the drawer title already says "Language" (the label stays the group's name) */
|
|
101
|
+
showLabel?: boolean;
|
|
102
|
+
/** ♿ 0.1.15 (God 00:37): inline only. The group's accessible name. Default: `label` (e.g. "Language"), so a visible
|
|
103
|
+
* label and the name always agree; set it when the drawer needs a fuller name (e.g. "Choose a language") */
|
|
104
|
+
ariaLabel?: string;
|
|
105
|
+
/** ➖ 0.1.15 (John): inline only. A 1px --div rule above the block, for when it follows nav / theme items (default false) */
|
|
106
|
+
divider?: boolean;
|
|
85
107
|
drawerScope?: AbDrawerScope; // 🗺️ default 'app'
|
|
86
108
|
drawerSide?: 'top' | 'bottom' | 'start' | 'end'; // 🧭 default 'bottom'
|
|
87
109
|
}
|
|
@@ -99,9 +121,48 @@ export function getAbTypeaheadIndex(labels: readonly string[], from: number, cha
|
|
|
99
121
|
return -1; // 🙅
|
|
100
122
|
}
|
|
101
123
|
|
|
124
|
+
/**
|
|
125
|
+
* 🧩 0.1.15: the inline list (no trigger, no popover), e.g. inside the mobile app drawer.
|
|
126
|
+
* Its own component (James): AbLocaleSwitcher picks this OR the popover by type, so switching `presentation`
|
|
127
|
+
* at runtime remounts instead of changing the hook order. Links mark the active row with aria-current, buttons aria-pressed.
|
|
128
|
+
*/
|
|
129
|
+
export function AbLocaleSwitcherInline(props: AbLocaleSwitcherProps) {
|
|
130
|
+
const { locales, current, label, onSelect, getHref, className, style, showLabel = true, divider = false, ariaLabel } = props;
|
|
131
|
+
const base = useId(); // 🆔
|
|
132
|
+
return (
|
|
133
|
+
<div className={clsx('AbLocaleSwitcher', styles.inline, className)} style={style} data-ab-part="locale-switcher" data-presentation="inline" data-divider={divider ? 'true' : undefined} role="group" aria-labelledby={showLabel && ariaLabel == null ? `${base}-label` : undefined} aria-label={ariaLabel ?? (showLabel ? undefined : label)}>
|
|
134
|
+
{showLabel && <div id={`${base}-label`} className={styles.inlineLabel}>{label}</div> /* 🏷️ hidden when the drawer title says it */}
|
|
135
|
+
<ul className={styles.inlineList}>
|
|
136
|
+
{locales.map((l) => {
|
|
137
|
+
const on = l.code === current; // ✅
|
|
138
|
+
const inner = (<><span className={styles.inlineText}>{l.label}</span><span className={styles.inlineCheck} aria-hidden="true">{on ? <svg viewBox="0 0 18 18" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" data-ab-part="locale-check"><path d="M3.5 9.5 7.25 13 14.5 5.5" /></svg> : null}</span></>);
|
|
139
|
+
return (
|
|
140
|
+
<li key={l.code}>
|
|
141
|
+
{getHref ? (
|
|
142
|
+
<a className={styles.inlineItem} href={getHref(l.code)} hrefLang={l.code} lang={l.code} data-active={on ? 'true' : 'false'} aria-current={on ? 'true' : undefined} onClick={() => onSelect?.(l.code)}>{inner}</a>
|
|
143
|
+
) : (
|
|
144
|
+
<button type="button" className={styles.inlineItem} lang={l.code} data-active={on ? 'true' : 'false'} aria-pressed={on} onClick={() => onSelect?.(l.code)}>{inner}</button>
|
|
145
|
+
)}
|
|
146
|
+
</li>
|
|
147
|
+
);
|
|
148
|
+
})}
|
|
149
|
+
</ul>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 🌍 AbLocaleSwitcher: `presentation="inline"` renders AbLocaleSwitcherInline, anything else the popover / drawer.
|
|
156
|
+
* 🔁 Two component types, so a runtime `presentation` change remounts cleanly (rules of hooks).
|
|
157
|
+
*/
|
|
102
158
|
export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
|
|
159
|
+
return props.presentation === 'inline' ? <AbLocaleSwitcherInline {...props} /> : <AbLocaleSwitcherPopover {...props} />;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function AbLocaleSwitcherPopover(props: AbLocaleSwitcherProps) {
|
|
103
163
|
// 🧩 props
|
|
104
|
-
const { locales, current, label, onSelect, getHref, variant = 'icon', align = 'end', icon, className, style, presentation = 'menu', drawerScope = 'app', drawerSide = 'bottom' } = props;
|
|
164
|
+
const { locales, current, label, onSelect, getHref, variant = 'icon', align = 'end', icon, className, style, presentation: rawPresentation = 'menu', drawerScope = 'app', drawerSide = 'bottom' } = props;
|
|
165
|
+
const presentation: AbPresentation = rawPresentation === 'inline' ? 'menu' : rawPresentation; // 🗄️ (never 'inline' here: see the dispatcher)
|
|
105
166
|
// 🗄️ how this open happens (decided on click)
|
|
106
167
|
const [mode, setMode] = useState<'menu' | 'drawer'>(presentation === 'drawer' ? 'drawer' : 'menu');
|
|
107
168
|
// 🚪 open?
|
|
@@ -136,3 +136,23 @@
|
|
|
136
136
|
.root > .menu { display: none; } /* 🙈 needs JS */
|
|
137
137
|
.noJs { display: block; } /* 👁️ */
|
|
138
138
|
}
|
|
139
|
+
|
|
140
|
+
/* ===== 🧩 0.1.15 (God 00:08): presentation="inline", the language list inside the mobile app drawer =====
|
|
141
|
+
* Rows match AbDrawerList / the Home drawer: 48px, 12px padding, radius 8, --tint + --accent-text + 650 when active. */
|
|
142
|
+
.inline { display: grid; gap: 4px; } /* 📐 */
|
|
143
|
+
.inlineLabel { padding: 14px 12px 6px; font-size: 11px; font-weight: 700; line-height: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ab-color-faint, #807062); } /* 🏷️ = sidebar group label */
|
|
144
|
+
.inlineList { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; } /* 📜 John: 8px between rows */
|
|
145
|
+
.inlineList > li { display: block; margin: 0; padding: 0; line-height: 0; } /* 🧹 no inherited li spacing / line box: the row is the box */
|
|
146
|
+
.inlineItem {
|
|
147
|
+
display: flex; align-items: center; gap: 12px; box-sizing: border-box; inline-size: 100%; block-size: 48px; min-block-size: 44px; /* 👆 John: exactly 48px (≥ 44px hit area) */
|
|
148
|
+
padding: 8px 12px; border: 0; border-radius: var(--ab-radius-row, 8px); background: none; /* 🧹 */
|
|
149
|
+
font: inherit; font-size: 16px; line-height: 20px; text-align: start; color: var(--ab-color-text, #211a16); text-decoration: none; cursor: pointer; /* 🔤 */
|
|
150
|
+
}
|
|
151
|
+
.inlineItem:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } /* 🖱️ */
|
|
152
|
+
.inlineItem[data-active='true'] { background: var(--ab-color-tint, #f4e7db); color: var(--ab-color-accent-text, #88603d); font-weight: 650; } /* 🎯 */
|
|
153
|
+
.inlineItem:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; } /* ♿ */
|
|
154
|
+
.inlineText { flex: 1 1 auto; min-width: 0; } /* 🏷️ */
|
|
155
|
+
.inlineCheck { flex: none; display: inline-flex; inline-size: 18px; block-size: 18px; color: var(--ab-locale-check-color, var(--ab-color-btn, #8b6340)); } /* ✓ John: bronze 2px stroke, 18px (James P2: the --ab-color-btn token) */
|
|
156
|
+
:global(.dark) .inlineCheck, :global([data-theme='dark']) .inlineCheck { color: var(--ab-locale-check-color, var(--ab-color-accent, #c29a6f)); } /* 🌙 the warm accent */
|
|
157
|
+
/* ➖ 0.1.15 (John): language goes LAST in a drawer with nav / theme items, under a 1px --div rule */
|
|
158
|
+
.inline[data-divider='true'] { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); }
|