splitwise / src /lib /components /MoneyText.svelte
assafvayner's picture
assafvayner HF Staff
feat(ui): add layout, tab bar, login and logout
59d41c0
Raw
History Blame Contribute Delete
537 Bytes
<script lang="ts">
import { formatCents } from '$lib/domain/money';
let {
cents,
currency,
signed = false,
class: className = ''
}: { cents: number; currency: string; signed?: boolean; class?: string } = $props();
const text = $derived(
signed && cents > 0 ? `+${formatCents(cents, currency)}` : formatCents(cents, currency)
);
const tone = $derived(
!signed ? '' : cents > 0 ? 'text-green-700' : cents < 0 ? 'text-red-700' : 'text-gray-500'
);
</script>
<span class="tabular-nums {tone} {className}">{text}</span>