generated from Nigh/svelte-static-pwa-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from szres/add-glyph-draw-guess
add glyph draw guess
- Loading branch information
Showing
5 changed files
with
728 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script> | ||
import Glyph from './Glyph.svelte'; | ||
let guess = { points: '', name: '-', score: 0 }; | ||
</script> | ||
|
||
<div class="flex justify-center pb-2"> | ||
<div class="flex flex-col"> | ||
<Glyph glyph={guess.points} /> | ||
<span class="text-center">{guess.name}</span> | ||
</div> | ||
</div> | ||
<div class="flex justify-center"> | ||
<Glyph | ||
width="500" | ||
height="500" | ||
drawable="true" | ||
on:newGuess={(e) => (guess = e.detail.guess)} | ||
on:newResult | ||
/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,42 @@ | ||
<script> | ||
import Glyph from './Glyph.svelte'; | ||
import GlyphDraw from './GlyphDraw.svelte'; | ||
let predictionDepth = 5; | ||
let predictions = [ | ||
{ name: '', points: '' }, | ||
{ name: '', points: '' }, | ||
{ name: '', points: '' }, | ||
{ name: '', points: '' }, | ||
{ name: '', points: '' } | ||
]; | ||
const newPrediction = () => { | ||
predictions = []; | ||
for (let index = 0; index < predictionDepth; index++) { | ||
predictions = [...predictions, { name: '', points: '' }]; | ||
} | ||
}; | ||
const writePrediction = (c) => { | ||
for (let index = 0; index < predictionDepth; index++) { | ||
if (predictions[index].name === '') { | ||
predictions[index] = c; | ||
predictions = predictions; | ||
return; | ||
} | ||
} | ||
newPrediction(); | ||
writePrediction(c); | ||
}; | ||
const onNewResult = (e) => { | ||
let result = e.detail.result; | ||
writePrediction(result); | ||
}; | ||
</script> | ||
|
||
<div class="grid grid-flow-row gap-4 h-max m-4 justify-center content-center"> | ||
<ul class="steps"> | ||
<li data-content="?" class="step step-neutral"><Glyph glyph="bhcjd" />DEFEND</li> | ||
<li data-content="?" class="step step-neutral"><Glyph glyph="trjch-" />HUMAN</li> | ||
<li data-content="?" class="step step-neutral"><Glyph glyph="bthjrd" />CIVILIZATION</li> | ||
<li data-content="?" class="step step-neutral"><Glyph glyph="lhtmrjk" />SHAPERS</li> | ||
<li data-content="?" class="step step-neutral"><Glyph glyph="htajra" />LIE</li> | ||
</ul> | ||
<div> | ||
<Glyph width="500" height="500" drawable="true" /> | ||
<div class="flex flex-col h-max m-4"> | ||
<div class="flex justify-center mb-4"> | ||
{#each predictions as prediction} | ||
<Glyph glyph={prediction.points} /> | ||
{/each} | ||
</div> | ||
<GlyphDraw on:newResult={onNewResult} /> | ||
</div> |
Oops, something went wrong.