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

Add latest book visibility switcher #32

Open
wants to merge 1 commit into
base: feature/implement-automerge
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/assets/icons/eye-slash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/icons/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 28 additions & 3 deletions src/components/_home/_Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ import { Loader, Table, Text } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { useNavigate } from "react-router";
import AddCircle from "../../assets/icons/add_circle.svg";
import Eye from "../../assets/icons/eye.svg";
import EyeSlash from "../../assets/icons/eye-slash.svg";
import FileTypeJson from "../../assets/icons/bi_filetype-json.svg";
import Logo from "../../assets/icons/logo.svg";
import { parseTimestamp } from "../../lib/date/parseTimestamp";
import { useProjects } from "../../lib/operators/useProjects";
import { Action } from "./Action";
import { CreateTestbookModal } from "./CreateTestbookModal";
import classes from "./home.module.scss";
import { useState } from "react";

export function _Home() {
const projects = useProjects();
const navigate = useNavigate();
const [opened, { open, close }] = useDisclosure(false);
const [testsVisible, setTestsVisibility] = useState(true);
const invisibilityPlaceholder = "************";

const toggleTestsVisibility = () => {
setTestsVisibility(!testsVisible);
};

return (
<div className={classes.container}>
<CreateTestbookModal opened={opened} close={close} />
Expand Down Expand Up @@ -49,7 +59,18 @@ export function _Home() {
</Text>
) : (
<>
<div className={classes.tableTitle}>Last testbooks</div>
<div className={classes.tableTitle}>
<div>Last testbooks</div>
<div>
<button type="button" onClick={toggleTestsVisibility}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the Mantine Button component here instead. There's a variant called transparent that would fit well.

We have something similar in the codebase already. See the delete button in the CommentsList component.

https://mantine.dev/core/button/

{testsVisible ? (
<img src={EyeSlash} height={25} width={25} />
) : (
<img src={Eye} color="black" height={25} width={25} />
)}
</button>
</div>
</div>
<Table
verticalSpacing={10}
horizontalSpacing={20}
Expand All @@ -69,8 +90,12 @@ export function _Home() {
key={item.id}
onClick={() => navigate(`/project/${item.id}`)}
>
<Table.Td>{item.title}</Table.Td>
<Table.Td>{item.customer}</Table.Td>
<Table.Td>
{testsVisible ? item.title : invisibilityPlaceholder}
</Table.Td>
<Table.Td>
{testsVisible ? item.customer : invisibilityPlaceholder}
</Table.Td>
<Table.Td>{parseTimestamp(item.createdAt)}</Table.Td>

<Table.Td>
Expand Down
7 changes: 6 additions & 1 deletion src/components/_home/home.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@
}

.tableTitle {
text-align: left;
display: flex;
justify-content: space-between;
font-size: 20px;
font-weight: 700;
width: 100%;
margin-bottom: 15px;
button {
all: unset;
cursor: pointer;
}
}

thead {
Expand Down