From c3d26185a26a2c450aec0d9a049e36cfee07293a Mon Sep 17 00:00:00 2001 From: yatsukbogdan Date: Thu, 10 Nov 2022 22:08:40 +0200 Subject: [PATCH 1/6] Adds new styles for PillButton component with divider --- .../CatalogTree/next/SyncModeSelect.tsx | 11 +-- .../ui/PillSelect/PillButton.module.scss | 78 +++++++++++++++++-- .../components/ui/PillSelect/PillButton.tsx | 27 ++++--- .../components/ui/PillSelect/PillSelect.tsx | 7 +- 4 files changed, 93 insertions(+), 30 deletions(-) diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx b/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx index 9cc8e7756821f..adbb0f15639d1 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx @@ -28,13 +28,10 @@ export const SyncModeSelect: React.FC = ({ options, onChang return options.map(({ value }) => { const { syncMode, destinationSyncMode } = value; return { - label: ( - <> - - {` | `} - - - ), + label: [ + , + , + ], value, }; }); diff --git a/airbyte-webapp/src/components/ui/PillSelect/PillButton.module.scss b/airbyte-webapp/src/components/ui/PillSelect/PillButton.module.scss index 3cf05bde64ae5..b5e5352bee966 100644 --- a/airbyte-webapp/src/components/ui/PillSelect/PillButton.module.scss +++ b/airbyte-webapp/src/components/ui/PillSelect/PillButton.module.scss @@ -19,15 +19,48 @@ } } +@mixin divider-theme($name, $background, $hover) { + &.#{$name} { + .divider { + background-color: $background; + } + + &:not(:disabled) { + &:hover, + &.active { + .divider { + background: $hover; + } + } + } + } +} + +@mixin disabled-theme($name, $background, $text) { + &.#{$name} { + &.disabled { + .icon { + visibility: hidden; + } + + .text { + color: $text; + } + + background-color: $background; + } + } +} + .button { + height: 19px; max-width: 100%; display: flex; flex-direction: row; align-items: center; - padding: 3px 10px; - gap: variables.$spacing-sm; + padding: 0; border: none; - border-radius: 20px; + border-radius: variables.$spacing-xl; cursor: pointer; transition: background-color variables.$transition-out, color variables.$transition-out; @@ -38,11 +71,44 @@ @include theme("red", colors.$red-50, colors.$red-600, colors.$red-100); @include theme("strongRed", colors.$red-300, colors.$white, colors.$red-400); - @include theme("disabled", colors.$grey-50, colors.$grey, colors.$grey-50); + @include disabled-theme("grey", colors.$grey-50, colors.$grey-600); + @include disabled-theme("blue", colors.$blue-50, colors.$blue-600); + @include disabled-theme("strongBlue", colors.$blue-500, colors.$blue-200); + @include disabled-theme("green", colors.$green-50, colors.$green-600); + @include disabled-theme("red", colors.$red-50, colors.$red-600); + @include disabled-theme("strongRed", colors.$red-300, colors.$white); + + @include divider-theme("grey", colors.$grey-100, colors.$grey-200); + @include divider-theme("blue", colors.$blue-100, colors.$blue-200); + @include divider-theme("strongBlue", colors.$blue-200, colors.$blue-100); + @include divider-theme("green", colors.$green-100, colors.$green-500); + @include divider-theme("red", colors.$red-100, colors.$red-200); + @include divider-theme("strongRed", colors.$red-100, colors.$red-100); } .text { - white-space: nowrap; - overflow: hidden; text-overflow: ellipsis; + overflow: hidden; +} + +.icon { + margin-left: auto; + margin-right: variables.$spacing-md; +} + +.labelContainer { + display: flex; + flex-direction: row; + align-items: center; + padding: variables.$spacing-xs variables.$spacing-md; + justify-content: flex-start; + flex: 1; + overflow: hidden; + white-space: nowrap; +} + +.divider { + height: 100%; + min-width: 1px; + transition: background-color variables.$transition-out, color variables.$transition-out; } diff --git a/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx b/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx index 9d9c52338acaf..092c8dbd84ff1 100644 --- a/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx +++ b/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx @@ -19,29 +19,32 @@ const STYLES_BY_VARIANT: Readonly> = { interface PillButtonProps extends React.ButtonHTMLAttributes { active?: boolean; variant?: PillButtonVariant; + labels?: React.ReactNode[]; } -export const PillButton: React.FC> = ({ - children, - active, - variant = "grey", - ...buttonProps -}) => { +export const PillButton: React.FC = ({ active, variant = "grey", labels = [], ...buttonProps }) => { const buttonClassName = classNames( styles.button, { [styles.active]: active, + [styles.disabled]: buttonProps.disabled, }, - buttonProps.disabled ? styles.disabled : STYLES_BY_VARIANT[variant], + STYLES_BY_VARIANT[variant], buttonProps.className ); - return ( ); }; diff --git a/airbyte-webapp/src/components/ui/PillSelect/PillSelect.tsx b/airbyte-webapp/src/components/ui/PillSelect/PillSelect.tsx index 5c8d2b7e60dab..1ddc43f424fd1 100644 --- a/airbyte-webapp/src/components/ui/PillSelect/PillSelect.tsx +++ b/airbyte-webapp/src/components/ui/PillSelect/PillSelect.tsx @@ -11,7 +11,6 @@ interface PillSelectProps extends PickedPopoutProps { export const PillSelect: React.FC = ({ className, ...props }) => { const { isMulti, variant, disabled } = props; - return ( = ({ className, ...props }) = ? value.map(({ label }: { label: string }) => label).join(", ") : value.label : ""; - return ( { @@ -35,9 +34,7 @@ export const PillSelect: React.FC = ({ className, ...props }) = }} active={isOpen} className={className} - > - {label} - + /> } placement="bottom-start" disabled={isOpen || !isMulti || value?.length <= 1} From a0918b170c010de669df9dc7af5ec6c65462d1c1 Mon Sep 17 00:00:00 2001 From: yatsukbogdan Date: Mon, 28 Nov 2022 16:06:28 +0200 Subject: [PATCH 2/6] Change labels to children property usage; Add new storybook component for PillSelect --- .../CatalogTree/next/StreamPathSelect.tsx | 1 + .../CatalogTree/next/SyncModeSelect.tsx | 9 ++++- .../components/ui/PillSelect/PillButton.tsx | 13 +++---- .../components/ui/PillSelect/PillSelect.tsx | 5 +-- .../ui/PillSelect/index.stories.tsx | 36 ++++++++++++++++++- 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/StreamPathSelect.tsx b/airbyte-webapp/src/components/connection/CatalogTree/next/StreamPathSelect.tsx index 86c006c9e31f7..c6f26aff400b9 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/StreamPathSelect.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/StreamPathSelect.tsx @@ -53,6 +53,7 @@ export const StreamPathSelect: React.FC = (props) => { const options = props.paths.map((path) => ({ value: path, label: pathDisplayName(path), + pillLabel: pathDisplayName(path), })); return ( diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx b/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx index adbb0f15639d1..a1d77e6d80f63 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx @@ -28,7 +28,14 @@ export const SyncModeSelect: React.FC = ({ options, onChang return options.map(({ value }) => { const { syncMode, destinationSyncMode } = value; return { - label: [ + label: ( + <> + + {` | `} + + + ), + pillLabel: [ , , ], diff --git a/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx b/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx index 092c8dbd84ff1..39c52db1e1828 100644 --- a/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx +++ b/airbyte-webapp/src/components/ui/PillSelect/PillButton.tsx @@ -1,6 +1,7 @@ import { faCaretDown } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import classNames from "classnames"; +import { Children } from "react"; import { Text } from "../Text"; import styles from "./PillButton.module.scss"; @@ -19,10 +20,9 @@ const STYLES_BY_VARIANT: Readonly> = { interface PillButtonProps extends React.ButtonHTMLAttributes { active?: boolean; variant?: PillButtonVariant; - labels?: React.ReactNode[]; } -export const PillButton: React.FC = ({ active, variant = "grey", labels = [], ...buttonProps }) => { +export const PillButton: React.FC = ({ children, active, variant = "grey", ...buttonProps }) => { const buttonClassName = classNames( styles.button, { @@ -32,16 +32,17 @@ export const PillButton: React.FC = ({ active, variant = "grey" STYLES_BY_VARIANT[variant], buttonProps.className ); + const arrayChildren = Children.toArray(children); return (