@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbao01/next",
3
- "version": "0.0.5",
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://next.ayomidebakare.site",
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
- "@heroicons/react": "^2.1.1",
46
- "@mbao01/common": "^0.0.4",
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": "90d186e3fc64e9dae9f8755fd057540a23e6a4cd"
96
+ "gitHead": "ceb6cef48e8547b4da5c51dda329bd6edee73c0b"
97
97
  }
@@ -1,8 +1,8 @@
1
- import c from "clsx";
2
1
  import NextLink from "next/link";
3
- import { getLinkClasses } from "./constant";
2
+ import { ExternalLinkIcon } from "@radix-ui/react-icons";
3
+ import { cn } from "@mbao01/common/utilities";
4
4
  import { type LinkProps } from "./types";
5
- import { ArrowUpRightIcon } from "@heroicons/react/20/solid";
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
- className={c(getLinkClasses({ hover, variant }), className)}
19
+ target={target}
20
+ className={cn(getLinkClasses({ hover, variant }), className)}
21
+ {...props}
21
22
  >
22
23
  {children}
23
24
  {target === "_blank" && (
24
- <ArrowUpRightIcon
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 c from 'clsx';
2
- import { LinkVariant } from './types';
1
+ import { cva } from "@mbao01/common/libs";
3
2
 
4
- const LINK_VARIANTS = {
5
- accent: c('link-accent'),
6
- default: c('link-default'),
7
- error: c('link-error'),
8
- info: c('link-info'),
9
- link: c('link-link'),
10
- neutral: c('link-neutral'),
11
- primary: c('link-primary'),
12
- secondary: c('link-secondary'),
13
- success: c('link-success'),
14
- warning: c('link-warning'),
15
- } satisfies Record<LinkVariant, string>;
16
-
17
- export const getLinkClasses = ({ hover, variant }: { hover?: boolean; variant?: LinkVariant }) => {
18
- return c('link transition-all', LINK_VARIANTS[variant!], {
19
- 'link-hover': hover,
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 LinkVariant =
4
- | "default"
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,3 +1,3 @@
1
1
  export * from "@mbao01/common";
2
- export { Breadcrumbs } from "./components/Breadcrumbs";
2
+
3
3
  export { Link } from "./components/Link";
@@ -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';
@@ -1,4 +0,0 @@
1
- export type BreadcrumbsProps = {
2
- root?: string;
3
- labels?: Record<string, string>;
4
- };