Skip to content

Commit

Permalink
just click on cells to edit them
Browse files Browse the repository at this point in the history
  • Loading branch information
npinsker committed Jan 15, 2025
1 parent 7a9f981 commit 23207c6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 66 deletions.
66 changes: 24 additions & 42 deletions hunts/src/NameCell.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from "react";
import { Badge, Popover, OverlayTrigger } from "react-bootstrap";
import { useSelector, useDispatch } from "react-redux";
import { faWrench, faTag } from "@fortawesome/free-solid-svg-icons";
import { showModal } from "./modalSlice";
import ClickableIcon from "./ClickableIcon";
import { toggleCollapsed } from "./collapsedPuzzlesSlice";
import { IconChevronDown, IconChevronRight } from "@tabler/icons";
import { faCircle } from "@fortawesome/free-solid-svg-icons";
Expand Down Expand Up @@ -84,6 +82,7 @@ const useToggleRowExpandedProps = (row: Row<Puzzle>) => {
...originalProps,
onClick: (e: MouseEvent) => {
dispatch(toggleCollapsed({ rowId: row.id, huntId: CURRENT_HUNT_ID }));
e.stopPropagation();
return originalProps.onClick(e);
},
};
Expand All @@ -109,8 +108,31 @@ export default function NameCell({

return (
<div
onMouseEnter={() => {
setUiHovered(true);
}}
onMouseLeave={() => {
setUiHovered(false);
}}
onClick={() => {
dispatch(
showModal({
type: "EDIT_PUZZLE",
props: {
huntId,
puzzleId: row.values.id,
name: row.values.name,
url: row.values.url,
isMeta: row.values.is_meta,
hasChannels: !!row.original.chat_room?.text_channel_url,
},
})
);
}}
style={{
paddingLeft: `${row.depth * 2}rem`,
minHeight: '1.4rem', cursor: 'pointer',
backgroundColor: uiHovered ? '#ffe579' : undefined
}}
>
<div
Expand Down Expand Up @@ -147,46 +169,6 @@ export default function NameCell({
<Badge bg="dark" text="white">META</Badge>{" "}
</>
) : null}
<div
style={{
display: "inline-block",
visibility: uiHovered ? "visible" : "hidden",
}}
>
<ClickableIcon
icon={faWrench}
onClick={() =>
dispatch(
showModal({
type: "EDIT_PUZZLE",
props: {
huntId,
puzzleId: row.values.id,
name: row.values.name,
url: row.values.url,
isMeta: row.values.is_meta,
hasChannels: !!row.original.chat_room?.text_channel_url,
},
})
)
}
/>{" "}
<ClickableIcon
icon={faTag}
onClick={() =>
dispatch(
showModal({
type: "EDIT_TAGS",
props: {
huntId,
puzzleId: row.values.id,
puzzleName: row.values.name,
},
})
)
}
/>
</div>
</div>
</div>
);
Expand Down
10 changes: 5 additions & 5 deletions hunts/src/NotesCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function NotesCell({ row, value }: { row: Row; value: string }) {
const [ editing, setEditing ] = useState(false);
const [ editedNotesValue, setEditedNotesValue ] = useState(value);
const dispatch = useDispatch<Dispatch>();

return (
<div
onMouseEnter={() => {
Expand All @@ -26,7 +26,7 @@ export default function NotesCell({ row, value }: { row: Row; value: string }) {
setEditedNotesValue(value);
}
}}
style={{width: "100%", minHeight: '2rem', cursor: !editing ? 'pointer' : undefined, backgroundColor: uiHovered && !editing ? '#ffe579' : undefined}}
style={{width: "100%", minHeight: '1.4rem', cursor: !editing ? 'pointer' : undefined, backgroundColor: uiHovered && !editing ? '#ffe579' : undefined}}
>
{editing ?
<div style={{ display: 'flex' }}>
Expand All @@ -53,7 +53,7 @@ export default function NotesCell({ row, value }: { row: Row; value: string }) {
}
}}
/>
<div
<div
style={{ cursor: 'pointer' }}
onClick={() => { setEditing(false); }}
>
Expand All @@ -64,5 +64,5 @@ export default function NotesCell({ row, value }: { row: Row; value: string }) {
</div>
);
}


46 changes: 27 additions & 19 deletions hunts/src/TagCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { RootState } from "./store";
import type { Hunt, Puzzle, Row } from "./types";

function TagCell({ row }: { row: Row<Puzzle> }) {
const [uiHovered, setUiHovered] = React.useState(false);
const dispatch = useDispatch();
const { id: huntId } = useSelector<RootState, Hunt>((state) => state.hunt);
const puzzleId = row.original.id;
Expand All @@ -21,32 +22,39 @@ function TagCell({ row }: { row: Row<Puzzle> }) {
: row.original.tags.filter((t) => !t.is_meta && t.name !== row.original.name);

return (
<>
<div
onMouseEnter={() => {
setUiHovered(true);
}}
onMouseLeave={() => {
setUiHovered(false);
}}
onClick={() => {
dispatch(
showModal({
type: "EDIT_TAGS",
props: {
huntId,
puzzleId: row.values.id,
puzzleName: row.values.name,
},
})
);
}}
style={{
cursor: 'pointer',
minHeight: '1.4rem',
backgroundColor: uiHovered ? '#ffe579' : undefined
}}>
{tagsToShow.map(({ name, color, id }) => (
<TagPill
name={name}
color={color}
key={name}
onClick={() => dispatch(toggleFilterTag({ name, color, id }))}
/>
))}{" "}

<ClickableIcon
icon={faTag}
onClick={() =>
dispatch(
showModal({
type: "EDIT_TAGS",
props: {
huntId,
puzzleId: row.values.id,
puzzleName: row.values.name,
},
})
)
}
/>{" "}
</>
))}
</div>
);
}

Expand Down

0 comments on commit 23207c6

Please sign in to comment.