Skip to content

The Open Standard for Generative UI

feat(ThemeProvider): Add number typography styles and update mini chart (#163)

subham72248422a150
diff --git a/js/packages/react-ui/package.json b/js/packages/react-ui/package.json
index 295ae1554..9304f16f9 100644
--- a/js/packages/react-ui/package.json
+++ b/js/packages/react-ui/package.json
@@ -2,7 +2,7 @@
"type": "module",
"name": "@crayonai/react-ui",
"license": "MIT",
- "version": "0.8.15",
+ "version": "0.8.16",
"description": "Component library for Generative UI SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -21,6 +21,9 @@
"./tailwind": {
"types": "./dist/lib/tailwind/tailwind.d.ts",
"default": "./dist/lib/tailwind/tailwind.js"
+ },
+ "./scssUtils": {
+ "default": "./dist/styles/cssUtils.scss"
}
},
"files": [
diff --git a/js/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsx b/js/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsx
index f80a5a029..0e83d6c39 100644
--- a/js/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsx
@@ -93,7 +93,13 @@ export const MiniAreaChart = ({
return (
<ChartContainer
config={chartConfig}
- style={{ width: size, height: size, aspectRatio: 1 / 1 }}
+ style={{
+ width: size,
+ height: size,
+ aspectRatio: 1 / 1,
+ minHeight: 100,
+ minWidth: 100,
+ }}
rechartsProps={{
aspect: 1 / 1,
}}
diff --git a/js/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsx b/js/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsx
index baeb8b4a8..7ef2fa1a4 100644
--- a/js/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsx
@@ -97,7 +97,13 @@ export const MiniBarChart = ({
return (
<ChartContainer
config={chartConfig}
- style={{ width: size, height: size, aspectRatio: 1 / 1 }}
+ style={{
+ width: size,
+ height: size,
+ aspectRatio: 1 / 1,
+ minHeight: 100,
+ minWidth: 100,
+ }}
rechartsProps={{
aspect: 1 / 1,
}}
diff --git a/js/packages/react-ui/src/components/Charts/MiniBarChart/miniBarChart.scss b/js/packages/react-ui/src/components/Charts/MiniBarChart/miniBarChart.scss
deleted file mode 100644
index d395a1ecb..000000000
--- a/js/packages/react-ui/src/components/Charts/MiniBarChart/miniBarChart.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-.crayon-charts-mini-bar-chart-container {
- padding: 4px;
-}
diff --git a/js/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsx b/js/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsx
index 60615eb6f..74250882a 100644
--- a/js/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsx
@@ -83,7 +83,13 @@ export const MiniLineChart = ({
return (
<ChartContainer
config={chartConfig}
- style={{ width: size, height: size, aspectRatio: 1 / 1 }}
+ style={{
+ width: size,
+ height: size,
+ aspectRatio: 1 / 1,
+ minHeight: 100,
+ minWidth: 100,
+ }}
rechartsProps={{
aspect: 1 / 1,
}}
diff --git a/js/packages/react-ui/src/components/Charts/charts.scss b/js/packages/react-ui/src/components/Charts/charts.scss
index 25bb23ac6..faf37fbf9 100644
--- a/js/packages/react-ui/src/components/Charts/charts.scss
+++ b/js/packages/react-ui/src/components/Charts/charts.scss
@@ -3,7 +3,6 @@
// bar chart css
@forward "./BarChart/barChart.scss";
@forward "./HorizontalBarChart/horizontalBarChart.scss";
-@forward "./MiniBarChart/miniBarChart.scss";
// area chart css
@forward "./AreaChart/areaChart.scss";
diff --git a/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx b/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
index dc79ea7c6..1bf871ae9 100644
--- a/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
+++ b/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
@@ -209,8 +209,6 @@ const layoutTheme: LayoutTheme = {
const typographyTheme: TypographyTheme = {
// Typography
- // fontPrimary: '400 16px/20px "Inter"',
- // fontPrimaryLetterSpacing: "0px",
// Display & Headings
// Large
@@ -226,25 +224,11 @@ const typographyTheme: TypographyTheme = {
fontHeadingExtraSmall: '500 16px/1.25 "Inter"',
fontHeadingExtraSmallLetterSpacing: "0px",
- // Title Variants
- // Default
- // fontTitle: '500 16px/20px "Inter"',
- // fontTitleLetterSpacing: "0px",
- // Medium
- // fontTitleMedium: '500 16px/20px "Inter"',
- // fontTitleMediumLetterSpacing: "0px",
- // Small
- // fontTitleSmall: '500 16px/20px "Inter"',
- // fontTitleSmallLetterSpacing: "0px",
-
// Body Text
// Regular
fontBody: '400 16px/1.5 "Inter"',
fontBodyLetterSpacing: "0px",
- // fontBodyMedium: '400 16px/20px "Inter"',
- // fontBodyMediumLetterSpacing: "0px",
-
fontBodySmall: '400 14px/1.5 "Inter"',
fontBodySmallLetterSpacing: "0px",
@@ -278,12 +262,7 @@ const typographyTheme: TypographyTheme = {
fontLabelHeavy: '500 16px/1.2 "Inter"',
fontLabelHeavyLetterSpacing: "0px",
- // Medium
- // fontLabelMedium: '400 16px/20px "Inter"',
- // fontLabelMediumLetterSpacing: "0px",
- // fontLabelMediumHeavy: '600 16px/20px "Inter"',
- // fontLabelMediumHeavyLetterSpacing: "0px",
// Small
fontLabelSmall: '400 14px/1.2 "Inter"',
fontLabelSmallLetterSpacing: "0px",
@@ -460,6 +439,10 @@ export const ThemeProvider = ({
--crayon-font-body-small-heavy-letter-spacing: ${theme.fontBodySmallHeavyLetterSpacing};
--crayon-font-body-small: ${theme.fontBodySmall};
--crayon-font-body-small-letter-spacing: ${theme.fontBodySmallLetterSpacing};
+ --crayon-font-body-large-heavy: ${theme.fontBodyLargeHeavy};
+ --crayon-font-body-large-heavy-letter-spacing: ${theme.fontBodyLargeHeavyLetterSpacing};
+ --crayon-font-body-large: ${theme.fontBodyLarge};
+ --crayon-font-body-large-letter-spacing: ${theme.fontBodyLargeLetterSpacing};
--crayon-font-label: ${theme.fontLabel};
--crayon-font-label-letter-spacing: ${theme.fontLabelLetterSpacing};
--crayon-font-label-heavy: ${theme.fontLabelHeavy};
@@ -488,15 +471,32 @@ export const ThemeProvider = ({
--crayon-font-heading-small-letter-spacing: ${theme.fontHeadingSmallLetterSpacing};
--crayon-font-heading-extra-small: ${theme.fontHeadingExtraSmall};
--crayon-font-heading-extra-small-letter-spacing: ${theme.fontHeadingExtraSmallLetterSpacing};
- --crayon-font-body-large-heavy: ${theme.fontBodyLargeHeavy};
- --crayon-font-body-large-heavy-letter-spacing: ${theme.fontBodyLargeHeavyLetterSpacing};
- --crayon-font-body-large: ${theme.fontBodyLarge};
- --crayon-font-body-large-letter-spacing: ${theme.fontBodyLargeLetterSpacing};
--crayon-font-label-2-extra-small: ${theme.fontLabel2ExtraSmall};
--crayon-font-label-2-extra-small-letter-spacing: ${theme.fontLabel2ExtraSmallLetterSpacing};
--crayon-font-label-2-extra-small-heavy: ${theme.fontLabel2ExtraSmallHeavy};
--crayon-font-label-2-extra-small-heavy-letter-spacing: ${theme.fontLabel2ExtraSmallHeavyLetterSpacing};
+ --crayon-font-number-large: ${theme.fontNumberLarge || theme.fontBodyLarge};
+ --crayon-font-number-large-letter-spacing: ${theme.fontNumberLargeLetterSpacing || theme.fontBodyLargeLetterSpacing};
+ --crayon-font-number-large-heavy: ${theme.fontNumberLargeHeavy || theme.fontBodyLargeHeavy};
+ --crayon-font-number-large-heavy-letter-spacing: ${theme.fontNumberLargeHeavyLetterSpacing || theme.fontBodyLargeHeavyLetterSpacing};
+ --crayon-font-number-heavy: ${theme.fontNumberHeavy || theme.fontBodyHeavy};
+ --crayon-font-number-heavy-letter-spacing: ${theme.fontNumberHeavyLetterSpacing || theme.fontBodyHeavyLetterSpacing};
+ --crayon-font-number: ${theme.fontNumber || theme.fontBody};
+ --crayon-font-number-letter-spacing: ${theme.fontNumberLetterSpacing || theme.fontBodyLetterSpacing};
+ --crayon-font-number-small: ${theme.fontNumberSmall || theme.fontBodySmall};
+ --crayon-font-number-small-letter-spacing: ${theme.fontNumberSmallLetterSpacing || theme.fontBodySmallLetterSpacing};
+ --crayon-font-number-small-heavy: ${theme.fontNumberSmallHeavy || theme.fontBodySmallHeavy};
+ --crayon-font-number-small-heavy-letter-spacing: ${theme.fontNumberSmallHeavyLetterSpacing || theme.fontBodySmallHeavyLetterSpacing};
+ --crayon-font-number-extra-small: ${theme.fontNumberExtraSmall || theme.fontLabelExtraSmall};
+ --crayon-font-number-extra-small-letter-spacing: ${theme.fontNumberExtraSmallLetterSpacing || theme.fontLabelExtraSmallLetterSpacing};
+ --crayon-font-number-extra-small-heavy: ${theme.fontNumberExtraSmallHeavy || theme.fontLabelExtraSmallHeavy};
+ --crayon-font-number-extra-small-heavy-letter-spacing: ${theme.fontNumberExtraSmallHeavyLetterSpacing || theme.fontLabelExtraSmallHeavyLetterSpacing};
+ --crayon-font-number-title: ${theme.fontNumberTitle || theme.fontHeadingLarge};
+ --crayon-font-number-title-letter-spacing: ${theme.fontNumberTitleLetterSpacing || theme.fontHeadingLargeLetterSpacing};
+ --crayon-font-number-title-medium: ${theme.fontNumberTitleMedium || theme.fontHeadingMedium};
+ --crayon-font-number-title-medium-letter-spacing: ${theme.fontNumberTitleMediumLetterSpacing || theme.fontHeadingMediumLetterSpacing};
+
--crayon-shadow-s: ${theme.shadowS};
--crayon-shadow-m: ${theme.shadowM};
--crayon-shadow-l: ${theme.shadowL};
diff --git a/js/packages/react-ui/src/components/ThemeProvider/types.ts b/js/packages/react-ui/src/components/ThemeProvider/types.ts
index 70443692e..c431445e3 100644
--- a/js/packages/react-ui/src/components/ThemeProvider/types.ts
+++ b/js/packages/react-ui/src/components/ThemeProvider/types.ts
@@ -252,6 +252,28 @@ export interface TypographyTheme {
fontLabel2ExtraSmallLetterSpacing?: string;
fontLabel2ExtraSmallHeavy?: string;
fontLabel2ExtraSmallHeavyLetterSpacing?: string;
+
+ // Number Font
+ fontNumberLarge?: string;
+ fontNumberLargeLetterSpacing?: string;
+ fontNumberLargeHeavy?: string;
+ fontNumberLargeHeavyLetterSpacing?: string;
+ fontNumberHeavy?: string;
+ fontNumberHeavyLetterSpacing?: string;
+ fontNumber?: string;
+ fontNumberLetterSpacing?: string;
+ fontNumberSmall?: string;
+ fontNumberSmallLetterSpacing?: string;
+ fontNumberSmallHeavy?: string;
+ fontNumberSmallHeavyLetterSpacing?: string;
+ fontNumberExtraSmall?: string;
+ fontNumberExtraSmallLetterSpacing?: string;
+ fontNumberExtraSmallHeavy?: string;
+ fontNumberExtraSmallHeavyLetterSpacing?: string;
+ fontNumberTitle?: string;
+ fontNumberTitleLetterSpacing?: string;
+ fontNumberTitleMedium?: string;
+ fontNumberTitleMediumLetterSpacing?: string;
}
// Effect-related theme properties
diff --git a/js/packages/react-ui/src/cssUtils.scss b/js/packages/react-ui/src/cssUtils.scss
index 3b1c01775..f32ccba7f 100644
--- a/js/packages/react-ui/src/cssUtils.scss
+++ b/js/packages/react-ui/src/cssUtils.scss
@@ -151,6 +151,18 @@ $typography: (
small: typography(crayon-font-heading-small),
extra-small: typography(crayon-font-heading-extra-small),
),
+ number: (
+ large: typography(crayon-font-number-large),
+ large-heavy: typography(crayon-font-number-large-heavy),
+ heavy: typography(crayon-font-number-heavy),
+ default: typography(crayon-font-number),
+ small: typography(crayon-font-number-small),
+ small-heavy: typography(crayon-font-number-small-heavy),
+ extra-small: typography(crayon-font-number-extra-small),
+ extra-small-heavy: typography(crayon-font-number-extra-small-heavy),
+ title: typography(crayon-font-number-title),
+ title-medium: typography(crayon-font-number-title-medium),
+ ),
);
@mixin typography($font-name, $font-variant) {