Skip to content

refactor(amount): make amount markup flat #1105

Merged
merged 2 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions src/amount/__snapshots__/amount.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,26 @@ exports[`amount should render without problems 1`] = `
<span
className="label__inner"
>
<span>
<span
className="amount__major"
>
1 233 141
</span>
<div
className="amount__minor-container"
>
<span
className="amount__separator"
>
,
</span>
<span
className="amount__minor"
>
45
</span>
</div>
<span
className="amount__currency"
>

</span>
<span
className="amount__major"
>
1 233 141
</span>
<span
className="amount__separator"
>
,
</span>
<span
className="amount__minor"
>
45
</span>
<span
className="amount__currency"
>

</span>
</span>
</span>
Expand Down
4 changes: 0 additions & 4 deletions src/amount/amount.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
display: inline-block;
white-space: nowrap;

&__minor-container {
display: inline-block;
}

&__currency {
display: inline-block;
text-align: right;
Expand Down
8 changes: 4 additions & 4 deletions src/amount/amount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ export class Amount extends React.Component<AmountProps> {
const { majorPart, minorPart, currencySymbol } = formatAmount(amount);

const amountInner = (
<span>
<>
<span className={ this.cn('major') }>{ majorPart }</span>
{ this.renderSeparatorAndMinorPart(minorPart) }
{ this.renderCurrencySymbol(currencySymbol) }
</span>
</>
);

return (
Expand Down Expand Up @@ -141,10 +141,10 @@ export class Amount extends React.Component<AmountProps> {

if (needMinorPart) {
return (
<div className={ this.cn('minor-container') }>
<>
<span className={ this.cn('separator') }>{ AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR }</span>
<span className={ this.cn('minor') }>{ minorPart }</span>
</div>
</>
);
}

Expand Down