Skip to content

Commit 770dfcf

Browse files
committed
client(LineInput.tsx): update the removeBadge function so it only triggers on double click
1 parent 1ed5e94 commit 770dfcf

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

client/build/asset-manifest.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/build/index.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/build/static/js/main.b1581886.js renamed to client/build/static/js/main.ba7571ef.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/build/static/js/main.b1581886.js.map renamed to client/build/static/js/main.ba7571ef.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/components/input/ColorInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const ColorInput: FC<ColorInputProps> = (props) => {
1818
const isError = props.validate(props.value).trim() !== "";
1919

2020
const generateHex = useCallback((): string => {
21-
// return "#" + Math.floor(Math.random() * 16777215).toString(16);
2221
return "#" + Math.random().toString(16).slice(2, 8).toLowerCase();
2322
}, []);
2423

client/src/components/input/LineInput.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,10 @@ const LineInput: FC<InputProps> = (props) => {
2222
});
2323
};
2424

25-
const removeBadge = (badge: Badge) => {
25+
const removeBadge = (index: number) => {
2626
props.updateLine({
2727
lineNumber: props.line.lineNumber,
28-
badges: [...props.line.badges].filter(
29-
(b) =>
30-
!(
31-
b.color === badge.color &&
32-
b.iconName === badge.iconName &&
33-
b.label === badge.label
34-
)
35-
),
28+
badges: [...props.line.badges].filter((_, i) => i !== index),
3629
});
3730
};
3831

@@ -66,7 +59,10 @@ const LineInput: FC<InputProps> = (props) => {
6659
Badges: {props.line.badges.length}
6760
</span>
6861

69-
<HoverText label="Click the badge to remove it" className="ml-auto">
62+
<HoverText
63+
label="Double click on the badge to remove it"
64+
className="ml-auto"
65+
>
7066
<div
7167
className="cursor-pointer text-gh-text-secondary
7268
hover:text-gh-text transition-all duration-150"
@@ -96,11 +92,16 @@ const LineInput: FC<InputProps> = (props) => {
9692

9793
{props.line.badges.length > 0 && (
9894
<div className="flex items-center gap-3 p-2 overflow-hidden flex-wrap">
99-
{props.line.badges.map((badge) => {
95+
{props.line.badges.map((badge, index) => {
10096
return (
10197
<div
10298
key={`${badge.iconName}-${Math.random()}`}
103-
onClick={() => removeBadge(badge)}
99+
onClick={(event) => {
100+
// double click
101+
if (event.detail === 2) {
102+
removeBadge(index);
103+
}
104+
}}
104105
className="flex items-center gap-3 py-[.45rem] px-3 bg-gh-bg-secondary
105106
cursor-pointer border border-solid border-gh-bg-secondary
106107
hover:border-gh-red transition-all duration-150"

client/src/components/popups/LinePopup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface LinePopupProps {
1717
const LinePopup: FC<LinePopupProps> = (props) => {
1818
const [icon, setIcon] = useState<string>("react");
1919
const [label, setLabel] = useState<string>("react");
20-
const [color, setColor] = useState<string>("#3498db");
20+
const [color, setColor] = useState<string>("#5ed3f3");
2121

2222
const handleSave = () => {
2323
props.addBadge({
@@ -33,7 +33,7 @@ const LinePopup: FC<LinePopupProps> = (props) => {
3333
props.closePopup();
3434
setIcon("react");
3535
setLabel("react");
36-
setColor("#3498db");
36+
setColor("#5ed3f3");
3737
};
3838

3939
const activeClasses = "opacity-100 pointer-events-auto scale-100";
@@ -79,7 +79,7 @@ const LinePopup: FC<LinePopupProps> = (props) => {
7979

8080
<ColorInput
8181
label="Badge color"
82-
placeholder="#3498db"
82+
placeholder="#5ed3f3"
8383
value={color}
8484
setValue={(val: string) => setColor(val)}
8585
validate={(val) => validateHex(val)}

0 commit comments

Comments
 (0)