1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

🔧 Improve Summary styling

This commit is contained in:
Stefano Pigozzi 2021-05-11 18:34:07 +02:00
parent d8ac277f47
commit 9ef3a05f04
Signed by untrusted user who does not match committer: steffo
GPG key ID: 6965406171929D01
3 changed files with 50 additions and 63 deletions

View file

@ -7,6 +7,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
/**
* A long line displaying the summary of a certain entity, such as a repository or an user.
*
* @param icon - The icon of the summary.
* @param title - The title of the summary.
* @param subtitle - The subtitle of the summary.
* @param upperLabel - The label for the upper value.
@ -20,7 +21,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
* @constructor
*/
export default function Summary(
{ title, subtitle, upperLabel, upperValue, lowerLabel, lowerValue, buttons, className, ...props },
{ icon, title, subtitle, upperLabel, upperValue, lowerLabel, lowerValue, buttons, className, ...props },
) {
return (
<div className={classNames(Style.Summary, className)} {...props}>

View file

@ -45,7 +45,6 @@
.Title {
grid-area: c;
font-size: large;
align-self: flex-end;
}
@ -65,11 +64,17 @@
display: grid;
grid-template-columns: auto 1fr;
grid-template-rows: 1fr 1fr;
grid-column-gap: 10px;
align-items: center;
font-size: small;
}
.Middle .Label {
grid-column: 1;
text-align: right;
font-weight: bold;
}
.Middle .Value {

View file

@ -1,12 +1,10 @@
import React, { useContext } from "react"
import Style from "./RepositorySummaryBase.module.css"
import classNames from "classnames"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import Button from "../base/Button"
import { faArchive, faFolder, faFolderOpen, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons"
import { useHistory } from "react-router"
import useBackend from "../../hooks/useBackend"
import ContextUser from "../../contexts/ContextUser"
import Summary from "../base/Summary"
/**
@ -50,64 +48,47 @@ export default function SummaryRepository(
await refresh()
}
const buttons = <>
{canDelete ?
<Button
color={"Red"}
icon={faTrash}
onClick={onDeleteClick}
>
Delete
</Button>
: null}
{canEdit ?
<Button
color={"Yellow"}
icon={faPencilAlt}
onClick={onEditClick}
>
Edit
</Button>
: null}
{canArchive ?
<Button
color={"Grey"}
icon={faArchive}
onClick={repo.is_active ? onArchiveClick : onUnarchiveClick}
>
{repo.is_active ? "Archive" : "Unarchive"}
</Button>
: null}
</>
return (
<div className={classNames(Style.RepositorySummary, className)} {...props}>
<div className={Style.Left}>
<div className={Style.IconContainer}>
<FontAwesomeIcon
icon={repo.is_active ? faFolderOpen : faFolder}
/>
</div>
<div className={Style.Title}>
{repo.name}
</div>
<div className={Style.Author}>
{repo.owner.username}
</div>
</div>
<div className={Style.Middle}>
<div className={classNames(Style.MiddleLabel, Style.MiddleTop)}>
Start:
</div>
<div className={classNames(Style.MiddleValue, Style.MiddleTop)}>
{repo.start}
</div>
<div className={classNames(Style.MiddleLabel, Style.MiddleBot)}>
End:
</div>
<div className={classNames(Style.MiddleValue, Style.MiddleBot)}>
{repo.end}
</div>
</div>
<div className={Style.Right}>
{canDelete ?
<Button
color={"Red"}
icon={faTrash}
onClick={onDeleteClick}
>
Delete
</Button>
: null}
{canEdit ?
<Button
color={"Yellow"}
icon={faPencilAlt}
onClick={onEditClick}
>
Edit
</Button>
: null}
{canArchive ?
<Button
color={"Grey"}
icon={faArchive}
onClick={repo.is_active ? onArchiveClick : onUnarchiveClick}
>
{repo.is_active ? "Archive" : "Unarchive"}
</Button>
: null}
</div>
</div>
<Summary
icon={repo.is_active ? faFolderOpen : faFolder}
title={repo.name}
subtitle={repo.author}
upperLabel={"Start"}
upperValue={repo.start ? new Date(repo.start).toLocaleString() : null}
lowerLabel={"End"}
lowerValue={repo.end ? new Date(repo.end).toLocaleString() : null}
buttons={buttons}
{...props}
/>
)
}