2024-02-08 16:56:32 +00:00
|
|
|
import React from "react";
|
2024-05-10 15:18:24 +00:00
|
|
|
import classnames from "classnames";
|
2024-02-08 16:56:32 +00:00
|
|
|
|
|
|
|
|
const baseClass = "data-set";
|
|
|
|
|
|
|
|
|
|
interface IDataSetProps {
|
|
|
|
|
title: React.ReactNode;
|
|
|
|
|
value: React.ReactNode;
|
2025-02-21 11:52:41 +00:00
|
|
|
orientation?: "horizontal" | "vertical";
|
2026-05-05 12:50:18 +00:00
|
|
|
/** When true, aligns the value row by text baseline instead of vertical
|
|
|
|
|
* center. Use this when the value contains only text (with or without
|
|
|
|
|
* tooltips) so neighboring DataSets in a horizontal row share the same
|
|
|
|
|
* baseline. Do NOT use when the value contains icons, buttons, or status
|
|
|
|
|
* indicators that need vertical centering. */
|
|
|
|
|
textOnly?: boolean;
|
2024-05-10 15:18:24 +00:00
|
|
|
className?: string;
|
2024-02-08 16:56:32 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-21 11:52:41 +00:00
|
|
|
const DataSet = ({
|
|
|
|
|
title,
|
|
|
|
|
value,
|
|
|
|
|
orientation = "vertical",
|
2026-05-05 12:50:18 +00:00
|
|
|
textOnly = false,
|
2025-02-21 11:52:41 +00:00
|
|
|
className,
|
|
|
|
|
}: IDataSetProps) => {
|
|
|
|
|
const classNames = classnames(baseClass, className, {
|
|
|
|
|
[`${baseClass}__horizontal`]: orientation === "horizontal",
|
2026-05-05 12:50:18 +00:00
|
|
|
[`${baseClass}--text-only`]: textOnly,
|
2025-02-21 11:52:41 +00:00
|
|
|
});
|
2024-05-10 15:18:24 +00:00
|
|
|
|
2024-02-08 16:56:32 +00:00
|
|
|
return (
|
2024-05-10 15:18:24 +00:00
|
|
|
<div className={classNames}>
|
2025-02-21 11:52:41 +00:00
|
|
|
<dt>
|
|
|
|
|
{title}
|
|
|
|
|
{orientation === "horizontal" && ":"}
|
|
|
|
|
</dt>
|
2024-02-08 16:56:32 +00:00
|
|
|
<dd>{value}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default DataSet;
|