-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨feat(lld): UI of inscriptions table for ordis
- Loading branch information
1 parent
255f035
commit 075494c
Showing
10 changed files
with
275 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"ledger-live-desktop": patch | ||
--- | ||
|
||
LLD ORDINALS add dummy table to display inscriptions inside BTC account screen. |
80 changes: 80 additions & 0 deletions
80
...live-desktop/src/newArch/features/Collectibles/Ordinals/components/Inscriptions/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,80 @@ | ||
import React from "react"; | ||
import { Account } from "@ledgerhq/types-live"; | ||
import { Box, Flex } from "@ledgerhq/react-ui"; | ||
import { useInscriptionsModel } from "./useInscriptionsModel"; | ||
import TableContainer from "~/renderer/components/TableContainer"; | ||
import TableHeader from "LLD/features/Collectibles/components/Collection/TableHeader"; | ||
import { OrdinalsRowProps, TableHeaderTitleKey } from "LLD/features/Collectibles/types/Collection"; | ||
import TableRow from "LLD/features/Collectibles/components/Collection/TableRow"; | ||
import ShowMore from "LLD/features/Collectibles/components/Collection/ShowMore"; | ||
import { MediaProps } from "LLD/features/Collectibles/types/Media"; | ||
|
||
type ViewProps = ReturnType<typeof useInscriptionsModel>; | ||
|
||
type Props = { | ||
account: Account; | ||
}; | ||
|
||
export type InscriptionsItemProps = { | ||
isLoading: boolean; | ||
tokenName: string; | ||
collectionName: string; | ||
tokenIcons: OrdinalsRowProps["tokenIcons"]; | ||
media: MediaProps; | ||
onClick: () => void; | ||
}; | ||
|
||
const Item: React.FC<InscriptionsItemProps> = ({ | ||
isLoading, | ||
tokenName, | ||
collectionName, | ||
tokenIcons, | ||
media, | ||
onClick, | ||
}) => { | ||
return ( | ||
<TableRow | ||
isLoading={isLoading} | ||
tokenName={tokenName} | ||
collectionName={collectionName} | ||
tokenIcons={tokenIcons} | ||
media={media} | ||
onClick={onClick} | ||
/> | ||
); | ||
}; | ||
|
||
function View({ temporyObjects, displayShowMore, onShowMore }: ViewProps) { | ||
return ( | ||
<Box> | ||
<TableContainer id="oridinals-inscriptions" mb={50}> | ||
<TableHeader titleKey={TableHeaderTitleKey.Inscriptions} /> | ||
{/** titlekey doesn't need to be translated so we keep it hard coded */} | ||
{temporyObjects ? ( | ||
temporyObjects.map((item, index) => ( | ||
<Item | ||
key={index} | ||
isLoading={item.isLoading} | ||
tokenName={item.tokenName} | ||
collectionName={item.collectionName} | ||
tokenIcons={item.tokenIcons} | ||
media={item.media} | ||
onClick={item.onClick} | ||
/> | ||
)) | ||
) : ( | ||
<Flex justifyContent={"center"} my={12}> | ||
{"NOTHING TO SHOW"} | ||
</Flex> | ||
)} | ||
{displayShowMore && <ShowMore onShowMore={onShowMore} />} | ||
</TableContainer> | ||
</Box> | ||
); | ||
} | ||
|
||
const Inscriptions: React.FC<Props> = ({ account }: Props) => { | ||
return <View {...useInscriptionsModel({ account })} />; | ||
}; | ||
|
||
export default Inscriptions; |
118 changes: 118 additions & 0 deletions
118
...c/newArch/features/Collectibles/Ordinals/components/Inscriptions/useInscriptionsModel.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,118 @@ | ||
import { useEffect, useMemo, useState } from "react"; | ||
import { Icons } from "@ledgerhq/react-ui"; | ||
import { Account } from "@ledgerhq/types-live"; | ||
import { InscriptionsItemProps } from "./index"; | ||
|
||
type Props = { | ||
account: Account; | ||
}; | ||
|
||
export const useInscriptionsModel = ({ account }: Props) => { | ||
const [displayShowMore, setDisplayShowMore] = useState(false); | ||
const [displayedObjects, setDisplayedObjects] = useState<InscriptionsItemProps[]>([]); | ||
|
||
const temporyObjects: InscriptionsItemProps[] = useMemo( | ||
() => [ | ||
{ | ||
isLoading: false, | ||
tokenName: "NodeMonke#5673", | ||
collectionName: "NodeMonkes", | ||
tokenIcons: [Icons.OrdinalsAlpha, Icons.OrdinalsPaliblockPalindrome], | ||
media: { | ||
uri: "https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2Ff976d219206858d782cccd90d25882cc77cafd3d6c159728f0d3407e25961ab0i0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252Ff976d219206858d782cccd90d25882cc77cafd3d6c159728f0d3407e25961ab0i0.png&w=1920&q=75", | ||
previewUri: | ||
"https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2Ff976d219206858d782cccd90d25882cc77cafd3d6c159728f0d3407e25961ab0i0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252Ff976d219206858d782cccd90d25882cc77cafd3d6c159728f0d3407e25961ab0i0.png&w=1920&q=75", | ||
mediaType: "image", | ||
isLoading: false, | ||
useFallback: true, | ||
contentType: "image", | ||
}, | ||
onClick: () => console.log("clicked"), | ||
}, | ||
{ | ||
isLoading: false, | ||
tokenName: "NodeMonke#5673#22", | ||
collectionName: "NodeMonkes#2", | ||
tokenIcons: [Icons.OrdinalsAlpha, Icons.OrdinalsPaliblockPalindrome], | ||
media: { | ||
uri: "https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
previewUri: | ||
"https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
mediaType: "image", | ||
isLoading: false, | ||
useFallback: true, | ||
contentType: "image", | ||
}, | ||
onClick: () => console.log("clicked"), | ||
}, | ||
{ | ||
isLoading: false, | ||
tokenName: "NodeMonke#5673#33", | ||
collectionName: "NodeMonkes#2", | ||
tokenIcons: [Icons.OrdinalsAlpha, Icons.OrdinalsPaliblockPalindrome], | ||
media: { | ||
uri: "https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
previewUri: | ||
"https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
mediaType: "image", | ||
isLoading: false, | ||
useFallback: true, | ||
contentType: "image", | ||
}, | ||
onClick: () => console.log("clicked"), | ||
}, | ||
{ | ||
isLoading: false, | ||
tokenName: "NodeMonke#5673#44", | ||
collectionName: "NodeMonkes#2", | ||
tokenIcons: [Icons.OrdinalsAlpha, Icons.OrdinalsPaliblockPalindrome], | ||
media: { | ||
uri: "https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
previewUri: | ||
"https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
mediaType: "image", | ||
isLoading: false, | ||
useFallback: true, | ||
contentType: "image", | ||
}, | ||
onClick: () => console.log("clicked"), | ||
}, | ||
{ | ||
isLoading: false, | ||
tokenName: "NodeMonke#5673#55", | ||
collectionName: "NodeMonkes#2", | ||
tokenIcons: [Icons.OrdinalsAlpha, Icons.OrdinalsPaliblockPalindrome], | ||
media: { | ||
uri: "https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
previewUri: | ||
"https://www.cryptoslam.io/_next/image?url=https%3A%2F%2Fd6rvidx1ucs57.cloudfront.net%2Fcryptoslam-token-images.s3.amazonaws.com%2FBitcoin%2Fnodemonkes%2Fimage%2F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png%3Fd%3D354%26u%3Dhttps%253A%252F%252Fcryptoslam-token-images.s3.amazonaws.com%252FBitcoin%252Fnodemonkes%252Fimage%252F33199e5e35a90b516d274e8c076ca205436db00a36bc5a99d2f0e26110ca7abai0.png&w=1920&q=75", | ||
mediaType: "image", | ||
isLoading: false, | ||
useFallback: true, | ||
contentType: "image", | ||
}, | ||
onClick: () => console.log("clicked"), | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
if (temporyObjects.length > 3) setDisplayShowMore(true); | ||
setDisplayedObjects(temporyObjects.slice(0, 3)); | ||
}, [temporyObjects]); | ||
|
||
const onShowMore = () => { | ||
setDisplayedObjects(prevDisplayedObjects => { | ||
const newDisplayedObjects = [ | ||
...prevDisplayedObjects, | ||
...temporyObjects.slice(prevDisplayedObjects.length, prevDisplayedObjects.length + 3), | ||
]; | ||
if (newDisplayedObjects.length === temporyObjects.length) setDisplayShowMore(false); | ||
return newDisplayedObjects; | ||
}); | ||
}; | ||
|
||
console.log(displayedObjects); | ||
return { account, temporyObjects: displayedObjects, displayShowMore, onShowMore }; | ||
}; |
Empty file.
14 changes: 14 additions & 0 deletions
14
.../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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from "react"; | ||
import { Account } from "@ledgerhq/types-live"; | ||
import Inscriptions from "../../components/Inscriptions"; | ||
|
||
type Props = { | ||
account: Account; | ||
}; | ||
|
||
const OrdinalsAccount: React.FC<Props> = ({ account }) => { | ||
return <Inscriptions account={account} />; | ||
// here we will add the rare sats table | ||
}; | ||
|
||
export default OrdinalsAccount; |
19 changes: 14 additions & 5 deletions
19
...e-desktop/src/newArch/features/Collectibles/components/Collection/TableRow/TokenTitle.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
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