From 958c187e826d48ca845459f1fc3298851efb6be8 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Sat, 4 Jun 2022 23:38:16 +0300 Subject: [PATCH 1/5] Various components cleanups - coding style (let -> const, etc.) - avoid double typing of component props, it's not necessary - consistent non-default exports everywhere (except for SquigglePlayground since I'm not 100% sure it's not used somewhere else) - extract common components in SquigglePlayground to avoid copy-paste - other minor improvements --- packages/components/src/components/Alert.tsx | 58 ++- .../components/src/components/CodeEditor.tsx | 5 +- .../src/components/DistributionChart.tsx | 166 +++--- .../src/components/FunctionChart.tsx | 2 +- .../src/components/FunctionChart1Dist.tsx | 8 +- .../components/src/components/JsonEditor.tsx | 10 +- .../src/components/NumberShower.tsx | 13 +- .../src/components/SquiggleChart.tsx | 102 ++-- .../src/components/SquiggleEditor.tsx | 20 +- .../src/components/SquigglePlayground.tsx | 485 +++++++++--------- packages/components/src/index.ts | 4 +- .../src/stories/SquiggleChart.stories.js.map | 1 - 12 files changed, 429 insertions(+), 445 deletions(-) delete mode 100644 packages/components/src/stories/SquiggleChart.stories.js.map diff --git a/packages/components/src/components/Alert.tsx b/packages/components/src/components/Alert.tsx index 4e1dc646..590b1cca 100644 --- a/packages/components/src/components/Alert.tsx +++ b/packages/components/src/components/Alert.tsx @@ -10,23 +10,32 @@ export const Alert: React.FC<{ backgroundColor: string; headingColor: string; bodyColor: string; - icon: React.ReactNode; - children: React.ReactNode; + icon: (props: React.ComponentProps<"svg">) => JSX.Element; + iconColor: string; + children?: React.ReactNode; }> = ({ heading = "Error", backgroundColor, headingColor, bodyColor, - icon, + icon: Icon, + iconColor, children, }) => { return (
-
{icon}
+
@@ -35,49 +44,42 @@ export const Alert: React.FC<{ export const ErrorAlert: React.FC<{ heading: string; - children: React.ReactNode; -}> = ({ heading = "Error", children }) => ( + children?: React.ReactNode; +}> = (props) => (