Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 5x 5x 5x 5x 5x 46x 46x 46x | // A month's rent status as a chip: an icon and text, never colour alone
// (Design canvas: Kuukauden vuokran tilat).
import Box from '@mui/material/Box'
import { colors } from '#/theme/tokens'
import { statusText, statusTone, type StatusTone } from './labels'
import type { RentStatus } from './status'
const CHECK = 'M5 12 L10 17 L19 7'
const CLOCK = 'M12 3 a9 9 0 1 0 0.01 0 M12 7 V12 L15 14'
const ALERT = 'M12 3 L22 20 H2 Z M12 10 V14 M12 17 V17.01'
const HALF = 'M12 3 a9 9 0 1 0 0.01 0 M12 3 V21'
const tones: Record<StatusTone, { bg: string; icon: string }> = {
green: { bg: colors.greenTint, icon: CHECK },
yellow: { bg: colors.yellowTint, icon: HALF },
late: { bg: colors.lateTint, icon: ALERT },
lavender: { bg: colors.lavenderTint, icon: CLOCK },
}
export function StatusChip(props: {
status: RentStatus
text?: string
/** Smaller, for a flat's card on the flats list. */
small?: boolean
}) {
const tone = tones[statusTone(props.status)]
const small = props.small === true
return (
<Box
component="span"
sx={{
display: 'inline-flex',
alignItems: 'center',
gap: small ? 0.625 : 0.75,
minHeight: small ? 28 : 32,
px: small ? 1.25 : 1.5,
borderRadius: 999,
bgcolor: tone.bg,
fontSize: small ? 12 : 13,
fontWeight: 900,
whiteSpace: 'nowrap',
flexShrink: 0,
}}
>
<svg
width={small ? 14 : 16}
height={small ? 14 : 16}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.6"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d={tone.icon} />
</svg>
{props.text ?? statusText(props.status)}
</Box>
)
}
|