@mbao01/ui 0.1.6 → 0.1.8
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 -1
- package/dist/types/components/Link/constant.d.ts +4 -5
- package/dist/types/components/Link/types.d.ts +3 -4
- package/dist/types/index.d.ts +0 -1
- package/package.json +4 -4
- package/src/components/Link/Link.tsx +7 -9
- package/src/components/Link/constant.ts +20 -20
- package/src/components/Link/types.ts +3 -15
- package/src/index.ts +0 -1
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +0 -2
- package/dist/types/components/Breadcrumbs/constant.d.ts +0 -6
- package/dist/types/components/Breadcrumbs/index.d.ts +0 -1
- package/dist/types/components/Breadcrumbs/types.d.ts +0 -4
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -30
- package/src/components/Breadcrumbs/constant.ts +0 -17
- package/src/components/Breadcrumbs/index.ts +0 -1
- package/src/components/Breadcrumbs/types.ts +0 -4
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
hover?: boolean | undefined;
|
|
4
|
-
|
|
5
|
-
}) => string;
|
|
1
|
+
export declare const getLinkClasses: (props?: ({
|
|
2
|
+
variant?: "accent" | "default" | "error" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
|
|
3
|
+
hover?: boolean | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { To, LinkProps as RouterLinkProps } from "react-router-dom";
|
|
2
|
-
|
|
2
|
+
import { type VariantProps } from "@mbao01/common/libs";
|
|
3
|
+
import { getLinkClasses } from "./constant";
|
|
3
4
|
export type LinkProps = Omit<RouterLinkProps, "to"> & {
|
|
4
5
|
href: To;
|
|
5
|
-
|
|
6
|
-
variant?: LinkVariant;
|
|
7
|
-
};
|
|
6
|
+
} & VariantProps<typeof getLinkClasses>;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"test:coverage": "vitest run --coverage"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
43
|
+
"@mbao01/common": "^0.0.7",
|
|
44
|
+
"@radix-ui/react-icons": "^1.3.0",
|
|
45
45
|
"clsx": "^2.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"react-router-dom": "^6.22.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "5a26b3e951c2b2a1a6cf5cb597129bc25a336a2d"
|
|
91
91
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import c from "clsx";
|
|
2
1
|
import { Link as RouterLink } from "react-router-dom";
|
|
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 = ({
|
|
8
8
|
href,
|
|
@@ -15,16 +15,14 @@ export const Link = ({
|
|
|
15
15
|
}: LinkProps) => {
|
|
16
16
|
return (
|
|
17
17
|
<RouterLink
|
|
18
|
-
{...props}
|
|
19
18
|
to={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
|
</RouterLink>
|
|
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,19 +1,7 @@
|
|
|
1
1
|
import type { To, LinkProps as RouterLinkProps } from "react-router-dom";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
| "default"
|
|
5
|
-
| "neutral"
|
|
6
|
-
| "primary"
|
|
7
|
-
| "secondary"
|
|
8
|
-
| "accent"
|
|
9
|
-
| "link"
|
|
10
|
-
| "info"
|
|
11
|
-
| "success"
|
|
12
|
-
| "warning"
|
|
13
|
-
| "error";
|
|
2
|
+
import { type VariantProps } from "@mbao01/common/libs";
|
|
3
|
+
import { getLinkClasses } from "./constant";
|
|
14
4
|
|
|
15
5
|
export type LinkProps = Omit<RouterLinkProps, "to"> & {
|
|
16
6
|
href: To;
|
|
17
|
-
|
|
18
|
-
variant?: LinkVariant;
|
|
19
|
-
};
|
|
7
|
+
} & VariantProps<typeof getLinkClasses>;
|
package/src/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Breadcrumbs } from './Breadcrumbs';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useLocation } from "react-router-dom";
|
|
2
|
-
import { getBreadcrumbs } from "./constant";
|
|
3
|
-
import type { BreadcrumbsProps } from "./types";
|
|
4
|
-
import { Link } from "../Link";
|
|
5
|
-
|
|
6
|
-
export const Breadcrumbs = ({ root, labels }: BreadcrumbsProps) => {
|
|
7
|
-
const location = useLocation();
|
|
8
|
-
const breadcrumbs = getBreadcrumbs(location.pathname, labels);
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<div className="breadcrumbs -ml-1 w-fit px-1 text-sm">
|
|
12
|
-
<ul>
|
|
13
|
-
{root && (
|
|
14
|
-
<li>
|
|
15
|
-
<Link hover href="/">
|
|
16
|
-
{root}
|
|
17
|
-
</Link>
|
|
18
|
-
</li>
|
|
19
|
-
)}
|
|
20
|
-
{breadcrumbs.map((crumb) => (
|
|
21
|
-
<li key={crumb.href.pathname}>
|
|
22
|
-
<Link hover href={crumb.href} className="capitalize">
|
|
23
|
-
{crumb.segment}
|
|
24
|
-
</Link>
|
|
25
|
-
</li>
|
|
26
|
-
))}
|
|
27
|
-
</ul>
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
@@ -1,17 +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
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
12
|
-
segment: labels?.[segment] || segment, // always fallback to segment if label is falsy
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return breadcrumbs;
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Breadcrumbs } from './Breadcrumbs';
|