MCPcopy Create free account
hub / github.com/TheOrcDev/orcish-fullstack-admin / ScreenSize

Function ScreenSize

components/ui/screen-size.tsx:5–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { useEffect, useState } from "react";
4
5export const ScreenSize = () => {
6 const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
7
8 useEffect(() => {
9 function updateDimensions() {
10 setDimensions({
11 width: window.innerWidth,
12 height: window.innerHeight,
13 });
14 }
15
16 updateDimensions();
17 window.addEventListener("resize", updateDimensions);
18
19 return () => {
20 window.removeEventListener("resize", updateDimensions);
21 };
22 }, []);
23
24 const { width, height } = dimensions;
25
26 return (
27 <div className="fixed bottom-5 right-5 flex items-center gap-2 rounded-full bg-black px-2.5 py-1 font-mono text-xs font-medium text-white">
28 <span>
29 {width.toLocaleString()} x {height.toLocaleString()}
30 </span>
31 <div className="h-4 w-px bg-gray-800" />
32 <span className="sm:hidden">XS</span>
33 <span className="hidden sm:inline md:hidden">SM</span>
34 <span className="hidden md:inline lg:hidden">MD</span>
35 <span className="hidden lg:inline xl:hidden">LG</span>
36 <span className="hidden xl:inline 2xl:hidden">XL</span>
37 <span className="hidden 2xl:inline">2XL</span>
38 </div>
39 );
40};

Callers

nothing calls this directly

Calls 1

updateDimensionsFunction · 0.85

Tested by

no test coverage detected