@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 CHANGED
@@ -36,7 +36,7 @@ export default {
36
36
  ...
37
37
  ],
38
38
  "plugins": [
39
- require("@mbao01/common/plugin"), // -> import the tailwind library plugin
39
+ ...require("@mbao01/common/plugin"), // -> import the tailwind library plugin
40
40
  ...
41
41
  ]
42
42
  }
@@ -1,5 +1,4 @@
1
- import { LinkVariant } from './types';
2
- export declare const getLinkClasses: ({ hover, variant }: {
3
- hover?: boolean | undefined;
4
- variant?: LinkVariant | undefined;
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
- export type LinkVariant = "default" | "neutral" | "primary" | "secondary" | "accent" | "link" | "info" | "success" | "warning" | "error";
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
- hover?: boolean;
6
- variant?: LinkVariant;
7
- };
6
+ } & VariantProps<typeof getLinkClasses>;
@@ -1,3 +1,2 @@
1
1
  export * from "@mbao01/common";
2
- export * from "./components/Breadcrumbs";
3
2
  export * from "./components/Link";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/ui",
3
3
  "private": false,
4
- "version": "0.1.6",
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
- "@heroicons/react": "^2.1.1",
44
- "@mbao01/common": "^0.0.5",
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": "d40fb1867ee09180de85ab18ffe74c4436e43413"
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 { 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 = ({
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
- 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
  </RouterLink>
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,19 +1,7 @@
1
1
  import type { To, LinkProps as RouterLinkProps } from "react-router-dom";
2
-
3
- export type LinkVariant =
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
- hover?: boolean;
18
- variant?: LinkVariant;
19
- };
7
+ } & VariantProps<typeof getLinkClasses>;
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from "@mbao01/common";
2
2
 
3
- export * from "./components/Breadcrumbs";
4
3
  export * from "./components/Link";
@@ -1,2 +0,0 @@
1
- import type { BreadcrumbsProps } from "./types";
2
- export declare const Breadcrumbs: ({ root, labels }: BreadcrumbsProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- export declare const getBreadcrumbs: (pathname: string, labels?: Record<string, string>) => {
2
- href: {
3
- pathname: string;
4
- };
5
- segment: string;
6
- }[];
@@ -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
- };
@@ -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';
@@ -1,4 +0,0 @@
1
- export type BreadcrumbsProps = {
2
- root?: string;
3
- labels?: Record<string, string>;
4
- };