-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
917045c
commit 87a4695
Showing
13 changed files
with
266 additions
and
22 deletions.
There are no files selected for viewing
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
Empty file.
46 changes: 46 additions & 0 deletions
46
...live-desktop/src/newArch/features/Collectibles/Ordinals/components/RareSats/RowLayout.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,46 @@ | ||
import React from "react"; | ||
import { Flex } from "@ledgerhq/react-ui"; | ||
import styled from "styled-components"; | ||
|
||
type Props = { | ||
firstColumnElement: JSX.Element; | ||
secondColumnElement: JSX.Element; | ||
thirdColumnElement?: JSX.Element; | ||
bgColor?: string; | ||
isDoubleRow?: boolean; | ||
}; | ||
|
||
const Container = styled(Flex)` | ||
&:not(:nth-child(2)) { | ||
border-top: 1px solid ${p => p.theme.colors.palette.text.shade10}; | ||
padding-top: 15px; | ||
} | ||
&:nth-child(2) { | ||
padding-bottom: 15px; | ||
} | ||
`; | ||
|
||
const RowLayout: React.FC<Props> = ({ | ||
firstColumnElement, | ||
secondColumnElement, | ||
thirdColumnElement, | ||
bgColor, | ||
isDoubleRow, | ||
}) => { | ||
const verticalPadding = isDoubleRow ? 1 : 3; | ||
return ( | ||
<Container py={verticalPadding} px={4} flexDirection={"row"} alignItems={"center"} bg={bgColor}> | ||
<Flex flex={1}>{firstColumnElement}</Flex> | ||
<Flex flex={1} flexDirection={"row"} columnGap={20}> | ||
<Flex flex={1} justifyContent={"flex-end"}> | ||
{secondColumnElement} | ||
</Flex> | ||
<Flex flex={0.2} justifyContent={"flex-end"}> | ||
{thirdColumnElement} | ||
</Flex> | ||
</Flex> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default RowLayout; |
35 changes: 35 additions & 0 deletions
35
...ve-desktop/src/newArch/features/Collectibles/Ordinals/components/RareSats/TableHeader.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,35 @@ | ||
import React from "react"; | ||
import { Text } from "@ledgerhq/react-ui"; | ||
import { useTranslation } from "react-i18next"; | ||
import RowLayout from "./RowLayout"; | ||
|
||
export const TableHeader = () => { | ||
const { t } = useTranslation(); | ||
|
||
const firstColumn = ( | ||
<Text variant={"bodyLineHeight"} fontSize={12} color={"neutral.c70"}> | ||
{t("ordinals.rareSats.table.type")} | ||
</Text> | ||
); | ||
|
||
const secondColumn = ( | ||
<Text variant={"bodyLineHeight"} fontSize={12} color={"neutral.c70"}> | ||
{t("ordinals.rareSats.table.year")} | ||
</Text> | ||
); | ||
|
||
const thirdColumn = ( | ||
<Text variant={"bodyLineHeight"} fontSize={12} color={"neutral.c70"}> | ||
{t("ordinals.rareSats.table.utxo")} | ||
</Text> | ||
); | ||
|
||
return ( | ||
<RowLayout | ||
firstColumnElement={firstColumn} | ||
secondColumnElement={secondColumn} | ||
thirdColumnElement={thirdColumn} | ||
bgColor={"opacityDefault.c05"} | ||
/> | ||
); | ||
}; |
62 changes: 62 additions & 0 deletions
62
...ger-live-desktop/src/newArch/features/Collectibles/Ordinals/components/RareSats/index.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,62 @@ | ||
import React from "react"; | ||
import { useRareSatsModel } from "./useRareSatsModel"; | ||
import TableContainer from "~/renderer/components/TableContainer"; | ||
import TableHeader from "LLD/features/Collectibles/components/Collection/TableHeader"; | ||
import { TableHeaderTitleKey } from "LLD/features/Collectibles/types/Collection"; | ||
import { Box, Icons, Text, Flex } from "@ledgerhq/react-ui"; | ||
import { TableHeader as TableHeaderContainer } from "./TableHeader"; | ||
import RowLayout from "LLD/features/Collectibles/Ordinals/components/RareSats/RowLayout"; | ||
import IconContainer from "LLD/features/Collectibles/components/Collection/TableRow/IconContainer"; | ||
import TokenTitle from "LLD/features/Collectibles/components/Collection/TableRow/TokenTitle"; | ||
|
||
type ViewProps = ReturnType<typeof useRareSatsModel>; | ||
|
||
const Item = ({ ...props }) => { | ||
const firstColumn = ( | ||
<Flex columnGap={2}> | ||
<IconContainer icons={[Icons.OrdinalsAlpha, Icons.OrdinalsOmega]} /> | ||
<TokenTitle tokenName={[props.name]} complementaryData={"collectionName"} isLoading={false} /> | ||
</Flex> | ||
); | ||
const secondColumn = ( | ||
<Text variant={"bodyLineHeight"} fontSize={12} color={"neutral.c70"}> | ||
{props.year} | ||
</Text> | ||
); | ||
const thirdColumn = ( | ||
<Text variant={"bodyLineHeight"} fontSize={12} color={"neutral.c70"}> | ||
{props.utxo_size} | ||
</Text> | ||
); | ||
|
||
return ( | ||
<RowLayout | ||
isDoubleRow={props.isDoubleRow} | ||
firstColumnElement={firstColumn} | ||
secondColumnElement={secondColumn} | ||
thirdColumnElement={thirdColumn} | ||
/> | ||
); | ||
}; | ||
|
||
function View(_props: ViewProps) { | ||
return ( | ||
<Box> | ||
<TableContainer id="oridinals-inscriptions"> | ||
<TableHeader titleKey={TableHeaderTitleKey.RareSats} /> | ||
<TableHeaderContainer /> | ||
<Flex flexDirection={"column"}> | ||
{_props.rareSats.map((rareSat, index) => ( | ||
<Item key={index} {...rareSat} /> | ||
))} | ||
</Flex> | ||
</TableContainer> | ||
</Box> | ||
); | ||
} | ||
|
||
const RareSats = () => { | ||
return <View {...useRareSatsModel({})} />; | ||
}; | ||
|
||
export default RareSats; |
42 changes: 42 additions & 0 deletions
42
...sktop/src/newArch/features/Collectibles/Ordinals/components/RareSats/useRareSatsModel.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,42 @@ | ||
import { mockedRareSats } from "../../../__integration__/mockedRareSats"; | ||
import { mappingKeysWithIconAndName, MappingKeys } from "../Icons"; | ||
|
||
type RareSatsProps = {}; | ||
|
||
type RareSat = { | ||
count: number; | ||
display_name: string; | ||
year: string; | ||
utxo_size: string; | ||
icon?: React.ReactNode; | ||
name?: string; | ||
isDoubleRow?: boolean; | ||
}; | ||
|
||
export const useRareSatsModel = (_props: RareSatsProps) => { | ||
const processedRareSats: RareSat[] = mockedRareSats.map(sat => { | ||
const { display_name } = sat; | ||
const key = display_name.toLowerCase().replace(" ", "_") as MappingKeys; | ||
const iconAndName = mappingKeysWithIconAndName[key]; | ||
return { | ||
...sat, | ||
icon: iconAndName?.icon, | ||
name: iconAndName?.name, | ||
}; | ||
}); | ||
|
||
const utxoSizeCount: Record<string, number> = processedRareSats.reduce( | ||
(acc, sat) => { | ||
acc[sat.utxo_size] = (acc[sat.utxo_size] || 0) + 1; | ||
return acc; | ||
}, | ||
{} as Record<string, number>, | ||
); | ||
|
||
const finalRareSats: RareSat[] = processedRareSats.map(sat => ({ | ||
...sat, | ||
isDoubleRow: utxoSizeCount[sat.utxo_size] > 1, | ||
})); | ||
|
||
return { rareSats: finalRareSats }; | ||
}; |
9 changes: 8 additions & 1 deletion
9
.../ledger-live-desktop/src/newArch/features/Collectibles/Ordinals/screens/Account/index.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
20 changes: 20 additions & 0 deletions
20
apps/ledger-live-desktop/src/newArch/features/Collectibles/__integration__/mockedRareSats.ts
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,20 @@ | ||
export const mockedRareSats = [ | ||
{ | ||
count: 8000, | ||
display_name: "common", | ||
year: "2011", | ||
utxo_size: "239", | ||
}, | ||
{ | ||
count: 8000, | ||
display_name: "legendary", | ||
year: "2011", | ||
utxo_size: "239", | ||
}, | ||
{ | ||
count: 8000, | ||
display_name: "rare", | ||
year: "2011", | ||
utxo_size: "3212", | ||
}, | ||
]; |
29 changes: 29 additions & 0 deletions
29
...esktop/src/newArch/features/Collectibles/components/Collection/TableRow/IconContainer.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,29 @@ | ||
import React from "react"; | ||
import { Flex } from "@ledgerhq/react-ui"; | ||
import { IconProps } from "../../../types/Collection"; | ||
|
||
type Props = { | ||
icons: (({ size, color, style }: IconProps) => JSX.Element)[]; | ||
}; | ||
|
||
const IconContainer: React.FC<Props> = ({ icons }) => { | ||
return ( | ||
<Flex | ||
borderRadius={"8px"} | ||
justifyContent={"center"} | ||
alignContent={"center"} | ||
bg={"opacityDefault.c05"} | ||
borderColor={"opacityDefault.c10"} | ||
borderWidth={"1px"} | ||
borderStyle={"solid"} | ||
p={"8px"} | ||
columnGap={"8px"} | ||
> | ||
{icons.map((Icon, index) => ( | ||
<Icon key={index} size={"XS"} color={"neutral.c100"} /> | ||
))} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default IconContainer; |
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