ab-nextjs-components 0.1.13 โ 0.1.14
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 +30 -0
- package/ab-app-bar/index.tsx +39 -10
- package/ab-app-bar/styles.module.css +43 -4
- package/ab-bottom-drawer/index.tsx +71 -0
- package/ab-bottom-drawer/styles.module.css +66 -0
- package/ab-breadcrumbs/index.tsx +92 -0
- package/ab-breadcrumbs/styles.module.css +54 -0
- package/ab-button/helpers.ts +6 -1
- package/ab-button/index.tsx +8 -2
- package/ab-button/styles.module.css +39 -0
- package/ab-card/styles.module.css +1 -1
- package/ab-carousel/styles.module.css +1 -1
- package/ab-chip/index.tsx +16 -4
- package/ab-chip/styles.module.css +12 -1
- package/ab-confirm-drawer/index.tsx +97 -0
- package/ab-confirm-drawer/styles.module.css +41 -0
- package/ab-drawer/index.tsx +307 -0
- package/ab-drawer/styles.module.css +127 -0
- package/ab-drawer/use-ab-drawer.ts +89 -0
- package/ab-drawer-list/index.tsx +118 -0
- package/ab-drawer-list/styles.module.css +65 -0
- package/ab-flow-diagram/styles.module.css +2 -2
- package/ab-icon/builtin.ts +4 -0
- package/ab-icon-button/index.tsx +12 -1
- package/ab-icon-button/styles.module.css +1 -1
- package/ab-install-snippet/index.tsx +51 -29
- package/ab-install-snippet/styles.module.css +34 -2
- package/ab-kbd/styles.module.css +1 -1
- package/ab-list/index.tsx +107 -0
- package/ab-list/styles.module.css +82 -0
- package/ab-locale-switcher/index.tsx +42 -10
- package/ab-locale-switcher/styles.module.css +4 -4
- package/ab-navbar/styles.module.css +20 -2
- package/ab-navbar/view.tsx +7 -4
- package/ab-package-card/index.tsx +49 -2
- package/ab-package-card/styles.module.css +40 -0
- package/ab-search-trigger/index.tsx +17 -2
- package/ab-search-trigger/styles.module.css +27 -1
- package/ab-sidebar/index.tsx +5 -2
- package/ab-sidebar/styles.module.css +48 -5
- package/ab-sidebar/view.tsx +14 -4
- package/ab-theme-toggle/index.tsx +21 -6
- package/ab-theme-toggle/styles.module.css +18 -3
- package/ab-toc/index.tsx +9 -2
- package/ab-toc/styles.module.css +20 -8
- package/ab-version-switcher/index.tsx +143 -0
- package/ab-version-switcher/styles.module.css +76 -0
- package/index.ts +27 -0
- package/package.json +18 -3
- package/server/ab-button/index.tsx +6 -2
- package/server/ab-button/styles.module.css +39 -0
- package/types/index.d.ts +19 -0
package/ab-sidebar/index.tsx
CHANGED
|
@@ -66,6 +66,7 @@ export interface AbSidebarProps extends AbSidebarBaseProps {
|
|
|
66
66
|
defaultCollapsed?: boolean; // ๐ช uncontrolled start
|
|
67
67
|
onCollapsedChange?: (collapsed: boolean) => void; // ๐
|
|
68
68
|
collapsible?: boolean; // ๐ show the collapse button (default true when sections are given)
|
|
69
|
+
collapseButtonVariant?: 'plain' | 'outlined'; // โช 0.1.14 (P9): 'outlined' = 32ร32 bordered `<<` / `>>` (default 'plain' chevron)
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
/**
|
|
@@ -73,7 +74,8 @@ export interface AbSidebarProps extends AbSidebarBaseProps {
|
|
|
73
74
|
* tooltips, and a collapse button (aria-expanded + aria-controls; hidden when JS is off).
|
|
74
75
|
*/
|
|
75
76
|
const AbSidebar = (props: AbSidebarProps): ReactElement => {
|
|
76
|
-
const { collapsed: controlled, defaultCollapsed = false, onCollapsedChange, collapsible, activeHref, page, labels, id = 'ab-sidebar-list' } = props;
|
|
77
|
+
const { collapsed: controlled, defaultCollapsed = false, onCollapsedChange, collapsible, collapseButtonVariant = 'plain', activeHref, page, labels, id = 'ab-sidebar-list' } = props;
|
|
78
|
+
const outlined = collapseButtonVariant === 'outlined'; // โช P9
|
|
77
79
|
// ๐งญ route
|
|
78
80
|
const appLocales = useAbLocales(); // ๐ from AbLinkProvider
|
|
79
81
|
const pathname = stripAbLocalePrefix(usePathname() ?? '', props.locales ?? appLocales); // ๐งญ `/fr/docs` โ `/docs`
|
|
@@ -94,12 +96,13 @@ const AbSidebar = (props: AbSidebarProps): ReactElement => {
|
|
|
94
96
|
type="button"
|
|
95
97
|
className={styles.abSidebarToggle} // ๐ hidden under (scripting: none)
|
|
96
98
|
data-ab-part="collapse"
|
|
99
|
+
data-variant={outlined ? 'outlined' : undefined} // โช P9
|
|
97
100
|
aria-expanded={!collapsed} // โฟ
|
|
98
101
|
aria-controls={id} // โฟ
|
|
99
102
|
aria-label={toggleLabel} // ๐ท๏ธ
|
|
100
103
|
onClick={() => setCollapsed(!collapsed)}
|
|
101
104
|
>
|
|
102
|
-
<AbIcon name={collapsed ? 'chevron_right' : 'chevron_left'} size={20} />
|
|
105
|
+
<AbIcon name={outlined ? (collapsed ? 'keyboard_double_arrow_right' : 'keyboard_double_arrow_left') : collapsed ? 'chevron_right' : 'chevron_left'} size={outlined ? 18 : 20} />
|
|
103
106
|
</button>
|
|
104
107
|
) : undefined;
|
|
105
108
|
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
color: inherit; /* ๐๏ธ */
|
|
77
77
|
cursor: pointer; /* ๐ */
|
|
78
78
|
}
|
|
79
|
-
.abSidebarToggle:hover { background: color-mix(in srgb, currentColor 8%, transparent); } /* ๐ฑ๏ธ */
|
|
79
|
+
.abSidebarToggle:hover { background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); } /* ๐ฑ๏ธ */
|
|
80
80
|
.abSidebarToggle:focus-visible,
|
|
81
81
|
.abSidebarLink:focus-visible {
|
|
82
|
-
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* โฟ */
|
|
82
|
+
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); /* โฟ */
|
|
83
83
|
outline-offset: var(--ab-focus-ring-offset, 2px); /* โฟ */
|
|
84
84
|
}
|
|
85
85
|
@media (scripting: none) {
|
|
@@ -125,10 +125,10 @@
|
|
|
125
125
|
}
|
|
126
126
|
.abSidebarLabel { min-width: 0; overflow-wrap: anywhere; } /* ๐ซ no overflow, ReactNode-friendly */
|
|
127
127
|
.abSidebarLink[data-depth='1'] { padding-inline-start: 44px; font-size: 14px; } /* ๐ณ */
|
|
128
|
-
.abSidebarLink:hover { background: color-mix(in srgb, currentColor 8%, transparent); } /* ๐ฑ๏ธ */
|
|
128
|
+
.abSidebarLink:hover { background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); } /* ๐ฑ๏ธ */
|
|
129
129
|
.abSidebarLink[data-active='true'] {
|
|
130
|
-
background: var(--ab-color-secondary-container, color-mix(in srgb, #8f4c38 14%, transparent)); /* ๐ฏ */
|
|
131
|
-
color: var(--ab-color-on-secondary-container, inherit); /* ๐๏ธ */
|
|
130
|
+
background: var(--ab-color-tint, var(--ab-color-secondary-container, color-mix(in srgb, #8f4c38 14%, transparent))); /* ๐ฏ */
|
|
131
|
+
color: var(--ab-color-accent-text, var(--ab-color-on-secondary-container, inherit)); /* ๐๏ธ */
|
|
132
132
|
font-weight: 600; /* ๐ค */
|
|
133
133
|
}
|
|
134
134
|
.abSidebarIcon { flex: none; } /* ๐ฃ */
|
|
@@ -144,3 +144,46 @@
|
|
|
144
144
|
.abSidebar[data-collapsed='true'] .abSidebarLink { width: 48px; justify-content: center; padding: 0; }
|
|
145
145
|
.abSidebar[data-collapsed='true'] .abSidebarLabel,
|
|
146
146
|
.abSidebar[data-collapsed='true'] .abSidebarBadge { display: none; }
|
|
147
|
+
|
|
148
|
+
/* ===== ๐ 0.1.14 (P8/P9, Home spec ยง4 sidebar) ===== */
|
|
149
|
+
.abSidebar[data-density='compact'] { max-width: none; gap: 0; padding: 0; } /* ๐ the pane sets the width (248 / 260 / 288) */
|
|
150
|
+
.abSidebar[data-density='compact'] .abSidebarHeader { min-height: 0; padding: 12px 10px 6px 16px; } /* ๐ท๏ธ version switcher + collapse */
|
|
151
|
+
.abSidebar[data-density='compact'] .abSidebarSections { gap: 1px; padding: 4px 10px 16px; box-sizing: border-box; } /* ๐ฆ mock nav: 1px between every row and label */
|
|
152
|
+
.abSidebar[data-density='compact'] .abSidebarSection { gap: 1px; }
|
|
153
|
+
.abSidebar[data-density='compact'] .abSidebarList { gap: 1px; }
|
|
154
|
+
.abSidebar[data-density='compact'] .abSidebarHeading {
|
|
155
|
+
padding: 14px 10px 6px; font-size: 11px; font-weight: 700; line-height: 15px; letter-spacing: 0.06em; /* ๐ค 35px label row, like the mock */
|
|
156
|
+
color: var(--ab-color-faint, #807062); opacity: 1; /* ๐จ AA faint */
|
|
157
|
+
}
|
|
158
|
+
.abSidebar[data-density='compact'] .abSidebarLink {
|
|
159
|
+
gap: 10px; min-height: 0; height: 32px; padding: 0 10px; box-sizing: border-box; /* ๐ */
|
|
160
|
+
font-family: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2; letter-spacing: 0; /* ๐ค Inter body */
|
|
161
|
+
color: var(--ab-color-muted, #6b5b50); /* ๐๏ธ */
|
|
162
|
+
}
|
|
163
|
+
.abSidebar[data-density='compact'] .abSidebarLink[data-size='sm'] { height: 30px; } /* ๐ฆ packages */
|
|
164
|
+
.abSidebar[data-density='compact'] .abSidebarLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; } /* โ๏ธ one line */
|
|
165
|
+
.abSidebar[data-density='compact'] .abSidebarIcon { color: var(--ab-color-faint, #807062); } /* ๐ฃ */
|
|
166
|
+
.abSidebar[data-density='compact'] .abSidebarLink:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } /* ๐ฑ๏ธ */
|
|
167
|
+
.abSidebar[data-active-shape='rounded'] .abSidebarLink { border-radius: var(--ab-radius-row, 8px); } /* ๐ท */
|
|
168
|
+
.abSidebar[data-active-shape='rounded'] .abSidebarLink[data-active='true'] {
|
|
169
|
+
background: var(--ab-color-tint, #f4e7db); color: var(--ab-color-accent-text, #88603d); font-weight: 650; /* ๐ฏ */
|
|
170
|
+
}
|
|
171
|
+
.abSidebar[data-active-shape='rounded'] .abSidebarLink[data-active='true'] .abSidebarIcon { color: inherit; } /* ๐ฃ filled, accent */
|
|
172
|
+
.abSidebar[data-density='compact'] .abSidebarLink:focus-visible,
|
|
173
|
+
.abSidebar[data-density='compact'] .abSidebarToggle:focus-visible { outline-color: var(--ab-color-accent, #a67c52); outline-offset: -2px; } /* โฟ inside the pane */
|
|
174
|
+
.abSidebar[data-badge='text'] .abSidebarBadge {
|
|
175
|
+
padding: 0; border-radius: 0; background: none; line-height: 1; /* ๐งน no chip */
|
|
176
|
+
font: 500 10.5px var(--ab-font-code, 'Roboto Mono', ui-monospace, monospace); color: var(--ab-color-faint, #807062); /* โจ๏ธ */
|
|
177
|
+
}
|
|
178
|
+
/* โฟ James: faint on --tint is 3.9:1, so on the active row the text badge takes the row's --accent-text (โฅ 4.5:1 on tint) */
|
|
179
|
+
.abSidebar[data-badge='text'] .abSidebarLink[data-active='true'] .abSidebarBadge { color: inherit; }
|
|
180
|
+
/* โช P9: outlined collapse, 32ร32, radius 8, 1px --border, --card, --muted */
|
|
181
|
+
.abSidebarToggle[data-variant='outlined'] {
|
|
182
|
+
width: 32px; height: 32px; box-sizing: border-box; flex: none; /* ๐ */
|
|
183
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-row, 8px); /* ๐ฒ */
|
|
184
|
+
background: var(--ab-color-card, #fff); color: var(--ab-color-muted, #6b5b50); /* ๐จ */
|
|
185
|
+
}
|
|
186
|
+
.abSidebarToggle[data-variant='outlined']:hover { background: linear-gradient(var(--ab-color-hover, rgb(166 124 82 / 0.08)), var(--ab-color-hover, rgb(166 124 82 / 0.08))), var(--ab-color-card, #fff); } /* ๐ฑ๏ธ */
|
|
187
|
+
.abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarHeader { padding: 12px 0 6px; justify-content: center; } /* ๐ช rail */
|
|
188
|
+
.abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarSections { padding-inline: 8px; }
|
|
189
|
+
.abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarLink { width: 40px; height: 40px; } /* ๐ */
|
package/ab-sidebar/view.tsx
CHANGED
|
@@ -63,6 +63,7 @@ export interface AbSidebarSection {
|
|
|
63
63
|
id: string; // ๐
|
|
64
64
|
label?: string; // ๐ท๏ธ heading (omit for an unlabelled group)
|
|
65
65
|
items: AbSidebarItem[]; // ๐
|
|
66
|
+
itemSize?: 'md' | 'sm'; // ๐ 0.1.14 (P8): 'sm' = 30px rows + 16px icons (the Home PACKAGES group)
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/** ๐ฐ๏ธ Legacy (โค 0.1.12) link shape; still accepted via `links`. */
|
|
@@ -93,6 +94,10 @@ export interface AbSidebarBaseProps {
|
|
|
93
94
|
header?: ReactNode; // ๐ท๏ธ top slot (brand, workspace switcherโฆ)
|
|
94
95
|
labels?: AbSidebarLabels; // ๐
|
|
95
96
|
locales?: readonly string[]; // ๐ 0.1.13: stripped from the pathname (default: AbLinkProvider's)
|
|
97
|
+
// ๐ 0.1.14 (P8, Home spec ยง4 sidebar)
|
|
98
|
+
density?: 'comfortable' | 'compact'; // ๐ 'compact' = 32px rows, 13.5/500, 18px icons, 11px group labels
|
|
99
|
+
activeShape?: 'pill' | 'rounded'; // ๐ท 'rounded' = 8px-radius --tint row (default 'pill')
|
|
100
|
+
badgeVariant?: 'chip' | 'text'; // ๐ท๏ธ 'text' = plain mono 10.5 --faint meta (e.g. a version), no chip
|
|
96
101
|
// ๐ฐ๏ธ legacy API (โค 0.1.12)
|
|
97
102
|
type?: 'customer' | 'admin';
|
|
98
103
|
page?: string;
|
|
@@ -121,13 +126,14 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
|
|
|
121
126
|
active: (href: string, legacyValue?: string) => boolean;
|
|
122
127
|
toggle?: ReactNode;
|
|
123
128
|
}): ReactElement {
|
|
124
|
-
const { className, id = 'ab-sidebar-list', sections, collapsed = false, header, labels, type = 'customer', links, brandHref = '/', brandLabel = 'abElements' } = props;
|
|
129
|
+
const { className, id = 'ab-sidebar-list', sections, collapsed = false, header, labels, type = 'customer', links, brandHref = '/', brandLabel = 'abElements', density = 'comfortable', activeShape = 'pill', badgeVariant = 'chip' } = props;
|
|
130
|
+
const compact = density === 'compact'; // ๐ P8
|
|
125
131
|
const groups = toAbSidebarSections(sections, links); // ๐๏ธ
|
|
126
132
|
// ๐ฐ๏ธ legacy value lookup (page === link.value)
|
|
127
133
|
const valueOf = (href: string) => links?.find((l) => l.href === href)?.value;
|
|
128
134
|
|
|
129
135
|
// ๐ one item (+ children)
|
|
130
|
-
const renderItem = (item: AbSidebarItem, depth: number): ReactElement => {
|
|
136
|
+
const renderItem = (item: AbSidebarItem, depth: number, small = false): ReactElement => {
|
|
131
137
|
const on = active(item.href, valueOf(item.href)); // ๐ฏ
|
|
132
138
|
const text = item.labelText ?? (typeof item.label === 'string' ? item.label : undefined); // โฟ plain name
|
|
133
139
|
const link = (
|
|
@@ -137,10 +143,11 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
|
|
|
137
143
|
data-ab-part="item"
|
|
138
144
|
data-active={on ? 'true' : 'false'}
|
|
139
145
|
data-depth={depth}
|
|
146
|
+
data-size={small ? 'sm' : undefined} // ๐ P8
|
|
140
147
|
aria-current={on ? 'page' : undefined} // โฟ
|
|
141
148
|
aria-label={collapsed ? text : undefined} // โฟ rail: the label is visually hidden
|
|
142
149
|
>
|
|
143
|
-
{item.icon && <Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={20} className={styles.abSidebarIcon} />}
|
|
150
|
+
{item.icon && <Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={compact ? (small ? 16 : 18) : 20} className={styles.abSidebarIcon} />}
|
|
144
151
|
<span className={styles.abSidebarLabel}>{item.label}</span>
|
|
145
152
|
{item.badge != null && <span className={styles.abSidebarBadge} data-ab-part="badge">{item.badge}</span>}
|
|
146
153
|
</Link>
|
|
@@ -162,6 +169,9 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
|
|
|
162
169
|
data-ab-part={collapsed ? 'rail' : 'sidebar'} // ๐งฉ
|
|
163
170
|
data-collapsed={collapsed ? 'true' : 'false'} // ๐ช
|
|
164
171
|
className={clsx('AbSidebar', styles.abSidebar, className)} // ๐ท๏ธ
|
|
172
|
+
data-density={compact ? 'compact' : undefined} // ๐ P8
|
|
173
|
+
data-active-shape={activeShape === 'rounded' ? 'rounded' : undefined} // ๐ท P8
|
|
174
|
+
data-badge={badgeVariant === 'text' ? 'text' : undefined} // ๐ท๏ธ P8
|
|
165
175
|
aria-label={labels?.nav ?? 'Sidebar'} // โฟ
|
|
166
176
|
>
|
|
167
177
|
{/* ๐ท๏ธ header slot, or the legacy brand link */}
|
|
@@ -173,7 +183,7 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
|
|
|
173
183
|
{groups.map((g) => (
|
|
174
184
|
<section key={g.id} className={styles.abSidebarSection} data-ab-part="section" aria-labelledby={g.label ? `${id}-${g.id}` : undefined}>
|
|
175
185
|
{g.label && <h2 id={`${id}-${g.id}`} className={styles.abSidebarHeading}>{g.label}</h2>}
|
|
176
|
-
<ul className={styles.abSidebarList}>{g.items.map((it) => renderItem(it, 0))}</ul>
|
|
186
|
+
<ul className={styles.abSidebarList}>{g.items.map((it) => renderItem(it, 0, g.itemSize === 'sm'))}</ul>
|
|
177
187
|
</section>
|
|
178
188
|
))}
|
|
179
189
|
</div>
|
|
@@ -64,6 +64,9 @@ export interface AbThemeToggleLabels {
|
|
|
64
64
|
light: string; // ๐ "Light"
|
|
65
65
|
dark: string; // ๐ "Dark"
|
|
66
66
|
system: string; // ๐ฅ๏ธ "System"
|
|
67
|
+
// ๐ฏ 0.1.14 (John): action names for the icon button when it shows the target mode,
|
|
68
|
+
// e.g. { dark: 'Switch to dark theme', light: 'Switch to light theme' }. Falls back to "Theme: Dark"
|
|
69
|
+
switchTo?: Partial<Record<AbThemeMode, string>>;
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
// โ๏ธ props
|
|
@@ -76,6 +79,10 @@ export interface AbThemeToggleProps {
|
|
|
76
79
|
defaultMode?: AbThemeMode; // ๐ฑ before hydration (default 'light')
|
|
77
80
|
icons?: Partial<Record<AbThemeMode, ReactNode>>; // ๐ผ๏ธ override glyphs
|
|
78
81
|
size?: 'sm' | 'md'; // ๐ sm = 32px, md = 40px segments (hit area โฅ 24px either way)
|
|
82
|
+
appearance?: 'fill' | 'thumb'; // ๐ 0.1.14 (P7): 'thumb' = the Home pill (28px segments, raised card thumb, filled active glyph). Default 'fill'
|
|
83
|
+
// ๐ฏ 0.1.14 (John): icon variant only. 'target' = glyph + name of the mode a click switches TO
|
|
84
|
+
// (moon in light, sun in dark, like the Home mock). Default 'target' with appearance="thumb", else 'current' (unchanged)
|
|
85
|
+
iconShows?: 'current' | 'target';
|
|
79
86
|
className?: string; // ๐ท๏ธ
|
|
80
87
|
style?: CSSProperties; // ๐จ
|
|
81
88
|
}
|
|
@@ -100,7 +107,8 @@ export function getNextAbThemeMode(modes: readonly AbThemeMode[], current: AbThe
|
|
|
100
107
|
|
|
101
108
|
export function AbThemeToggle(props: AbThemeToggleProps) {
|
|
102
109
|
// ๐งฉ props
|
|
103
|
-
const { labels, variant = 'segmented', modes = AB_THEME_MODES, value, onChange, defaultMode = 'light', icons, size = 'md', className, style } = props;
|
|
110
|
+
const { labels, variant = 'segmented', modes = AB_THEME_MODES, value, onChange, defaultMode = 'light', icons, size = 'md', appearance = 'fill', iconShows, className, style } = props;
|
|
111
|
+
const thumb = appearance === 'thumb'; // ๐ P7
|
|
104
112
|
// ๐ engine: persists + applies to <html>
|
|
105
113
|
const engine = useAbThemeMode(defaultMode);
|
|
106
114
|
// ๐๏ธ controlled or engine-driven
|
|
@@ -115,11 +123,15 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
|
|
|
115
123
|
};
|
|
116
124
|
|
|
117
125
|
// ๐ผ๏ธ glyph for a mode (decorative: the label names it)
|
|
118
|
-
|
|
126
|
+
// P7 thumb: 17px (segments) / 22px (mobile icon), filled while active (spec ยง2 icons)
|
|
127
|
+
const glyph = (mode: AbThemeMode, active = false) =>
|
|
128
|
+
icons?.[mode] ?? <AbIcon name={DEFAULT_ICON_NAMES[mode]} size={thumb ? (variant === 'icon' ? 22 : 17) : 20} variant={thumb && active ? 'filled' : undefined} />;
|
|
119
129
|
|
|
120
130
|
// ๐ single cycling button variant
|
|
121
131
|
if (variant === 'icon') {
|
|
122
132
|
const next = modes[(Math.max(0, modes.indexOf(current)) + 1) % modes.length]; // โญ๏ธ
|
|
133
|
+
const target = (iconShows ?? (thumb ? 'target' : 'current')) === 'target'; // ๐ฏ John: Home mock shows the target
|
|
134
|
+
const name = target ? (labels.switchTo?.[next] ?? `${labels.group}: ${labels[next]}`) : `${labels.group}: ${labels[current]}`; // โฟ
|
|
123
135
|
return (
|
|
124
136
|
<button
|
|
125
137
|
type="button" // ๐งพ
|
|
@@ -128,11 +140,13 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
|
|
|
128
140
|
data-ab-part="theme-toggle" // ๐๏ธ
|
|
129
141
|
data-mode={current} // ๐๏ธ
|
|
130
142
|
data-size={size} // ๐
|
|
131
|
-
|
|
132
|
-
|
|
143
|
+
data-appearance={thumb ? 'thumb' : undefined} // ๐ P7
|
|
144
|
+
data-shows={target ? 'target' : 'current'} // ๐ฏ
|
|
145
|
+
aria-label={name} // โฟ "Switch to dark theme" (target) / "Theme: Dark" (current)
|
|
146
|
+
title={name} // ๐ฌ
|
|
133
147
|
onClick={() => select(next)} // ๐
|
|
134
148
|
>
|
|
135
|
-
<span aria-hidden="true">{glyph(current)}</span>
|
|
149
|
+
<span aria-hidden="true">{glyph(target ? next : current)}</span>
|
|
136
150
|
</button>
|
|
137
151
|
);
|
|
138
152
|
}
|
|
@@ -157,6 +171,7 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
|
|
|
157
171
|
data-ab-part="theme-toggle" // ๐๏ธ
|
|
158
172
|
data-mode={current} // ๐๏ธ
|
|
159
173
|
data-size={size} // ๐
|
|
174
|
+
data-appearance={thumb ? 'thumb' : undefined} // ๐ P7
|
|
160
175
|
onKeyDown={onKeyDown} // โจ๏ธ
|
|
161
176
|
>
|
|
162
177
|
{modes.map((mode, i) => {
|
|
@@ -176,7 +191,7 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
|
|
|
176
191
|
data-mode={mode} // ๐๏ธ
|
|
177
192
|
onClick={() => select(mode)} // ๐ฑ๏ธ
|
|
178
193
|
>
|
|
179
|
-
<span aria-hidden="true">{glyph(mode)}</span>
|
|
194
|
+
<span aria-hidden="true">{glyph(mode, checked)}</span>
|
|
180
195
|
</button>
|
|
181
196
|
);
|
|
182
197
|
})}
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
gap: 2px; /* ๐งฑ */
|
|
43
43
|
padding: 3px; /* ๐งฑ */
|
|
44
44
|
border-radius: 9999px; /* ๐ */
|
|
45
|
-
border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* ๐๏ธ */
|
|
45
|
+
border: 1px solid var(--ab-color-border, var(--ab-color-outline-variant, rgb(0 0 0 / 0.12))); /* ๐๏ธ */
|
|
46
46
|
background: var(--ab-color-surface-container, transparent); /* ๐จ */
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -76,14 +76,29 @@
|
|
|
76
76
|
/* ๐ฑ๏ธ hover (unselected only) */
|
|
77
77
|
.segment[aria-checked='false']:hover,
|
|
78
78
|
.icon:hover {
|
|
79
|
-
background: color-mix(in srgb, currentColor 10%, transparent); /* ๐ซ๏ธ */
|
|
79
|
+
background: var(--ab-color-hover, color-mix(in srgb, currentColor 10%, transparent)); /* ๐ซ๏ธ */
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/* โฟ visible focus ring (theme token, G18) */
|
|
83
83
|
.segment:focus-visible,
|
|
84
84
|
.icon:focus-visible {
|
|
85
|
-
outline: 2px solid var(--ab-focus-ring, var(--ab-color-primary, #A67C52)); /* ๐ */
|
|
85
|
+
outline: 2px solid var(--ab-color-accent, var(--ab-focus-ring, var(--ab-color-primary, #A67C52))); /* ๐ */
|
|
86
86
|
outline-offset: 2px; /* โ๏ธ */
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/* ๐ง reduced motion: handled by ab-nextjs-animations (.ab-motion-colors) */
|
|
90
|
+
|
|
91
|
+
/* ===== ๐ 0.1.14 (P7, Home spec ยง4): appearance="thumb" ===== */
|
|
92
|
+
.group[data-appearance='thumb'] {
|
|
93
|
+
gap: 2px; padding: 3px; border-radius: var(--ab-radius-pill, 999px); /* ๐ */
|
|
94
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); background: var(--ab-color-card2, #fbf3ec); /* ๐จ */
|
|
95
|
+
}
|
|
96
|
+
.group[data-appearance='thumb'] .segment { width: 28px; height: 28px; color: var(--ab-color-faint, #807062); } /* ๐ โฅ 24px target */
|
|
97
|
+
.group[data-appearance='thumb'] .segment[aria-checked='true'] {
|
|
98
|
+
background: var(--ab-color-thumb, #fff); color: var(--ab-color-accent-text, #88603d); /* ๐ dark thumb #3a2b1f (theme) */
|
|
99
|
+
box-shadow: var(--ab-shadow-thumb, 0 1px 3px rgb(33 26 22 / 0.12)); /* โจ */
|
|
100
|
+
}
|
|
101
|
+
.group[data-appearance='thumb'] .segment[aria-checked='false']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } /* ๐ฑ๏ธ */
|
|
102
|
+
.group[data-appearance='thumb'] .segment:focus-visible, .icon[data-appearance='thumb']:focus-visible { outline-color: var(--ab-color-accent, #a67c52); } /* โฟ */
|
|
103
|
+
.icon[data-appearance='thumb'] { width: 40px; height: 40px; border-radius: var(--ab-radius-button, 10px); color: var(--ab-color-muted, #6b5b50); } /* ๐ฑ mobile 40ร40, 22px glyph */
|
|
104
|
+
.icon[data-appearance='thumb']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
package/ab-toc/index.tsx
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
47
|
// โ๏ธ React
|
|
48
|
-
import type { ReactElement } from 'react';
|
|
48
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
49
49
|
// ๐งต classes
|
|
50
50
|
import clsx from 'clsx';
|
|
51
51
|
// ๐จ styles
|
|
@@ -84,6 +84,7 @@ export interface AbTocProps {
|
|
|
84
84
|
onNavigate?: (id: string) => void; // ๐ e.g. scrollToAbSection(id, { container }) (hooks 0.1.7); without it a plain #id jump, which scrolls the nearest scroller (the main pane in core 0.1.6 panes)
|
|
85
85
|
id?: string; // ๐ root id (default "ab-toc"); the title gets `${id}-title`
|
|
86
86
|
className?: string; // ๐ท๏ธ
|
|
87
|
+
footer?: ReactNode; // ๐งฉ 0.1.14 (P14): below the list after a 1px rule (Edit this page ยท Changelog ยท a promo card); links get the 12.5px Home style
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
/**
|
|
@@ -91,7 +92,7 @@ export interface AbTocProps {
|
|
|
91
92
|
* aria-current="location". Pair with `useAbScrollSpy` from ab-nextjs-hooks 0.1.7 for `activeId`.
|
|
92
93
|
* No hooks here, so it also renders on the server.
|
|
93
94
|
*/
|
|
94
|
-
const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavigate, id = 'ab-toc', className }: AbTocProps): ReactElement | null => {
|
|
95
|
+
const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavigate, id = 'ab-toc', className, footer }: AbTocProps): ReactElement | null => {
|
|
95
96
|
if (!items.length) return null; // ๐ nothing to list
|
|
96
97
|
const headingId = `${id}-title`; // ๐
|
|
97
98
|
return (
|
|
@@ -115,6 +116,12 @@ const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavi
|
|
|
115
116
|
);
|
|
116
117
|
})}
|
|
117
118
|
</ol>
|
|
119
|
+
{footer != null && (
|
|
120
|
+
<>
|
|
121
|
+
<hr className={styles.abTocSep} />{/* โ mock .toc-sep */}
|
|
122
|
+
<div className={styles.abTocFooter} data-ab-part="toc-footer">{footer}</div>
|
|
123
|
+
</>
|
|
124
|
+
)}
|
|
118
125
|
</nav>
|
|
119
126
|
);
|
|
120
127
|
};
|
package/ab-toc/styles.module.css
CHANGED
|
@@ -36,19 +36,31 @@
|
|
|
36
36
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.
|
|
39
|
+
/* ๐ 0.1.14 (P14 + token move): the Home TOC (spec ยง4), on the theme 0.3.5 tokens, M3 fallbacks kept */
|
|
40
|
+
.abToc { font-size: 13px; } /* ๐ */
|
|
41
|
+
.abTocTitle { margin: 0 0 10px; font-size: 11px; font-weight: 700; line-height: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ab-color-faint, var(--ab-color-on-surface-variant, inherit)); } /* ๐ท๏ธ "ON THIS PAGE" */
|
|
42
|
+
.abTocList { list-style: none; margin: 0; padding: 0; border-inline-start: 1px solid var(--ab-color-div, rgb(0 0 0 / 0.12)); } /* โ rail */
|
|
42
43
|
.abTocList > li[data-level='3'] { padding-inline-start: 12px; } /* ๐ */
|
|
43
44
|
.abTocList > li[data-level='4'] { padding-inline-start: 24px; } /* ๐ */
|
|
44
45
|
.abTocLink {
|
|
45
46
|
display: block; /* ๐ */
|
|
46
47
|
margin-inline-start: -1px; /* โ sit on the rail */
|
|
47
|
-
padding:
|
|
48
|
+
padding: 6px 0 6px 14px; /* ๐ฆ mock */
|
|
49
|
+
line-height: 18px; /* ๐ 30px rows (WebKit-measured against the mock) */
|
|
48
50
|
border-inline-start: 2px solid transparent; /* โ */
|
|
49
|
-
color: var(--ab-color-on-surface-variant, inherit); /* ๐๏ธ */
|
|
51
|
+
color: var(--ab-color-muted, var(--ab-color-on-surface-variant, inherit)); /* ๐๏ธ */
|
|
50
52
|
text-decoration: none; /* ๐ซ */
|
|
51
53
|
}
|
|
52
|
-
.abTocLink:hover { color: var(--ab-color-on-surface, inherit); } /* ๐ฑ๏ธ */
|
|
53
|
-
.abTocLink[data-active='true'] { border-inline-start-color: var(--ab-color-primary, currentColor); color: var(--ab-color-primary, inherit); font-weight:
|
|
54
|
-
.abTocLink:focus-visible { outline: var(--ab-
|
|
54
|
+
.abTocLink:hover { color: var(--ab-color-text, var(--ab-color-on-surface, inherit)); } /* ๐ฑ๏ธ */
|
|
55
|
+
.abTocLink[data-active='true'] { border-inline-start-color: var(--ab-color-accent, var(--ab-color-primary, currentColor)); color: var(--ab-color-accent-text, var(--ab-color-primary, inherit)); font-weight: 650; } /* ๐ฏ */
|
|
56
|
+
.abTocLink:focus-visible { outline: 2px solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); outline-offset: -2px; } /* โฟ */
|
|
57
|
+
/* ๐งฉ P14 footer */
|
|
58
|
+
.abTocSep { height: 1px; margin: 18px 0 12px; border: 0; background: var(--ab-color-div, rgb(0 0 0 / 0.12)); } /* โ */
|
|
59
|
+
.abTocFooter > a, .abTocFooter > p > a, .abTocFooter > ul > li > a {
|
|
60
|
+
display: flex; align-items: center; gap: 8px; padding: 5px 0; /* ๐ */
|
|
61
|
+
font-size: 12.5px; line-height: 17px; color: var(--ab-color-muted, inherit); text-decoration: none; /* ๐ค 27px rows */
|
|
62
|
+
}
|
|
63
|
+
.abTocFooter a:hover { color: var(--ab-color-accent-text, inherit); } /* ๐ฑ๏ธ */
|
|
64
|
+
.abTocFooter a:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; border-radius: 4px; } /* โฟ */
|
|
65
|
+
.abTocFooter a svg { flex: none; width: 15px; height: 15px; color: var(--ab-color-faint, inherit); } /* ๐ฃ GitHub ยท north_east */
|
|
66
|
+
.abTocFooter > ul { list-style: none; margin: 0; padding: 0; }
|
|
@@ -0,0 +1,143 @@
|
|
|
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: AbVersionSwitcher (P9)
|
|
28
|
+
* @file: ab-version-switcher/index.tsx
|
|
29
|
+
* @type: Client component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbVersionSwitcher label="Docs" version="v0.2.x" versions={[{ value: "v0.2.x", href: "/docs" }, { value: "v0.1.x", href: "/v0.1/docs" }]} />
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
* MOTTO: We'll always do more ๐!!!
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
'use client';
|
|
44
|
+
|
|
45
|
+
// โ๏ธ React
|
|
46
|
+
import { useEffect, useId, useRef, useState, type ReactElement } from 'react';
|
|
47
|
+
// ๐งต classes
|
|
48
|
+
import clsx from 'clsx';
|
|
49
|
+
// ๐ฃ icons
|
|
50
|
+
import AbIcon from '../ab-icon';
|
|
51
|
+
// ๐ the menu it opens (spec ยง5: "opens AbMenu")
|
|
52
|
+
import AbMenu from '../ab-menu';
|
|
53
|
+
// ๐จ styles
|
|
54
|
+
import styles from './styles.module.css';
|
|
55
|
+
|
|
56
|
+
/** ๐ท๏ธ one version */
|
|
57
|
+
export interface AbVersionOption {
|
|
58
|
+
value: string; // ๐ e.g. 'v0.2.x'
|
|
59
|
+
label?: string; // ๐ท๏ธ menu text (default: value)
|
|
60
|
+
href?: string; // ๐ real navigation (works without JS via the <details> fallback)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** โ๏ธ props */
|
|
64
|
+
export interface AbVersionSwitcherProps {
|
|
65
|
+
label?: string; // ๐ท๏ธ default "Docs"
|
|
66
|
+
version: string; // โ
current version (shown bold), e.g. 'v0.2.x'
|
|
67
|
+
versions?: readonly AbVersionOption[]; // ๐ the choices (none / one = a static label, no menu)
|
|
68
|
+
onSelect?: (value: string) => void; // ๐ฃ button items
|
|
69
|
+
menuLabel?: string; // โฟ accessible name of the trigger (default "{label} {version}": contains the visible text, WCAG 2.5.3)
|
|
70
|
+
className?: string; // ๐ท๏ธ
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* ๐ท๏ธ AbVersionSwitcher (P9): the sidebar's "Docs **v0.2.x** โพ" control. 28px, 8px radius, hairline border,
|
|
75
|
+
* card background, 16px `expand_more`; opens an AbMenu below it (Escape / outside click close, focus returns).
|
|
76
|
+
* JS off: with `href`s it's a native `<details>` list of links.
|
|
77
|
+
*/
|
|
78
|
+
const AbVersionSwitcher = ({ label = 'Docs', version, versions = [], onSelect, menuLabel, className }: AbVersionSwitcherProps): ReactElement => {
|
|
79
|
+
const [open, setOpen] = useState(false); // ๐ช
|
|
80
|
+
const menuId = `ab-version-menu-${useId().replace(/:/g, '')}`; // ๐
|
|
81
|
+
const wrap = useRef<HTMLDivElement>(null); // ๐
|
|
82
|
+
const btn = useRef<HTMLButtonElement>(null); // ๐
|
|
83
|
+
const name = menuLabel ?? `${label} ${version}`; // โฟ WCAG 2.5.3 label-in-name (James)
|
|
84
|
+
const hasMenu = versions.length > 1; // ๐
|
|
85
|
+
|
|
86
|
+
// โ Escape + outside click close it
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!open) return;
|
|
89
|
+
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') { setOpen(false); btn.current?.focus(); } }; // โ + โฉ๏ธ
|
|
90
|
+
const onDown = (e: PointerEvent) => { if (!wrap.current?.contains(e.target as Node)) setOpen(false); }; // ๐
|
|
91
|
+
document.addEventListener('keydown', onKey);
|
|
92
|
+
document.addEventListener('pointerdown', onDown);
|
|
93
|
+
return () => { document.removeEventListener('keydown', onKey); document.removeEventListener('pointerdown', onDown); };
|
|
94
|
+
}, [open]);
|
|
95
|
+
|
|
96
|
+
// ๐งฑ the visible face (same for button, static label and no-JS summary)
|
|
97
|
+
const face = (
|
|
98
|
+
<>
|
|
99
|
+
<span>{label}</span> <b className={styles.abVersionValue}>{version}</b>
|
|
100
|
+
{hasMenu && <AbIcon name="expand_more" size={16} className={styles.abVersionIcon} />}
|
|
101
|
+
</>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (!hasMenu) return <span className={clsx('AbVersionSwitcher', styles.abVersion, className)} data-ab-part="version-switcher">{face}</span>; // ๐ท๏ธ static
|
|
105
|
+
|
|
106
|
+
const linksOnly = versions.every((v) => v.href); // ๐ can it work without JS?
|
|
107
|
+
return (
|
|
108
|
+
<div ref={wrap} className={clsx('AbVersionSwitcher', styles.abVersionRoot, className)} data-ab-part="version-switcher">
|
|
109
|
+
<button
|
|
110
|
+
ref={btn}
|
|
111
|
+
type="button"
|
|
112
|
+
className={clsx(styles.abVersion, linksOnly && styles.abVersionJs)}
|
|
113
|
+
aria-label={name}
|
|
114
|
+
aria-haspopup="menu"
|
|
115
|
+
aria-expanded={open}
|
|
116
|
+
aria-controls={menuId}
|
|
117
|
+
onClick={() => setOpen((o) => !o)}
|
|
118
|
+
>
|
|
119
|
+
{face}
|
|
120
|
+
</button>
|
|
121
|
+
<AbMenu
|
|
122
|
+
id={menuId}
|
|
123
|
+
hidden={!open}
|
|
124
|
+
isActive={open}
|
|
125
|
+
className={styles.abVersionMenu}
|
|
126
|
+
items={versions.map((v) => ({ id: v.value, label: v.label ?? v.value, href: v.href, selected: v.value === version, onClick: () => { onSelect?.(v.value); setOpen(false); } }))}
|
|
127
|
+
/>
|
|
128
|
+
{/* ๐ซ JS off: a native <details> of links (CSS shows it only under scripting: none) */}
|
|
129
|
+
{linksOnly && (
|
|
130
|
+
<details className={styles.abVersionNoJs} data-ab-part="version-switcher-nojs">
|
|
131
|
+
<summary className={styles.abVersion} aria-label={name}>{face}</summary>
|
|
132
|
+
<ul className={styles.abVersionNoJsList}>
|
|
133
|
+
{versions.map((v) => <li key={v.value}><a href={v.href} aria-current={v.value === version ? 'page' : undefined}>{v.label ?? v.value}</a></li>)}
|
|
134
|
+
</ul>
|
|
135
|
+
</details>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// ๐ฆ exports
|
|
142
|
+
export default AbVersionSwitcher;
|
|
143
|
+
export { AbVersionSwitcher };
|
|
@@ -0,0 +1,76 @@
|
|
|
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: AbVersionSwitcher styles
|
|
28
|
+
* @file: ab-version-switcher/styles.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
|
+
/* ๐๏ธ knobs (defaults = the approved mock, mapped onto today's theme tokens) */
|
|
41
|
+
.abVersion, .abVersionRoot {
|
|
42
|
+
--ab-version-height: 28px; /* ๐ */
|
|
43
|
+
--ab-version-radius: 8px; /* โญ */
|
|
44
|
+
--ab-version-background: var(--ab-color-card, var(--md-sys-color-surface-container-lowest, #fff)); /* ๐จ --card */
|
|
45
|
+
--ab-version-border: var(--ab-color-border, var(--ab-color-outline-variant, rgb(92 64 48 / 0.13))); /* โ --border */
|
|
46
|
+
--ab-version-color: var(--ab-color-muted, var(--ab-color-on-surface-variant, #6b5b50)); /* ๐๏ธ --muted */
|
|
47
|
+
--ab-version-strong: var(--ab-color-text, var(--ab-color-on-surface, #211a16)); /* ๐๏ธ --text */
|
|
48
|
+
--ab-version-hover: var(--ab-color-hover, color-mix(in srgb, var(--ab-color-bronze, #a67c52) 8%, transparent)); /* ๐ฑ๏ธ --hover */
|
|
49
|
+
--ab-version-ring: var(--ab-color-accent, var(--ab-color-bronze, #a67c52)); /* โฟ --accent */
|
|
50
|
+
}
|
|
51
|
+
.abVersionRoot { position: relative; display: inline-block; } /* ๐ menu anchor */
|
|
52
|
+
.abVersion {
|
|
53
|
+
display: inline-flex; align-items: center; gap: 4px; /* ๐ */
|
|
54
|
+
box-sizing: border-box; height: var(--ab-version-height); padding: 0 6px 0 10px; /* ๐ฆ */
|
|
55
|
+
border: 1px solid var(--ab-version-border); border-radius: var(--ab-version-radius); /* โ */
|
|
56
|
+
background: var(--ab-version-background); color: var(--ab-version-color); /* ๐จ */
|
|
57
|
+
font: inherit; font-size: 12px; line-height: 1; white-space: nowrap; /* ๐ค */
|
|
58
|
+
cursor: pointer; list-style: none; /* ๐ฑ๏ธ (summary: no marker) */
|
|
59
|
+
}
|
|
60
|
+
.abVersion::-webkit-details-marker { display: none; } /* ๐งน */
|
|
61
|
+
span.abVersion { cursor: default; } /* ๐ท๏ธ static */
|
|
62
|
+
.abVersion:hover { background: linear-gradient(var(--ab-version-hover), var(--ab-version-hover)), var(--ab-version-background); } /* ๐ฑ๏ธ */
|
|
63
|
+
.abVersion:focus-visible { outline: 2px solid var(--ab-version-ring); outline-offset: 2px; } /* โฟ */
|
|
64
|
+
.abVersionValue { color: var(--ab-version-strong); font-weight: 650; } /* ๐ช */
|
|
65
|
+
.abVersionIcon { width: 16px; height: 16px; } /* โพ */
|
|
66
|
+
.abVersionMenu[hidden] { display: none; } /* ๐ AbMenu's own display would beat [hidden] */
|
|
67
|
+
.abVersionMenu { position: absolute; inset-block-start: calc(100% + 4px); inset-inline-start: 0; z-index: 20; min-width: 160px; } /* ๐ */
|
|
68
|
+
|
|
69
|
+
/* ๐ซ no-JS: the details list replaces the button */
|
|
70
|
+
.abVersionNoJs { display: none; }
|
|
71
|
+
.abVersionNoJsList { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--ab-version-border); border-radius: 8px; background: var(--ab-version-background); font-size: 13px; }
|
|
72
|
+
.abVersionNoJsList a { display: block; padding: 6px 8px; color: inherit; text-decoration: none; }
|
|
73
|
+
@media (scripting: none) {
|
|
74
|
+
.abVersionJs, .abVersionMenu { display: none; }
|
|
75
|
+
.abVersionNoJs { display: block; }
|
|
76
|
+
}
|