The best way to control Claude Code, Codex and more from any computer or phone

main
astro 166 lines 4.56 KB
Raw
1 ---
2 /**
3 * Mobile product switcher — the docs tab bar's counterpart inside the
4 * hamburger drawer. Desktop hides it (the horizontal tab bar owns
5 * navigation there); on mobile the tab bar is hidden and this switcher
6 * is how you move between hubs.
7 *
8 * A disclosure (<details>), not a native <select>, so brand marks and
9 * the category headings render like the desktop dropdowns. Picking a
10 * product navigates to that hub's landing page.
11 */
12 import { DOCS_TABS, DOCS_TAB_GROUPS, activeTab, groupTabs } from "../../docs-tabs";
13 import { TAB_ICONS } from "../../docs-icons";
14
15 const current = activeTab(Astro.url.pathname);
16
17 // Same taxonomy as the desktop dropdowns (docs-tabs.ts), so a new hub
18 // lands in the right category on both without a second list to update.
19 const grouped: { heading?: string; tabs: typeof DOCS_TABS }[] = [
20 { tabs: DOCS_TABS.filter((tab) => tab.slot === "start") },
21 ...DOCS_TAB_GROUPS.map((group) => ({ heading: group.label, tabs: groupTabs(group) })),
22 { heading: "Meta", tabs: DOCS_TABS.filter((tab) => tab.slot === "end") },
23 ];
24 ---
25
26 <details class="alc-switcher">
27 <summary class="alc-switcher__current">
28 {
29 TAB_ICONS[current.label] && (
30 <svg
31 class="alc-switcher__icon"
32 aria-hidden="true"
33 width="16"
34 height="16"
35 viewBox="0 0 24 24"
36 set:html={TAB_ICONS[current.label]}
37 />
38 )
39 }
40 <span>{current.label}</span>
41 <svg
42 class="alc-switcher__chevron"
43 aria-hidden="true"
44 width="12"
45 height="12"
46 viewBox="0 0 24 24"
47 fill="none"
48 stroke="currentColor"
49 stroke-width="2"
50 stroke-linecap="round"
51 stroke-linejoin="round"
52 >
53 <path d="m6 9 6 6 6-6" />
54 </svg>
55 </summary>
56 <div class="alc-switcher__panel">
57 {
58 grouped.map((group) => (
59 <>
60 {group.heading && (
61 <div class="alc-switcher__heading">{group.heading}</div>
62 )}
63 {group.tabs.map((tab) => (
64 <a
65 href={tab.href}
66 class:list={["alc-switcher__item", { "alc-switcher__item--active": tab.label === current.label }]}
67 aria-current={tab.label === current.label ? "true" : undefined}
68 >
69 {TAB_ICONS[tab.label] && (
70 <svg
71 class="alc-switcher__icon"
72 aria-hidden="true"
73 width="15"
74 height="15"
75 viewBox="0 0 24 24"
76 set:html={TAB_ICONS[tab.label]}
77 />
78 )}
79 <span>{tab.label}</span>
80 </a>
81 ))}
82 </>
83 ))
84 }
85 </div>
86 </details>
87
88 <style>
89 /* Below 72rem only: wider viewports get the header tab bar. */
90 .alc-switcher {
91 margin: 0 0 0.75rem;
92 }
93 @media (min-width: 72rem) {
94 .alc-switcher {
95 display: none;
96 }
97 }
98 .alc-switcher__current {
99 display: flex;
100 align-items: center;
101 gap: 9px;
102 padding: 10px 13px;
103 border: 1px solid var(--alc-hairline-2);
104 border-radius: 10px;
105 font-size: var(--sl-text-base);
106 font-weight: 600;
107 color: var(--sl-color-white);
108 cursor: pointer;
109 user-select: none;
110 list-style: none;
111 }
112 .alc-switcher__current::marker,
113 .alc-switcher__current::-webkit-details-marker {
114 display: none;
115 }
116 .alc-switcher[open] .alc-switcher__current {
117 border-color: var(--alc-accent-deep);
118 }
119 .alc-switcher__icon {
120 flex-shrink: 0;
121 opacity: 0.9;
122 }
123 .alc-switcher__chevron {
124 margin-inline-start: auto;
125 color: var(--alc-fg-4);
126 transition: transform var(--alc-dur, 0.2s) var(--alc-ease, ease);
127 }
128 .alc-switcher[open] .alc-switcher__chevron {
129 transform: rotateZ(180deg);
130 }
131 .alc-switcher__panel {
132 margin-top: 6px;
133 border: 1px solid var(--alc-hairline-2);
134 border-radius: 12px;
135 background: var(--alc-bg-elev-1, var(--sl-color-bg-nav));
136 padding: 6px 0;
137 overflow: hidden;
138 }
139 .alc-switcher__heading {
140 padding: 8px 14px 3px;
141 font-size: 10.5px;
142 font-weight: 600;
143 letter-spacing: 0.07em;
144 text-transform: uppercase;
145 color: var(--alc-fg-4);
146 border-top: 1px solid var(--alc-hairline);
147 margin-top: 5px;
148 }
149 .alc-switcher__item {
150 display: flex;
151 align-items: center;
152 gap: 10px;
153 padding: 8px 14px;
154 font-size: var(--sl-text-sm);
155 color: var(--alc-fg-2);
156 text-decoration: none;
157 }
158 .alc-switcher__item:hover {
159 color: var(--alc-accent-deep);
160 }
161 .alc-switcher__item--active {
162 color: var(--alc-accent-deep);
163 font-weight: 600;
164 background: color-mix(in srgb, var(--alc-accent-deep) 10%, transparent);
165 }
166 </style>