-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: collectibles widget #481
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #481 +/- ##
=======================================
Coverage 22.38% 22.38%
=======================================
Files 132 132
Lines 5521 5521
Branches 241 241
=======================================
Hits 1236 1236
Misses 4285 4285
|
e6f0956
to
7c0ec2b
Compare
afdc14d
to
e8d90a8
Compare
3501687
to
2bd391c
Compare
@@ -0,0 +1,67 @@ | |||
import { Square, SquareProps } from 'leather-styles/jsx'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this as it was the only other thing using use-events
so I can also move that package here.
We use that in CollectibleItemLayout
which I migrated here but could revert to the extension
if desired.
The hook usePressable
is only used once in the extension accounts.tsx
= AddAccountAction
src: string; | ||
} | ||
|
||
const mockOrdinals: Ordinal[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I obtained these mocks by logging all the inscriptions we have on Leather Dev wallet and picking out different samples.
The structure here is what we are sending to the components but it seems different than the BIS docs and also what we have in leather.io/query
for mock-inscriptions
Today I found this other utils
that is mapping BIS to this format - createBestInSlotInscription
I think it's OK for now and we can improve this and share the mocks better if needed / ditch these altogether when connecting the API.
}; | ||
|
||
export default meta; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some mocks of what we use to actually render inscriptions here.
- Video seems to be handled the same as
html
/svg
in an iframe anyway. - Audio seems to just show an icon now
I can inscribe audio + video on ordinals bot if we think that's useful. For video the network fee is high so it's ~ $392 for what I tested. Audio can be cheaper ~ $122.02.
5951b4d
to
432e828
Compare
export function CollectibleHtml({ src }: CollectibleHtmlProps) { | ||
return ( | ||
<CollectibleCardLayout> | ||
<WebView source={{ uri: src }} width={200} height={200} style={{ overflow: 'hidden' }} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to do a bit more work here as I still see some scroll bars
html_scroll.mp4
@@ -0,0 +1,21 @@ | |||
import { type Collectible, type CollectibleCardProps } from '@leather.io/ui/native'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this as a way to just get only the data we need to display from the mocks.
Later I found createBestInSlotInscription
which is actually giving us this data and more.
I will investigate more when hooking up APIs but maybe it could be good to have a BE proxy for this type of stuff - data we need for App Home for example.
- I tried using jsdom as a polyfill but then hit an error Can't resolve 'vm' in jsdom | ||
- maybe we should write our own sanitizer? | ||
*/} | ||
{/* {content ? sanitize(content) : ''} */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using dompurify.sanitize
here but it seems not to work on native.
I tried a polyfill of jsdom
but then that failed and needed another polyfill
so I need to investigate a better way.
Maybe we could run sanitize
in the query instead? So that we just provide the data ready to render
packages/ui/src/components/collectibles/native/collectible-card.native.tsx
Outdated
Show resolved
Hide resolved
apps/mobile/src/components/widgets/collectibles/collectibles-widget.layout.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, @pete-watters.
export interface Ordinal { | ||
id: string; | ||
number: number; | ||
output: string; | ||
txid: string; | ||
offset: string; | ||
address: string; | ||
preview: string; | ||
title: string; | ||
genesisBlockHeight: number; | ||
genesisBlockHash: string; | ||
genesisTimestamp: number; | ||
value: string; | ||
mimeType: string; | ||
name: string; | ||
src: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this should live in models pkg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move it when connecting to real data
@@ -1,6 +1,6 @@ | |||
import { motion, stagger, useAnimate } from 'framer-motion'; | |||
import { css } from 'leather-styles/css'; | |||
import { HasChildren } from 'src/utils/has-children'; | |||
import { HasChildren } from 'src/utils/has-children.shared'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase on dev and make sure there are no src/
imports? Think they should cause type errors on rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased and cleaned this up. I think we should add path aliases to the tsconfig
to clean up all of the relative path imports. Is there a reason not to do that?
It would mean we need to have the src/
path in ui/tsconfig.json
:
"paths": {
"leather-styles/*": ["leather-styles/*"],
"@components/*": ["src/components/*"],
"@icons/*": ["src/icons/*"],
"@hooks/*": ["src/hooks/*"],
"@utils/*": ["src/utils/*"],
168c039
to
355ae5b
Compare
355ae5b
to
58c3b69
Compare
This PR:
Once the UI package is released I can complete leather-io/extension#5876
Mobile demo
collectibles.mp4
Mobile storybook demo
collectible-storybook.mp4
There are some remaining items to figure out:
dompurify.sanitize
for text ordinalsWebView
ordinals