Merge pull request #1 from TreetopFlyer/feature/layout-updates

Feature/layout updates
This commit is contained in:
Seth Trowbridge 2023-06-07 21:15:10 -04:00 committed by GitHub
commit bb74512aad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 417 additions and 318 deletions

View File

@ -1,15 +1,9 @@
{
"compilerOptions": { "types": ["./store"], "checkJs": true },
"importMap": "./deno.map.json",
"fmt": {
"options": {
"lineWidth": 256
}
},
"tasks": {
"dev": "deno task serve & deno task test",
"fmt": "deno fmt --watch",
"serve": "deno run -A --unstable --no-check https://deno.land/std@0.167.0/http/file_server.ts",
"test": "deno test store.test.ts --watch --no-lock --no-check"
"compilerOptions": { "types": ["*.d.ts"], "checkJs": true },
"imports": {
"@twind/": "https://esm.sh/@twind/",
"react": "https://esm.sh/preact@10.11.3/compat",
"htm": "https://esm.sh/htm@3.1.1/preact",
"app": "./js/app.js"
}
}

View File

@ -1,8 +0,0 @@
{
"imports": {
"@twind/": "https://esm.sh/@twind/",
"react": "https://esm.sh/preact@10.11.3/compat",
"htm": "https://esm.sh/htm@3.1.1/preact",
"app": "./src/app.js"
}
}

View File

@ -1,7 +1,12 @@
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!---->
<div id="app"></div>
<script type="importmap-shim" src="./deno.map.json"></script>
<script type="module-shim">import "app";</script>
<script async src="https://unpkg.com/es-module-shims@0.13.1/dist/es-module-shims.min.js"></script>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body>
<div id="app"></div>
<script type="importmap-shim" src="./deno.json"></script>
<script type="module-shim">import "app";</script>
<script async src="https://unpkg.com/es-module-shims@0.13.1/dist/es-module-shims.min.js"></script>
</body>
</html>

View File

@ -15,23 +15,20 @@ TW.Init(ShadowCSS, ShadowDiv);
React.render(html`
<${Store.Provider}>
<div class="max-w-[1170px] mx-auto">
<div class="grid grid-cols-[300px_auto] items-center">
<div class="col-start-1 p-10">
<img src="./logo.png"/>
</div>
<div class="flex justify-center">
<${UI.Select}/>
</div>
<div class="col-start-1">
<${UI.Header}/>
<div class="flex flex-col items-start lg:flex-row my-4">
<${UI.Controls}/>
</div>
<div class="">
<${UI.Chart}>
<${UI.Audiogram}/>
<div class="absolute bottom-0 right-0"><${UI.Display}/></div>
<//>
</div>
</div>
</div>
<//>
`, ShadowDiv);

View File

@ -28,6 +28,55 @@ export const ColumnLookup =(inFrequency)=>
/** @type {(inDecimal:number)=>string} */
const Perc =(inDecimal)=> `${inDecimal*100}%`;
/** @type {(inTest:Store.Test)=>Store.Grade} */
export const Grade =(inTest)=>
{
/** @type {Store.Grade} */
const output = { Total:0, Marks:0, Score:0 };
/** @type {(inGoal:number, inResult:number)=>number} */
const Mapper =(inGoal, inResult)=>
{
const err = Math.abs(inGoal-inResult);
if(err == 0){ return 1; }
else if(err > 0 && err <= 5){ return 0.9; }
else if(err > 5 && err <= 10){ return 0.7; }
else if(err > 10 && err <= 15){ return 0.2; }
else{ return 0; }
}
for(let i=0; i<inTest.Plot.length; i++)
{
const {TestL, TestR, UserL, UserR} = inTest.Plot[i];
if(TestL)
{
output.Total ++;
if(UserL)
{
output.Marks++;
output.Score += Mapper(TestL.Stim, UserL.Stim);
}
}
if(TestR)
{
output.Total ++;
if(UserR)
{
output.Marks++;
output.Score += Mapper(TestR.Stim, UserR.Stim);
}
}
}
if(output.Marks > 0)
{
output.Score = Math.floor((output.Score/output.Marks) * 10000)/100;
}
return output;
}
/** Creates a new Store.Context object that contain the current selections
* @type {(inState:Store.State, inTest?:Store.Test)=>Store.Context} */
const Reselect =(inState, inTest)=>
@ -44,7 +93,8 @@ const Reselect =(inState, inTest)=>
if(plot.Hz == hz)
{
output.Freq = plot;
output.Mark = plot[`User${inState.Chan.Value ? "R" : "L"}`];
output.Mark = inState.Chan.Value ? plot.UserR : plot.UserL;
break;
}
}
}
@ -111,7 +161,7 @@ export function Reducer(inState, inAction)
const test = clone.Test[Data];
if(test)
{
clone.TestIndex = Data;
clone.Pick = Data;
clone.Live = Reselect(clone, test);
clone.Draw =
{
@ -121,6 +171,7 @@ export function Reducer(inState, inAction)
TestL: Redraw(test, 0, clone.Stim, false),
TestR: Redraw(test, 1, clone.Stim, false)
};
test.Done = Grade(test);
}
}
else if (Name == "Mark")
@ -131,6 +182,8 @@ export function Reducer(inState, inAction)
clone.Live.Mark = Data !== null ? {Stim:clone.Stim.Value, Resp:Data} : undefined;
clone.Live.Freq[key] = clone.Live.Mark;
clone.Draw[key] = Redraw(clone.Live.Test, clone.Chan.Value, clone.Stim, true);
clone.Live.Test.Done = Grade(clone.Live.Test);
SaveTests(clone);
}
}
else if( Name=="Stim" || Name=="Chan" || Name=="Freq")
@ -146,6 +199,25 @@ export function Reducer(inState, inAction)
clone.Live = Reselect(clone);
}
}
else if (Name == "Errs")
{
clone.Errs = Data;
}
else if (Name == "Kill")
{
if(clone.Live.Test)
{
clone.Live.Test.Plot.forEach(freq=>
{
freq.UserL = undefined;
freq.UserR = undefined;
});
clone.Draw["UserL"] = Redraw(clone.Live.Test, clone.Chan.Value, clone.Stim, true);
clone.Draw["UserR"] = Redraw(clone.Live.Test, clone.Chan.Value, clone.Stim, true);
clone.Live.Test.Done = Grade(clone.Live.Test);
SaveTests(clone);
}
}
else if (Name == "ShowCursor")
{
clone.Show.Cursor = Data;
@ -155,35 +227,14 @@ export function Reducer(inState, inAction)
clone.Show.Answer = Data;
}
SaveSettings(clone);
return clone;
}
/** @type {Store.State} */
export const Initial = Reducer(
{
Chan: { Min:0, Max:1, Value:0, Step:1 },
Freq: { Min:2, Max:8, Value:3, Step:1 },
Stim: { Min:-10, Max:120, Value:30, Step:5 },
Live:
{
Test: undefined,
Freq: undefined,
Mark: undefined
},
Draw:
{
UserL:{Points:[], Paths:[]},
UserR:{Points:[], Paths:[]},
TestL:{Points:[], Paths:[]},
TestR:{Points:[], Paths:[]}
},
Show:
{
Cursor:true,
Answer:false
},
TestIndex: 0,
Test: [
/** @type {Store.Test[]} */
const TestDefault = [
{
Name: "Patient A Asymmetric Notch",
Plot:
@ -236,11 +287,60 @@ export const Initial = Reducer(
{ Hz: 8000, TestL: { Stim: 0, Resp: true }, TestR: { Stim: 5, Resp: true } }
]
}
]
}, {Name:"Test", Data:0});
];
/** @type {Store.Test[]} */
const TestActual = JSON.parse(localStorage.getItem("app-tests")||"false") || TestDefault;
/**@type {(inState:Store.State)=>void} */
const SaveTests =(inState)=> localStorage.setItem("app-tests", JSON.stringify(inState.Test));
/** @type {preact.Context<Store.Binding>} */
export const Context = React.createContext([Initial, (_a)=>{}]);
/** @type {Store.StatePartSimple} */
const SettingsDefault =
{
Chan: { Min:0, Max:1, Value:0, Step:1 },
Freq: { Min:2, Max:8, Value:3, Step:1 },
Stim: { Min:-10, Max:120, Value:30, Step:5 },
Errs: 0,
Pick: 0,
Show: { Cursor:true, Answer:false }
};
/** @type {Store.StatePartSimple} */
const SettingsActual = JSON.parse(localStorage.getItem("app-settings")||"false") || SettingsDefault;
/**@type {(inState:Store.State)=>void} */
const SaveSettings =(inState)=>
{
/** @type {Store.StatePartSimple} */
const clone = {
Chan:inState.Chan,
Freq:inState.Freq,
Stim:inState.Stim,
Errs:inState.Errs,
Pick:inState.Pick,
Show:inState.Show
};
localStorage.setItem("app-settings", JSON.stringify(clone));
};
export const Initial = Reducer(
{
...SettingsActual,
Test: TestActual,
Live:
{
Test: undefined,
Freq: undefined,
Mark: undefined
},
Draw:
{
UserL:{Points:[], Paths:[]},
UserR:{Points:[], Paths:[]},
TestL:{Points:[], Paths:[]},
TestR:{Points:[], Paths:[]}
}
}, {Name:"Test", Data:SettingsActual.Pick});
export const Context = React.createContext(/** @type {Store.Binding} */([Initial, (_a)=>{}]));
/** @type {(props:{children:preact.ComponentChildren})=>preact.VNode} */
export const Provider =(props)=>
@ -252,54 +352,3 @@ export const Provider =(props)=>
/** @type {()=>Store.Binding} */
export const Consumer =()=> React.useContext(Context);
/** @type {(inTest:Store.Test|undefined)=>Store.Grade} */
export const Grade =(inTest)=>
{
/** @type {Store.Grade} */
const output = { Total:0, Done:0, Score:0 };
/** @type {(inGoal:number, inResult:number)=>number} */
const Mapper =(inGoal, inResult)=>
{
const err = Math.abs(inGoal-inResult);
if(err == 0){ return 1; }
else if(err > 0 && err <= 5){ return 0.9; }
else if(err > 5 && err <= 10){ return 0.7; }
else if(err > 10 && err <= 15){ return 0.2; }
else{ return 0; }
}
if(inTest)
{
for(let i=0; i<inTest.Plot.length; i++)
{
const {TestL, TestR, UserL, UserR} = inTest.Plot[i];
if(TestL)
{
output.Total ++;
if(UserL)
{
output.Done++;
output.Score += Mapper(TestL.Stim, UserL.Stim);
}
}
if(TestR)
{
output.Total ++;
if(UserR)
{
output.Done++;
output.Score += Mapper(TestR.Stim, UserR.Stim);
}
}
}
}
if(output.Done > 0)
{
output.Score = Math.floor((output.Score/output.Done) * 10000)/100;
}
return output;
}

