@mbao01/next 0.0.5 → 0.0.7
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/README.md +1 -2
- package/dist/types/components/Link/constant.d.ts +4 -5
- package/dist/types/components/Link/types.d.ts +3 -5
- package/dist/types/index.d.ts +0 -1
- package/dist/types/tsconfig.declaration.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/Link/Link.tsx +7 -9
- package/src/components/Link/constant.ts +20 -20
- package/src/components/Link/types.ts +4 -16
- package/src/index.ts +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -32
- package/src/components/Breadcrumbs/constant.ts +0 -16
- package/src/components/Breadcrumbs/index.ts +0 -1
- package/src/components/Breadcrumbs/types.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist/types"
|
|
21
21
|
],
|
|
22
22
|
"bugs": "https://github.com/mbao01/mbao01/issues",
|
|
23
|
-
"homepage": "https://
|
|
23
|
+
"homepage": "https://ui.ayomidebakare.site/next/",
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
26
|
"url": "git+https://github.com/mbao01/mbao01.git"
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"test:coverage": "vitest run --coverage"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
45
|
+
"@mbao01/common": "^0.0.6",
|
|
46
|
+
"@radix-ui/react-icons": "^1.3.0",
|
|
47
47
|
"clsx": "^2.1.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"next": "^14.1.0"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "ceb6cef48e8547b4da5c51dda329bd6edee73c0b"
|
|
97
97
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import c from "clsx";
|
|
2
1
|
import NextLink from "next/link";
|
|
3
|
-
import {
|
|
2
|
+
import { ExternalLinkIcon } from "@radix-ui/react-icons";
|
|
3
|
+
import { cn } from "@mbao01/common/utilities";
|
|
4
4
|
import { type LinkProps } from "./types";
|
|
5
|
-
import {
|
|
5
|
+
import { getLinkClasses } from "./constant";
|
|
6
6
|
|
|
7
7
|
export const Link = <T,>({
|
|
8
8
|
href,
|
|
@@ -15,16 +15,14 @@ export const Link = <T,>({
|
|
|
15
15
|
}: LinkProps<T>) => {
|
|
16
16
|
return (
|
|
17
17
|
<NextLink
|
|
18
|
-
{...props}
|
|
19
18
|
href={href}
|
|
20
|
-
|
|
19
|
+
target={target}
|
|
20
|
+
className={cn(getLinkClasses({ hover, variant }), className)}
|
|
21
|
+
{...props}
|
|
21
22
|
>
|
|
22
23
|
{children}
|
|
23
24
|
{target === "_blank" && (
|
|
24
|
-
<
|
|
25
|
-
name="external"
|
|
26
|
-
className="ml-[2px] inline h-4 w-4 align-middle"
|
|
27
|
-
/>
|
|
25
|
+
<ExternalLinkIcon name="external" className="ml-[2px] inline" />
|
|
28
26
|
)}
|
|
29
27
|
</NextLink>
|
|
30
28
|
);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LinkVariant } from './types';
|
|
1
|
+
import { cva } from "@mbao01/common/libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
3
|
+
export const getLinkClasses = cva("link transition-all", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
accent: "link-accent",
|
|
7
|
+
default: "link-default",
|
|
8
|
+
error: "link-error",
|
|
9
|
+
info: "link-info",
|
|
10
|
+
link: "link-link",
|
|
11
|
+
neutral: "link-neutral",
|
|
12
|
+
primary: "link-primary",
|
|
13
|
+
secondary: "link-secondary",
|
|
14
|
+
success: "link-success",
|
|
15
|
+
warning: "link-warning",
|
|
16
|
+
},
|
|
17
|
+
hover: {
|
|
18
|
+
true: "link-hover",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { LinkProps as NextLinkProps } from "next/link";
|
|
2
|
+
import { type VariantProps } from "@mbao01/common/libs";
|
|
3
|
+
import { getLinkClasses } from "./constant";
|
|
2
4
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
| "neutral"
|
|
6
|
-
| "primary"
|
|
7
|
-
| "secondary"
|
|
8
|
-
| "accent"
|
|
9
|
-
| "link"
|
|
10
|
-
| "info"
|
|
11
|
-
| "success"
|
|
12
|
-
| "warning"
|
|
13
|
-
| "error";
|
|
14
|
-
|
|
15
|
-
export type LinkProps<T> = NextLinkProps<T> & {
|
|
16
|
-
hover?: boolean;
|
|
17
|
-
variant?: LinkVariant;
|
|
18
|
-
};
|
|
5
|
+
export type LinkProps<T> = NextLinkProps<T> &
|
|
6
|
+
VariantProps<typeof getLinkClasses>;
|
package/src/index.ts
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { usePathname } from "next/navigation";
|
|
3
|
-
|
|
4
|
-
import { getBreadcrumbs } from "./constant";
|
|
5
|
-
import type { BreadcrumbsProps } from "./types";
|
|
6
|
-
import { Link } from "../Link";
|
|
7
|
-
|
|
8
|
-
export const Breadcrumbs = ({ root, labels }: BreadcrumbsProps) => {
|
|
9
|
-
const pathname = usePathname();
|
|
10
|
-
const breadcrumbs = getBreadcrumbs(pathname, labels);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div className="breadcrumbs -ml-1 w-fit px-1 text-sm">
|
|
14
|
-
<ul>
|
|
15
|
-
{root && (
|
|
16
|
-
<li>
|
|
17
|
-
<Link hover href="/">
|
|
18
|
-
{root}
|
|
19
|
-
</Link>
|
|
20
|
-
</li>
|
|
21
|
-
)}
|
|
22
|
-
{breadcrumbs.map((crumb) => (
|
|
23
|
-
<li key={crumb.href.pathname}>
|
|
24
|
-
<Link hover href={crumb.href} className="capitalize">
|
|
25
|
-
{crumb.segment}
|
|
26
|
-
</Link>
|
|
27
|
-
</li>
|
|
28
|
-
))}
|
|
29
|
-
</ul>
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const getBreadcrumbs = (
|
|
2
|
-
pathname: string,
|
|
3
|
-
labels?: Record<string, string>
|
|
4
|
-
) => {
|
|
5
|
-
const segments = pathname.split("/").filter(Boolean);
|
|
6
|
-
|
|
7
|
-
const breadcrumbs = segments.map((segment, index) => {
|
|
8
|
-
const path = `/${segments.slice(0, index + 1).join("/")}`;
|
|
9
|
-
return {
|
|
10
|
-
href: { pathname: path },
|
|
11
|
-
segment: labels?.[segment] || segment, // always fallback to segment if label is falsy
|
|
12
|
-
};
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
return breadcrumbs;
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Breadcrumbs } from './Breadcrumbs';
|