Skip to content

Commit

Permalink
🐛 Fix price align
Browse files Browse the repository at this point in the history
  • Loading branch information
LEGRELLE, Félix committed Dec 17, 2024
1 parent 44f4c6f commit b426642
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
11 changes: 3 additions & 8 deletions examples/react-template/screens/Price.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,13 @@ export const PriceScreen = (): JSX.Element => {

<Price level={2} amount={18.99} />

<Divider />
<Title level={TitleLevels.THREE}>Inlined</Title>

<Price level={7} amount={1000} mention='(1)' period='months' />

<Divider />
<Title level={TitleLevels.THREE}>Alignement</Title>
<Price level={1} amount={1000} mention='(1)' period='months' />
<Price level={1} amount={1000} mention='(1)' period='months' align={Alignable.ALIGNED_START} />

<Price level={1} amount={1000} mention='(1)' period='months' />
<Price level={1} amount={1000} mention='(1)' period='months' align={Alignable.ALIGNED_CENTER} />

<Price level={1} amount={1000} mention='(1)' period='months' />
<Price level={1} amount={1000} mention='(1)' period='months' align={Alignable.ALIGNED_END} />

<Divider />

Expand Down
18 changes: 7 additions & 11 deletions packages/react/components/price/Price.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,16 @@ const Price = ({
)
}

const alignmentClasses = {
[Alignable.ALIGNED_START]: 'justified-start',
[Alignable.ALIGNED_CENTER]: 'justified-center',
[Alignable.ALIGNED_END]: 'justified-end',
}

return (
<div
id={id}
className={hashClass(
styled,
clsx(
'price-container',
is(`level-${level || '1'}`),
(align == Alignable.ALIGNED_START && is('justified-left')) ||
(align == Alignable.ALIGNED_CENTER && is('justified-center')) ||
(align == Alignable.ALIGNED_END && is('justified-right')) ||
'',
),
)}
className={hashClass(styled, clsx('price-container', is(`level-${level || '1'}`), align && is(alignmentClasses[align])))}
>
{overline && <p className={hashClass(styled, clsx('overline'))}>{overline}</p>}
{oldAmountComponent}
Expand Down

0 comments on commit b426642

Please sign in to comment.