fleet/frontend/components/TableContainer/DataTable/TextCell/TextCell.tsx
RachelElysia 18852aae66
Fleet UI: macOS dashboard MDM solutions (#7014)
Co-authored-by: gillespi314 <73313222+gillespi314@users.noreply.github.com>
2022-08-15 17:47:07 -05:00

29 lines
610 B
TypeScript

import React from "react";
interface ITextCellProps {
value: string | number | boolean;
formatter?: (val: any) => string; // string, number, or null
greyed?: boolean;
classes?: string;
}
const TextCell = ({
value,
formatter = (val) => val, // identity function if no formatter is provided
greyed,
classes = "w250",
}: ITextCellProps): JSX.Element => {
let val = value;
if (typeof value === "boolean") {
val = value.toString();
}
return (
<span className={`text-cell ${classes} ${greyed && "grey-cell"}`}>
{formatter(val)}
</span>
);
};
export default TextCell;