View File

@ -2,7 +2,7 @@ import * as TW from "@twind/core@1.0.1";
import TWPreTail from "@twind/preset-tailwind@1.0.1";
import TWPreAuto from "@twind/preset-autoprefix@1.0.1";
/** @type {TW.TwindConfig} */
/** @type {TW.TwindUserConfig} */
export const Configure = {
theme:
{
@ -71,7 +71,7 @@ export const Configure = {
}
],
[
'text-shadow-lcd', {"text-shadow": "0px 2px 2px #00000055"}
'text-shadow-lcd', {"text-shadow": "0px 1px 1px #00000055"}
],
[ 'box-notch', "border-t(1 [#ffffff]) border-r(1 [#ffffff]) border-b(1 [#00000033]) border-l(1 [#00000033]) flex items-center justify-end gap-1 p-2" ],
[ "box-buttons", "flex gap-1 items-center p-2 rounded-lg bg-gradient-to-b from-[#00000022] border-b(1 [#ffffff]) border-t(1 [#00000033])"]

View File

@ -3,7 +3,7 @@ import { html } from "htm";
import * as Store from "./store.js";
import * as Tone from "./tone.js";
/** @typedef {({children}:{children?:preact.ComponentChildren})=>preact.VNode} BasicElement */
/** @typedef {({children, classes}:{children?:preact.ComponentChildren, classes?:string})=>preact.VNode} BasicElement */
/** @type {({children, icon, light, disabled, inactive, onClick, classes}:{children:preact.VNode, icon?:preact.VNode, light:boolean, disabled:boolean, inactive:boolean, onClick:()=>void, classes?:string})=>preact.VNode} */
export function Button({children, icon, light, disabled, inactive, onClick, classes})
@ -36,44 +36,65 @@ export function Button({children, icon, light, disabled, inactive, onClick, clas
}
/** @type {BasicElement} */
export const Select =()=>
export const Header =()=>
{
const [State, Dispatch] = Store.Consumer();
const grade = Store.Grade(State.Live.Test);
const grade = State.Live.Test?.Done || {Marks:0, Total:0, Score:0};
/** @type {(e:Event)=>void} */
const handleChange =(e)=> Dispatch({Name:"Test", Data:parseInt(/** @type {HTMLSelectElement}*/(e.target).value)});
return html`
<div class="inline-flex flex-row align-center bg-metal rounded-lg overflow-hidden shadow-md font-sans">
<div class="box-notch">
<div >Select Test</div>
<div class="box-buttons">
<select id="test-select" class="px-2 py-2 rounded-lg border(1 slate-200) font-bold text(xl white) cursor-pointer bg-earmark" value=${State.TestIndex} onChange=${handleChange}>
<div class="flex flex-row items-stretch bg-metal rounded-lg overflow-hidden shadow-md font-sans">
<div class="p-4">
<img class="h-auto max-w-[200px]" src="./logo.png"/>
</div>
<div class="p-4 flex-1">
<div class="box-buttons w-full">
<select id="test-select" class="w-full px-2 py-2 rounded-lg border(1 slate-200) font-bold text(xl white) cursor-pointer bg-earmark" value=${State.Pick} onChange=${handleChange}>
${State.Test.map((t, i)=>html`<option class="text-black" value=${i}>${t.Name}</option>`)}
</select>
</div>
<div class="box-buttons w-full mt-2">
<p>Patient Error:</p>
<${Button} inactive=${State.Errs == 0.0} light=${State.Errs == 0.0} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"Errs", Data:0.0})}>None<//>
<${Button} inactive=${State.Errs == 0.1} light=${State.Errs == 0.1} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"Errs", Data:0.1})}>Slight<//>
<${Button} inactive=${State.Errs == 0.3} light=${State.Errs == 0.3} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"Errs", Data:0.3})}>Moderate<//>
<${Button} inactive=${State.Errs == 0.6} light=${State.Errs == 0.6} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"Errs", Data:0.6})}>Severe<//>
</div>
<div class="box-notch">
<div>Progress</div>
<div class="box-buttons flex-col">
<div>Complete: ${grade.Done} of ${grade.Total}</div>
</div>
<div class="p-4">
<div class="box-buttons flex-col w-[200px] h-full justify-center">
<div>Complete: ${grade.Marks} of ${grade.Total}</div>
<div class="w-full h-4 bg-zinc-400 rounded-full overflow-hidden">
<div class="h-full w-[${grade.Done/grade.Total*100}%] bg-earmark"></div>
<div class="h-full w-[${grade.Marks/grade.Total*100}%] bg-earmark"></div>
</div>
<div class="text-sm">Accuracy: ${grade.Score}%</div>
</div>
</div>
<div class="box-notch">
<div>Display</div>
<div class="box-buttons flex-col">
<${Button} light=${State.Show.Cursor} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"ShowCursor", Data:!State.Show.Cursor})}>Cursor<//>
<${Button} light=${State.Show.Answer} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"ShowAnswer", Data:!State.Show.Answer})}>Answer<//>
<${Button} disabled=${grade.Marks == 0} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"Kill", Data:0})}>Start Over<//>
</div>
</div>
</div>`;
}
/** @type {BasicElement} */
export const Display =()=>
{
const [State, Dispatch] = Store.Consumer();
return html`
<div class="flex justify-end">
<div class="bg-metal rounded-lg overflow-hidden shadow-md p-4">
<div class="box-buttons">
<${Button} light=${State.Show.Cursor} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"ShowCursor", Data:!State.Show.Cursor})}>Cursor<//>
<${Button} light=${State.Show.Answer} classes="flex-1 text-xs" onClick=${()=>Dispatch({Name:"ShowAnswer", Data:!State.Show.Answer})}>Answer<//>
</div>
</div>
</div>
`;
};
/** @type {BasicElement} */
export const Controls =()=>
{
@ -93,7 +114,26 @@ export const Controls =()=>
if(State.Live.Freq)
{
const testMark = State.Live.Freq[/** @type {"TestL"|"TestR"}*/(`Test${State.Chan.Value ? "R":"L"}`)];
const handler = testMark.Stim <= State.Stim.Value ? ()=>{playSet(2)} : ()=>{playSet(0)}
const audible = State.Stim.Value >= testMark.Stim;
const error = State.Stim.Value - testMark.Stim;
let errorMapped = error;
if(error >= 30){ errorMapped = 0.0; }
else if(error >= 25){ errorMapped = 0.1; }
else if(error >= 20){ errorMapped = 0.2; }
else if(error >= 15){ errorMapped = 0.3; }
else if(error >= 10){ errorMapped = 0.5; }
else if(error >= 5){ errorMapped = 0.7; }
else if(error == 0){ errorMapped = 1.0; }
else if(error >= -5){ errorMapped = 0.5; }
else if(error >=-10){ errorMapped = 0.1; }
else if(error >=-15){ errorMapped = 0.0; }
const errorScaled = State.Errs*errorMapped;
const errorSampled = Math.random() < errorScaled;
const percieved = errorSampled ? !audible : audible
const handler = percieved ? ()=>playSet(2) : ()=>playSet(0);
console.log("Error:", error, "Error Mapped:", errorMapped, "Error Scaled:", errorScaled, "Error Sampled:", errorSampled);
timer = setTimeout(handler, 800 + Math.random()*1300);
}
}
@ -104,18 +144,17 @@ export const Controls =()=>
const classTitle = "flex-1 text-sm"
return html`
<div class="font-sans bg-metal rounded-lg overflow-hidden shadow-md">
<div class="box-notch">
<div class=${classTitle}>Channel</div>
<div class="flex flex-col w-full md:w-[320px] font-sans justify-center gap-4">
<div class="flex-col bg-metal rounded-lg overflow-hidden shadow-md">
<div class="p-4 pb-1">
<div class="box-buttons min-w-[50%]">
<${Button} inactive=${State.Chan.Value == 0} light=${State.Chan.Value == 0} classes="flex-1" onClick=${()=>Dispatch({Name:"Chan", Data:-1})}>Left<//>
<${Button} inactive=${State.Chan.Value == 1} light=${State.Chan.Value == 1} classes="flex-1" onClick=${()=>Dispatch({Name:"Chan", Data:1})}>Right<//>
</div>
</div>
<div class="box-notch">
<div class=${classTitle}>Frequency</div>
<div class="p-4 py-1">
<div class="box-buttons min-w-[50%]">
<div class="w-24 text-center text-shadow-lcd"><strong>${Store.ColumnMapping[State.Freq.Value][0]}</strong> Hz</div>
<div class="flex-1 text-center text-shadow-lcd"><strong>${Store.ColumnMapping[State.Freq.Value][0]}</strong> Hz</div>
<${Button} disabled=${State.Freq.Value == State.Freq.Min} onClick=${()=>Dispatch({Name:"Freq", Data:-1})}>
<svg class="my-1 h-3 w-3 overflow-visible stroke(white 2)">
<${Glyph.Minus}/>
@ -128,10 +167,9 @@ export const Controls =()=>
<//>
</div>
</div>
<div class="box-notch">
<div class=${classTitle}>Stimulus</div>
<div class="p-4 pt-2">
<div class="box-buttons min-w-[50%]">
<div class="w-24 text-center text-shadow-lcd"><strong>${State.Stim.Value}</strong> dbHL</div>
<div class="flex-1 text-center text-shadow-lcd"><strong>${State.Stim.Value}</strong> dbHL</div>
<${Button} disabled=${State.Stim.Value == State.Stim.Min} onClick=${()=>Dispatch({Name:"Stim", Data:-1})}>
<svg class="my-1 h-3 w-3 overflow-visible stroke(white 2)">
<${Glyph.Minus}/>
@ -144,8 +182,30 @@ export const Controls =()=>
<//>
</div>
</div>
<div class="box-notch">
<svg width="80" height="80" preserveAspectRatio="none" viewBox="0 0 79 79" fill="none">
</div>
<div class="flex-col bg-metal rounded-lg overflow-hidden shadow-md">
<div class="p-4 pb-0">
<div class="box-buttons flex-1">
<div class="flex-1">
<${Button}
classes="w-full flex-1 self-center"
onClick=${()=>playSet(1)}
disabled=${playGet==1}
icon=${html`<svg class="w-3 h-3 mx-1" viewBox="0 0 20 20">
<polygon points="0,0 20,10 0,20" fill="#ffffff" stroke="none"></polygon>
</svg>`}
>
<span class="py-2">Present Tone</span>
<//>
<div class="flex gap-1 mt-2">
<${Button} onClick=${()=>{pulsedSet(true )}} light=${pulsedGet } inactive${pulsedGet } classes="flex-1 text(center xs)">Pulsed <//>
<${Button} onClick=${()=>{pulsedSet(false)}} light=${!pulsedGet} inactive${!pulsedGet} classes="flex-1 text(center xs)">Continuous<//>
</div>
</div>
</div>
<svg width="80" height="80" preserveAspectRatio="none" viewBox="0 0 79 79" fill="none" class="mx-auto mt-2">
<circle fill="url(#metal)" cx="39" cy="40" r="35"></circle>
<circle fill="url(#metal)" cx="39.5" cy="39.5" r="29.5" transform="rotate(180 39.5 39.5)"></circle>
<circle fill="url(#metal)" cx="39" cy="40" r="27"></circle>
@ -172,27 +232,10 @@ export const Controls =()=>
</radialGradient>
</defs>
</svg>
<div class="box-buttons flex-1">
<div class="flex-1">
<${Button}
classes="w-full flex-1 self-center"
onClick=${()=>playSet(1)}
disabled=${playGet==1}
icon=${html`<svg class="w-3 h-3 mx-1" viewBox="0 0 20 20">
<polygon points="0,0 20,10 0,20" fill="#ffffff" stroke="none"></polygon>
</svg>`}
>
<span class="py-2">Present Tone</span>
<//>
<div class="flex gap-1 mt-2">
<${Button} onClick=${()=>{pulsedSet(true )}} light=${pulsedGet } inactive${pulsedGet } classes="flex-1 text(center xs)">Pulsed <//>
<${Button} onClick=${()=>{pulsedSet(false)}} light=${!pulsedGet} inactive${!pulsedGet} classes="flex-1 text(center xs)">Continuous<//>
</div>
</div>
</div>
</div>
<div class="box-notch">
<div class=${classTitle}>Threshold</div>
<div class="flex-col bg-metal rounded-lg overflow-hidden shadow-md">
<div class="p-4">
<div class="box-buttons flex-col gap-2 min-w-[50%]">
<${Button}
onClick=${()=>Dispatch({Name:"Mark", Data:true })}
@ -231,6 +274,7 @@ export const Controls =()=>
</div>
</div>
</div>
</div>
`;
};
@ -274,6 +318,7 @@ export const Audiogram =()=>
}`;
};
/** @type {BasicElement} */
export function Chart({children})
{
@ -299,8 +344,8 @@ export function Chart({children})
);
}
return html`
<div class="relative w-full h-[800px] font(sans medium) text(xs)">
<div class="absolute right-0 bottom-0 w-[calc(100%-60px)] h-[calc(100%-50px)] border(1 zinc-300)">
<div class="relative w-full pb-[calc(55%+70px)] font(sans medium) text(xs) self-start">
<div class="absolute right-0 bottom-0 w-[calc(100%-60px)] h-[calc(100%-70px)] border(1 zinc-300)">
<span class="block absolute top-[-65px] left-0 w-full text(sm center) font-black">Frequency in Hz</span>
<span class="inline-block absolute top-[50%] left-[-50px] ">
<span class="inline-block -rotate-90 origin-top -translate-x-1/2 text(sm center) font-black">
@ -308,7 +353,7 @@ export function Chart({children})
</span>
</span>
<div class=${`relative top-[${inset}px] left-[${inset}px] w-[calc(100%-${inset*2}px)] h-[calc(100%-${inset*2}px)]`}>
<span class="block absolute top-0 left-[-${inset}px] w-[calc(100%+${inset*2}px)] h-[27%] bg-black opacity-10"></span>
<span class="block absolute top-0 left-[-${inset}px] w-[calc(100%+${inset*2}px)] h-[27%] bg-black opacity-5"></span>
${ rules }
<div class="absolute top-0 left-0 w-full h-full">
${ children }

