-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sat bundle layout to sign psbt screen (#65)
* chore: move bundle from ConfirmBtcTransactionComponent to it own component * chore: use getSatLabel from utils in RareSatsBundleGridItem * feat: tweak useDetectOrdinalInSignPsbt hook to use V2 of rare sats api and implement sats bundle component in SignPsbtRequest screen
- Loading branch information
Showing
8 changed files
with
154 additions
and
365 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
src/app/components/confirmBtcTransactionComponent/bundle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import BundleIcon from '@assets/img/rareSats/satBundle.svg'; | ||
import AssetModal from '@components/assetModal'; | ||
import { CaretDown } from '@phosphor-icons/react'; | ||
import { StyledP } from '@ui-library/common.styled'; | ||
import { BundleSatRange, BundleV2, Inscription } from '@utils/rareSats'; | ||
import { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import styled from 'styled-components'; | ||
import Theme from 'theme'; | ||
import { BundleItem } from './bundleItem'; | ||
|
||
interface BundleItemContainerProps { | ||
addMargin: boolean; | ||
} | ||
|
||
const BundleItemsContainer = styled.div<BundleItemContainerProps>` | ||
margin-top: ${(props) => (props.addMargin ? props.theme.space.m : 0)}; | ||
`; | ||
|
||
const SatsBundleContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
margin-bottom: ${(props) => props.theme.space.s}; | ||
border-radius: ${(props) => props.theme.space.s}; | ||
padding: ${(props) => props.theme.space.m}; | ||
background-color: ${(props) => props.theme.colors.elevation1}; | ||
`; | ||
|
||
const SatsBundleButton = styled.button` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
background-color: ${(props) => props.theme.colors.elevation1}; | ||
`; | ||
|
||
const Row = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
`; | ||
|
||
const BundleTitle = styled(StyledP)` | ||
margin-left: ${(props) => props.theme.space.s}; | ||
`; | ||
|
||
const BundleValue = styled(StyledP)` | ||
margin-right: ${(props) => props.theme.space.xs}; | ||
`; | ||
|
||
const Title = styled(StyledP)((props) => ({ | ||
marginBottom: props.theme.space.xs, | ||
})); | ||
|
||
function SatsBundle({ bundle, title }: { bundle: BundleV2; title?: string }) { | ||
const [showBundleDetail, setShowBundleDetail] = useState(false); | ||
const [inscriptionToShow, setInscriptionToShow] = useState<Inscription | undefined>(undefined); | ||
|
||
const { t } = useTranslation('translation'); | ||
|
||
return ( | ||
<> | ||
{inscriptionToShow && ( | ||
<AssetModal | ||
show={!!inscriptionToShow} | ||
onClose={() => setInscriptionToShow(undefined)} | ||
inscription={inscriptionToShow} | ||
/> | ||
)} | ||
<SatsBundleContainer> | ||
{title && <Title typography="body_medium_m">{title}</Title>} | ||
<SatsBundleButton | ||
type="button" | ||
onClick={() => setShowBundleDetail((prevState) => !prevState)} | ||
> | ||
<Row> | ||
<img src={BundleIcon} alt="bundle" /> | ||
<BundleTitle typography="body_medium_m" color="white_200"> | ||
{t('RARE_SATS.SATS_BUNDLE')} | ||
</BundleTitle> | ||
</Row> | ||
<Row> | ||
<BundleValue typography="body_medium_m" color="white_0">{`${bundle.totalExoticSats} ${t( | ||
'NFT_DASHBOARD_SCREEN.RARE_SATS', | ||
)}`}</BundleValue> | ||
<CaretDown color={Theme.colors.white_0} size={16} /> | ||
</Row> | ||
</SatsBundleButton> | ||
|
||
{showBundleDetail && | ||
bundle.satRanges.map((item: BundleSatRange, index: number) => ( | ||
<BundleItemsContainer key={`${item.block}-${item.offset}`} addMargin={index === 0}> | ||
<BundleItem | ||
item={item} | ||
ordinalEyePressed={(inscription: Inscription) => { | ||
// show ordinal modal to show asset | ||
setInscriptionToShow(inscription); | ||
}} | ||
showDivider={index !== bundle.satRanges.length - 1} | ||
/> | ||
</BundleItemsContainer> | ||
))} | ||
</SatsBundleContainer> | ||
</> | ||
); | ||
} | ||
|
||
export default SatsBundle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.