-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wallet) Fix NFT image flashing HTML broken before the image is lo…
…aded (#20302) Fix NFT image flashing HTML broken before the image is loaded
- Loading branch information
1 parent
59e7318
commit 77c10bb
Showing
6 changed files
with
91 additions
and
21 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
.../desktop/views/portfolio/components/nft-grid-view/nft-grid-view-item-skeleton.stories.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,15 @@ | ||
// Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import * as React from 'react' | ||
import { NftGridViewItemSkeleton } from "./nft-grid-view-item-skeleton" | ||
|
||
export const _NftGridViewItemSkeleton = () => { | ||
return ( | ||
<NftGridViewItemSkeleton /> | ||
) | ||
} | ||
|
||
export default _NftGridViewItemSkeleton |
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
44 changes: 44 additions & 0 deletions
44
components/brave_wallet_ui/nft/components/nft-image/image-loader.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,44 @@ | ||
// Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import * as React from 'react' | ||
|
||
// styles | ||
import { Image } from './nft-image.styles' | ||
|
||
interface ImageLoaderProps { | ||
src: string | ||
width?: string | ||
height?: string | ||
lazyLoad?: 'lazy' | 'eager' | ||
onLoaded?: () => void | ||
} | ||
|
||
export const ImageLoader = ({ | ||
src, | ||
width, | ||
height, | ||
lazyLoad, | ||
onLoaded | ||
}: ImageLoaderProps) => { | ||
const [loaded, setLoaded] = React.useState(false) | ||
|
||
const handleImageLoaded = () => { | ||
setLoaded(true) | ||
if (onLoaded) onLoaded() | ||
} | ||
|
||
return ( | ||
<> | ||
{loaded && <Image src={src} customWidth={width} customHeight={height} />} | ||
<img | ||
src={src} | ||
style={{ display: 'none' }} | ||
loading={lazyLoad} | ||
onLoad={handleImageLoaded} | ||
/> | ||
</> | ||
) | ||
} |
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