diff --git a/airbyte-webapp/src/components/EntityTable/components/ConnectEntitiesCell.tsx b/airbyte-webapp/src/components/EntityTable/components/ConnectEntitiesCell.tsx index cdf9048488ab..dbff24eeb6e2 100644 --- a/airbyte-webapp/src/components/EntityTable/components/ConnectEntitiesCell.tsx +++ b/airbyte-webapp/src/components/EntityTable/components/ConnectEntitiesCell.tsx @@ -2,7 +2,7 @@ import React from "react"; import { FormattedMessage } from "react-intl"; import styled from "styled-components"; -import { ImageBlock } from "components/ui/ImageBlock"; +import { NumberBadge } from "components/ui/NumberBadge"; interface IProps { values: Array<{ @@ -13,16 +13,16 @@ interface IProps { entity: "source" | "destination"; } +const Number = styled(NumberBadge)` + margin-right: 6px; +`; + const Content = styled.div<{ enabled?: boolean }>` display: flex; align-items: center; color: ${({ theme, enabled }) => (!enabled ? theme.greyColor40 : "inheret")}; `; -const Image = styled(ImageBlock)` - margin-right: 6px; -`; - const Connector = styled.div` font-weight: normal; font-size: 12px; @@ -34,7 +34,7 @@ const ConnectEntitiesCell: React.FC = ({ values, enabled, entity }) => { if (values.length === 1) { return ( - +
{values[0].name} {values[0].connector} @@ -44,12 +44,16 @@ const ConnectEntitiesCell: React.FC = ({ values, enabled, entity }) => { } if (!values.length) { - return null; + return ( + + + + ); } return ( - +
{`${values[0].connector}, ${values[1].connector}${values.length > 2 ? ",..." : ""}`} diff --git a/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.module.scss b/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.module.scss index 1b7963a9cd05..5d80661bfaf9 100644 --- a/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.module.scss +++ b/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.module.scss @@ -9,35 +9,6 @@ margin-right: 6px; } -.circle { - height: 20px; - width: 20px; - min-width: 20px; - border-radius: 50%; - text-align: center; - margin-right: 6px; - overflow: hidden; - - &.darkBlue { - background: colors.$dark-blue-100; - } - - &.green { - background: colors.$green; - color: colors.$white; - } - - &.red { - background: colors.$red; - color: colors.$white; - } - - &.blue { - background: colors.$blue; - color: colors.$white; - } -} - .small { border-radius: 0%; } @@ -46,16 +17,3 @@ max-height: 100%; max-width: 100%; } - -.number { - font-family: fonts.$primary; - font-style: normal; - font-weight: 600; - font-size: 10px; - color: colors.$white; - padding: 3px 0; - - &.light { - font-weight: 500; - } -} diff --git a/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.stories.tsx b/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.stories.tsx index 5c10509544b3..f8cf9d105ad7 100644 --- a/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.stories.tsx +++ b/airbyte-webapp/src/components/ui/ImageBlock/ImageBlock.stories.tsx @@ -13,6 +13,5 @@ const Template: ComponentStory = (args) => = ({ img, num, small, color, light, ariaLabel }) => { - const imageCircleClassnames = classnames({ - [styles.circle]: num, - [styles.iconContainer]: !num || num === undefined, - [styles.small]: small && !num, - [styles.darkBlue]: !small && num && !color, - [styles.green]: color === "green", - [styles.red]: color === "red", - [styles.blue]: color === "blue", - [styles.light]: light, +export const ImageBlock: React.FC = ({ img, small, "aria-label": ariaLabel }) => { + const imageCircleClassnames = classnames(styles.iconContainer, { + [styles.small]: small, }); - const numberStyles = classnames(styles.number, { [styles.light]: light }); - return (
- {num ?
{num}
:
{getIcon(img)}
} +
{getIcon(img)}
); }; diff --git a/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.module.scss b/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.module.scss new file mode 100644 index 000000000000..e0a6b4a5d309 --- /dev/null +++ b/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.module.scss @@ -0,0 +1,39 @@ +@use "../../../scss/colors"; +@use "../../../scss/fonts"; + +.circle { + height: 20px; + width: fit-content; + min-width: 20px; + border-radius: 10px; + padding: 0 4px; + text-align: center; + overflow: hidden; + display: flex; + justify-content: center; + align-items: center; + line-height: normal; + font-family: fonts.$primary; + font-style: normal; + font-weight: 500; + font-size: 10px; + + &.default { + background: colors.$dark-blue-100; + } + + &.green { + background: colors.$green; + color: colors.$black; + } + + &.red { + background: colors.$red; + color: colors.$black; + } + + &.blue { + background: colors.$blue; + color: colors.$white; + } +} diff --git a/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.stories.tsx b/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.stories.tsx new file mode 100644 index 000000000000..e356afd008f8 --- /dev/null +++ b/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.stories.tsx @@ -0,0 +1,16 @@ +import { ComponentStory, ComponentMeta } from "@storybook/react"; + +import { NumberBadge } from "./NumberBadge"; + +export default { + title: "UI/NumberBadge", + component: NumberBadge, + argTypes: {}, +} as ComponentMeta; + +const Template: ComponentStory = (args) => ; + +export const Primary = Template.bind({}); +Primary.args = { + value: 10, +}; diff --git a/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.tsx b/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.tsx new file mode 100644 index 000000000000..d38716afd5ce --- /dev/null +++ b/airbyte-webapp/src/components/ui/NumberBadge/NumberBadge.tsx @@ -0,0 +1,26 @@ +import classnames from "classnames"; +import React from "react"; + +import styles from "./NumberBadge.module.scss"; + +interface NumberBadgeProps { + value: number; + color?: "green" | "red" | "blue" | "default"; + className?: string; + "aria-label"?: string; +} + +export const NumberBadge: React.FC = ({ value, color, className, "aria-label": ariaLabel }) => { + const numberBadgeClassnames = classnames(styles.circle, className, { + [styles.default]: !color || color === "default", + [styles.green]: color === "green", + [styles.red]: color === "red", + [styles.blue]: color === "blue", + }); + + return ( +
+
{value}
+
+ ); +}; diff --git a/airbyte-webapp/src/components/ui/NumberBadge/index.tsx b/airbyte-webapp/src/components/ui/NumberBadge/index.tsx new file mode 100644 index 000000000000..57fea8264b27 --- /dev/null +++ b/airbyte-webapp/src/components/ui/NumberBadge/index.tsx @@ -0,0 +1 @@ +export * from "./NumberBadge"; diff --git a/airbyte-webapp/src/views/Connection/CatalogDiffModal/components/DiffIconBlock.tsx b/airbyte-webapp/src/views/Connection/CatalogDiffModal/components/DiffIconBlock.tsx index a9c3467fd2ca..b74e011a35ea 100644 --- a/airbyte-webapp/src/views/Connection/CatalogDiffModal/components/DiffIconBlock.tsx +++ b/airbyte-webapp/src/views/Connection/CatalogDiffModal/components/DiffIconBlock.tsx @@ -1,6 +1,6 @@ import { useIntl } from "react-intl"; -import { ImageBlock } from "components/ui/ImageBlock"; +import { NumberBadge } from "components/ui/NumberBadge"; import styles from "./DiffIconBlock.module.scss"; @@ -15,11 +15,10 @@ export const DiffIconBlock: React.FC = ({ newCount, removedC return (
{removedCount > 0 && ( - = ({ newCount, removedC /> )} {newCount > 0 && ( - = ({ newCount, removedC /> )} {changedCount > 0 && ( -