//@ts-check import React from "https://esm.sh/preact@10.11.3/compat"; /// import {html} from "https://esm.sh/htm@3.1.1/preact"; export default { Button({children, icon, light, disabled}) { return html` ${ icon && html`${icon}` } ${children} `; }, /** @type {({children}:{inset:number, children:React.ReactNode})=>JSX.Element} */ Chart({children}) { const inset = 20 const size = 1/6; /** @type {Record} */ const mappingX = { "125": [size*0.0, true ], "250": [size*1.0, true ], "500": [size*2.0, true ], "1000": [size*3.0, true ], "2000": [size*4.0, true ], "3000": [size*4.5, false], "4000": [size*5.0, true ], "6000": [size*5.5, false], "8000": [size*6.0, true ], }; const rulesX = Object.entries(mappingX).map(([label, [position, normal]])=> { return html` ${label} `; }); const rulesY = []; const rulesYMin = -10; const rulesYMax = 120; for(let db = rulesYMin; db <= rulesYMax; db+=10) { const percent = ((db-rulesYMin) / (rulesYMax-rulesYMin))*100; rulesY.push(html` ${db} `); } return html` Frequency in Hz Hearing Level (dbHL) ${ rulesX } ${ rulesY } ${ children } `; } }