View File

@ -12,7 +12,11 @@ declare namespace Store {
UserR?: TestFrequencySample;
};
type Test = { Name: string; Plot: Array<TestFrequency> };
type Test = {
Name : string;
Done?: Grade;
Plot : Array<TestFrequency>
};
type Context = {
Test?: Test;
@ -20,25 +24,38 @@ declare namespace Store {
Mark?: TestFrequencySample;
};
type State = {
type StatePartSimple =
{
Chan: Range;
Freq: Range;
Stim: Range;
Errs: number;
Pick: number;
Show:
{
Cursor:boolean,
Answer:boolean
}
};
type StatePartComplex =
{
Live: Context;
Draw: DrawChart;
Show: {Cursor:boolean, Answer:boolean}
TestIndex: number;
Test: Array<Test>;
};
type State = StatePartSimple & StatePartComplex;
type ActionMark = { Name: "Mark"; Data: boolean | null };
type ActionTest = { Name: "Test"; Data: number };
type ActionChan = { Name: "Chan"; Data: number };
type ActionFreq = { Name: "Freq"; Data: number };
type ActionStim = { Name: "Stim"; Data: number };
type ActionErrs = { Name: "Errs"; Data: number };
type ActionKill = { Name: "Kill"; Data: number };
type ActionShowCursor = {Name: "ShowCursor", Data:boolean};
type ActionShowAnswer = {Name: "ShowAnswer", Data:boolean};
type Action = ActionMark | ActionTest | ActionChan | ActionFreq | ActionStim | ActionShowCursor | ActionShowAnswer;
type Action = ActionMark | ActionTest | ActionChan | ActionFreq | ActionStim | ActionErrs | ActionKill | ActionShowCursor | ActionShowAnswer;
type Reducer = (inState: State, inAction: Action) => State;
type ContextUpdater = (inState: State) => boolean;
@ -55,7 +72,7 @@ declare namespace Store {
type Grade = {
Total:number,
Done:number,
Marks:number,
Score:number
};
}

View File

@ -1,5 +1,5 @@
import { assertEquals } from "https://deno.land/std@0.166.0/testing/asserts.ts";
import { Reducer, ColumnMapping, Initial } from "./src/store.js";
import { Reducer, ColumnMapping, Initial } from "../js/store.js";
let state:Store.State = {
Chan: { Min:0, Max:1, Value:0, Step:1 },