@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dust-tt/sparkle",
3
- "version": "0.2.213",
3
+ "version": "0.2.214-pr2",
4
4
  "scripts": {
5
5
  "build": "rm -rf dist && rollup -c",
6
6
  "build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
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
+ };