Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Brant Ashe committed May 28, 2024
1 parent 395c6dc commit 7e90146
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
21 changes: 3 additions & 18 deletions src/app/(test)/test/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BgBanner from '@/components/BgBanner';
import type { Metadata } from 'next';
import { Assistant } from 'next/font/google';

Expand All @@ -11,24 +12,8 @@ export const metadata: Metadata = {
export default function RootLayout() {
return (
<html lang="en">
<body
className={inter.className}
style={{
display: 'flex',
margin: 0,
alignItems: 'center',
height: '100vh',
}}
>
<div
style={{
height: 400,
width: '100%',
background: 'red',
}}
>
test
</div>
<body className={inter.className}>
<BgBanner />
</body>
</html>
);
Expand Down
30 changes: 27 additions & 3 deletions src/components/BgBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import { useEffect, useState } from 'react';
import { useEffect, useLayoutEffect, useRef, useState } from 'react';

import styles from './testcomponents.module.css';
// import styles from './testcomponents.module.css';

type BgBannerProps = {
debug?: boolean;
Expand All @@ -13,6 +13,15 @@ export default function TestBgBanner({ debug }: BgBannerProps) {
x: number;
y: number;
} | null>();
const ref = useRef<HTMLDivElement>(null);

useLayoutEffect(() => {
const node = ref.current;

if (node) {
node.style.top = '50svh';
}
}, []);

useEffect(() => {
// TODO: debounce
Expand All @@ -32,7 +41,22 @@ export default function TestBgBanner({ debug }: BgBannerProps) {

return (
<>
<div className={styles['bg-banner']} />
<div
ref={ref}
style={{
display: 'flex',
alignItems: 'center',
top: '50svh',
transform: 'translateY(50%)',
height: 400,
width: '100%',
margin: 0,
background: 'red',
}}
>
test
</div>
{/* <div className={styles['bg-banner']} /> */}
{debug ? (
<div>
{orientation?.x || 0}, {orientation?.y || 0}
Expand Down

0 comments on commit 7e90146

Please sign in to comment.