import React from "react"; import {html} from "htm"; import * as TW from "./twind.js"; import * as UI from "./ui.js"; import * as Store from "./store.js"; // @ts-ignore: const ShadowDOM = document.querySelector("#app").attachShadow({mode: "open"}); const ShadowDiv = document.createElement("div"); const ShadowCSS = document.createElement("style"); ShadowDOM.append(ShadowCSS); ShadowDOM.append(ShadowDiv); TW.Init(ShadowCSS, ShadowDiv); const Controls =()=> { const [State, Dispatch] = Store.Consumer(); return html`
Channel
${State.Chan.Value}
<${UI.Button} light=${State.Chan.Value == 0} inactive=${State.Chan.Value == 0} onClick=${()=>Dispatch({Name:"Chan", Data:-1})}>Left <${UI.Button} light=${State.Chan.Value == 1} inactive=${State.Chan.Value == 1} onClick=${()=>Dispatch({Name:"Chan", Data:1})}>Right
Frequency
${Store.ColumnMapping[State.Freq.Value][0]}
<${UI.Button} disabled=${State.Freq.Value == State.Freq.Min} onClick=${()=>Dispatch({Name:"Freq", Data:-1})}>- <${UI.Button} disabled=${State.Freq.Value == State.Freq.Max} onClick=${()=>Dispatch({Name:"Freq", Data:1})}>+
Stimulus
${State.Stim.Value}
<${UI.Button} disabled=${State.Stim.Value == State.Stim.Min} onClick=${()=>Dispatch({Name:"Stim", Data:-1})}>- <${UI.Button} disabled=${State.Stim.Value == State.Stim.Max} onClick=${()=>Dispatch({Name:"Stim", Data:1})}>+
Mark
<${UI.Button} onClick=${()=>Dispatch({Name:"Mark", Data:true })}>Response <${UI.Button} onClick=${()=>Dispatch({Name:"Mark", Data:false})}>No Response <${UI.Button} onClick=${()=>Dispatch({Name:"Mark", Data:null })} disabled=${State.Live.Mark == undefined}>Clear
`; }; const Audiogram =()=> { const [State] = Store.Consumer(); const testMarksL = State.Draw.TestL.Points.map(p=>html`<${UI.Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${false}/>`); const userMarksL = State.Draw.UserL.Points.map(p=>html`<${UI.Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${false} classes=${State.Live.Mark == p.Mark ? "stroke-bold":""}/>`); const testMarksR = State.Draw.TestR.Points.map(p=>html`<${UI.Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${true} />`); const userMarksR = State.Draw.UserR.Points.map(p=>html`<${UI.Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${true} classes=${State.Live.Mark == p.Mark ? "stroke-bold":""}/>`); const testLinesL = State.Draw.TestL.Paths.map( p=>html``); const userLinesL = State.Draw.UserL.Paths.map( p=>html``); const testLinesR = State.Draw.TestR.Paths.map( p=>html``); const userLinesR = State.Draw.UserR.Paths.map( p=>html``); return html` ${testMarksL}${testLinesL} ${testMarksR}${testLinesR} ${userMarksL}${userLinesL} ${userMarksR}${userLinesR} `; }; React.render(html` <${Store.Provider}> <${Controls}/> <${UI.Chart}> <${Audiogram}/> `, ShadowDiv);