Skip to content

Commit

Permalink
Update Price component to Vanilla-Extract
Browse files Browse the repository at this point in the history
  • Loading branch information
Youakeem committed Sep 16, 2024
1 parent 00e406f commit 0845705
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions apps/store/src/components/Price.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import styled from '@emotion/styled'
import clsx from 'clsx'
import type { ComponentProps } from 'react'
import { Text, theme } from 'ui'
import { Text, xStack } from 'ui'
import type { CurrencyCode } from '@/services/graphql/generated'
import { useFormatter } from '@/utils/useFormatter'

type Props = {
type Props = ComponentProps<'div'> & {
currencyCode: CurrencyCode
amount: number
reducedAmount?: number
Expand All @@ -16,31 +16,30 @@ type Props = {
export const Price = ({
color = 'textPrimary',
secondaryColor = 'textSecondary',
reducedAmount,
amount,
currencyCode,
className,
...props
}: Props) => {
const formatter = useFormatter()

return (
<Wrapper>
{props.reducedAmount !== undefined && (
<div className={clsx(xStack({ gap: 'xs' }), className)} {...props}>
{reducedAmount !== undefined && (
<Text as="p" size="md" strikethrough={true} color={secondaryColor}>
{formatter.monthlyPrice({
amount: props.amount,
currencyCode: props.currencyCode,
amount,
currencyCode,
})}
</Text>
)}
<Text as="p" size="md" color={color}>
{formatter.monthlyPrice({
currencyCode: props.currencyCode,
amount: props.reducedAmount ?? props.amount,
currencyCode,
amount: reducedAmount ?? amount,
})}
</Text>
</Wrapper>
</div>
)
}

const Wrapper = styled.div({
display: 'flex',
columnGap: theme.space.xs,
})

0 comments on commit 0845705

Please sign in to comment.