Skip to content

Commit

Permalink
refactor: address breaking changes in ui badge
Browse files Browse the repository at this point in the history
- tag was renamed to badge
- transparent prop was renamed to outlined
  • Loading branch information
tigranpetrossian committed Feb 4, 2025
1 parent 30a2d8e commit a96407a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMoney, formatMoney, truncateMiddle } from '@leather.io/utils';

import { PsbtInput } from '@app/features/psbt-signer/hooks/use-parsed-inputs';
import { TagWithTooltip } from '@app/ui/components/tag/tag-with-tooltip';
import { BadgeWithTooltip } from '@app/ui/components/badge/badge-with-tooltip';

import { PsbtInputOutputItemLayout } from '../../psbt-input-output-item.layout';

Expand All @@ -15,7 +15,7 @@ export function PsbtInputItem({ utxo }: { utxo: PsbtInput }) {
amount={formatMoney(createMoney(utxo.value, 'BTC'))}
label={
utxo.toSign ? (
<TagWithTooltip hoverLabel={hoverLabel} label="Approve" transparent />
<BadgeWithTooltip hoverLabel={hoverLabel} label="Approve" outlined />
) : undefined
}
txId={truncateMiddle(utxo.txid)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMoney, formatMoney, truncateMiddle } from '@leather.io/utils';

import { PsbtOutput } from '@app/features/psbt-signer/hooks/use-parsed-outputs';
import { TagWithTooltip } from '@app/ui/components/tag/tag-with-tooltip';
import { BadgeWithTooltip } from '@app/ui/components/badge/badge-with-tooltip';

import { PsbtInputOutputItemLayout } from '../../psbt-input-output-item.layout';

Expand All @@ -19,7 +19,7 @@ export function PsbtOutputItem({ output }: { output: PsbtOutput }) {
amount={formatMoney(createMoney(Number(output.value), 'BTC'))}
label={
output.toSign ? (
<TagWithTooltip transparent hoverLabel={hoverLabel} label="You" />
<BadgeWithTooltip outlined hoverLabel={hoverLabel} label="You" />
) : undefined
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HStack, styled } from 'leather-styles/jsx';
import { LockIcon, UnlockIcon } from '@leather.io/ui';

import { usePsbtSignerContext } from '@app/features/psbt-signer/psbt-signer.context';
import { TagWithTooltip } from '@app/ui/components/tag/tag-with-tooltip';
import { BadgeWithTooltip } from '@app/ui/components/badge/badge-with-tooltip';

const immutableLabel =
'Any modification to the transaction, including the fee amount or other inputs/outputs, will invalidate the signature.';
Expand All @@ -16,12 +16,12 @@ export function PsbtRequestDetailsHeader() {
return (
<HStack alignItems="center" gap="space.02">
<styled.h2 textStyle="heading.05">Transaction</styled.h2>
<TagWithTooltip
<BadgeWithTooltip
hoverLabel={isPsbtMutable ? uncertainLabel : immutableLabel}
icon={isPsbtMutable ? <UnlockIcon variant="small" /> : <LockIcon variant="small" />}
label={isPsbtMutable ? 'Uncertain' : 'Certain'}
transparent
variant={isPsbtMutable ? 'warning' : 'default'}
outlined
/>
</HStack>
);
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/fund/components/fiat-provider-item.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FundPageSelectors } from '@tests/selectors/fund.selectors';

import { StarIcon, Tag, ZapIcon } from '@leather.io/ui';
import { Badge, StarIcon, ZapIcon } from '@leather.io/ui';

import { AvailableRegions } from '@app/query/common/remote-config/remote-config.query';

Expand Down Expand Up @@ -38,10 +38,10 @@ export function FiatProviderItem(props: FiatProviderProps) {
const Attributes = (
<>
{hasFastCheckoutProcess && (
<Tag icon={<ZapIcon variant="small" />} label="Fast checkout" variant="success" />
<Badge icon={<ZapIcon variant="small" />} label="Fast checkout" variant="success" />
)}
{!hasTradingFees && (
<Tag icon={<StarIcon variant="small" />} label="0 % Fees" variant="warning" />
<Badge icon={<StarIcon variant="small" />} label="0 % Fees" variant="warning" />
)}
</>
);
Expand Down
17 changes: 17 additions & 0 deletions src/app/ui/components/badge/badge-with-tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Badge, type BadgeProps } from '@leather.io/ui';

import { BasicTooltip } from '../tooltip/basic-tooltip';

type TooltipSideType = 'bottom' | 'left' | 'right' | 'top';

interface BadgeWithTooltipProps extends BadgeProps {
hoverLabel: string;
side?: TooltipSideType;
}
export function BadgeWithTooltip({ hoverLabel, side = 'bottom', ...props }: BadgeWithTooltipProps) {
return (
<BasicTooltip label={hoverLabel} side={side}>
<Badge {...props} />
</BasicTooltip>
);
}
21 changes: 0 additions & 21 deletions src/app/ui/components/tag/tag-with-tooltip.tsx

This file was deleted.

0 comments on commit a96407a

Please sign in to comment.