Skip to content

Commit 94bf06a

Browse files
authored
🪟 🐛 🎨 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
1 parent 0b153d1 commit 94bf06a

File tree

12 files changed

+101
-53
lines changed

12 files changed

+101
-53
lines changed

airbyte-webapp/src/components/CreateConnection/__snapshots__/CreateConnectionForm.test.tsx.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ exports[`CreateConnectionForm should render 1`] = `
635635
<div
636636
class="<removed-for-snapshot-test>"
637637
>
638+
<div
639+
class="<removed-for-snapshot-test>"
640+
/>
638641
<label
639642
class="<removed-for-snapshot-test>"
640643
>

airbyte-webapp/src/components/connection/CatalogTree/CatalogTreeHeader.module.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use "scss/variables";
2+
13
%headerCell {
24
font-size: 10px;
35
line-height: 13px;
@@ -7,7 +9,7 @@
79
@extend %headerCell;
810

911
max-width: 43px;
10-
text-align: center;
12+
padding-left: variables.$spacing-sm;
1113
}
1214

1315
.catalogHeader,

airbyte-webapp/src/components/connection/CatalogTree/StreamHeader.module.scss

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
@use "scss/variables";
33
@forward "./CatalogTreeHeader.module.scss";
44

5+
$icon-size: 20px;
6+
57
.icon {
6-
margin-right: 7px;
7-
margin-top: -1px;
8+
width: $icon-size;
9+
height: $icon-size;
10+
display: flex;
11+
align-items: center;
12+
justify-content: center;
813

914
&.plus {
1015
color: colors.$green;
@@ -19,7 +24,6 @@
1924
display: flex;
2025
flex-direction: row;
2126
justify-content: flex-end;
22-
padding-left: 27px;
2327
}
2428

2529
.streamHeaderContent {

airbyte-webapp/src/components/connection/CatalogTree/StreamHeader.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
2-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
31
import classnames from "classnames";
42
import React, { useMemo } from "react";
53
import { FormattedMessage } from "react-intl";
64

75
import { Cell, Row } from "components";
6+
import { MinusIcon } from "components/icons/MinusIcon";
7+
import { PlusIcon } from "components/icons/PlusIcon";
88
import { CheckBox } from "components/ui/CheckBox";
99
import { DropDownOptionDataItem } from "components/ui/DropDown";
1010
import { Switch } from "components/ui/Switch";
@@ -101,15 +101,7 @@ export const StreamHeader: React.FC<StreamHeaderProps> = ({
101101
<Row className={styles.catalogSectionRow}>
102102
{!disabled && (
103103
<div className={checkboxCellCustomStyle}>
104-
{changedSelected && (
105-
<div>
106-
{isStreamEnabled ? (
107-
<FontAwesomeIcon icon={faPlus} size="2x" className={iconStyle} />
108-
) : (
109-
<FontAwesomeIcon icon={faMinus} size="2x" className={iconStyle} />
110-
)}
111-
</div>
112-
)}
104+
<div className={iconStyle}>{changedSelected && (isStreamEnabled ? <PlusIcon /> : <MinusIcon />)}</div>
113105
<CheckBox checked={isSelected} onChange={selectForBulkEdit} />
114106
</div>
115107
)}

airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
line-height: 13px;
4747
display: flex;
4848
justify-content: flex-end;
49-
padding-left: variables.$spacing-xl + variables.$spacing-sm;
49+
gap: variables.$spacing-sm;
5050
}
5151

5252
.cellText {

airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRowIcon.module.scss

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
@use "scss/colors";
2+
@use "scss/variables";
3+
4+
$icon-size: 20px;
25

36
.icon {
4-
margin-right: 7px;
7+
width: $icon-size;
8+
height: $icon-size;
9+
display: flex;
10+
justify-content: center;
11+
align-items: center;
12+
transition: opacity variables.$transition-out;
13+
opacity: 0;
14+
15+
&.visible {
16+
opacity: 1;
17+
}
518

619
&.plus {
720
color: colors.$green;
@@ -13,12 +26,5 @@
1326

1427
&.changed {
1528
color: colors.$blue;
16-
display: flex;
17-
flex-direction: row;
18-
align-items: center;
1929
}
2030
}
21-
22-
:export {
23-
modificationIconColor: colors.$blue;
24-
}
Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,58 @@
1-
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
2-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
31
import classNames from "classnames";
2+
import { useState } from "react";
3+
import { useUpdateEffect } from "react-use";
44

5+
import { MinusIcon } from "components/icons/MinusIcon";
56
import { ModificationIcon } from "components/icons/ModificationIcon";
7+
import { PlusIcon } from "components/icons/PlusIcon";
68

79
import { SyncSchemaStream } from "core/domain/catalog";
810

911
import styles from "./CatalogTreeTableRowIcon.module.scss";
10-
import { useCatalogTreeTableRowProps } from "./useCatalogTreeTableRowProps";
12+
import { StatusToDisplay, useCatalogTreeTableRowProps } from "./useCatalogTreeTableRowProps";
1113

1214
interface CatalogTreeTableRowIconProps {
1315
stream: SyncSchemaStream;
16+
className?: string;
1417
}
15-
export const CatalogTreeTableRowIcon: React.FC<CatalogTreeTableRowIconProps> = ({ stream }) => {
16-
const { statusToDisplay, isSelected } = useCatalogTreeTableRowProps(stream);
1718

18-
if (statusToDisplay === "added") {
19-
return (
20-
<FontAwesomeIcon
21-
icon={faPlus}
22-
size="2x"
23-
className={classNames(styles.icon, { [styles.plus]: !isSelected, [styles.changed]: isSelected })}
24-
/>
25-
);
26-
} else if (statusToDisplay === "removed") {
27-
return (
28-
<FontAwesomeIcon
29-
icon={faMinus}
30-
size="2x"
31-
className={classNames(styles.icon, { [styles.minus]: !isSelected, [styles.changed]: isSelected })}
32-
/>
33-
);
34-
} else if (statusToDisplay === "changed") {
35-
return (
36-
<div className={classNames(styles.icon, styles.changed)}>
37-
<ModificationIcon color={styles.modificationIconColor} />
38-
</div>
39-
);
19+
const getIcon = (statusToDisplay: StatusToDisplay): React.ReactNode | null => {
20+
switch (statusToDisplay) {
21+
case "added":
22+
return <PlusIcon />;
23+
case "removed":
24+
return <MinusIcon />;
25+
case "changed":
26+
return <ModificationIcon color="currentColor" />;
4027
}
41-
return <div />;
28+
29+
return null;
30+
};
31+
32+
const VISIBLE_STATES: readonly StatusToDisplay[] = ["added", "changed", "removed"];
33+
34+
export const CatalogTreeTableRowIcon: React.FC<CatalogTreeTableRowIconProps> = ({ stream, className }) => {
35+
const { statusToDisplay, isSelected } = useCatalogTreeTableRowProps(stream);
36+
const [visibleStatus, setVisibleStatus] = useState(statusToDisplay);
37+
38+
const isVisible = VISIBLE_STATES.includes(statusToDisplay);
39+
40+
useUpdateEffect(() => {
41+
if (isVisible) {
42+
setVisibleStatus(statusToDisplay);
43+
}
44+
}, [statusToDisplay, isVisible]);
45+
46+
const computedClassName = classNames(
47+
styles.icon,
48+
{
49+
[styles.plus]: visibleStatus === "added" && !isSelected,
50+
[styles.minus]: visibleStatus === "removed" && !isSelected,
51+
[styles.changed]: visibleStatus === "changed" || isSelected,
52+
[styles.visible]: isVisible,
53+
},
54+
className
55+
);
56+
57+
return <div className={computedClassName}>{getIcon(visibleStatus)}</div>;
4258
};

airbyte-webapp/src/components/connection/CatalogTree/next/useCatalogTreeTableRowProps.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useConnectionFormService } from "hooks/services/ConnectionForm/Connecti
1111

1212
import styles from "./CatalogTreeTableRow.module.scss";
1313

14-
type StatusToDisplay = "disabled" | "added" | "removed" | "changed" | "unchanged";
14+
export type StatusToDisplay = "disabled" | "added" | "removed" | "changed" | "unchanged";
1515

1616
export const useCatalogTreeTableRowProps = (stream: SyncSchemaStream) => {
1717
const [isSelected] = useBulkEditSelect(stream.id);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
interface MinusIconProps {
2+
color?: string;
3+
}
4+
5+
export const MinusIcon: React.FC<MinusIconProps> = ({ color = "currentColor" }) => (
6+
<svg width="12" height="2" viewBox="0 0 12 2" fill="none">
7+
<path d="M11.8334 1.83317V0.166504H0.166687V1.83317H11.8334Z" fill={color} />
8+
</svg>
9+
);

airbyte-webapp/src/components/icons/ModificationIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { theme } from "theme";
2+
23
interface ModificationIconProps {
34
color?: string;
45
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
interface PlusIconProps {
2+
color?: string;
3+
}
4+
5+
export const PlusIcon: React.FC<PlusIconProps> = ({ color = "currentColor" }) => (
6+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
7+
<path
8+
d="M5.16669 5.1665V0.166504H6.83335V5.1665H11.8334V6.83317H6.83335V11.8332H5.16669V6.83317H0.166687V5.1665H5.16669Z"
9+
fill={color}
10+
/>
11+
</svg>
12+
);

airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/__snapshots__/ConnectionReplicationTab.test.tsx.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,9 @@ exports[`ConnectionReplicationTab should render 1`] = `
581581
<div
582582
class="<removed-for-snapshot-test>"
583583
>
584+
<div
585+
class="<removed-for-snapshot-test>"
586+
/>
584587
<label
585588
class="<removed-for-snapshot-test>"
586589
>

0 commit comments

Comments
 (0)