ab-nextjs-components 0.2.3 โ†’ 0.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ab-nextjs-components",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "description": "๐Ÿš€ A lightweight collection of server & client React components created by Abraham Ukachi, and optimized for Next.js applications ๐Ÿ˜Ž.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -42,7 +42,7 @@
42
42
  "peerDependencies": {
43
43
  "ab-nextjs-animations": "^0.2.5",
44
44
  "ab-nextjs-hooks": "^0.1.7",
45
- "ab-nextjs-icons": "^0.2.4",
45
+ "ab-nextjs-icons": "^0.2.6",
46
46
  "ab-nextjs-theme": "^0.3.7",
47
47
  "clsx": "^2",
48
48
  "next": "^16.3.4",
@@ -55,7 +55,7 @@
55
55
  "@types/react": "^19",
56
56
  "ab-nextjs-animations": "^0.2.5",
57
57
  "ab-nextjs-hooks": "^0.1.7",
58
- "ab-nextjs-icons": "^0.2.4",
58
+ "ab-nextjs-icons": "^0.2.6",
59
59
  "ab-nextjs-theme": "^0.3.7",
60
60
  "clsx": "^2.1.1",
61
61
  "esbuild": "^0.28.2",
@@ -102,13 +102,8 @@
102
102
  "ab-navbar",
103
103
  "ab-sidebar",
104
104
  "ab-text",
105
- "ab-test-hello",
106
- "ab-key-feature",
107
- "ab-main-headline",
108
- "ab-preview",
109
105
  "ab-product",
110
106
  "ab-product-item",
111
- "ab-switch-back",
112
107
  "ab-demo-box",
113
108
  "ab-demo-code",
114
109
  "ab-splash",
@@ -145,7 +140,8 @@
145
140
  "ab-app-bar",
146
141
  "ab-card",
147
142
  "ab-package-card",
148
- "ab-toc"
143
+ "ab-toc",
144
+ "ab-error-hero"
149
145
  ],
