Skip to content

Commit

Permalink
refactor(amount): make amount markup flat (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
reme3d2y committed Apr 17, 2020
1 parent 6fdcb7a commit 9464a95
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 34 deletions.
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

0 comments on commit 9464a95

Please sign in to comment.