@dust-tt/sparkle 0.2.213 → 0.2.214-pr2
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/dist/cjs/_index.d.ts +2 -0
- package/dist/cjs/components/Breadcrumbs.d.ts +13 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/stories/Breadcrumbs.stories.d.ts +8 -0
- package/dist/esm/_index.d.ts +2 -0
- package/dist/esm/components/Breadcrumbs.d.ts +13 -0
- package/dist/esm/index.js +15 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stories/Breadcrumbs.stories.d.ts +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_index.ts +3 -0
- package/src/components/Breadcrumbs.tsx +56 -0
- package/src/stories/Breadcrumbs.stories.tsx +31 -0
package/package.json
CHANGED
package/src/_index.ts
CHANGED
|
@@ -148,6 +148,9 @@ export { Markdown };
|
|
|
148
148
|
import { DataTable } from "./components/DataTable";
|
|
149
149
|
export { DataTable };
|
|
150
150
|
|
|
151
|
+
import { Breadcrumbs } from "@sparkle/components/Breadcrumbs";
|
|
152
|
+
export { Breadcrumbs };
|
|
153
|
+
|
|
151
154
|
import {
|
|
152
155
|
LogoHorizontalColor as LogoHorizontalColorLogo,
|
|
153
156
|
LogoHorizontalColorLayer1 as LogoHorizontalColorLogoLayer1,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import { SparkleContextLinkType } from "@sparkle/context";
|
|
5
|
+
import { ChevronRightIcon, Icon, SparkleContext } from "@sparkle/index";
|
|
6
|
+
|
|
7
|
+
type BreadcrumbProps = {
|
|
8
|
+
items: {
|
|
9
|
+
label: string;
|
|
10
|
+
icon?: ComponentType<{ className?: string }>;
|
|
11
|
+
href?: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function Breadcrumbs({ items }: BreadcrumbProps) {
|
|
16
|
+
const { components } = React.useContext(SparkleContext);
|
|
17
|
+
|
|
18
|
+
const Link: SparkleContextLinkType = components.link;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="gap-2 s-flex s-flex-row s-items-center">
|
|
22
|
+
{items.map((item, index) => (
|
|
23
|
+
<div key={index} className="s-flex s-flex-row s-items-center s-gap-1">
|
|
24
|
+
<Icon visual={item.icon} className="s-text-brand" />
|
|
25
|
+
<div>
|
|
26
|
+
{item.href ? (
|
|
27
|
+
<Link
|
|
28
|
+
href={item.href}
|
|
29
|
+
className={
|
|
30
|
+
index === items.length - 1
|
|
31
|
+
? "s-text-element-900"
|
|
32
|
+
: "s-text-element-700"
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
{item.label}
|
|
36
|
+
</Link>
|
|
37
|
+
) : (
|
|
38
|
+
<span
|
|
39
|
+
className={
|
|
40
|
+
index === items.length - 1
|
|
41
|
+
? "s-text-element-900"
|
|
42
|
+
: "s-text-element-700"
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
{item.label}
|
|
46
|
+
</span>
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
{index === items.length - 1 ? null : (
|
|
50
|
+
<ChevronRightIcon className="s-text-element-500" />
|
|
51
|
+
)}
|
|
52
|
+
</div>
|
|
53
|
+
))}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import { Breadcrumbs, CompanyIcon, HomeIcon } from "../index_with_tw_base";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/Breadcrumbs",
|
|
8
|
+
component: Breadcrumbs,
|
|
9
|
+
} satisfies Meta<typeof Breadcrumbs>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
export const BreadcrumbsExample = () => {
|
|
14
|
+
const items1 = [
|
|
15
|
+
{ label: "Home", href: "#", icon: HomeIcon },
|
|
16
|
+
{ label: "Vaults", href: ".." },
|
|
17
|
+
{ label: "My Vault" },
|
|
18
|
+
];
|
|
19
|
+
const items2 = [
|
|
20
|
+
{ label: "Home", href: "#", icon: HomeIcon },
|
|
21
|
+
{ label: "Vaults", href: "#", icon: CompanyIcon },
|
|
22
|
+
{ label: "My Vault", href: "#" },
|
|
23
|
+
{ label: "Data Sources" },
|
|
24
|
+
];
|
|
25
|
+
return (
|
|
26
|
+
<div className="s-flex s-flex-col s-gap-4">
|
|
27
|
+
<Breadcrumbs items={items1} />
|
|
28
|
+
<Breadcrumbs items={items2} />
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|