ab-nextjs-components 0.1.11 → 0.1.13
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 +36 -0
- package/README.md +30 -0
- package/ab-app-bar/index.tsx +181 -0
- package/ab-app-bar/styles.module.css +119 -0
- package/ab-avatar/index.tsx +2 -1
- package/ab-avatar/styles.module.css +32 -0
- package/ab-balloon/index.tsx +134 -23
- package/ab-balloon/styles.module.css +84 -7
- package/ab-brand/index.tsx +1 -1
- package/ab-button/helpers.ts +3 -1
- package/ab-button/index.tsx +17 -3
- package/ab-button/styles.module.css +42 -0
- package/ab-card/index.tsx +89 -0
- package/ab-card/styles.module.css +68 -0
- package/ab-collapsible/index.tsx +1 -1
- package/ab-color/index.tsx +1 -0
- package/ab-color/styles.module.css +32 -0
- package/ab-demo-box/index.tsx +1 -0
- package/ab-demo-box/styles.module.css +32 -0
- package/ab-demo-code/index.tsx +1 -0
- package/ab-demo-code/styles.module.css +32 -0
- package/ab-icon/builtin.ts +15 -1
- package/ab-icon/helpers.ts +37 -0
- package/ab-icon/index.tsx +14 -8
- package/ab-icon/registrar.tsx +68 -0
- package/ab-icon-button/index.tsx +8 -3
- package/ab-image/index.tsx +1 -0
- package/ab-image/styles.module.css +32 -0
- package/ab-info/index.tsx +2 -1
- package/ab-info/styles.module.css +32 -0
- package/ab-input/index.tsx +1 -0
- package/ab-input/styles.module.css +1 -0
- package/ab-install-snippet/styles.module.css +32 -8
- package/ab-kbd/index.tsx +65 -0
- package/ab-kbd/styles.module.css +55 -0
- package/ab-key-feature/index.tsx +2 -1
- package/ab-key-feature/styles.module.css +32 -0
- package/ab-like-button/index.tsx +1 -1
- package/ab-link/index.tsx +112 -0
- package/ab-link/locale.ts +53 -0
- package/ab-locale-switcher/index.tsx +17 -0
- package/ab-locale-switcher/styles.module.css +11 -0
- package/ab-main-headline/index.tsx +1 -0
- package/ab-main-headline/styles.module.css +32 -0
- package/ab-menu/index.tsx +6 -5
- package/ab-menu/styles.module.css +32 -0
- package/ab-name/index.tsx +1 -0
- package/ab-name/styles.module.css +32 -0
- package/ab-navbar/index.tsx +54 -46
- package/ab-navbar/styles.module.css +84 -28
- package/ab-navbar/view.tsx +163 -0
- package/ab-package-card/index.tsx +94 -0
- package/ab-package-card/styles.module.css +41 -0
- package/ab-page-paginator/index.tsx +1 -0
- package/ab-page-paginator/styles.module.css +32 -0
- package/ab-page-switcher/index.tsx +1 -0
- package/ab-page-switcher/styles.module.css +32 -0
- package/ab-preview/index.tsx +1 -0
- package/ab-preview/styles.module.css +32 -0
- package/ab-price/index.tsx +1 -0
- package/ab-price/styles.module.css +32 -0
- package/ab-price-tag/index.tsx +1 -0
- package/ab-price-tag/styles.module.css +32 -0
- package/ab-product/index.tsx +1 -0
- package/ab-product/styles.module.css +32 -0
- package/ab-product-item/index.tsx +1 -0
- package/ab-product-item/styles.module.css +32 -0
- package/ab-search-result/index.tsx +1 -0
- package/ab-search-result/styles.module.css +32 -0
- package/ab-search-trigger/index.tsx +142 -0
- package/ab-search-trigger/styles.module.css +70 -0
- package/ab-sidebar/index.tsx +88 -49
- package/ab-sidebar/styles.module.css +136 -31
- package/ab-sidebar/view.tsx +182 -0
- package/ab-switch-back/index.tsx +2 -1
- package/ab-switch-back/styles.module.css +32 -0
- package/ab-tab/index.tsx +2 -1
- package/ab-tab/styles.module.css +32 -0
- package/ab-tabs/index.tsx +1 -0
- package/ab-tabs/styles.module.css +32 -0
- package/ab-test-hello/index.tsx +1 -0
- package/ab-test-hello/styles.module.css +32 -0
- package/ab-text/index.tsx +1 -0
- package/ab-text/styles.module.css +32 -0
- package/ab-toc/index.tsx +124 -0
- package/ab-toc/styles.module.css +54 -0
- package/css/chrome-mq.css +32 -0
- package/css/doodle.css +32 -0
- package/css/logo.css +32 -0
- package/css/spinner.css +32 -0
- package/css/toast.css +32 -0
- package/index.ts +18 -0
- package/package.json +27 -10
- package/server/ab-avatar/index.tsx +2 -1
- package/server/ab-avatar/styles.module.css +32 -0
- package/server/ab-badge/index.tsx +1 -0
- package/server/ab-badge/styles.module.css +32 -0
- package/server/ab-brand/index.tsx +1 -1
- package/server/ab-button/index.tsx +1 -1
- package/server/ab-button/styles.module.css +11 -0
- package/server/ab-icon/index.tsx +13 -8
- package/server/ab-key-feature/index.tsx +2 -1
- package/server/ab-key-feature/styles.module.css +32 -0
- package/server/ab-name/index.tsx +1 -0
- package/server/ab-name/styles.module.css +32 -0
- package/server/ab-nav-link/index.tsx +2 -1
- package/server/ab-nav-link/styles.module.css +32 -0
- package/server/ab-navbar/index.tsx +44 -45
- package/server/ab-polygon/index.tsx +1 -0
- package/server/ab-polygon/styles.module.css +32 -0
- package/server/ab-sidebar/index.tsx +44 -49
- package/server/ab-switch-back/index.tsx +2 -1
- package/server/ab-switch-back/styles.module.css +32 -0
- package/server/ab-test-hello/index.tsx +1 -0
- package/server/ab-test-hello/styles.module.css +32 -0
- package/server/ab-text/index.tsx +1 -0
- package/server/ab-text/styles.module.css +32 -0
- package/server/index.ts +1 -0
- package/styles.css +32 -0
- package/types/index.d.ts +35 -0
- package/server/ab-navbar/styles.module.css +0 -35
- package/server/ab-sidebar/styles.module.css +0 -41
|
@@ -0,0 +1,112 @@
|
|
|
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: AbLink + AbLinkProvider (G42)
|
|
28
|
+
* @file: ab-link/index.tsx
|
|
29
|
+
* @type: Component (client) — injectable link
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> import { Link } from 'ab-nextjs-i18n/navigation'
|
|
34
|
+
* -|> <AbLinkProvider component={Link}><AbSidebar sections={…} /></AbLinkProvider>
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
39
|
+
* MOTTO: We'll always do more 😜!!!
|
|
40
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
'use client';
|
|
44
|
+
|
|
45
|
+
// ⚛️ React
|
|
46
|
+
import { createContext, createElement, useContext, type ComponentProps, type ComponentType, type ReactElement, type ReactNode } from 'react';
|
|
47
|
+
// 🌍 pure, server-safe locale helper (0.1.13)
|
|
48
|
+
import { stripAbLocalePrefix } from './locale';
|
|
49
|
+
export { stripAbLocalePrefix };
|
|
50
|
+
// 🔗 the default link (the ONLY next/link import in the package, see __tests__/ab-link.test.tsx)
|
|
51
|
+
import NextLink from 'next/link';
|
|
52
|
+
|
|
53
|
+
/** 🔗 Any Link-like component: takes next/link's props (`href`, `prefetch`, `replace`, …). */
|
|
54
|
+
export type AbLinkComponent = ComponentType<ComponentProps<typeof NextLink>>;
|
|
55
|
+
/** 🎛️ AbLink props = next/link props. */
|
|
56
|
+
export type AbLinkProps = ComponentProps<typeof NextLink>;
|
|
57
|
+
|
|
58
|
+
// 🧠 context: null = use next/link
|
|
59
|
+
const AbLinkContext = createContext<AbLinkComponent | null>(null);
|
|
60
|
+
// 🌍 0.1.13 (Joseph #10): the app's locale codes, so active states can ignore the `/fr` prefix
|
|
61
|
+
const AbLocalesContext = createContext<readonly string[]>([]);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/** 🪝 useAbLocales — the locale codes given to the nearest {@link AbLinkProvider} (default none). */
|
|
65
|
+
export function useAbLocales(): readonly string[] {
|
|
66
|
+
return useContext(AbLocalesContext); // 🌍
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 🧩 0.1.13 (Joseph #9): the STRUCTURAL shape a provided link needs: an `href` (any type, e.g. next-intl's
|
|
70
|
+
* `string | { pathname, query }`) and children. next/link, next-intl's Link, ab-nextjs-i18n's Link all fit. */
|
|
71
|
+
export interface AbLinkLikeProps {
|
|
72
|
+
href?: unknown; // 🔗
|
|
73
|
+
children?: ReactNode; // 🧒
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** ⚙️ Props of {@link AbLinkProvider}: generic over the link's own props, so no cast is needed. */
|
|
77
|
+
export interface AbLinkProviderProps<P extends AbLinkLikeProps = ComponentProps<typeof NextLink>> {
|
|
78
|
+
/** 🔗 the link every Ab component renders, e.g. ab-nextjs-i18n's locale-aware `Link`. */
|
|
79
|
+
component: ComponentType<P>;
|
|
80
|
+
/** 🌍 0.1.13: locale codes (e.g. `routing.locales`), stripped from the pathname for active states. */
|
|
81
|
+
locales?: readonly string[];
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 🔌 AbLinkProvider — swaps the link used by every Ab component (sidebar, navbar, menu, tab, app bar, cards, …).
|
|
87
|
+
* Wrap the app (or one layout) once:
|
|
88
|
+
* <AbLinkProvider component={Link}>…</AbLinkProvider> // Link from 'ab-nextjs-i18n/navigation'
|
|
89
|
+
*/
|
|
90
|
+
export function AbLinkProvider<P extends AbLinkLikeProps>({ component, locales, children }: AbLinkProviderProps<P>): ReactElement {
|
|
91
|
+
// 🧠 Ab components always pass next/link-compatible props (href string, className, aria-*, onClick, …)
|
|
92
|
+
const link = <AbLinkContext.Provider value={component as unknown as AbLinkComponent}>{children}</AbLinkContext.Provider>;
|
|
93
|
+
return locales ? <AbLocalesContext.Provider value={locales}>{link}</AbLocalesContext.Provider> : link; // 🌍
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 🪝 useAbLink — the link component in effect (the provider's, or next/link). */
|
|
97
|
+
export function useAbLink(): AbLinkComponent {
|
|
98
|
+
return useContext(AbLinkContext) ?? (NextLink as AbLinkComponent); // 🔗
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 🔗 AbLink — renders the provided link component (default next/link). Server twins can render it too:
|
|
103
|
+
* it's a client component, so it reads the provider from the client tree above it.
|
|
104
|
+
*/
|
|
105
|
+
export function AbLink(props: AbLinkProps): ReactElement {
|
|
106
|
+
// 🔌 the context value is a stable component reference (not created during render), so createElement
|
|
107
|
+
// keeps the react-hooks/static-components rule happy without changing behaviour
|
|
108
|
+
return createElement(useAbLink(), props); // ➡️ same props, same ref (React 19 ref-as-prop)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 📦 exports
|
|
112
|
+
export default AbLink;
|
|
@@ -0,0 +1,53 @@
|
|
|
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: stripAbLocalePrefix (0.1.13)
|
|
28
|
+
* @file: ab-link/locale.ts
|
|
29
|
+
* @type: Server-safe helper
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> stripAbLocalePrefix('/fr/docs', ['en', 'fr']) // → '/docs'
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
* MOTTO: We'll always do more 😜!!!
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
// 🌍 0.1.13 (Joseph #10): no 'use client', so server twins can import it too
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 🌍 stripAbLocalePrefix — `/fr/docs/core` → `/docs/core` when `fr` is one of `locales`; `/fr` → `/`.
|
|
46
|
+
* Only exact locale segments are removed (`/fresh` stays), so it is safe for any path.
|
|
47
|
+
*/
|
|
48
|
+
export function stripAbLocalePrefix(pathname: string, locales: readonly string[] = []): string {
|
|
49
|
+
const seg = /^\/([^/?#]+)/.exec(pathname)?.[1]; // 🔍 first segment
|
|
50
|
+
if (!seg || !locales.some((l) => l.toLowerCase() === seg.toLowerCase())) return pathname; // 🙅 not a locale
|
|
51
|
+
const rest = pathname.slice(seg.length + 1); // ✂️
|
|
52
|
+
return rest === '' || rest[0] !== '/' ? `/${rest.replace(/^\/?/, '')}` : rest; // 🧭 keep a leading slash
|
|
53
|
+
}
|
|
@@ -205,6 +205,23 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
|
|
|
205
205
|
);
|
|
206
206
|
})}
|
|
207
207
|
</ul>
|
|
208
|
+
{/* 🚫 JS off (0.1.13, gap-review): a native <details> list of hreflang links replaces the menu.
|
|
209
|
+
Only rendered with getHref (a callback can't run without JS). CSS shows it under (scripting: none). */}
|
|
210
|
+
{getHref ? (
|
|
211
|
+
<details className={styles.noJs} data-ab-part="locale-switcher-nojs">
|
|
212
|
+
<summary className={styles.trigger} aria-label={`${label}: ${active?.label ?? current}`}>
|
|
213
|
+
<span aria-hidden="true">{icon ?? <AbIcon name="language" size={20} />}</span>
|
|
214
|
+
<span lang={current}>{active?.label ?? current}</span>
|
|
215
|
+
</summary>
|
|
216
|
+
<ul className={styles.noJsList}>
|
|
217
|
+
{locales.map((l) => (
|
|
218
|
+
<li key={l.code}>
|
|
219
|
+
<a href={getHref(l.code)} hrefLang={l.code} lang={l.code} aria-current={l.code === current ? 'true' : undefined} className={styles.item}>{l.label}</a>
|
|
220
|
+
</li>
|
|
221
|
+
))}
|
|
222
|
+
</ul>
|
|
223
|
+
</details>
|
|
224
|
+
) : null}
|
|
208
225
|
</div>
|
|
209
226
|
);
|
|
210
227
|
}
|
|
@@ -125,3 +125,14 @@
|
|
|
125
125
|
width: 1em; /* 📏 fixed column */
|
|
126
126
|
color: var(--ab-color-bronze-text, #8A6440); /* ♿ */
|
|
127
127
|
}
|
|
128
|
+
|
|
129
|
+
/* 🚫 JS off fallback (0.1.13): native <details> + hreflang links */
|
|
130
|
+
.noJs { display: none; } /* 🙈 JS on */
|
|
131
|
+
.noJsList { list-style: none; margin: 4px 0 0; padding: 4px; } /* 📜 */
|
|
132
|
+
.noJs > summary { list-style: none; } /* 🚫 marker */
|
|
133
|
+
.noJs > summary::-webkit-details-marker { display: none; } /* 🚫 marker (WebKit) */
|
|
134
|
+
@media (scripting: none) {
|
|
135
|
+
.root > .trigger,
|
|
136
|
+
.root > .menu { display: none; } /* 🙈 needs JS */
|
|
137
|
+
.noJs { display: block; } /* 👁️ */
|
|
138
|
+
}
|
|
@@ -1,3 +1,35 @@
|
|
|
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: styles.module.css
|
|
28
|
+
* @file: ab-main-headline/styles.module.css
|
|
29
|
+
* @type: CSS Stylesheet
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
1
33
|
.abMainHeadline {
|
|
2
34
|
display: flex;
|
|
3
35
|
flex-direction: column;
|
package/ab-menu/index.tsx
CHANGED
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
* @project: ab-nextjs-components
|
|
9
9
|
* @name: AbMenu - Client (port of lyd-menu)
|
|
10
10
|
* @file: ab-menu/index.tsx
|
|
11
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
'use client';
|
|
14
15
|
|
|
15
16
|
import type { ReactElement } from 'react';
|
|
16
17
|
import { forwardRef } from 'react';
|
|
17
|
-
import Link from 'next/link
|
|
18
|
+
import Link from '../ab-link'; // 🔗 G42: injectable via AbLinkProvider (default next/link)
|
|
18
19
|
import clsx from 'clsx';
|
|
20
|
+
import AbIcon from '../ab-icon'; // 🔣 G2
|
|
19
21
|
import styles from './styles.module.css';
|
|
20
22
|
|
|
21
23
|
export interface AbMenuItemData {
|
|
@@ -71,9 +73,8 @@ const AbMenu = forwardRef<HTMLMenuElement, AbMenuProps>(function AbMenu(
|
|
|
71
73
|
const body = (
|
|
72
74
|
<>
|
|
73
75
|
{item.icon ? (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</span>
|
|
76
|
+
// 🔣 0.1.13 (G2): AbIcon (filled when selected), no Material Symbols font
|
|
77
|
+
<AbIcon name={item.icon} variant={item.selected ? 'filled' : 'outlined'} size={20} className={styles.abMenuIcon} />
|
|
77
78
|
) : null}
|
|
78
79
|
<span className={styles.abMenuLabel}>{item.label}</span>
|
|
79
80
|
</>
|
|
@@ -87,7 +88,7 @@ const AbMenu = forwardRef<HTMLMenuElement, AbMenuProps>(function AbMenu(
|
|
|
87
88
|
if (item.href && !item.disabled) {
|
|
88
89
|
return (
|
|
89
90
|
<li key={item.id} className={clsx('menu-item', itemClass)} data-id={item.id} data-action={item.action}>
|
|
90
|
-
<Link href={item.href} className={styles.abMenuLink} onClick={item.onClick}>
|
|
91
|
+
<Link href={item.href} className={styles.abMenuLink} onClick={item.onClick} aria-current={item.selected ? 'page' : undefined}>
|
|
91
92
|
{body}
|
|
92
93
|
</Link>
|
|
93
94
|
</li>
|
|
@@ -1,3 +1,35 @@
|
|
|
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: styles.module.css
|
|
28
|
+
* @file: ab-menu/styles.module.css
|
|
29
|
+
* @type: CSS Stylesheet
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
1
33
|
.abMenu {
|
|
2
34
|
display: flex;
|
|
3
35
|
flex-direction: column;
|
package/ab-name/index.tsx
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
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: styles.module.css
|
|
28
|
+
* @file: ab-name/styles.module.css
|
|
29
|
+
* @type: CSS Stylesheet
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
1
33
|
.abName {
|
|
2
34
|
display: inline-flex;
|
|
3
35
|
align-items: baseline;
|
package/ab-navbar/index.tsx
CHANGED
|
@@ -5,64 +5,72 @@
|
|
|
5
5
|
* ~~~~~~~~~~~~
|
|
6
6
|
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
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
|
+
*
|
|
8
26
|
* @project: ab-nextjs-components
|
|
9
|
-
* @name: AbNavbar - Client (
|
|
27
|
+
* @name: AbNavbar - Client (G41)
|
|
10
28
|
* @file: ab-navbar/index.tsx
|
|
29
|
+
* @type: Client Component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* <AbNavbar activeHref="/docs" items={[
|
|
34
|
+
* { kind: 'link', href: '/', icon: 'home', label: 'Home' },
|
|
35
|
+
* { kind: 'button', id: 'menu', icon: 'menu', label: 'Menu', onSelect: openSheet },
|
|
36
|
+
* ]} />
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
41
|
+
* MOTTO: We'll always do more 😜!!!
|
|
42
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
11
43
|
*/
|
|
12
44
|
|
|
13
45
|
'use client';
|
|
14
46
|
|
|
47
|
+
// ⚛️ React
|
|
15
48
|
import type { ReactElement } from 'react';
|
|
16
|
-
|
|
49
|
+
// 🧭 route fallback
|
|
17
50
|
import { usePathname } from 'next/navigation';
|
|
18
|
-
|
|
19
|
-
import
|
|
51
|
+
// 🌍 0.1.13 (Joseph #10): locale-stripped pathname
|
|
52
|
+
import { stripAbLocalePrefix, useAbLocales } from '../ab-link';
|
|
53
|
+
// 🔣 client AbIcon
|
|
54
|
+
import AbIcon from '../ab-icon';
|
|
55
|
+
// 🖼️ shared view
|
|
56
|
+
import { AbNavbarView, isAbNavbarActive, type AbNavbarBaseProps } from './view';
|
|
20
57
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
value: string;
|
|
25
|
-
label: string;
|
|
26
|
-
};
|
|
58
|
+
// 📦 shared types
|
|
59
|
+
export type { AbNavbarItem, AbNavbarLinkItem, AbNavbarButtonItem, AbNavbarLink } from './view';
|
|
60
|
+
export { isAbNavbarActive } from './view';
|
|
27
61
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type?: 'customer' | 'admin';
|
|
31
|
-
page?: string;
|
|
32
|
-
links?: AbNavbarLink[];
|
|
33
|
-
}
|
|
62
|
+
/** ⚙️ Client props (link and button items). */
|
|
63
|
+
export type AbNavbarProps = AbNavbarBaseProps;
|
|
34
64
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<nav data-type={type} data-ab-part="bottomBar" className={clsx('AbNavbar', styles.abNavbar, className)} aria-label="Primary">
|
|
44
|
-
<ul className={styles.abNavbarList}>
|
|
45
|
-
{links.map((link) => {
|
|
46
|
-
const active = page ? page === link.value : pathname === link.href || pathname.startsWith(`${link.href}/`);
|
|
47
|
-
return (
|
|
48
|
-
<li key={link.value}>
|
|
49
|
-
<Link
|
|
50
|
-
href={link.href}
|
|
51
|
-
data-active={active ? 'true' : 'false'}
|
|
52
|
-
className={styles.abNavbarLink}
|
|
53
|
-
>
|
|
54
|
-
<span className={clsx('material-symbols-rounded', styles.abNavbarIcon)} aria-hidden>
|
|
55
|
-
{link.icon}
|
|
56
|
-
</span>
|
|
57
|
-
<span>{link.label}</span>
|
|
58
|
-
</Link>
|
|
59
|
-
</li>
|
|
60
|
-
);
|
|
61
|
-
})}
|
|
62
|
-
</ul>
|
|
63
|
-
</nav>
|
|
64
|
-
);
|
|
65
|
+
/** 📱 AbNavbar (client, G41): mobile bottom bar, filled active icon, aria-current, safe-area padding. */
|
|
66
|
+
const AbNavbar = (props: AbNavbarProps): ReactElement => {
|
|
67
|
+
const appLocales = useAbLocales(); // 🌍 from AbLinkProvider
|
|
68
|
+
const pathname = stripAbLocalePrefix(usePathname() ?? '', props.locales ?? appLocales); // 🧭 `/fr/docs` → `/docs`
|
|
69
|
+
const { page, activeHref } = props;
|
|
70
|
+
const active = (href: string, value?: string) => (page ? page === value : isAbNavbarActive(href, activeHref ?? pathname)); // 🎯
|
|
71
|
+
return <AbNavbarView props={props} Icon={AbIcon} active={active} />;
|
|
65
72
|
};
|
|
66
73
|
|
|
74
|
+
// 📦 exports
|
|
67
75
|
export default AbNavbar;
|
|
68
76
|
export { AbNavbar };
|
|
@@ -1,35 +1,91 @@
|
|
|
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: AbNavbar - Styles (G41)
|
|
28
|
+
* @file: ab-navbar/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
|
+
/* 📱 bottom bar: M3 navigation bar, safe-area aware */
|
|
1
40
|
.abNavbar {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
box-sizing: border-box;
|
|
41
|
+
width: 100%; /* 📏 */
|
|
42
|
+
box-sizing: border-box; /* 📦 */
|
|
43
|
+
padding: 12px 8px calc(16px + env(safe-area-inset-bottom, 0px)); /* 📱 home indicator */
|
|
44
|
+
padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px)); /* 📱 notch */
|
|
45
|
+
background: var(--ab-color-surface-container, transparent); /* 🎨 */
|
|
8
46
|
}
|
|
9
47
|
.abNavbarList {
|
|
10
|
-
display: flex;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
padding: 0;
|
|
16
|
-
overflow-x: auto;
|
|
48
|
+
display: flex; /* 📐 */
|
|
49
|
+
justify-content: space-around; /* ↔️ */
|
|
50
|
+
list-style: none; /* 🚫 */
|
|
51
|
+
margin: 0; /* 🚫 */
|
|
52
|
+
padding: 0; /* 🚫 */
|
|
17
53
|
}
|
|
54
|
+
.abNavbarList > li { flex: 1 1 0; display: flex; justify-content: center; } /* ⚖️ equal slots */
|
|
55
|
+
/* 🔗 item: pill icon over a label */
|
|
18
56
|
.abNavbarLink {
|
|
19
|
-
display:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
display: flex; /* 📐 */
|
|
58
|
+
flex-direction: column; /* ⬇️ */
|
|
59
|
+
align-items: center; /* ↔️ */
|
|
60
|
+
gap: 4px; /* ↕️ */
|
|
61
|
+
min-width: 64px; /* 👆 */
|
|
62
|
+
border: 0; /* 🚫 (buttons) */
|
|
63
|
+
background: none; /* 🚫 */
|
|
64
|
+
font: inherit; /* 🔤 */
|
|
65
|
+
color: var(--ab-color-on-surface-variant, inherit); /* 🖋️ */
|
|
66
|
+
text-decoration: none; /* 🚫 */
|
|
67
|
+
cursor: pointer; /* 👆 */
|
|
30
68
|
}
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
69
|
+
.abNavbarPill {
|
|
70
|
+
display: grid; /* 📐 */
|
|
71
|
+
place-items: center; /* 🎯 */
|
|
72
|
+
width: 64px; /* 📏 */
|
|
73
|
+
height: 32px; /* 📏 */
|
|
74
|
+
border-radius: 999px; /* 🟢 */
|
|
34
75
|
}
|
|
35
|
-
.
|
|
76
|
+
.abNavbarLabel { font-size: 12px; font-weight: 500; line-height: 16px; } /* 🔤 */
|
|
77
|
+
.abNavbarLink[data-active='true'],
|
|
78
|
+
.abNavbarLink[aria-expanded='true'] { color: var(--ab-color-on-surface, inherit); } /* 🎯 */
|
|
79
|
+
.abNavbarLink[data-active='true'] .abNavbarPill,
|
|
80
|
+
.abNavbarLink[aria-expanded='true'] .abNavbarPill { background: var(--ab-color-secondary-container, rgb(0 0 0 / 0.08)); } /* 🎯 */
|
|
81
|
+
.abNavbarLink[data-active='true'] .abNavbarLabel { font-weight: 700; } /* 🔤 */
|
|
82
|
+
.abNavbarLink:focus-visible {
|
|
83
|
+
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* ♿ */
|
|
84
|
+
outline-offset: var(--ab-focus-ring-offset, 2px); /* ♿ */
|
|
85
|
+
border-radius: 12px; /* 🟢 */
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* 🚫🚧 0.1.13: disabled / coming-soon button items (inert, still focusable) */
|
|
89
|
+
.abNavbarLink[aria-disabled='true'] { cursor: default; opacity: 0.6; } /* 🚫 */
|
|
90
|
+
.abNavbarSoon { font-size: 10px; line-height: 12px; opacity: 0.85; } /* 🚧 tag under the label */
|
|
91
|
+
.abNavbarSrOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* 🕶️ */
|