Skip to content

Commit

Permalink
remove re-used variables
Browse files Browse the repository at this point in the history
  • Loading branch information
scoronelhamilton committed Oct 11, 2022
1 parent 68c62cf commit 01a2be9
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,74 +151,4 @@ const BillsGrid = ({ count }: { count: number }) => {
)
}

const BillsGrid2 = () => {
const [randomBills, setRandomBills] = useState<BillValue[]>([])
const billsContainer = useRef<HTMLDivElement>(null)

const ROWS = 6
const COLUMNS = 6
const TOTAL_BILLS = ROWS * COLUMNS
const rowPositions = ['-150', '-220', '-10', '-300', '-100', '-200']

const billValues = [
BillValue.Five,
BillValue.Ten,
BillValue.Twenty,
BillValue.Fifty,
BillValue.OneHundred,
BillValue.FiveHundred
]

const generateRandomBills = () => {
const bills = []

for (let i = 0; i < TOTAL_BILLS; i++) {
const randomIndex = Math.floor(Math.random() * billValues.length)
const bill = billValues[randomIndex]
bills.push(bill)
}

setRandomBills(bills)
}

const moveRows = () => {
const container = billsContainer.current
if (!container) return

container.childNodes.forEach((child, i) => {
const row = child as HTMLDivElement
const position = rowPositions[i]
if (position) {
row.style.transform = `translateX(${position}px)`
}
})
}

useLayoutEffect(() => {
generateRandomBills()
}, [])

useLayoutEffect(() => {
if (billsContainer.current && randomBills.length > 0) {
moveRows()
}
}, [randomBills, billsContainer])

return (
<div ref={billsContainer} className={` grid gap-4 grid-cols=${COLUMNS} overflow-hidden pb-20`}>
{randomBills.map((row, i) => (
<div key={`row-${i}`} className="relative h-[132px]">
<div className={`absolute flex items-center`}>
{row.map((col, j) => (
<div key={`bill_${i}_${j}`} className="m3-4 relative mr-4 aspect-[2.44] h-[132px]">
{<Image src={getBillImage(col)} alt="" layout="fill" />}
</div>
))}
</div>
</div>
))}
</div>
)
}

export default Home

1 comment on commit 01a2be9

@vercel
Copy link

@vercel vercel bot commented on 01a2be9 Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

allyu-frontend – ./

allyu-frontend-allyu.vercel.app
allyu-frontend.vercel.app
allyu-frontend-git-main-allyu.vercel.app

Please sign in to comment.