Skip to content

Commit

Permalink
@0.2.10: minor sizing bug in VideoBlockComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
artemis-prime committed Feb 3, 2024
1 parent 97856e8 commit 5978cfa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions pkgs/luxdefi-ui/blocks/components/video-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ const VideoBlockComponent: React.FC<{
const [_dim, setDim] = useState<Dimensions | undefined>(undefined)

const onResize = () => {
const height = window.innerHeight
const width = window.innerWidth

setDim({
w: width,
h: height
w: window.innerWidth,
h: window.innerHeight
})
}

Expand All @@ -39,7 +36,7 @@ const VideoBlockComponent: React.FC<{
window.addEventListener('resize', onResize)
return () => window.removeEventListener('resize', onResize)
}
}, [])
}, [window])

useLayoutEffect(() => {
onResize()
Expand All @@ -52,13 +49,14 @@ const VideoBlockComponent: React.FC<{

const b = block as VideoBlock
if (b.sizing?.vh) {
const H = `${b.sizing.vh}vh`
const ar = asNum(b.dim.md.w) / asNum(b.dim.md.h)
// serverside, generate the css for the correctly sized poster image
if (!_dim) {
const height = `${b.sizing.vh}vh`
return <div className='dummy-div' style={{
height: H,
width: `calc(${H}*${ar})`,
maxWidth: '100%',
height: height,
width: `calc(${height}*${ar})`,
backgroundImage: `url(${b.poster!})`,
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
Expand Down
2 changes: 1 addition & 1 deletion pkgs/luxdefi-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luxdefi/ui",
"version": "0.2.9",
"version": "0.2.10",
"description": "Library that contains shared UI primitives, styles, and core types",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down

0 comments on commit 5978cfa

Please sign in to comment.