150
146
  "exports": {
151
147
  ".": {
@@ -223,13 +219,8 @@
223
219
  "./ab-navbar": "./ab-navbar/index.tsx",
224
220
  "./ab-sidebar": "./ab-sidebar/index.tsx",
225
221
  "./ab-text": "./ab-text/index.tsx",
226
- "./ab-test-hello": "./ab-test-hello/index.tsx",
227
- "./ab-key-feature": "./ab-key-feature/index.tsx",
228
- "./ab-main-headline": "./ab-main-headline/index.tsx",
229
- "./ab-preview": "./ab-preview/index.tsx",
230
222
  "./ab-product": "./ab-product/index.tsx",
231
223
  "./ab-product-item": "./ab-product-item/index.tsx",
232
- "./ab-switch-back": "./ab-switch-back/index.tsx",
233
224
  "./ab-demo-box": "./ab-demo-box/index.tsx",
234
225
  "./ab-demo-code": "./ab-demo-code/index.tsx",
235
226
  "./server/ab-brand": "./server/ab-brand/index.tsx",
@@ -238,9 +229,6 @@
238
229
  "./server/ab-sidebar": "./server/ab-sidebar/index.tsx",
239
230
  "./server/ab-nav-link": "./server/ab-nav-link/index.tsx",
240
231
  "./server/ab-text": "./server/ab-text/index.tsx",
241
- "./server/ab-test-hello": "./server/ab-test-hello/index.tsx",
242
- "./server/ab-key-feature": "./server/ab-key-feature/index.tsx",
243
- "./server/ab-switch-back": "./server/ab-switch-back/index.tsx",
244
232
  "./styles.css": "./styles.css",
245
233
  "./css/*": "./css/*",
246
234
  "./assets/*": "./assets/*",
@@ -251,6 +239,7 @@
251
239
  "./ab-card": "./ab-card/index.tsx",
252
240
  "./ab-package-card": "./ab-package-card/index.tsx",
253
241
  "./ab-toc": "./ab-toc/index.tsx",
242
+ "./ab-error-hero": "./ab-error-hero/index.tsx",
254
243
  "./ab-sidebar/view": "./ab-sidebar/view.tsx",
255
244
  "./ab-navbar/view": "./ab-navbar/view.tsx"
256
245
  },
@@ -40,6 +40,8 @@
40
40
  import type { CSSProperties, ReactElement, ReactNode } from 'react';
41
41
  // ๐Ÿงต class joiner
42
42
  import clsx from 'clsx';
43
+ // ๐Ÿ”— 404 gaps: the provider-aware link (client component, fine to render from a server twin)
44
+ import AbLink from '../../ab-link';
43
45
  // ๐ŸŽจ styles (server copy)
44
46
  // ๐Ÿงฌ 0.2.3 (Joseph 03:41): ONE source for the button box โ€” the client module's CSS (no server copy to drift)
45
47
  import styles from '../../ab-button/styles.module.css';
@@ -141,7 +143,8 @@ const AbButton = ({
141
143
  return <span id={id} role="link" aria-disabled="true" tabIndex={mode === 'aria' ? 0 : -1} className={classNames} style={style} hidden={hidden} {...dataAttrs}>{content}</span>;
142
144
  }
143
145
  // โœ… a link is a link (no role=button)
144
- return <a id={id} href={href} className={classNames} style={style} hidden={hidden} {...dataAttrs}>{content}</a>;
146
+ // ๐Ÿ”Œ 404 gaps: AbLink (a client leaf) reads AbLinkProvider from the client tree โ†’ locale prefix ๐ŸŒ
147
+ return <AbLink id={id} href={href} className={classNames} style={style} hidden={hidden} {...dataAttrs}>{content}</AbLink>;
145
148
  }
146
149
 
147
150
  // ๐Ÿ”˜ button: aria mode is type="button" so a disabled CTA can never submit, even without JS
package/server/index.ts CHANGED
@@ -23,6 +23,3 @@ export { default as AbNavbar } from './ab-navbar/index.tsx'
23
23
  export { default as AbSidebar } from './ab-sidebar/index.tsx'
24
24
  export { default as AbNavLink } from './ab-nav-link/index.tsx'
25
25
  export { default as AbText } from './ab-text/index.tsx'
26
- export { default as AbTestHello } from './ab-test-hello/index.tsx'
27
- export { default as AbKeyFeature } from './ab-key-feature/index.tsx'
28
- export { default as AbSwitchBack } from './ab-switch-back/index.tsx'
package/types/index.d.ts CHANGED
@@ -81,6 +81,9 @@ export { default as AbToc, getAbMainScroller, AB_MAIN_SCROLLER_SELECTOR } from '
81
81
  export { default as AbTocPromo } from '../ab-toc/promo.tsx';
82
82
  export type { AbTocPromoProps } from '../ab-toc/promo.tsx';
83
83
  export type { AbTocItem, AbTocProps } from '../ab-toc/index.tsx';
84
+ // ๐Ÿšง 404 gaps: AbErrorHero
85
+ export { default as AbErrorHero } from '../ab-error-hero/index.tsx';
86
+ export type { AbErrorHeroProps } from '../ab-error-hero/index.tsx';
84
87
  // ๐Ÿ—„๏ธ 0.1.14 (G53): AbDrawer + useAbDrawer (also at `ab-nextjs-components/ab-drawer`)
85
88
  export { default as AbDrawer, useAbDrawer, getAbDrawerHost, AB_DRAWER_DURATION, AB_DRAWER_RETURN_FOCUS } from '../ab-drawer/index.tsx';
86
89
  // ๐Ÿค 0.2.0 drawers v2: edge swipes + the swipe / snap rules
@@ -131,13 +134,8 @@ export type { AbBreadcrumbItem, AbBreadcrumbsProps } from '../ab-breadcrumbs/ind
131
134
  export { default as AbList, AbListItem } from '../ab-list/index.tsx';
132
135
  export type { AbListProps, AbListItemProps } from '../ab-list/index.tsx';
133
136
  export { default as AbText } from '../ab-text/index.tsx';
134
- export { default as AbTestHello } from '../ab-test-hello/index.tsx';
135
- export { default as AbKeyFeature } from '../ab-key-feature/index.tsx';
136
- export { default as AbMainHeadline } from '../ab-main-headline/index.tsx';
137
- export { default as AbPreview } from '../ab-preview/index.tsx';
138
137
  export { default as AbProduct } from '../ab-product/index.tsx';
139
138
  export { default as AbProductItem } from '../ab-product-item/index.tsx';
140
- export { default as AbSwitchBack } from '../ab-switch-back/index.tsx';
141
139
  export { default as AbDemoBox } from '../ab-demo-box/index.tsx';
142
140
  export { default as AbDemoCode } from '../ab-demo-code/index.tsx';
143
141
  export { default as AbPolygon } from '../server/ab-polygon/index.tsx';
@@ -1,61 +0,0 @@
1
- /*
2
- * @license MIT
3
- * ~~~~~~~~~~~~
4
- * ab-nextjs-components
5
- * ~~~~~~~~~~~~
6
- * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
- *
8
- * @project: ab-nextjs-components
9
- * @name: AbKeyFeature - Client (port of lyd-key-feature)
10
- * @file: ab-key-feature/index.tsx
11
- * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
12
- */
13
-
14
- 'use client';
15
-
16
- import type { ReactElement } from 'react';
17
- import Link from '../ab-link'; // ๐Ÿ”— G42: injectable via AbLinkProvider (default next/link)
18
- import clsx from 'clsx';
19
- import styles from './styles.module.css';
20
-
21
- export interface AbKeyFeatureProps {
22
- className?: string;
23
- hidden?: boolean;
24
- icon: string;
25
- name: string;
26
- title: string;
27
- description?: string;
28
- linkHidden?: boolean;
29
- linkLabel?: string;
30
- link?: string;
31
- watermark?: string;
32
- }
33
-
34
- const AbKeyFeature = ({
35
- className,
36
- hidden = false,
37
- icon,
38
- name,
39
- title,
40
- description,
41
- linkHidden = false,
42
- linkLabel = 'Learn more',
43
- link,
44
- watermark,
45
- }: AbKeyFeatureProps): ReactElement => {
46
- return (
47
- <article hidden={hidden} className={clsx('AbKeyFeature', styles.abKeyFeature, className)}>
48
- <span className={clsx('material-symbols-rounded', styles.abKeyFeatureIcon)} aria-hidden>{icon}</span>
49
- <span className={styles.abKeyFeatureName}>{name}</span>
50
- <h3 className={styles.abKeyFeatureTitle}>{title}</h3>
51
- {description ? <p className={styles.abKeyFeatureDesc}>{description}</p> : null}
52
- {!linkHidden && link ? (
53
- <Link href={link} className={styles.abKeyFeatureLink}>{linkLabel}</Link>
54
- ) : null}
55
- {watermark ? <span className={styles.abKeyFeatureWatermark} aria-hidden>{watermark}</span> : null}
56
- </article>
57
- );
58
- };
59
-
60
- export default AbKeyFeature;
61
- export { AbKeyFeature };
@@ -1,79 +0,0 @@
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-key-feature/styles.module.css
29
- * @type: CSS Stylesheet
30
- * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
- */
32
-
33
- .abKeyFeature {
34
- display: flex;
35
- flex-direction: column;
36
- gap: 0.5rem;
37
- padding: 1rem;
38
- border-radius: 1rem;
39
- position: relative;
40
- overflow: hidden;
41
- background: color-mix(in srgb, var(--ab-surface-container, #f3edf7) 85%, transparent);
42
- }
43
- .abKeyFeatureIcon {
44
- font-size: 2rem;
45
- color: var(--ab-primary, #6750a4);
46
- }
47
- .abKeyFeatureName {
48
- font-size: 0.75rem;
49
- font-weight: 700;
50
- text-transform: uppercase;
51
- letter-spacing: 0.06em;
52
- opacity: 0.7;
53
- }
54
- .abKeyFeatureTitle {
55
- margin: 0;
56
- font-size: 1.25rem;
57
- font-weight: 700;
58
- }
59
- .abKeyFeatureDesc {
60
- margin: 0;
61
- font-size: 0.9375rem;
62
- opacity: 0.8;
63
- }
64
- .abKeyFeatureLink {
65
- margin-top: 0.5rem;
66
- align-self: flex-start;
67
- color: var(--ab-primary, #6750a4);
68
- font-weight: 600;
69
- text-decoration: none;
70
- }
71
- .abKeyFeatureWatermark {
72
- position: absolute;
73
- right: -0.5rem;
74
- bottom: -0.5rem;
75
- font-size: 5rem;
76
- opacity: 0.06;
77
- pointer-events: none;
78
- user-select: none;
79
- }
@@ -1,58 +0,0 @@
1
- /*
2
- * @license MIT
3
- * ~~~~~~~~~~~~
4
- * ab-nextjs-components
5
- * ~~~~~~~~~~~~
6
- * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
- *
8
- * @project: ab-nextjs-components
9
- * @name: AbMainHeadline - Client (port of lyd-main-headline; providers stripped)
10
- * @file: ab-main-headline/index.tsx
11
- * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
12
- */
13
-
14
- 'use client';
15
-
16
- import type { ReactElement } from 'react';
17
- import clsx from 'clsx';
18
- import styles from './styles.module.css';
19
-
20
- export interface AbMainHeadlineProps {
21
- className?: string;
22
- timePeriod?: 'morning' | 'afternoon' | 'evening' | 'night';
23
- title: string;
24
- commaHidden?: boolean;
25
- subtitle: string;
26
- isFirstNameBold?: boolean;
27
- hasExclamationMark?: boolean;
28
- }
29
-
30
- const AbMainHeadline = ({
31
- className,
32
- timePeriod,
33
- title,
34
- commaHidden = false,
35
- subtitle,
36
- isFirstNameBold = false,
37
- hasExclamationMark = false,
38
- }: AbMainHeadlineProps): ReactElement => {
39
- const parts = title.trim().split(/\s+/);
40
- const first = parts[0] ?? '';
41
- const rest = parts.slice(1).join(' ');
42
-
43
- return (
44
- <header className={clsx('AbMainHeadline', styles.abMainHeadline, className)}>
45
- {timePeriod ? <span className={styles.abMainHeadlinePeriod}>{timePeriod}</span> : null}
46
- <h1 className={styles.abMainHeadlineTitle}>
47
- {isFirstNameBold ? <strong>{first}</strong> : first}
48
- {rest ? ` ${rest}` : ''}
49
- {!commaHidden ? ',' : ''}
50
- {hasExclamationMark ? '!' : ''}
51
- </h1>
52
- <p className={styles.abMainHeadlineSubtitle}>{subtitle}</p>
53
- </header>
54
- );
55
- };
56
-
57
- export default AbMainHeadline;
58
- export { AbMainHeadline };
@@ -1,56 +0,0 @@
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
-
33
- .abMainHeadline {
34
- display: flex;
35
- flex-direction: column;
36
- gap: 0.35rem;
37
- }
38
- .abMainHeadlineTitle {
39
- margin: 0;
40
- font-size: clamp(1.75rem, 4vw, 2.75rem);
41
- font-weight: 700;
42
- line-height: 1.15;
43
- }
44
- .abMainHeadlineTitle strong { font-weight: 900; }
45
- .abMainHeadlineSubtitle {
46
- margin: 0;
47
- font-size: 1.05rem;
48
- opacity: 0.75;
49
- }
50
- .abMainHeadlinePeriod {
51
- font-size: 0.75rem;
52
- font-weight: 700;
53
- text-transform: uppercase;
54
- letter-spacing: 0.08em;
55
- opacity: 0.55;
56
- }
@@ -1,79 +0,0 @@
1
- /*
2
- * @license MIT
3
- * ~~~~~~~~~~~~
4
- * ab-nextjs-components
5
- * ~~~~~~~~~~~~
6
- * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
- *
8
- * @project: ab-nextjs-components
9
- * @name: AbPreview - Client (Adapt of lyd-preview; db/providers stripped)
10
- * @file: ab-preview/index.tsx
11
- * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
12
- */
13
-
14
- 'use client';
15
-
16
- import type { ReactElement } from 'react';
17
- import Image from 'next/image';
18
- import clsx from 'clsx';
19
- import styles from './styles.module.css';
20
-
21
- export type AbPreviewItem = {
22
- id: string | number;
23
- src: string;
24
- alt?: string;
25
- href?: string;
26
- };
27
-
28
- export interface AbPreviewProps {
29
- className?: string;
30
- hidden?: boolean;
31
- items?: AbPreviewItem[];
32
- emptyLabel?: string;
33
- }
34
-
35
- const AbPreview = ({
36
- className,
37
- hidden = false,
38
- items = [],
39
- emptyLabel = 'No previews',
40
- }: AbPreviewProps): ReactElement => {
41
- if (!items.length) {
42
- return (
43
- <div hidden={hidden} className={clsx('AbPreview', styles.abPreview, className)}>
44
- <div className={styles.abPreviewEmpty}>{emptyLabel}</div>
45
- </div>
46
- );
47
- }
48
-
49
- return (
50
- <div hidden={hidden} className={clsx('AbPreview', styles.abPreview, className)}>
51
- {items.map((item) => {
52
- const inner = (
53
- <Image
54
- className={styles.abPreviewImg}
55
- src={item.src}
56
- alt={item.alt ?? ''}
57
- width={160}
58
- height={160}
59
- unoptimized
60
- />
61
- );
62
- return (
63
- <div key={item.id} className={styles.abPreviewItem}>
64
- {item.href ? (
65
- <a href={item.href} style={{ display: 'contents' }}>
66
- {inner}
67
- </a>
68
- ) : (
69
- inner
70
- )}
71
- </div>
72
- );
73
- })}
74
- </div>
75
- );
76
- };
77
-
78
- export default AbPreview;
79
- export { AbPreview };
@@ -1,58 +0,0 @@
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-preview/styles.module.css
29
- * @type: CSS Stylesheet
30
- * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
- */
32
-
33
- .abPreview {
34
- display: grid;
35
- grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
36
- gap: 0.75rem;
37
- }
38
- .abPreviewItem {
39
- position: relative;
40
- aspect-ratio: 1;
41
- border-radius: 0.85rem;
42
- overflow: hidden;
43
- background: color-mix(in srgb, var(--ab-surface-container, #f3edf7) 100%, transparent);
44
- display: flex;
45
- align-items: center;
46
- justify-content: center;
47
- }
48
- .abPreviewImg {
49
- object-fit: cover;
50
- width: 100%;
51
- height: 100%;
52
- }
53
- .abPreviewEmpty {
54
- font-size: 0.75rem;
55
- opacity: 0.6;
56
- text-align: center;
57
- padding: 0.5rem;
58
- }
@@ -1,73 +0,0 @@
1
- /*
2
- * @license MIT
3
- * ~~~~~~~~~~~~
4
- * ab-nextjs-components
5
- * ~~~~~~~~~~~~
6
- * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
- *
8
- * @project: ab-nextjs-components
9
- * @name: AbSwitchBack - Client (port of lyd-switch-back)
10
- * @file: ab-switch-back/index.tsx
11
- * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
12
- */
13
-
14
- 'use client';
15
-
16
- import type { ReactElement, ReactNode } from 'react';
17
- import Link from '../ab-link'; // ๐Ÿ”— G42: injectable via AbLinkProvider (default next/link)
18
- import Image from 'next/image';
19
- import clsx from 'clsx';
20
- import styles from './styles.module.css';
21
-
22
- export interface AbSwitchBackProps {
23
- className?: string;
24
- hidden?: boolean;
25
- switched?: boolean;
26
- image: string;
27
- imageAlt: string;
28
- title?: ReactNode;
29
- description?: ReactNode;
30
- cta1Label: string;
31
- cta1Link: string;
32
- cta2Label: string;
33
- cta2Link: string;
34
- }
35
-
36
- const AbSwitchBack = ({
37
- className,
38
- hidden = false,
39
- switched = false,
40
- image,
41
- imageAlt,
42
- title,
43
- description,
44
- cta1Label,
45
- cta1Link,
46
- cta2Label,
47
- cta2Link,
48
- }: AbSwitchBackProps): ReactElement => {
49
- return (
50
- <section
51
- hidden={hidden}
52
- data-switched={switched ? 'true' : 'false'}
53
- className={clsx('AbSwitchBack', styles.abSwitchBack, className)}
54
- >
55
- <div className={styles.abSwitchBackMedia}>
56
- <Image className={styles.abSwitchBackImage} src={image} alt={imageAlt} width={800} height={600} unoptimized />
57
- </div>
58
- <div className={styles.abSwitchBackCopy}>
59
- {title ? <h2 className={styles.abSwitchBackTitle}>{title}</h2> : null}
60
- {description ? <div className={styles.abSwitchBackDesc}>{description}</div> : null}
61
- <div className={styles.abSwitchBackActions}>
62
- <Link href={cta1Link} className={styles.abSwitchBackCta}>{cta1Label}</Link>
63
- <Link href={cta2Link} className={clsx(styles.abSwitchBackCta, styles.abSwitchBackCtaSecondary)}>
64
- {cta2Label}
65
- </Link>
66
- </div>
67
- </div>
68
- </section>
69
- );
70
- };
71
-
72
- export default AbSwitchBack;
73
- export { AbSwitchBack };
@@ -1,77 +0,0 @@
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-switch-back/styles.module.css
29
- * @type: CSS Stylesheet
30
- * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
- */
32
-
33
- .abSwitchBack {
34
- display: grid;
35
- grid-template-columns: 1fr;
36
- gap: 1.25rem;
37
- align-items: center;
38
- }
39
- @media (min-width: 768px) {
40
- .abSwitchBack {
41
- grid-template-columns: 1fr 1fr;
42
- }
43
- .abSwitchBack[data-switched='true'] .abSwitchBackMedia { order: 2; }
44
- .abSwitchBack[data-switched='true'] .abSwitchBackCopy { order: 1; }
45
- }
46
- .abSwitchBackMedia {
47
- position: relative;
48
- width: 100%;
49
- aspect-ratio: 4 / 3;
50
- border-radius: 1rem;
51
- overflow: hidden;
52
- background: #ddd;
53
- }
54
- .abSwitchBackImage {
55
- object-fit: cover;
56
- width: 100%;
57
- height: 100%;
58
- }
59
- .abSwitchBackCopy { display: flex; flex-direction: column; gap: 0.75rem; }
60
- .abSwitchBackTitle { margin: 0; font-size: 1.5rem; font-weight: 700; }
61
- .abSwitchBackDesc { margin: 0; opacity: 0.8; }
62
- .abSwitchBackActions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
63
- .abSwitchBackCta {
64
- display: inline-flex;
65
- align-items: center;
66
- padding: 0.5rem 1rem;
67
- border-radius: 9999px;
68
- text-decoration: none;
69
- font-weight: 600;
70
- background: var(--ab-primary, #6750a4);
71
- color: #fff;
72
- }
73
- .abSwitchBackCtaSecondary {
74
- background: transparent;
75
- color: var(--ab-primary, #6750a4);
76
- border: 1px solid color-mix(in srgb, var(--ab-primary, #6750a4) 40%, transparent);
77
- }