Skip to content

The Open Standard for Generative UI

Created Steps Component (#51)

subhame48431d20e08
diff --git a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx
index 0bff1db0c..1b08719fe 100644
--- a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx
@@ -27,8 +27,8 @@ export interface AreaChartProps<T extends AreaChartData> {
icons?: Partial<Record<keyof T[number], React.ComponentType>>;
isAnimationActive?: boolean;
showYAxis?: boolean;
- xAxisLabel?: string;
- yAxisLabel?: string;
+ xAxisLabel?: React.ReactNode;
+ yAxisLabel?: React.ReactNode;
}
export const AreaChart = <T extends AreaChartData>({
diff --git a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx
index d38599817..bb55f7815 100644
--- a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx
@@ -27,8 +27,8 @@ export interface BarChartProps<T extends BarChartData> {
icons?: Partial<Record<keyof T[number], React.ComponentType>>;
isAnimationActive?: boolean;
showYAxis?: boolean;
- xAxisLabel?: string;
- yAxisLabel?: string;
+ xAxisLabel?: React.ReactNode;
+ yAxisLabel?: React.ReactNode;
}
export const BarChart = <T extends BarChartData>({
diff --git a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx
index b32519abb..6463d3858 100644
--- a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx
@@ -27,8 +27,8 @@ export interface LineChartProps<T extends LineChartData> {
icons?: Partial<Record<keyof T[number], React.ComponentType>>;
isAnimationActive?: boolean;
showYAxis?: boolean;
- xAxisLabel?: string;
- yAxisLabel?: string;
+ xAxisLabel?: React.ReactNode;
+ yAxisLabel?: React.ReactNode;
}
export const LineChart = <T extends LineChartData>({
diff --git a/js/packages/react-ui/src/components/Steps/Steps.tsx b/js/packages/react-ui/src/components/Steps/Steps.tsx
new file mode 100644
index 000000000..61c2be270
--- /dev/null
+++ b/js/packages/react-ui/src/components/Steps/Steps.tsx
@@ -0,0 +1,33 @@
+import React from "react";
+
+export interface Step {
+ title: React.ReactNode;
+ details: React.ReactNode;
+}
+
+export interface StepsProps {
+ steps: Step[];
+}
+
+export const Steps: React.FC<StepsProps> = ({ steps }) => {
+ return (
+ <div className={`crayon-steps-container`}>
+ <div className="crayon-steps">
+ {steps.map((step, index) => (
+ <div key={index} className={`crayon-step-item`}>
+ <div className="crayon-step-connector">
+ <div className="crayon-step-number">
+ <div className="crayon-step-number-inner">{index + 1}</div>
+ </div>
+ {index < steps.length - 1 && <div className="crayon-connector-line" />}
+ </div>
+ <div className="crayon-step-content">
+ <span className="crayon-step-title">{step.title}</span>
+ <div className="crayon-step-details">{step.details}</div>
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+};
diff --git a/js/packages/react-ui/src/components/Steps/dependencies.ts b/js/packages/react-ui/src/components/Steps/dependencies.ts
new file mode 100644
index 000000000..7783b7014
--- /dev/null
+++ b/js/packages/react-ui/src/components/Steps/dependencies.ts
@@ -0,0 +1,2 @@
+const dependencies = ["Steps"];
+export default dependencies;
diff --git a/js/packages/react-ui/src/components/Steps/index.ts b/js/packages/react-ui/src/components/Steps/index.ts
new file mode 100644
index 000000000..b1b50d6b9
--- /dev/null
+++ b/js/packages/react-ui/src/components/Steps/index.ts
@@ -0,0 +1 @@
+export * from "./Steps";
diff --git a/js/packages/react-ui/src/components/Steps/steps.scss b/js/packages/react-ui/src/components/Steps/steps.scss
new file mode 100644
index 000000000..52b0dccd6
--- /dev/null
+++ b/js/packages/react-ui/src/components/Steps/steps.scss
@@ -0,0 +1,78 @@
+@use "../../cssUtils" as cssUtils;
+
+.crayon-steps-container {
+ min-width: 280px;
+ width: 100%;
+ margin: 0 auto;
+ @include cssUtils.typography(label, small);
+ color: cssUtils.$primary-text;
+}
+
+.crayon-steps {
+ display: flex;
+ flex-direction: column;
+}
+
+.crayon-step-item {
+ display: flex;
+ margin-bottom: cssUtils.$spacing-l;
+ position: relative;
+ color: cssUtils.$primary-text;
+}
+
+.crayon-step-connector {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-right: cssUtils.$spacing-xs;
+}
+
+.crayon-step-number {
+ padding: cssUtils.$spacing-2xs 0px cssUtils.$spacing-2xs 0px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ @include cssUtils.typography(label, default);
+ z-index: 2;
+ color: cssUtils.$secondary-text;
+ background-color: cssUtils.$bg-container;
+}
+.crayon-step-number-inner {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+ background-color: cssUtils.$bg-sunk;
+ color: cssUtils.$secondary-text;
+ outline: 1px solid cssUtils.$stroke-default;
+}
+.crayon-connector-line {
+ width: 1px;
+ flex-grow: 1;
+ position: absolute;
+ top: 0px;
+ bottom: -20px;
+ left: 10px;
+ z-index: 1;
+ border-left: 1px solid cssUtils.$stroke-default;
+}
+.crayon-step-content {
+ padding-top: cssUtils.$spacing-2xs;
+ display: flex;
+ flex-direction: column;
+ gap: cssUtils.$spacing-3xs;
+}
+.crayon-step-title {
+ @include cssUtils.typography(title, default);
+ color: cssUtils.$secondary-text;
+}
+
+.crayon-step-details {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: calc(cssUtils.$spacing-m + 2px);
+ @include cssUtils.typography(body, small);
+}
diff --git a/js/packages/react-ui/src/components/Steps/stories/steps.stories.tsx b/js/packages/react-ui/src/components/Steps/stories/steps.stories.tsx
new file mode 100644
index 000000000..6b5ba130f
--- /dev/null
+++ b/js/packages/react-ui/src/components/Steps/stories/steps.stories.tsx
@@ -0,0 +1,97 @@
+import type { Meta, StoryObj } from "@storybook/react";
+import { Card } from "../../Card";
+import { Steps, StepsProps } from "../Steps";
+
+const stepsData = [
+ {
+ title: "Calorie Surplus",
+ details:
+ "Explore effective methods for gaining weight in a healthy way, such as creating balanced meal plans, incorporating resistance exercises, and focusing on nutrient-rich foods.",
+ },
+ {
+ title: "Protein Intake",
+ details:
+ "Uncover effective approaches to achieve healthy weight gain, including designing nutritious meal schedules, engaging in strength workouts, and utilizing dietary supplements.",
+ },
+ {
+ title: "Resistance Training",
+ details:
+ "Learn about optimal techniques for healthy weight gain, featuring personalized meal strategies, weightlifting routines, and essential vitamins and minerals.",
+ },
+ {
+ title: "Rest and Recovery",
+ details:
+ "Find out the top tips for gaining weight healthily, like meal prepping, doing strength training exercises, and choosing high-calorie, nutritious snacks.",
+ },
+];
+
+const meta: Meta<StepsProps> = {
+ title: "Components/Steps",
+ component: Steps,
+ parameters: {
+ layout: "centered",
+ docs: {
+ description: {
+ component: "```tsx\nimport { Steps } from '@crayon-ui/react-ui';\n```",
+ },
+ },
+ },
+ tags: ["!dev", "autodocs"],
+ argTypes: {
+ steps: {
+ control: false,
+ description:
+ "Array of step objects containing title and details. Title is a string and details is a React Node.",
+ table: {
+ category: "Content",
+ type: { summary: "Step[]" },
+ defaultValue: { summary: "[]" },
+ required: true,
+ },
+ },
+ },
+} satisfies Meta<typeof Steps>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const StepsStory: Story = {
+ name: "Steps",
+ args: {
+ steps: stepsData,
+ },
+ render: (args) => (
+ <Card style={{ width: "500px" }}>
+ <Steps {...args} />
+ </Card>
+ ),
+ parameters: {
+ docs: {
+ source: {
+ code: `
+const steps = [
+ {
+ title: "Calorie Surplus",
+ details: "Explore effective methods for gaining weight in a healthy way...",
+ },
+ {
+ title: "Protein Intake",
+ details: "Uncover effective approaches to achieve healthy weight gain...",
+ },
+ {
+ title: "Resistance Training",
+ details: "Learn about optimal techniques for healthy weight gain...",
+ },
+ {
+ title: "Rest and Recovery",
+ details: "Find out the top tips for gaining weight healthily...",
+ },
+];
+
+<Card style={{ width: "500px" }}>
+ <Steps steps={steps} />
+</Card>`,
+ },
+ },
+ },
+};
diff --git a/js/packages/react-ui/src/components/index.scss b/js/packages/react-ui/src/components/index.scss
index f27440047..ad56af84b 100644
--- a/js/packages/react-ui/src/components/index.scss
+++ b/js/packages/react-ui/src/components/index.scss
@@ -32,3 +32,4 @@
@forward "./TagBlock/tagBlock.scss";
@forward "./TextArea/textArea.scss";
@forward "./TextContent/textContent.scss";
+@forward "./Steps/steps.scss";