Skip to content

Commit

Permalink
Merge pull request #486 from NBISweden/dev/row-selection
Browse files Browse the repository at this point in the history
Highlight rows on focus
  • Loading branch information
konere10 authored May 23, 2022
2 parents b70264d + 90cae09 commit 6f52c2e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions frontend/src/components/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ export const Cell = ({
comments,
entryId,
onCellUpdate,
onFocusRow,
onBlurRow,
}: {
topic: IssueActivityPair;
date: Date;
hours: number;
comments: string;
entryId: number;
onCellUpdate: (timeEntry: TimeEntry) => void;
onFocusRow: () => void;
onBlurRow: () => void;
}) => {
const [showCommentArea, setShowCommentArea] = useState<boolean>(false);
const [areaComments, setAreaComments] = useState<string>(null);
Expand Down Expand Up @@ -90,6 +94,8 @@ export const Cell = ({
)}`}
onChange={onCellChange}
onKeyUp={onDeleteCellEntry}
onFocus={onFocusRow}
onBlur={onBlurRow}
className="cell"
defaultValue={hours === 0 ? "" : hours}
/>
Expand All @@ -98,6 +104,7 @@ export const Cell = ({
className={comments === "" ? "comment comment-unfilled" : "comment"}
type="button"
title="Toggle comment area"
onFocus={onFocusRow}
onClick={() => onCommentButtonClick()}
></button>
)}
Expand All @@ -113,6 +120,7 @@ export const Cell = ({
rows={2}
maxLength={1000}
onKeyUp={onEscapeArea}
onFocus={onFocusRow}
onBlur={() => setShowCommentArea(false)}
defaultValue={areaComments !== null ? areaComments : comments}
/>
Expand Down
17 changes: 16 additions & 1 deletion frontend/src/components/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@ export const Row = ({

isFav: boolean;
}) => {
// State var for setting the className of the row depending on focus
const [rowClass, setRowClass] = React.useState("row");

const onFocusRow = () => {
setRowClass("row row-focused");
};

const onBlurRow = () => {
setRowClass("row");
};

return (
<>
<div className="row">
<div className={rowClass}>
<div className="col-1 cell-container grip-container">
{isFav ? (
<img src={grip} className="grip" alt="grip to change row sorting" />
Expand Down Expand Up @@ -96,6 +107,8 @@ export const Row = ({
hours={rowHours[i]}
comments={rowEntries[i] ? rowEntries[i].comments : ""}
entryId={rowEntries[i] ? rowEntries[i].id : 0}
onFocusRow={onFocusRow}
onBlurRow={onBlurRow}
/>
);
})}
Expand All @@ -107,6 +120,8 @@ export const Row = ({
className="cell not-outline"
value={getRowSum(topic)}
readOnly
onFocus={onFocusRow}
onBlur={onBlurRow}
/>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Other button classes are defined further down together with other classes for th
}

.star-button {
background-color: hsl(0deg 0% 97%);
background-color: transparent;
border: none;
display: flex;
}
Expand Down Expand Up @@ -635,3 +635,7 @@ Other button classes are defined further down together with other classes for th
right: 3px;
width: 0.7rem;
}

.row-focused {
background-color: hsl(186deg 30% 94%);
}

0 comments on commit 6f52c2e

Please sign in to comment.