Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight rows on focus #486

Merged
4 commits merged into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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%);
}