UNPKG

@lunit/oui

Version:

Lunit Oncology UI components

16 lines (15 loc) 866 B
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { PresentationTypography } from '../presentations.styled'; const capitalize = (str) => { return str.charAt(0).toUpperCase() + str.slice(1); }; const Score = ({ componentType = 'score', title, size = 'medium', metrics }) => { if (!componentType) throw new Error("The 'componentType' prop is required."); if (!title) throw new Error("The 'title' prop is required."); if (!metrics) throw new Error("The 'metrics' prop is required."); return (_jsxs(PresentationTypography, { size: size, style: { color: metrics.isFullColored ? metrics.color : 'inherit' }, children: [title, ": ", metrics.value, metrics.scoreType && (_jsx("span", { style: { color: metrics.color, marginLeft: 4 }, children: capitalize(metrics.scoreType) }))] })); }; export default Score;