Self-hosted house planner: true-scale 2D floor plan, 3D, satellite map overlay, sewer, electrical, water and underfloor heating with calculations, priced bill of materials. React + PHP, no database. By the team behind homedesignsai.pro
TypeScript 3darchitecturebill-of-materialscadconstructionelectrical-designfloor-planfloorplan-editorhome-designhouse-plannerkonvamaplibrephpplumbingreactreact-three-fiberself-hostedthreejstypescriptunderfloor-heating
import { useLayoutEffect, useRef, useState } from 'react'
export function useElementSize<T extends HTMLElement>() {
const ref = useRef<T>(null)
const [size, setSize] = useState({ width: 0, height: 0 })
useLayoutEffect(() => {
const el = ref.current
if (!el) return
const observer = new ResizeObserver(([entry]) => {
const { width, height } = entry.contentRect
setSize({ width: Math.round(width), height: Math.round(height) })
})
observer.observe(el)
return () => observer.disconnect()
}, [])
return [ref, size] as const
}