Skip to content

The Open Standard for Generative UI

Components by AD (#2)

Ankit Dascde7ddfd0863
diff --git a/frontend-sdk/packages/react-ui/.storybook/main.ts b/frontend-sdk/packages/react-ui/.storybook/main.ts
index 768eb03eb..2de07a859 100644
--- a/frontend-sdk/packages/react-ui/.storybook/main.ts
+++ b/frontend-sdk/packages/react-ui/.storybook/main.ts
@@ -3,7 +3,6 @@ import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
- "@storybook/addon-onboarding",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
@@ -12,5 +11,9 @@ const config: StorybookConfig = {
name: "@storybook/react-vite",
options: {},
},
+ previewHead: (head) => `
+ ${head}
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/normalize.css">
+ `,
};
export default config;
diff --git a/frontend-sdk/packages/react-ui/.storybook/preview.ts b/frontend-sdk/packages/react-ui/.storybook/preview.ts
index f61c04af4..37914b18f 100644
--- a/frontend-sdk/packages/react-ui/.storybook/preview.ts
+++ b/frontend-sdk/packages/react-ui/.storybook/preview.ts
@@ -11,6 +11,4 @@ const preview: Preview = {
},
};
-// write decoratorators and global styles here
-
export default preview;
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/FollowUpBlock.tsx b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/FollowUpBlock.tsx
new file mode 100644
index 000000000..76926243d
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/FollowUpBlock.tsx
@@ -0,0 +1,22 @@
+import clsx from "clsx";
+import React from "react";
+import { FollowUpItemProps } from "../FollowUpItem";
+
+export interface FollowUpBlockProps {
+ children: React.ReactElement<FollowUpItemProps> | React.ReactElement<FollowUpItemProps>[];
+ className?: string;
+ style?: React.CSSProperties;
+}
+
+const FollowUpBlock = React.forwardRef<HTMLDivElement, FollowUpBlockProps>((props, ref) => {
+ const { children, className, style } = props;
+ return (
+ <div ref={ref} className={clsx("crayon-follow-up-block", className)} style={style}>
+ {children}
+ </div>
+ );
+});
+
+FollowUpBlock.displayName = "FollowUpBlock";
+
+export { FollowUpBlock };
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/followUpBlock.scss b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/followUpBlock.scss
new file mode 100644
index 000000000..57abec4ec
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/followUpBlock.scss
@@ -0,0 +1,8 @@
+@use "sass:map";
+@use "../../cssUtils" as cssUtils;
+
+.crayon-follow-up-block {
+ display: flex;
+ flex-direction: column;
+ gap: map.get(cssUtils.$spacing, "3xs");
+}
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/index.ts b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/index.ts
new file mode 100644
index 000000000..34593ab9e
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/index.ts
@@ -0,0 +1 @@
+export * from "./FollowUpBlock";
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/stories/FollowUpBlock.stories.tsx b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/stories/FollowUpBlock.stories.tsx
new file mode 100644
index 000000000..0de8e14cd
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpBlock/stories/FollowUpBlock.stories.tsx
@@ -0,0 +1,64 @@
+import { Meta, StoryObj } from "@storybook/react";
+import { Plus } from "lucide-react";
+import { FollowUpItem } from "../../FollowUpItem";
+import "../../FollowUpItem/FollowUpItem.scss";
+import { FollowUpBlock } from "../FollowUpBlock";
+import "../FollowUpBlock.scss";
+
+const meta: Meta<typeof FollowUpBlock> = {
+ title: "Components/FollowUpBlock",
+ component: FollowUpBlock,
+ tags: ["autodocs"],
+ parameters: {
+ layout: "centered",
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof FollowUpBlock>;
+
+export const Default: Story = {
+ render: () => (
+ <FollowUpBlock>
+ <FollowUpItem
+ text="What is machine learning?"
+ onClick={() => console.log("Clicked")}
+ icon={<Plus size={16} />}
+ />
+ </FollowUpBlock>
+ ),
+};
+
+export const MultipleItems: Story = {
+ render: () => (
+ <FollowUpBlock>
+ <FollowUpItem
+ text="Tell me more about artificial intelligence"
+ onClick={() => console.log("Clicked 1")}
+ icon={<Plus size={16} />}
+ />
+ <FollowUpItem
+ text="How does deep learning work?"
+ onClick={() => console.log("Clicked 2")}
+ icon={<Plus size={16} />}
+ />
+ <FollowUpItem
+ text="What are neural networks?"
+ onClick={() => console.log("Clicked 3")}
+ icon={<Plus size={16} />}
+ />
+ </FollowUpBlock>
+ ),
+};
+
+export const CustomStyling: Story = {
+ render: () => (
+ <FollowUpBlock className="custom-class" style={{ backgroundColor: "#f5f5f5", padding: "20px" }}>
+ <FollowUpItem
+ text="How can I customize the appearance?"
+ onClick={() => console.log("Clicked")}
+ icon={<Plus size={16} />}
+ />
+ </FollowUpBlock>
+ ),
+};
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpItem/FollowUpItem.tsx b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/FollowUpItem.tsx
new file mode 100644
index 000000000..afe53f51f
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/FollowUpItem.tsx
@@ -0,0 +1,23 @@
+import clsx from "clsx";
+import React from "react";
+
+export interface FollowUpItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
+ text: React.ReactNode;
+ icon?: React.ReactNode;
+ className?: string;
+ style?: React.CSSProperties;
+}
+
+const FollowUpItem = React.forwardRef<HTMLButtonElement, FollowUpItemProps>((props, ref) => {
+ const { className, style, text, icon, ...rest } = props;
+ return (
+ <button ref={ref} className={clsx("crayon-follow-up-item", className)} style={style} {...rest}>
+ {text}
+ {icon}
+ </button>
+ );
+});
+
+FollowUpItem.displayName = "FollowUpItem";
+
+export { FollowUpItem };
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpItem/followUpItem.scss b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/followUpItem.scss
new file mode 100644
index 000000000..4b88aa59b
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/followUpItem.scss
@@ -0,0 +1,18 @@
+@use "sass:map";
+@use "../../cssUtils" as cssUtils;
+
+.crayon-follow-up-item {
+ @include cssUtils.typography(primary, default);
+ padding: map.get(cssUtils.$spacing, "xs") map.get(cssUtils.$spacing, "s");
+ border-bottom: 1px solid map.get(cssUtils.$colors, "strokes", "default");
+ border-top: 0;
+ border-left: 0;
+ border-right: 0;
+ background-color: transparent;
+ gap: map.get(cssUtils.$spacing, "xs");
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ width: 100%;
+ cursor: pointer;
+}
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpItem/index.ts b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/index.ts
new file mode 100644
index 000000000..9e260c3bd
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/index.ts
@@ -0,0 +1 @@
+export * from "./FollowUpItem";
diff --git a/frontend-sdk/packages/react-ui/src/components/FollowUpItem/stories/FollowUpItem.stories.tsx b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/stories/FollowUpItem.stories.tsx
new file mode 100644
index 000000000..bc6b5375a
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/FollowUpItem/stories/FollowUpItem.stories.tsx
@@ -0,0 +1,53 @@
+import { Meta, StoryObj } from "@storybook/react";
+import { ArrowRight } from "lucide-react";
+import { FollowUpItem } from "../FollowUpItem";
+import "../FollowUpItem.scss";
+
+const meta: Meta<typeof FollowUpItem> = {
+ title: "Components/FollowUpItem",
+ component: FollowUpItem,
+ tags: ["autodocs"],
+ argTypes: {
+ text: {
+ control: "text",
+ description: "The text content of the follow-up item",
+ },
+ icon: {
+ control: "boolean",
+ description: "Whether to show an icon",
+ },
+ className: {
+ control: "text",
+ description: "Additional CSS class names",
+ },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof FollowUpItem>;
+
+export const Default: Story = {
+ args: {
+ text: "Continue with this topic",
+ },
+};
+
+export const WithIcon: Story = {
+ args: {
+ text: "Tell me more",
+ icon: <ArrowRight size={16} />,
+ },
+};
+
+export const CustomStyling: Story = {
+ args: {
+ text: "Custom styled button",
+ icon: <ArrowRight size={16} />,
+ className: "custom-follow-up",
+ style: {
+ backgroundColor: "#f0f9ff",
+ borderColor: "#bae6fd",
+ color: "#0369a1",
+ },
+ },
+};
diff --git a/frontend-sdk/packages/react-ui/src/components/ListBlock/ListBlock.tsx b/frontend-sdk/packages/react-ui/src/components/ListBlock/ListBlock.tsx
new file mode 100644
index 000000000..4c79ad8e0
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListBlock/ListBlock.tsx
@@ -0,0 +1,21 @@
+import clsx from "clsx";
+import React from "react";
+import { ListItemProps } from "../ListItem";
+
+export interface ListBlockProps {
+ children: React.ReactElement<ListItemProps> | React.ReactElement<ListItemProps>[];
+ className?: string;
+ style?: React.CSSProperties;
+}
+
+const ListBlock = React.forwardRef<HTMLDivElement, ListBlockProps>((props, ref) => {
+ return (
+ <div ref={ref} className={clsx("crayon-list-block", props.className)} style={props.style}>
+ {props.children}
+ </div>
+ );
+});
+
+ListBlock.displayName = "ListBlock";
+
+export { ListBlock };
diff --git a/frontend-sdk/packages/react-ui/src/components/ListBlock/index.ts b/frontend-sdk/packages/react-ui/src/components/ListBlock/index.ts
new file mode 100644
index 000000000..4e7cff291
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListBlock/index.ts
@@ -0,0 +1 @@
+export * from "./ListBlock";
diff --git a/frontend-sdk/packages/react-ui/src/components/ListBlock/listBlock.scss b/frontend-sdk/packages/react-ui/src/components/ListBlock/listBlock.scss
new file mode 100644
index 000000000..b20727b68
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListBlock/listBlock.scss
@@ -0,0 +1,11 @@
+@use "sass:map";
+@use "../../cssUtils.scss" as cssUtils;
+
+.crayon-list-block {
+ box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ border: 1px solid map.get(cssUtils.$colors, "strokes", "default");
+ border-radius: map.get(cssUtils.$radius, "m");
+}
diff --git a/frontend-sdk/packages/react-ui/src/components/ListBlock/stories/ListBlock.stories.tsx b/frontend-sdk/packages/react-ui/src/components/ListBlock/stories/ListBlock.stories.tsx
new file mode 100644
index 000000000..4195f89b2
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListBlock/stories/ListBlock.stories.tsx
@@ -0,0 +1,62 @@
+import type { Meta, StoryObj } from "@storybook/react";
+import { ChevronRight, Mail, User } from "lucide-react";
+import { ListItem } from "../../ListItem";
+import "../../ListItem/listItem.scss";
+import { ListBlock } from "../ListBlock";
+import "../listBlock.scss";
+
+const meta: Meta<typeof ListBlock> = {
+ title: "Components/ListBlock",
+ component: ListBlock,
+ tags: ["autodocs"],
+};
+
+export default meta;
+type Story = StoryObj<typeof ListBlock>;
+
+export const Default: Story = {
+ render: () => (
+ <ListBlock>
+ <ListItem
+ decorativeIcon={<User size={16} />}
+ title="John Doe"
+ subtitle="Software Engineer"
+ actionIcon={<ChevronRight size={16} />}
+ />
+ <ListItem
+ decorativeIcon={<Mail size={16} />}
+ title="Jane Smith"
+ subtitle="Product Designer"
+ actionIcon={<ChevronRight size={16} />}
+ />
+ <ListItem
+ decorativeIcon={<Mail size={16} />}
+ title="Simple Item"
+ subtitle="Without icons"
+ actionIcon={<ChevronRight size={16} />}
+ />
+ </ListBlock>
+ ),
+};
+
+export const SingleItem: Story = {
+ render: () => (
+ <ListBlock>
+ <ListItem
+ decorativeIcon={<User size={16} />}
+ title="Single Item"
+ subtitle="With icons"
+ actionIcon={<ChevronRight size={16} />}
+ />
+ </ListBlock>
+ ),
+};
+
+export const NoIcons: Story = {
+ render: () => (
+ <ListBlock>
+ <ListItem title="First Item" subtitle="Description here" />
+ <ListItem title="Second Item" subtitle="Another description" />
+ </ListBlock>
+ ),
+};
diff --git a/frontend-sdk/packages/react-ui/src/components/ListItem/ListItem.tsx b/frontend-sdk/packages/react-ui/src/components/ListItem/ListItem.tsx
new file mode 100644
index 000000000..f43b2ea7f
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListItem/ListItem.tsx
@@ -0,0 +1,36 @@
+import clsx from "clsx";
+import React from "react";
+
+export interface ListItemProps {
+ className?: string;
+ style?: React.CSSProperties;
+ decorativeIcon?: React.ReactNode;
+ title?: React.ReactNode;
+ subtitle?: React.ReactNode;
+ actionIcon?: React.ReactNode;
+ onClick?: () => void;
+}
+
+const ListItem = React.forwardRef<HTMLDivElement, ListItemProps>((props, ref) => {
+ const { className, style, decorativeIcon, title, subtitle, actionIcon, onClick, ...rest } = props;
+ return (
+ <div
+ ref={ref}
+ className={clsx("crayon-list-item", className)}
+ style={style}
+ onClick={onClick}
+ {...rest}
+ >
+ <div className="crayon-list-item-content">
+ {decorativeIcon && decorativeIcon}
+ {title && <div className="crayon-list-item-title">{title}</div>}
+ {subtitle && <div className="crayon-list-item-subtitle">{subtitle}</div>}
+ </div>
+ {actionIcon && actionIcon}
+ </div>
+ );
+});
+
+ListItem.displayName = "ListItem";
+
+export { ListItem };
diff --git a/frontend-sdk/packages/react-ui/src/components/ListItem/index.ts b/frontend-sdk/packages/react-ui/src/components/ListItem/index.ts
new file mode 100644
index 000000000..f86a29296
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListItem/index.ts
@@ -0,0 +1 @@
+export * from "./ListItem";
diff --git a/frontend-sdk/packages/react-ui/src/components/ListItem/listItem.scss b/frontend-sdk/packages/react-ui/src/components/ListItem/listItem.scss
new file mode 100644
index 000000000..3763e1dc7
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListItem/listItem.scss
@@ -0,0 +1,38 @@
+@use "sass:map";
+@use "../../cssUtils.scss" as cssUtils;
+
+.crayon-list-item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: map.get(cssUtils.$spacing, "2xs");
+ border-bottom: 1px solid map.get(cssUtils.$colors, "strokes", "default");
+ padding: map.get(cssUtils.$spacing, "s");
+ cursor: pointer;
+
+ &:last-child {
+ border-bottom: none;
+ }
+
+ svg {
+ color: map.get(cssUtils.$colors, "text", "secondary");
+ }
+
+ .crayon-list-item-content {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ width: 100%;
+ }
+
+ .crayon-list-item-title {
+ @include cssUtils.typography("primary", "default");
+ color: map.get(cssUtils.$colors, "text", "primary");
+ }
+
+ .crayon-list-item-subtitle {
+ @include cssUtils.typography("primary", "default");
+ color: map.get(cssUtils.$colors, "text", "secondary");
+ }
+}
diff --git a/frontend-sdk/packages/react-ui/src/components/ListItem/stories/ListItem.stories.tsx b/frontend-sdk/packages/react-ui/src/components/ListItem/stories/ListItem.stories.tsx
new file mode 100644
index 000000000..367929af6
--- /dev/null
+++ b/frontend-sdk/packages/react-ui/src/components/ListItem/stories/ListItem.stories.tsx
@@ -0,0 +1,88 @@
+import type { Meta, StoryObj } from "@storybook/react";
+import { ChevronRight, Mail, User } from "lucide-react";
+import { ListItem } from "../ListItem";
+import "../listItem.scss";
+
+const meta: Meta<typeof ListItem> = {
+ title: "Components/ListItem",
+ component: ListItem,
+ tags: ["autodocs"],
+ parameters: {
+ layout: "centered",
+ },
+ argTypes: {
+ decorativeIcon: {
+ control: "select",
+ options: ["Mail", "User", "none"],
+ mapping: {
+ Mail: Mail,
+ User: User,
+ none: undefined,
+ },
+ },
+ actionIcon: {
+ control: "select",
+ options: ["ChevronRight", "none"],
+ mapping: {
+ ChevronRight: ChevronRight,
+ none: undefined,
+ },
+ },
+ onClick: { action: "clicked" },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof ListItem>;
+
+export const Default: Story = {
+ args: {
+ title: "List Item Title",
+ subtitle: "Subtitle text goes here",
+ decorativeIcon: <Mail size={16} />,
+ actionIcon: <ChevronRight size={16} />,
+ },
+};
+
+export const WithoutIcons: Story = {
+ args: {
+ title: "List Item Title",
+ subtitle: "Subtitle text goes here",
+ },
+};
+
+export const OnlyDecorativeIcon: Story = {
+ args: {
+ title: "List Item with Icon",
+ subtitle: "Has only decorative icon",
+ decorativeIcon: <User size={16} />,
+ },
+};
+
+export const OnlyActionIcon: Story = {
+ args: {
+ title: "List Item with Action",
+ subtitle: "Has only action icon",
+ actionIcon: <ChevronRight size={16} />,
+ },
+};
+
+export const TitleOnly: Story = {
+ args: {
+ title: "Title Only List Item",
+ },
+};
+
+// Example of how to render title and subtitle with custom styling
+export const CustomStyling: Story = {
+ args: {
+ title: <div style={{ fontWeight: "bold", color: "#333" }}>Custom Styled Title</div>,
+ subtitle: (
+ <div style={{ fontSize: "0.875rem", color: "#666" }}>
+ Custom styled subtitle with different color and size
+ </div>
+ ),
+ decorativeIcon: <Mail size={16} />,
+ actionIcon: <ChevronRight size={16} />,
+ },
+};
diff --git a/frontend-sdk/packages/react-ui/src/components/TextContent/textContent.scss b/frontend-sdk/packages/react-ui/src/components/TextContent/textContent.scss
index 06b818c6b..ad1446f66 100644
--- a/frontend-sdk/packages/react-ui/src/components/TextContent/textContent.scss
+++ b/frontend-sdk/packages/react-ui/src/components/TextContent/textContent.scss
@@ -1,7 +1,35 @@
@use "sass:map";
@use "../../cssUtils" as cssUtils;
+@mixin text-content-variants($variant) {
+ @if $variant == "sunk" {
+ padding: map.get(cssUtils.$spacing, "m");
+ background: map.get(cssUtils.$colors, "fills", "sunk");
+ border-radius: map.get(cssUtils.$radius, "m");
+ border-color: map.get(cssUtils.$colors, "strokes", "default");
+ } @else if $variant == "card" {
+ padding: map.get(cssUtils.$spacing, "m");
+ border-radius: map.get(cssUtils.$radius, "m");
+ border-color: map.get(cssUtils.$colors, "strokes", "default");
+ } @else if $variant == "clear" {
+ border-color: transparent;
+ }
+}
+
.text-content {
box-sizing: border-box;
@include cssUtils.typography(primary, default);
+ border: 1px solid;
+
+ &-sunk {
+ @include text-content-variants("sunk");
+ }
+
+ &-card {
+ @include text-content-variants("card");
+ }
+
+ &-clear {
+ @include text-content-variants("clear");
+ }
}
diff --git a/frontend-sdk/packages/react-ui/src/variables.css b/frontend-sdk/packages/react-ui/src/variables.css
index 4ddf38d94..d0181c409 100644
--- a/frontend-sdk/packages/react-ui/src/variables.css
+++ b/frontend-sdk/packages/react-ui/src/variables.css
@@ -23,8 +23,8 @@ body {
/* Text colors */
--brand-text: #ffffff;
--brand-secondary-text: #ffffff;
- --primary-text: #ffffff;
- --secondary-text: #ffffff;
+ --primary-text: #000000;
+ --secondary-text: #928f8f;
--disabled-text: #000000;
--danger-text: #d92d20;
--success-text: #079455;