Skip to content

Commit 404878b

Browse files
committed
Enhance Hero and Overlay components for improved responsiveness
- Introduced constants for camera positions in the Hero component to optimize rendering based on device type. - Updated camera position logic to dynamically adjust for mobile and desktop views. - Refined Overlay component layout for better alignment and responsiveness across different screen sizes.
1 parent ac6d908 commit 404878b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/components/hero/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import { Overlay } from "../overlay";
1616
const DESKTOP_HEIGHT = 256;
1717
const MOBILE_HEIGHT = 356;
1818

19+
const DESKTOP_CAMERA_POSITION = 2.3;
20+
const MOBILE_CAMERA_POSITION = 2.7;
21+
1922
export const HeroASCII = () => {
2023
const containerRef = useRef<HTMLDivElement>(null);
2124
useEffect(() => {
@@ -93,15 +96,20 @@ void main() {
9396
}
9497
fragColor = vec4(col, 1.0);
9598
}`;
99+
100+
const isMobile = () => window.innerWidth < 768;
101+
96102
const renderer = new Renderer({ antialias: true });
97103
const gl = renderer.gl;
98104
containerRef.current?.appendChild(gl.canvas);
99105
const camera = new Camera(gl, { near: 0.1, far: 100 });
100-
camera.position.set(2.2, 2.2, 2.2);
106+
camera.position.set(
107+
isMobile()
108+
? new Vec3(MOBILE_CAMERA_POSITION)
109+
: new Vec3(DESKTOP_CAMERA_POSITION)
110+
);
101111
camera.lookAt(new Vec3(0, 0, 0));
102112

103-
const isMobile = () => window.innerWidth < 768; // Common breakpoint for mobile
104-
105113
const updateSize = () => {
106114
const height = isMobile() ? MOBILE_HEIGHT : DESKTOP_HEIGHT;
107115
renderer.setSize(window.innerWidth - 32, window.innerHeight - height);

src/components/overlay/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ export const Overlay = () => {
22
return (
33
<div className="absolute inset-0 z-50 flex items-center justify-center">
44
<div className="w-full h-full relative">
5-
<div className="absolute top-12 right-12 text-white bg-black w-[264px] text-right font-mono text-sm pl-4 py-2">
5+
<div className="absolute top-1 md:top-12 left-1/2 -translate-x-1/2 md:left-auto md:right-12 md:translate-x-0 text-white bg-black w-[274px] lg:w-[264px] text-right font-mono text-sm lg:pl-4 py-2">
66
Vortex is a highly performant, extensible columnar data format
77
</div>
88

9-
<div className="absolute bottom-1 left-14 text-white bg-black w-[324px] text-left font-mono text-sm px-4 py-2">
9+
<div className="absolute bottom-1 left-1/2 -translate-x-1/2 md:left-14 md:translate-x-0 text-white bg-black w-[274px] lg:w-[324px] text-left font-mono text-sm lg:px-4 py-2">
1010
It&apos;s both a file format and a memory format, enabling compute
1111
over compressed data
1212
</div>

0 commit comments

Comments
 (0)