Background Demo

This commit is contained in:
Hannah-Dagemark 2025-03-26 14:12:34 +00:00
commit 4cb2909e62
2 changed files with 31 additions and 25 deletions

View file

@ -1,33 +1,12 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import Background from './components/background'
function App() {
const [count, setCount] = useState(0)
return (
<>
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<Background>
<div></div>
</Background>
</>
)
}

View file

@ -0,0 +1,27 @@
import React from "react"
const Background: React.FC<{children: React.ReactNode }> = ({ children }) => {
return (
<div className="relative min-h-screen min-w-screen flex items-center justify-center p-4 bg-amber-500 overflow-hidden">
<div className="absolute inset-0 flex flex-wrap justify-center items-start">
{Array.from({ length: 20}).map((_, row) => (
<div key={row} className="flex">
{Array.from({ length: 10}).map((_, col) => (
<div key={col}
className="w-12 h-14 bg-amber-300"
style={{
clipPath: "polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",
transform: row % 2 === 0 ? "translateX(50%)" : "none",
}}>
</div>
))}
</div>
))}
</div>
<div className="relative bg-white rounded-2xl shadow-lg p-8 h-100 w-200 text-center">{children}</div>
</div>
)
}
export default Background