From 794ac7a61a55f6f82499769f1ca331e764f4d737 Mon Sep 17 00:00:00 2001 From: yatsukbogdan Date: Mon, 19 Dec 2022 00:42:12 +0200 Subject: [PATCH 1/2] Aligns Switch design according to the latest Figma updates --- .../LabeledSwitch/LabeledSwitch.tsx | 2 +- .../connection/CatalogTree/BulkHeader.tsx | 2 +- .../connection/CatalogTree/FieldRow.tsx | 4 +- .../connection/CatalogTree/StreamHeader.tsx | 2 +- .../CatalogTree/next/BulkEditPanel.tsx | 7 +- .../CatalogTree/next/CatalogTreeTableRow.tsx | 2 +- .../StreamPanelHeader/StreamPanelHeader.tsx | 2 +- .../components/ui/Switch/Switch.module.scss | 120 +++++++++++------- .../components/ui/Switch/Switch.stories.tsx | 2 +- .../src/components/ui/Switch/Switch.tsx | 34 ++++- 10 files changed, 115 insertions(+), 62 deletions(-) diff --git a/airbyte-webapp/src/components/LabeledSwitch/LabeledSwitch.tsx b/airbyte-webapp/src/components/LabeledSwitch/LabeledSwitch.tsx index 48f2e9880af1..66cac29bd248 100644 --- a/airbyte-webapp/src/components/LabeledSwitch/LabeledSwitch.tsx +++ b/airbyte-webapp/src/components/LabeledSwitch/LabeledSwitch.tsx @@ -6,7 +6,7 @@ import { Switch } from "components/ui/Switch"; import styles from "./LabeledSwitch.module.scss"; -interface LabeledSwitchProps extends React.InputHTMLAttributes { +interface LabeledSwitchProps extends Omit, "size"> { message?: React.ReactNode; label?: React.ReactNode; checkbox?: boolean; diff --git a/airbyte-webapp/src/components/connection/CatalogTree/BulkHeader.tsx b/airbyte-webapp/src/components/connection/CatalogTree/BulkHeader.tsx index 4cbf1ad836d2..4bbbe17f7774 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/BulkHeader.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/BulkHeader.tsx @@ -82,7 +82,7 @@ export const BulkHeader: React.FC = () => { - onChangeOption({ selected: !options.selected })} /> + onChangeOption({ selected: !options.selected })} /> diff --git a/airbyte-webapp/src/components/connection/CatalogTree/FieldRow.tsx b/airbyte-webapp/src/components/connection/CatalogTree/FieldRow.tsx index f2ec7d64fceb..544d08d7a0bd 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/FieldRow.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/FieldRow.tsx @@ -61,10 +61,10 @@ const FieldRowInner: React.FC = ({ {!isNestedField && ( - onToggleFieldSelected(field.path, !isSelected)} /> + onToggleFieldSelected(field.path, !isSelected)} /> )} {isNestedField && ( - }> + }> )} diff --git a/airbyte-webapp/src/components/connection/CatalogTree/StreamHeader.tsx b/airbyte-webapp/src/components/connection/CatalogTree/StreamHeader.tsx index 9a1690c118b2..ea1f29071cbe 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/StreamHeader.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/StreamHeader.tsx @@ -118,7 +118,7 @@ export const StreamHeader: React.FC = ({
{

- onChangeOption({ selected: !options.selected })} /> + onChangeOption({ selected: !options.selected })} + />
diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx index 7da5ec35ec24..8434c84cecc8 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx @@ -66,7 +66,7 @@ export const CatalogTreeTableRow: React.FC = ({
)} - + {/* {fieldCount} */} diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/StreamDetailsPanel/StreamPanelHeader/StreamPanelHeader.tsx b/airbyte-webapp/src/components/connection/CatalogTree/next/StreamDetailsPanel/StreamPanelHeader/StreamPanelHeader.tsx index 15ac2571deb1..82f67856d27c 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/StreamDetailsPanel/StreamPanelHeader/StreamPanelHeader.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/StreamDetailsPanel/StreamPanelHeader/StreamPanelHeader.tsx @@ -51,7 +51,7 @@ export const StreamPanelHeader: React.FC = ({ return (
- +
= (args) => ; export const SwitchControl = Template.bind({}); SwitchControl.args = { checked: false, - small: false, + size: "sm", loading: false, }; diff --git a/airbyte-webapp/src/components/ui/Switch/Switch.tsx b/airbyte-webapp/src/components/ui/Switch/Switch.tsx index 3c27f54c5db9..cf72a9d73e9a 100644 --- a/airbyte-webapp/src/components/ui/Switch/Switch.tsx +++ b/airbyte-webapp/src/components/ui/Switch/Switch.tsx @@ -3,18 +3,39 @@ import React from "react"; import styles from "./Switch.module.scss"; -interface SwitchProps extends React.InputHTMLAttributes { - small?: boolean; +type SwitchSize = "lg" | "sm" | "xs"; + +type SwitchVariant = "default" | "strong-blue"; + +interface SwitchProps extends Omit, "size"> { + indeterminate?: boolean; loading?: boolean; + size?: SwitchSize; + variant?: SwitchVariant; } -export const Switch: React.FC = ({ loading, small, checked, value, ...props }) => { +export const Switch: React.FC = ({ + checked, + disabled, + indeterminate, + loading, + size = "lg", + value, + variant = "default", + ...props +}) => { const labelStyle = classnames(styles.switch, { - [styles.small]: small, + [styles.sizeLg]: size === "lg", + [styles.sizeSm]: size === "sm", + [styles.sizeXs]: size === "xs", [styles.loading]: loading, }); const spanStyle = classnames(styles.slider, { - [styles.small]: small, + [styles.sizeLg]: size === "lg", + [styles.sizeSm]: size === "sm", + [styles.sizeXs]: size === "xs", + [styles.variantDefault]: variant === "default", + [styles.variantStrongBlue]: variant === "strong-blue", [styles.loading]: loading, }); @@ -22,10 +43,11 @@ export const Switch: React.FC = ({ loading, small, checked, value,