2021-05-11 16:24:51 +00:00
|
|
|
import React from "react"
|
|
|
|
import Style from "./Summary.module.css"
|
|
|
|
import classNames from "classnames"
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
|
|
|
|
|
|
|
|
2021-05-11 16:27:11 +00:00
|
|
|
/**
|
|
|
|
* A long line displaying the summary of a certain entity, such as a repository or an user.
|
|
|
|
*
|
2021-05-11 16:34:07 +00:00
|
|
|
* @param icon - The icon of the summary.
|
2021-05-11 16:27:11 +00:00
|
|
|
* @param title - The title of the summary.
|
|
|
|
* @param subtitle - The subtitle of the summary.
|
2021-05-12 02:34:54 +00:00
|
|
|
* @param onClick - A function to call when the summary is clicked.
|
2021-05-11 16:27:11 +00:00
|
|
|
* @param upperLabel - The label for the upper value.
|
|
|
|
* @param upperValue - The upper value.
|
|
|
|
* @param lowerLabel - The label for the lower value.
|
|
|
|
* @param lowerValue - The lower value.
|
|
|
|
* @param buttons - Buttons to add to the right of the summary.
|
|
|
|
* @param className - Additional class(es) to add to the summary.
|
|
|
|
* @param props - Additional props to pass to the summary.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-11 16:24:51 +00:00
|
|
|
export default function Summary(
|
2021-05-12 02:34:54 +00:00
|
|
|
{ icon, title, subtitle, onClick, upperLabel, upperValue, lowerLabel, lowerValue, buttons, className, ...props },
|
2021-05-11 16:24:51 +00:00
|
|
|
) {
|
|
|
|
return (
|
|
|
|
<div className={classNames(Style.Summary, className)} {...props}>
|
2021-05-12 02:34:54 +00:00
|
|
|
<div className={classNames(Style.Left, onClick ? Style.Clickable : null)} onClick={onClick}>
|
2021-05-11 16:24:51 +00:00
|
|
|
<div className={Style.IconContainer}>
|
|
|
|
<FontAwesomeIcon icon={icon}/>
|
|
|
|
</div>
|
|
|
|
<div className={Style.Title}>
|
|
|
|
{title}
|
|
|
|
</div>
|
|
|
|
<div className={Style.Subtitle}>
|
|
|
|
{subtitle}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={Style.Middle}>
|
|
|
|
<div className={classNames(Style.Label, Style.Upper)}>
|
|
|
|
{upperLabel}
|
|
|
|
</div>
|
|
|
|
<div className={classNames(Style.Value, Style.Upper)}>
|
|
|
|
{upperValue}
|
|
|
|
</div>
|
|
|
|
<div className={classNames(Style.Label, Style.Lower)}>
|
|
|
|
{lowerLabel}
|
|
|
|
</div>
|
|
|
|
<div className={classNames(Style.Value, Style.Lower)}>
|
|
|
|
{lowerValue}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={Style.Right}>
|
|
|
|
{buttons}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|