The Open Standard for Generative UI
Refactor crayon component (#39)
subhama0606d5e2c1b
diff --git a/js/packages/react-ui/src/components/CardHeader/cardHeader.scss b/js/packages/react-ui/src/components/CardHeader/cardHeader.scssindex 7e509686a..70a7d7ce9 100644--- a/js/packages/react-ui/src/components/CardHeader/cardHeader.scss+++ b/js/packages/react-ui/src/components/CardHeader/cardHeader.scss@@ -17,7 +17,7 @@display: flex;flex-direction: row;align-items: center;- gap: map.get(cssUtils.$spacing, "s");+ gap: map.get(cssUtils.$spacing, "2xs");color: map.get(cssUtils.$colors, "text", "primary");@include cssUtils.typography(title, default);diff --git a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsxindex 914f7d93e..0bff1db0c 100644--- a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx+++ b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx@@ -1,5 +1,6 @@import React from "react";-import { Area, LabelList, AreaChart as RechartsAreaChart, XAxis } from "recharts";+import { Area, LabelList, AreaChart as RechartsAreaChart, XAxis, YAxis } from "recharts";+import { useLayoutContext } from "../../../context/LayoutContext";import {ChartConfig,ChartContainer,@@ -22,11 +23,12 @@ export interface AreaChartProps<T extends AreaChartData> {grid?: boolean;label?: boolean;legend?: boolean;- width?: number;- height?: number;opacity?: number;icons?: Partial<Record<keyof T[number], React.ComponentType>>;isAnimationActive?: boolean;+ showYAxis?: boolean;+ xAxisLabel?: string;+ yAxisLabel?: string;}export const AreaChart = <T extends AreaChartData>({@@ -37,17 +39,19 @@ export const AreaChart = <T extends AreaChartData>({grid = true,label = true,legend = true,- width = 800,- height = 400,opacity = 0.5,icons = {},isAnimationActive = true,+ showYAxis = false,+ xAxisLabel,+ yAxisLabel,}: AreaChartProps<T>) => {// excluding the categoryKeyconst dataKeys = Object.keys(data[0] || {}).filter((key) => key !== categoryKey);const palette = getPalette(theme);const colors = getDistributedColors(palette, dataKeys.length);+ const { layout } = useLayoutContext();// Create Configconst chartConfig: ChartConfig = dataKeys.reduce(@@ -62,8 +66,81 @@ export const AreaChart = <T extends AreaChartData>({{},);+ const getTickFormatter = (data: T) => {+ const dataLength = data.length;+ const maxLengthMap = {+ mobile: {+ default: 5,+ 10: 4,+ 11: 4,+ },+ tray: {+ default: 5,+ 8: 4,+ 9: 4,+ 10: 4,+ 11: 4,+ },+ copilot: {+ default: 5,+ 8: 4,+ 9: 4,+ 10: 4,+ 11: 4,+ },+ fullscreen: {+ default: 5,+ 11: 4,+ },+ };++ const layoutConfig =+ maxLengthMap[layout as keyof typeof maxLengthMap] || maxLengthMap.fullscreen;++ const maxLength =+ dataLength >= 11+ ? 4+ : layoutConfig[dataLength as keyof typeof layoutConfig] || layoutConfig.default;++ return (value: string) => {+ if (value.length > maxLength) {+ return `${value.slice(0, maxLength)}...`;+ }+ return value;+ };+ };const getAxisAngle = (data: T) => {- return data.length <= 6 ? 0 : -90;+ const angleConfig = {+ mobile: {+ default: 0,+ ranges: [+ { min: 6, max: 9, angle: -45 },+ { min: 10, max: 10, angle: -60 },+ { min: 11, max: Infinity, angle: -75 },+ ],+ },+ tray: {+ default: 0,+ ranges: [{ min: 8, max: Infinity, angle: -45 }],+ },+ copilot: {+ default: 0,+ ranges: [{ min: 8, max: Infinity, angle: -45 }],+ },+ fullscreen: {+ default: 0,+ ranges: [{ min: 12, max: Infinity, angle: -45 }],+ },+ };++ const layoutConfig = angleConfig[layout as keyof typeof angleConfig] || angleConfig.fullscreen;+ const dataLength = data.length;++ const matchRange = layoutConfig.ranges.find(+ (range) => dataLength >= range.min && dataLength <= range.max,+ );++ return matchRange?.angle ?? layoutConfig.default;};const getTickMargin = (data: T) => {return data.length <= 6 ? 10 : 15;@@ -73,12 +150,10 @@ export const AreaChart = <T extends AreaChartData>({<ChartContainer config={chartConfig}><RechartsAreaChartaccessibilityLayer- width={width}- height={height}data={data}margin={{top: label ? 20 : 10,- left: 12,+ left: showYAxis ? 0 : 12,right: 12,}}>@@ -90,8 +165,25 @@ export const AreaChart = <T extends AreaChartData>({axisLine={false}angle={getAxisAngle(data)}textAnchor="middle"- tickFormatter={(value) => value.slice(0, 4)}+ tickFormatter={getTickFormatter(data)}+ interval="preserveStartEnd"+ label={{+ value: xAxisLabel,+ position: "insideBottom",+ offset: -10,+ className: "crayon-chart-axis-label",+ }}/>+ {showYAxis && (+ <YAxis+ label={{+ value: yAxisLabel,+ position: "insideLeft",+ angle: -90,+ className: "crayon-chart-axis-label",+ }}+ />+ )}<ChartTooltip content={<ChartTooltipContent indicator="dot" />} />{dataKeys.map((key) => {@@ -141,7 +233,6 @@ export const AreaChart = <T extends AreaChartData>({activeDot={{r: 6,}}- isAnimationActive={isAnimationActive}/>);})}diff --git a/js/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsx b/js/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsxindex f70e68015..f99140350 100644--- a/js/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsx@@ -46,29 +46,10 @@ const meta: Meta<AreaChartProps<typeof areaChartData>> = {control: false,table: {type: { summary: "string" },+ defaultValue: { summary: "string" },category: "Data",},},- width: {- description: "The width of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "800" },- category: "Dimensions",- },- },- height: {- description: "The height of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "400" },- category: "Dimensions",- },- },theme: {description:"The color palette theme for the chart. Each theme provides a different set of colors for the areas.",@@ -137,6 +118,42 @@ const meta: Meta<AreaChartProps<typeof areaChartData>> = {category: "Display",},},+ isAnimationActive: {+ description: "Whether to animate the chart",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "Display",+ },+ },+ showYAxis: {+ description: "Whether to display the y-axis",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "Display",+ },+ },+ xAxisLabel: {+ description: "The label for the x-axis",+ control: false,+ table: {+ type: { summary: "string" },+ defaultValue: { summary: "string" },+ category: "Data",+ },+ },+ yAxisLabel: {+ description: "The label for the y-axis",+ control: false,+ table: {+ type: { summary: "string" },+ defaultValue: { summary: "string" },+ category: "Data",+ },+ },},} satisfies Meta<typeof AreaChart>;@@ -150,12 +167,12 @@ export const AreaChartStory: Story = {categoryKey: "month",theme: "ocean",variant: "linear",- width: 460,- height: 300,opacity: 0.5,grid: true,legend: true,label: true,+ isAnimationActive: true,+ showYAxis: false,},render: (args) => (<Card style={{ width: "500px" }}>@@ -187,6 +204,7 @@ const areaChartData = [grid={true}legend={true}label={true}+ isAnimationActive/></Card>`,},@@ -229,8 +247,6 @@ export const AreaChartStoryWithIcons: Story = {<AreaChartdata={areaChartData}categoryKey="month"- width={460}- height={300}theme="ocean"variant="linear"opacity={0.5}@@ -238,6 +254,56 @@ export const AreaChartStoryWithIcons: Story = {legend={true}label={true}icons={icons}+ isAnimationActive+ />+ </Card>`,+ },+ },+ },+};++export const AreaChartStoryWithYAxis: Story = {+ name: "Area Chart with Y-Axis and Axis Labels",+ args: {+ ...AreaChartStory.args,+ showYAxis: true,+ xAxisLabel: "Time Period",+ yAxisLabel: "Number of Users",+ },+ render: (args) => (+ <Card style={{ width: "500px" }}>+ <AreaChart {...args} />+ </Card>+ ),+ parameters: {+ docs: {+ source: {+ code: `+ import { Monitor, TabletSmartphone } from "lucide-react";++ const areaChartData = [+ { month: "January", desktop: 150, mobile: 90 },+ { month: "February", desktop: 280, mobile: 180 },+ { month: "March", desktop: 220, mobile: 140 },+ { month: "April", desktop: 180, mobile: 160 },+ { month: "May", desktop: 250, mobile: 120 },+ { month: "June", desktop: 300, mobile: 180 },+ ];++ <Card style={{ width: "500px" }}>+ <AreaChart+ data={areaChartData}+ categoryKey="month"+ theme="ocean"+ variant="linear"+ opacity={0.5}+ grid={true}+ legend={true}+ label={true}+ isAnimationActive+ showYAxis+ xAxisLabel="Time Period"+ yAxisLabel="Number of Users"/></Card>`,},diff --git a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsxindex 72d86277e..d38599817 100644--- a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx+++ b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx@@ -1,5 +1,6 @@import React from "react";-import { Bar, LabelList, BarChart as RechartsBarChart, XAxis } from "recharts";+import { Bar, LabelList, BarChart as RechartsBarChart, XAxis, YAxis } from "recharts";+import { useLayoutContext } from "../../../context/LayoutContext";import {ChartConfig,ChartContainer,@@ -22,11 +23,12 @@ export interface BarChartProps<T extends BarChartData> {grid?: boolean;label?: boolean;legend?: boolean;- width?: number;- height?: number;radius?: number;icons?: Partial<Record<keyof T[number], React.ComponentType>>;isAnimationActive?: boolean;+ showYAxis?: boolean;+ xAxisLabel?: string;+ yAxisLabel?: string;}export const BarChart = <T extends BarChartData>({@@ -37,17 +39,19 @@ export const BarChart = <T extends BarChartData>({grid = true,label = true,legend = true,- width = 800,- height = 400,icons = {},radius = 4,isAnimationActive = true,+ showYAxis = false,+ xAxisLabel,+ yAxisLabel,}: BarChartProps<T>) => {// excluding the categoryKeyconst dataKeys = Object.keys(data[0] || {}).filter((key) => key !== categoryKey);const palette = getPalette(theme);const colors = getDistributedColors(palette, dataKeys.length);+ const { layout } = useLayoutContext();// Create Configconst chartConfig: ChartConfig = dataKeys.reduce(@@ -62,8 +66,81 @@ export const BarChart = <T extends BarChartData>({{},);+ const getTickFormatter = (data: T) => {+ const dataLength = data.length;+ const maxLengthMap = {+ mobile: {+ default: 5,+ 10: 4,+ 11: 4,+ },+ tray: {+ default: 5,+ 8: 4,+ 9: 4,+ 10: 4,+ 11: 4,+ },+ copilot: {+ default: 5,+ 8: 4,+ 9: 4,+ 10: 4,+ 11: 4,+ },+ fullscreen: {+ default: 5,+ 11: 4,+ },+ };++ const layoutConfig =+ maxLengthMap[layout as keyof typeof maxLengthMap] || maxLengthMap.fullscreen;++ const maxLength =+ dataLength >= 11+ ? 4+ : layoutConfig[dataLength as keyof typeof layoutConfig] || layoutConfig.default;++ return (value: string) => {+ if (value.length > maxLength) {+ return `${value.slice(0, maxLength)}...`;+ }+ return value;+ };+ };const getAxisAngle = (data: T) => {- return data.length <= 6 ? 0 : -90;+ const angleConfig = {+ mobile: {+ default: 0,+ ranges: [+ { min: 6, max: 9, angle: -45 },+ { min: 10, max: 10, angle: -60 },+ { min: 11, max: Infinity, angle: -75 },+ ],+ },+ tray: {+ default: 0,+ ranges: [{ min: 8, max: Infinity, angle: -45 }],+ },+ copilot: {+ default: 0,+ ranges: [{ min: 8, max: Infinity, angle: -45 }],+ },+ fullscreen: {+ default: 0,+ ranges: [{ min: 12, max: Infinity, angle: -45 }],+ },+ };++ const layoutConfig = angleConfig[layout as keyof typeof angleConfig] || angleConfig.fullscreen;+ const dataLength = data.length;++ const matchRange = layoutConfig.ranges.find(+ (range) => dataLength >= range.min && dataLength <= range.max,+ );++ return matchRange?.angle ?? layoutConfig.default;};const getTickMargin = (data: T) => {return data.length <= 6 ? 10 : 15;@@ -73,8 +150,6 @@ export const BarChart = <T extends BarChartData>({<ChartContainer config={chartConfig}><RechartsBarChartaccessibilityLayer- width={width}- height={height}data={data}margin={{top: label ? 30 : 20,@@ -88,9 +163,25 @@ export const BarChart = <T extends BarChartData>({axisLine={false}angle={getAxisAngle(data)}textAnchor="middle"- tickFormatter={(value) => value.slice(0, 4)}+ tickFormatter={getTickFormatter(data)}+ interval="preserveStartEnd"+ label={{+ value: xAxisLabel,+ position: "insideBottom",+ offset: -10,+ className: "crayon-chart-axis-label",+ }}/>-+ {showYAxis && (+ <YAxis+ label={{+ value: yAxisLabel,+ position: "insideLeft",+ angle: -90,+ className: "crayon-chart-axis-label",+ }}+ />+ )}<ChartTooltip content={<ChartTooltipContent />} />{dataKeys.map((key) => {const transformedKey = keyTransform(key);diff --git a/js/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsx b/js/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsxindex 95d118e63..9d72f8d36 100644--- a/js/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsx@@ -46,29 +46,10 @@ const meta: Meta<BarChartProps<typeof barChartData>> = {control: false,table: {type: { summary: "string" },+ defaultValue: { summary: "string" },category: "Data",},},- width: {- description: "The width of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "800" },- category: "Dimensions",- },- },- height: {- description: "The height of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "400" },- category: "Dimensions",- },- },theme: {description:"The color palette theme for the chart. Each theme provides a different set of colors for the areas.",@@ -136,6 +117,42 @@ const meta: Meta<BarChartProps<typeof barChartData>> = {category: "Display",},},+ isAnimationActive: {+ description: "Whether to animate the chart",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "Display",+ },+ },+ showYAxis: {+ description: "Whether to display the y-axis",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "Display",+ },+ },+ xAxisLabel: {+ description: "The label for the x-axis",+ control: false,+ table: {+ type: { summary: "string" },+ defaultValue: { summary: "string" },+ category: "Data",+ },+ },+ yAxisLabel: {+ description: "The label for the y-axis",+ control: false,+ table: {+ type: { summary: "string" },+ defaultValue: { summary: "string" },+ category: "Data",+ },+ },},} satisfies Meta<typeof BarChart>;@@ -149,12 +166,12 @@ export const BarChartStory: Story = {categoryKey: "month",theme: "ocean",variant: "grouped",- width: 460,- height: 300,radius: 4,grid: true,label: true,legend: true,+ isAnimationActive: true,+ showYAxis: false,},render: (args) => (<Card style={{ width: "500px" }}>@@ -183,13 +200,12 @@ const barChartData = [categoryKey="month"data={barChartData}grid- height={300}labellegendradius={4}theme="sunset"variant="grouped"- width={460}+ isAnimationActive/></Card>`,@@ -229,23 +245,68 @@ export const BarChartStoryWithIcons: Story = {mobile: TabletSmartphone,};- <Card- style={{- width: '500px'- }}- >+ <Card style={{ width: "500px" }}><BarChartcategoryKey="month"data={barChartData}grid- height={300}labellegendradius={4}theme="sunset"variant="grouped"- width={460}icons={icons}+ isAnimationActive+ />+ </Card>+ `,+ },+ },+ },+};++export const BarChartStoryWithYAxis: Story = {+ name: "Bar Chart with Y-Axis and Axis Labels",+ args: {+ ...BarChartStory.args,+ showYAxis: true,+ xAxisLabel: "Time Period",+ yAxisLabel: "Number of Users",+ },+ render: (args) => (+ <Card style={{ width: "500px" }}>+ <BarChart {...args} />+ </Card>+ ),+ parameters: {+ docs: {+ source: {+ code: `+ import { Monitor, TabletSmartphone } from "lucide-react";++ const barChartData = [+ { month: "January", desktop: 150, mobile: 90 },+ { month: "February", desktop: 280, mobile: 180 },+ { month: "March", desktop: 220, mobile: 140 },+ { month: "April", desktop: 180, mobile: 160 },+ { month: "May", desktop: 250, mobile: 120 },+ { month: "June", desktop: 300, mobile: 180 },+ ];++ <Card style={{ width: "500px" }}>+ <BarChart+ categoryKey="month"+ data={barChartData}+ grid+ label+ legend+ radius={4}+ theme="sunset"+ variant="grouped"+ isAnimationActive+ showYAxis+ xAxisLabel="Time Period"+ yAxisLabel="Number of Users"/></Card>`,diff --git a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsxindex d731799d4..b32519abb 100644--- a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx+++ b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx@@ -1,5 +1,6 @@import React from "react";-import { LabelList, Line, LineChart as RechartsLineChart, XAxis } from "recharts";+import { LabelList, Line, LineChart as RechartsLineChart, XAxis, YAxis } from "recharts";+import { useLayoutContext } from "../../../context/LayoutContext";import {ChartConfig,ChartContainer,@@ -22,11 +23,12 @@ export interface LineChartProps<T extends LineChartData> {grid?: boolean;label?: boolean;legend?: boolean;- width?: number;- height?: number;strokeWidth?: number;icons?: Partial<Record<keyof T[number], React.ComponentType>>;isAnimationActive?: boolean;+ showYAxis?: boolean;+ xAxisLabel?: string;+ yAxisLabel?: string;}export const LineChart = <T extends LineChartData>({@@ -37,17 +39,19 @@ export const LineChart = <T extends LineChartData>({grid = true,label = true,legend = true,- width = 800,- height = 400,strokeWidth = 2,icons = {},isAnimationActive = true,+ showYAxis = false,+ xAxisLabel,+ yAxisLabel,}: LineChartProps<T>) => {// excluding the categoryKeyconst dataKeys = Object.keys(data[0] || {}).filter((key) => key !== categoryKey);const palette = getPalette(theme);const colors = getDistributedColors(palette, dataKeys.length);+ const { layout } = useLayoutContext();// Create Configconst chartConfig: ChartConfig = dataKeys.reduce(@@ -62,8 +66,81 @@ export const LineChart = <T extends LineChartData>({{},);+ const getTickFormatter = (data: T) => {+ const dataLength = data.length;+ const maxLengthMap = {+ mobile: {+ default: 5,+ 10: 4,+ 11: 4,+ },+ tray: {+ default: 5,+ 8: 4,+ 9: 4,+ 10: 4,+ 11: 4,+ },+ copilot: {+ default: 5,+ 8: 4,+ 9: 4,+ 10: 4,+ 11: 4,+ },+ fullscreen: {+ default: 5,+ 11: 4,+ },+ };++ const layoutConfig =+ maxLengthMap[layout as keyof typeof maxLengthMap] || maxLengthMap.fullscreen;++ const maxLength =+ dataLength >= 11+ ? 4+ : layoutConfig[dataLength as keyof typeof layoutConfig] || layoutConfig.default;++ return (value: string) => {+ if (value.length > maxLength) {+ return `${value.slice(0, maxLength)}...`;+ }+ return value;+ };+ };const getAxisAngle = (data: T) => {- return data.length <= 6 ? 0 : -90;+ const angleConfig = {+ mobile: {+ default: 0,+ ranges: [+ { min: 6, max: 9, angle: -45 },+ { min: 10, max: 10, angle: -60 },+ { min: 11, max: Infinity, angle: -75 },+ ],+ },+ tray: {+ default: 0,+ ranges: [{ min: 8, max: Infinity, angle: -45 }],+ },+ copilot: {+ default: 0,+ ranges: [{ min: 8, max: Infinity, angle: -45 }],+ },+ fullscreen: {+ default: 0,+ ranges: [{ min: 12, max: Infinity, angle: -45 }],+ },+ };++ const layoutConfig = angleConfig[layout as keyof typeof angleConfig] || angleConfig.fullscreen;+ const dataLength = data.length;++ const matchRange = layoutConfig.ranges.find(+ (range) => dataLength >= range.min && dataLength <= range.max,+ );++ return matchRange?.angle ?? layoutConfig.default;};const getTickMargin = (data: T) => {return data.length <= 6 ? 10 : 15;@@ -73,11 +150,10 @@ export const LineChart = <T extends LineChartData>({<ChartContainer config={chartConfig}><RechartsLineChartaccessibilityLayer- width={width}- height={height}data={data}margin={{- top: label ? 20 : 10,+ top: label ? 30 : 10,+ bottom: legend ? 0 : 10,left: 12,right: 12,}}@@ -90,8 +166,25 @@ export const LineChart = <T extends LineChartData>({axisLine={false}angle={getAxisAngle(data)}textAnchor="middle"- tickFormatter={(value) => value.slice(0, 4)}+ tickFormatter={getTickFormatter(data)}+ interval="preserveStartEnd"+ label={{+ value: xAxisLabel,+ position: "insideBottom",+ offset: -10,+ className: "crayon-chart-axis-label",+ }}/>+ {showYAxis && (+ <YAxis+ label={{+ value: yAxisLabel,+ position: "insideLeft",+ angle: -90,+ className: "crayon-chart-axis-label",+ }}+ />+ )}<ChartTooltip content={<ChartTooltipContent indicator="dot" />} />{dataKeys.map((key) => {const transformedKey = keyTransform(key);diff --git a/js/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsx b/js/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsxindex 77ef4aeba..9fa3f9170 100644--- a/js/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsx@@ -47,29 +47,10 @@ const meta: Meta<LineChartProps<typeof lineChartData>> = {control: false,table: {type: { summary: "string" },+ defaultValue: { summary: "string" },category: "Data",},},- width: {- description: "The width of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "800" },- category: "Dimensions",- },- },- height: {- description: "The height of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "400" },- category: "Dimensions",- },- },theme: {description:"The color palette theme for the chart. Each theme provides a different set of colors for the areas.",@@ -137,6 +118,42 @@ const meta: Meta<LineChartProps<typeof lineChartData>> = {category: "Display",},},+ isAnimationActive: {+ description: "Whether to animate the chart",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "Display",+ },+ },+ showYAxis: {+ description: "Whether to display the y-axis",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "Display",+ },+ },+ xAxisLabel: {+ description: "The label for the x-axis",+ control: false,+ table: {+ type: { summary: "string" },+ defaultValue: { summary: "string" },+ category: "Data",+ },+ },+ yAxisLabel: {+ description: "The label for the y-axis",+ control: false,+ table: {+ type: { summary: "string" },+ defaultValue: { summary: "string" },+ category: "Data",+ },+ },},} satisfies Meta<typeof LineChart>;@@ -150,12 +167,12 @@ export const LineChartStory: Story = {categoryKey: "month",theme: "ocean",variant: "natural",- width: 460,- height: 300,strokeWidth: 2,grid: true,label: true,legend: true,+ isAnimationActive: true,+ showYAxis: false,},render: (args) => (<Card style={{ width: "500px" }}>@@ -183,13 +200,12 @@ const lineChartData = [categoryKey="month"data={lineChartData}grid- height={300}labellegendstrokeWidth={2}theme="ocean"variant="natural"- width={460}+ isAnimationActive/></Card>`,@@ -238,14 +254,67 @@ const icons = {categoryKey="month"data={lineChartData}grid- height={300}labellegendstrokeWidth={2}theme="ocean"variant="natural"- width={460}icons={icons}+ isAnimationActive+ />+</Card>+ `,+ },+ },+ },+};++export const LineChartStoryWithYAxis: Story = {+ name: "Line Chart with Y-Axis and Axis Labels",+ args: {+ ...LineChartStory.args,+ showYAxis: true,+ xAxisLabel: "Time Period",+ yAxisLabel: "Number of Users",+ },+ render: (args) => (+ <Card style={{ width: "500px" }}>+ <LineChart {...args} />+ </Card>+ ),+ parameters: {+ docs: {+ source: {+ code: `+ import { Monitor, TabletSmartphone } from "lucide-react";++ const lineChartData = [+ { month: "January", desktop: 150, mobile: 90 },+ { month: "February", desktop: 280, mobile: 180 },+ { month: "March", desktop: 220, mobile: 140 },+ { month: "April", desktop: 180, mobile: 160 },+ { month: "May", desktop: 250, mobile: 120 },+ { month: "June", desktop: 300, mobile: 180 },+];++<Card+ style={{+ width: '500px'+ }}+>+ <LineChart+ categoryKey="month"+ data={lineChartData}+ grid+ label+ legend+ strokeWidth={2}+ theme="ocean"+ variant="natural"+ isAnimationActive+ showYAxis+ xAxisLabel: "Time Period",+ yAxisLabel: "Number of Users",/></Card>`,diff --git a/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx b/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsxindex 77d4b51c8..44496a4b6 100644--- a/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx+++ b/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx@@ -24,8 +24,6 @@ export interface PieChartProps<T extends PieChartData> {format?: "percentage" | "number";legend?: boolean;label?: boolean;- width?: number;- height?: number;isAnimationActive?: boolean;}@@ -53,8 +51,6 @@ export const PieChart = <T extends PieChartData>({format = "number",legend = true,label = true,- width = 800,- height = 400,isAnimationActive = true,}: PieChartProps<T>) => {const { layout } = useLayoutContext();@@ -156,7 +152,7 @@ export const PieChart = <T extends PieChartData>({config={chartConfig}className={clsx("crayon-pie-chart-container", layoutMap[layout])}>- <RechartsPieChart width={width} height={height}>+ <RechartsPieChart><ChartTooltip content={<ChartTooltipContent showPercentage={format === "percentage"} />} />{legend && <ChartLegend content={<ChartLegendContent nameKey={String(categoryKey)} />} />}<Piediff --git a/js/packages/react-ui/src/components/Charts/PieChart/stories/pieChart.stories.tsx b/js/packages/react-ui/src/components/Charts/PieChart/stories/pieChart.stories.tsxindex 880fe2dac..910d8c856 100644--- a/js/packages/react-ui/src/components/Charts/PieChart/stories/pieChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/PieChart/stories/pieChart.stories.tsx@@ -54,26 +54,6 @@ const meta: Meta<PieChartProps<typeof pieChartData>> = {category: "Data",},},- width: {- description: "The width of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "800" },- category: "Dimensions",- },- },- height: {- description: "The height of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "400" },- category: "Dimensions",- },- },theme: {description:"The color palette theme for the chart. Each theme provides a different set of colors for the areas.",@@ -122,6 +102,15 @@ const meta: Meta<PieChartProps<typeof pieChartData>> = {category: "Display",},},+ isAnimationActive: {+ description: "Whether to animate the chart",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "Display",+ },+ },},} satisfies Meta<typeof PieChart>;@@ -139,8 +128,7 @@ export const PieChartStory: Story = {format: "number",legend: true,label: true,- width: 460,- height: 300,+ isAnimationActive: true,},render: (args) => (<Card style={{ width: "500px" }}>@@ -171,12 +159,11 @@ export const PieChartStory: Story = {data={pieChartData}dataKey="value"format="percentage"- height={300}labellegendtheme="ocean"variant="donut"- width={460}+ isAnimationActive/></Card>`,diff --git a/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx b/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsxindex a03958d34..af863997c 100644--- a/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx+++ b/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx@@ -20,8 +20,6 @@ export interface RadarChartProps<T extends RadarChartData> {variant?: "line" | "area";grid?: boolean;legend?: boolean;- width?: number;- height?: number;strokeWidth?: number;areaOpacity?: number;icons?: Partial<Record<keyof T[number], React.ComponentType>>;@@ -35,8 +33,6 @@ export const RadarChart = <T extends RadarChartData>({variant = "line",grid = true,legend = true,- width = 800,- height = 400,strokeWidth = 2,areaOpacity = 0.5,icons = {},@@ -63,12 +59,7 @@ export const RadarChart = <T extends RadarChartData>({return (<ChartContainer config={chartConfig}>- <RechartsRadarChart- width={width}- height={height}- data={data}- margin={{ top: 10, right: 10, bottom: 10, left: 10 }}- >+ <RechartsRadarChart data={data} margin={{ top: 10, right: 10, bottom: 10, left: 10 }}>{grid && <PolarGrid className="crayon-chart-polar-grid" stroke="currentColor" />}<PolarAngleAxis dataKey={categoryKey as string} />diff --git a/js/packages/react-ui/src/components/Charts/RadarChart/stories/raderChart.stories.tsx b/js/packages/react-ui/src/components/Charts/RadarChart/stories/raderChart.stories.tsxindex be87ac340..e1e6a65be 100644--- a/js/packages/react-ui/src/components/Charts/RadarChart/stories/raderChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/RadarChart/stories/raderChart.stories.tsx@@ -51,26 +51,6 @@ const meta: Meta<RadarChartProps<typeof radarChartData>> = {category: "Data",},},- width: {- description: "The width of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "800" },- category: "Dimensions",- },- },- height: {- description: "The height of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "400" },- category: "Dimensions",- },- },theme: {description:"The color palette theme for the chart. Each theme provides a different set of colors for the areas.",@@ -138,6 +118,15 @@ const meta: Meta<RadarChartProps<typeof radarChartData>> = {category: "Display",},},+ isAnimationActive: {+ description: "Whether to animate the chart",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "Display",+ },+ },},} satisfies Meta<typeof RadarChart>;@@ -151,12 +140,11 @@ export const RadarChartStory: Story = {categoryKey: "month",theme: "ocean",variant: "area",- width: 460,- height: 300,strokeWidth: 2,areaOpacity: 0.5,legend: true,grid: true,+ isAnimationActive: true,},render: (args) => (<Card style={{ width: "500px" }}>@@ -186,12 +174,11 @@ export const RadarChartStory: Story = {categoryKey="month"data={radarChartData}grid- height={300}legendstrokeWidth={2}theme="sunset"variant="area"- width={460}+ isAnimationActive/></Card>`,@@ -241,13 +228,12 @@ const icons = {categoryKey="month"data={radarChartData}grid- height={300}legendstrokeWidth={2}theme="sunset"variant="area"- width={460}icons={icons}+ isAnimationActive/></Card>`,diff --git a/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx b/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsxindex da05b2b89..bd7bc5d33 100644--- a/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx+++ b/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx@@ -25,8 +25,6 @@ export interface RadialChartProps<T extends RadialChartData> {legend?: boolean;label?: boolean;grid?: boolean;- width?: number;- height?: number;isAnimationActive?: boolean;}@@ -53,8 +51,6 @@ export const RadialChart = <T extends RadialChartData>({legend = true,label = true,grid = true,- width = 800,- height = 400,isAnimationActive = true,}: RadialChartProps<T>) => {const { layout } = useLayoutContext();@@ -148,8 +144,6 @@ export const RadialChart = <T extends RadialChartData>({className={clsx("crayon-radial-chart-container", layoutMap[layout], "aspect-square")}><RadialBarChart- width={width}- height={height}data={transformedData}startAngle={variant === "circular" ? -90 : 0}endAngle={variant === "circular" ? 270 : 180}diff --git a/js/packages/react-ui/src/components/Charts/RadialChart/stories/radialChart.stories.tsx b/js/packages/react-ui/src/components/Charts/RadialChart/stories/radialChart.stories.tsxindex c1372b842..f60587869 100644--- a/js/packages/react-ui/src/components/Charts/RadialChart/stories/radialChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/RadialChart/stories/radialChart.stories.tsx@@ -55,26 +55,6 @@ const meta: Meta<RadialChartProps<typeof radialChartData>> = {category: "Data",},},- width: {- description: "The width of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "800" },- category: "Dimensions",- },- },- height: {- description: "The height of the chart area in pixels. This excludes margins and padding.",- control: false,- table: {- disable: true,- type: { summary: "number" },- defaultValue: { summary: "400" },- category: "Dimensions",- },- },theme: {description:"The color palette theme for the chart. Each theme provides a different set of colors for the areas.",@@ -132,6 +112,15 @@ const meta: Meta<RadialChartProps<typeof radialChartData>> = {category: "Display",},},+ isAnimationActive: {+ description: "Whether to animate the chart",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "Display",+ },+ },},} satisfies Meta<typeof RadialChart>;@@ -150,8 +139,7 @@ export const RadialChartStory: Story = {legend: true,label: true,grid: true,- width: 460,- height: 300,+ isAnimationActive: true,},render: (args) => (<Card style={{ width: "500px" }}>@@ -189,10 +177,9 @@ const radialChartData = [gridlabellegend+ isAnimationActivetheme="ocean"variant="circular"- width={460}- height={300}/></Card>`,diff --git a/js/packages/react-ui/src/components/Charts/charts.scss b/js/packages/react-ui/src/components/Charts/charts.scssindex 7736b78f1..d99cfec6a 100644--- a/js/packages/react-ui/src/components/Charts/charts.scss+++ b/js/packages/react-ui/src/components/Charts/charts.scss@@ -254,3 +254,9 @@fill: map.get(cssUtils.$colors, "text", "secondary");padding: 0;}++.crayon-chart-axis-label {+ fill: map.get(cssUtils.$colors, "text", "primary");+ @include cssUtils.typography(label, default);+ text-anchor: middle;+}diff --git a/js/packages/react-ui/src/components/FollowUpItem/followUpItem.scss b/js/packages/react-ui/src/components/FollowUpItem/followUpItem.scssindex 0eff85211..5168415c5 100644--- a/js/packages/react-ui/src/components/FollowUpItem/followUpItem.scss+++ b/js/packages/react-ui/src/components/FollowUpItem/followUpItem.scss@@ -5,7 +5,7 @@@include cssUtils.button-reset;@include cssUtils.typography(primary, default);box-sizing: border-box;- padding: map.get(cssUtils.$spacing, "xs") map.get(cssUtils.$spacing, "s");+ padding: map.get(cssUtils.$spacing, "xs") map.get(cssUtils.$spacing, "0");border-bottom: 1px solid map.get(cssUtils.$colors, "strokes", "default");background-color: transparent;gap: map.get(cssUtils.$spacing, "xs");diff --git a/js/packages/react-ui/src/components/Input/input.scss b/js/packages/react-ui/src/components/Input/input.scssindex eb278714b..fa4c4b5c5 100644--- a/js/packages/react-ui/src/components/Input/input.scss+++ b/js/packages/react-ui/src/components/Input/input.scss@@ -22,7 +22,9 @@&-large {padding: map.get(cssUtils.$spacing, "s");}-+ &::placeholder {+ color: map.get(cssUtils.$colors, "text", "disabled");+ }&:focus {outline: none;border-color: map.get(cssUtils.$colors, "strokes", "interactive-el-hover");diff --git a/js/packages/react-ui/src/components/Label/label.scss b/js/packages/react-ui/src/components/Label/label.scssindex 79031321a..7cf5cb035 100644--- a/js/packages/react-ui/src/components/Label/label.scss+++ b/js/packages/react-ui/src/components/Label/label.scss@@ -3,8 +3,8 @@.crayon-label {box-sizing: border-box;- @include cssUtils.typography(label, default);- color: map.get(cssUtils.$colors, "text", "primary");+ @include cssUtils.typography(primary, default);+ color: map.get(cssUtils.$colors, "text", "secondary");&-disabled {color: map.get(cssUtils.$colors, "text", "disabled");diff --git a/js/packages/react-ui/src/components/ListItem/ListItem.tsx b/js/packages/react-ui/src/components/ListItem/ListItem.tsxindex 918cd5e31..a7900b017 100644--- a/js/packages/react-ui/src/components/ListItem/ListItem.tsx+++ b/js/packages/react-ui/src/components/ListItem/ListItem.tsx@@ -26,7 +26,7 @@ const ListItem = React.forwardRef<HTMLDivElement, ListItemProps>((props, ref) =>{title && <div className="crayon-list-item-title">{title}</div>}{subtitle && <div className="crayon-list-item-subtitle">{subtitle}</div>}</div>- {actionIcon && actionIcon}+ {actionIcon && <div className="crayon-list-item-content-action-icon">{actionIcon}</div>}</div>);});diff --git a/js/packages/react-ui/src/components/ListItem/listItem.scss b/js/packages/react-ui/src/components/ListItem/listItem.scssindex c7a1411d9..fd10e1d49 100644--- a/js/packages/react-ui/src/components/ListItem/listItem.scss+++ b/js/packages/react-ui/src/components/ListItem/listItem.scss@@ -26,6 +26,13 @@align-items: flex-start;width: 100%;gap: map.get(cssUtils.$spacing, "2xs");++ &-action-icon {+ display: flex;+ align-items: center;+ justify-content: center;+ padding: map.get(cssUtils.$spacing, "3xs");+ }}.crayon-list-item-title {diff --git a/js/packages/react-ui/src/components/Tabs/Tabs.tsx b/js/packages/react-ui/src/components/Tabs/Tabs.tsxindex e02b72847..56561c0f9 100644--- a/js/packages/react-ui/src/components/Tabs/Tabs.tsx+++ b/js/packages/react-ui/src/components/Tabs/Tabs.tsx@@ -63,8 +63,8 @@ export const TabsTrigger = forwardRef<value={value}{...props}>- {icon}- {text}+ {icon && <span className="crayon-tabs-trigger-icon">{icon}</span>}+ {text && <span className="crayon-tabs-trigger-text">{text}</span>}</TabsPrimitive.Trigger>));diff --git a/js/packages/react-ui/src/components/Tabs/tabs.scss b/js/packages/react-ui/src/components/Tabs/tabs.scssindex e36616a42..98c8a79ca 100644--- a/js/packages/react-ui/src/components/Tabs/tabs.scss+++ b/js/packages/react-ui/src/components/Tabs/tabs.scss@@ -39,6 +39,12 @@padding: map.get(cssUtils.$spacing, "2xs");border-radius: map.get(cssUtils.$radius, "s");background-color: transparent;+ overflow-x: auto;+ scrollbar-width: none;+ -ms-overflow-style: none;+ &::-webkit-scrollbar {+ display: none;+ }}.crayon-tabs-trigger {@@ -46,11 +52,12 @@flex-direction: row;align-items: center;justify-content: center;- gap: map.get(cssUtils.$spacing, "3xs");+ gap: map.get(cssUtils.$spacing, "2xs");box-sizing: border-box;padding: map.get(cssUtils.$spacing, "2xs") map.get(cssUtils.$spacing, "3xs");border: 1px solid transparent;border-radius: map.get(cssUtils.$radius, "xs");+ min-width: 7.3rem;width: 100%;background-color: map.get(cssUtils.$colors, "fills", "container");color: map.get(cssUtils.$colors, "text", "primary");@@ -59,7 +66,19 @@background-color: map.get(cssUtils.$colors, "fills", "background");border-color: map.get(cssUtils.$colors, "strokes", "default");}- & svg {+ &-text {+ text-align: center;+ width: auto;+ max-width: 232px;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ }++ &-icon {+ display: flex;+ align-items: center;+ justify-content: center;width: 14px;height: 14px;}diff --git a/js/packages/react-ui/src/components/Tag/tag.scss b/js/packages/react-ui/src/components/Tag/tag.scssindex e31c621ca..3f9653b4b 100644--- a/js/packages/react-ui/src/components/Tag/tag.scss+++ b/js/packages/react-ui/src/components/Tag/tag.scss@@ -9,8 +9,8 @@max-width: 100%;height: auto;border: 1px solid map.get(cssUtils.$colors, "strokes", "default");- border-radius: map.get(cssUtils.$radius, "xs");- padding: map.get(cssUtils.$spacing, "3xs") map.get(cssUtils.$spacing, "2xs");+ border-radius: map.get(cssUtils.$radius, "s");+ padding: map.get(cssUtils.$spacing, "2xs") map.get(cssUtils.$spacing, "xs");background: map.get(cssUtils.$colors, "fills", "sunk");color: map.get(cssUtils.$colors, "text", "primary");@include cssUtils.typography(body, default);@@ -23,5 +23,7 @@&-text {overflow: hidden;+ white-space: nowrap;+ text-overflow: ellipsis;}}diff --git a/js/packages/react-ui/src/components/TextArea/textArea.scss b/js/packages/react-ui/src/components/TextArea/textArea.scssindex caacf4de5..c5c51b93d 100644--- a/js/packages/react-ui/src/components/TextArea/textArea.scss+++ b/js/packages/react-ui/src/components/TextArea/textArea.scss@@ -14,6 +14,10 @@resize: none;@include cssUtils.typography(primary, default);+ &::placeholder {+ color: map.get(cssUtils.$colors, "text", "disabled");+ }+&:disabled {cursor: not-allowed;}