-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟 🐛 🎨 Fix stream table icon checkboxes and icons (#21108)
* Update new stream table icon positioning and style * Add custom icons from design file * Add opacity animation * Fix checkbox sizing in current streams table * Update test snapshots
- Loading branch information
Showing
12 changed files
with
101 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 44 additions & 28 deletions
72
airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRowIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,58 @@ | ||
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import classNames from "classnames"; | ||
import { useState } from "react"; | ||
import { useUpdateEffect } from "react-use"; | ||
|
||
import { MinusIcon } from "components/icons/MinusIcon"; | ||
import { ModificationIcon } from "components/icons/ModificationIcon"; | ||
import { PlusIcon } from "components/icons/PlusIcon"; | ||
|
||
import { SyncSchemaStream } from "core/domain/catalog"; | ||
|
||
import styles from "./CatalogTreeTableRowIcon.module.scss"; | ||
import { useCatalogTreeTableRowProps } from "./useCatalogTreeTableRowProps"; | ||
import { StatusToDisplay, useCatalogTreeTableRowProps } from "./useCatalogTreeTableRowProps"; | ||
|
||
interface CatalogTreeTableRowIconProps { | ||
stream: SyncSchemaStream; | ||
className?: string; | ||
} | ||
export const CatalogTreeTableRowIcon: React.FC<CatalogTreeTableRowIconProps> = ({ stream }) => { | ||
const { statusToDisplay, isSelected } = useCatalogTreeTableRowProps(stream); | ||
|
||
if (statusToDisplay === "added") { | ||
return ( | ||
<FontAwesomeIcon | ||
icon={faPlus} | ||
size="2x" | ||
className={classNames(styles.icon, { [styles.plus]: !isSelected, [styles.changed]: isSelected })} | ||
/> | ||
); | ||
} else if (statusToDisplay === "removed") { | ||
return ( | ||
<FontAwesomeIcon | ||
icon={faMinus} | ||
size="2x" | ||
className={classNames(styles.icon, { [styles.minus]: !isSelected, [styles.changed]: isSelected })} | ||
/> | ||
); | ||
} else if (statusToDisplay === "changed") { | ||
return ( | ||
<div className={classNames(styles.icon, styles.changed)}> | ||
<ModificationIcon color={styles.modificationIconColor} /> | ||
</div> | ||
); | ||
const getIcon = (statusToDisplay: StatusToDisplay): React.ReactNode | null => { | ||
switch (statusToDisplay) { | ||
case "added": | ||
return <PlusIcon />; | ||
case "removed": | ||
return <MinusIcon />; | ||
case "changed": | ||
return <ModificationIcon color="currentColor" />; | ||
} | ||
return <div />; | ||
|
||
return null; | ||
}; | ||
|
||
const VISIBLE_STATES: readonly StatusToDisplay[] = ["added", "changed", "removed"]; | ||
|
||
export const CatalogTreeTableRowIcon: React.FC<CatalogTreeTableRowIconProps> = ({ stream, className }) => { | ||
const { statusToDisplay, isSelected } = useCatalogTreeTableRowProps(stream); | ||
const [visibleStatus, setVisibleStatus] = useState(statusToDisplay); | ||
|
||
const isVisible = VISIBLE_STATES.includes(statusToDisplay); | ||
|
||
useUpdateEffect(() => { | ||
if (isVisible) { | ||
setVisibleStatus(statusToDisplay); | ||
} | ||
}, [statusToDisplay, isVisible]); | ||
|
||
const computedClassName = classNames( | ||
styles.icon, | ||
{ | ||
[styles.plus]: visibleStatus === "added" && !isSelected, | ||
[styles.minus]: visibleStatus === "removed" && !isSelected, | ||
[styles.changed]: visibleStatus === "changed" || isSelected, | ||
[styles.visible]: isVisible, | ||
}, | ||
className | ||
); | ||
|
||
return <div className={computedClassName}>{getIcon(visibleStatus)}</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
interface MinusIconProps { | ||
color?: string; | ||
} | ||
|
||
export const MinusIcon: React.FC<MinusIconProps> = ({ color = "currentColor" }) => ( | ||
<svg width="12" height="2" viewBox="0 0 12 2" fill="none"> | ||
<path d="M11.8334 1.83317V0.166504H0.166687V1.83317H11.8334Z" fill={color} /> | ||
</svg> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { theme } from "theme"; | ||
|
||
interface ModificationIconProps { | ||
color?: string; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
interface PlusIconProps { | ||
color?: string; | ||
} | ||
|
||
export const PlusIcon: React.FC<PlusIconProps> = ({ color = "currentColor" }) => ( | ||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none"> | ||
<path | ||
d="M5.16669 5.1665V0.166504H6.83335V5.1665H11.8334V6.83317H6.83335V11.8332H5.16669V6.83317H0.166687V5.1665H5.16669Z" | ||
fill={color} | ||
/> | ||
</svg> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters