Skip to content

Commit

Permalink
Merge pull request #75 from fold-dev/fix/app-sandbox-image-load
Browse files Browse the repository at this point in the history
fix: lazy load App Sandbox image on homepage
  • Loading branch information
joduplessis authored Jun 6, 2024
2 parents dd81fdf + 412fa20 commit f366be6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fold-dev/docs",
"version": "24.6.6.0",
"version": "24.6.6.1",
"description": "UI components for product teams.",
"scripts": {
"prepare": "husky install",
Expand Down
31 changes: 24 additions & 7 deletions src/components/core.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1377,13 +1377,6 @@ export const CoreComponent = () => {
highlightCode(snippet1, 'javascript').then((html) => setHtml(html))
}, [])

useEffect(() => {
['app-sandbox-light.png', 'app-sandbox-dark.png'].map((imageUrl) => {
const img = new window.Image()
img.src = imageUrl
})
}, [])

return (
<>
<View
Expand Down Expand Up @@ -1513,6 +1506,30 @@ export const CoreComponent = () => {
width={1250}
style={{ left: 0, top: -35, transform: 'rotateZ(8deg)' }}
position="absolute">
<img
className="lazy-load-dark"
style={{
visibility: 'hidden',
position: 'absolute',
zIndex: -1,
top: 0,
left: 0,
width: 0,
height: 0,
}}
/>
<img
className="lazy-load-light"
style={{
visibility: 'hidden',
position: 'absolute',
zIndex: -1,
top: 0,
left: 0,
width: 0,
height: 0,
}}
/>
<img
style={{ position: 'relative', zIndex: 0 }}
src="app-sandbox-light.png"
Expand Down
8 changes: 8 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ body {
margin: 1rem 0;
}

.lazy-load-dark {
content: url("../../public/app-sandbox-dark.png");
}

.lazy-load-light {
content: url("../../public/app-sandbox-light.png");
}

[data-theme="dark"] .pro-image {
content: url("../../public/app-sandbox-dark.png");
}
Expand Down

0 comments on commit f366be6

Please sign in to comment.