<(../common.inc.plp)><:
+our $wordlistbase;
+
Html({
raw => <<'EOT',
<script src="/word/put.min.js"></script>
+<script src="/word/quiz.js"></script>
<script src="/word/memory.js"></script>
<style>
/* cards */
+#quiz {
+ display: grid;
+ grid: repeat(3, 1fr) / repeat(4, 1fr);
+ grid-gap: 1ex;
+ min-height: calc(100vh - 11.5ex);
+}
+@media (orientation: portrait) {
+ #quiz {
+ grid: repeat(6, 1fr) / repeat(2, 1fr);
+ }
+}
html {
overflow: hidden; /* rotation overflow on celebration */
}
display: inline-block;
background: #224;
border: 1px solid #888;
- margin: 2px;
perspective: 100em;
- height: 300px;
position: relative;
}
figure:not(.turn):hover {
/* card faces */
figure img {
- height: 100%;
- width: auto;
backface-visibility: hidden;
transform: rotateY(180deg); /* back */
transform-style: preserve-3d;
- float: left; /* ff workaround to prevent click selection */
+ -float: left; /* ff workaround to prevent click selection */
+}
+figure.mirror img {
+ transform: rotateY(180deg) scaleX(-1);
}
/* turn results */
figure.turn img {
transform: rotateY(0deg);
}
+figure.mirror.turn img {
+ transform: rotateY(0deg) scaleX(-1);
+}
figure.bad img {
filter: sepia(.5) hue-rotate(-45deg) saturate(2); /* red tint */
}
}
.good figure {
- animation: celebration 5s linear infinite;
+ animation: celebration 7s linear infinite;
background: none;
border: 0;
+ opacity: 1;
}
@keyframes celebration {
0% { filter: hue-rotate(0deg); transform: rotate(0deg) }
- 50% { filter: hue-rotate(180deg); transform: rotate(180deg) }
+ 33% { filter: hue-rotate(180deg); transform: rotate(180deg) }
+ 66% { filter: hue-rotate(360deg); transform: rotate(360deg) }
100% { filter: hue-rotate(360deg); transform: rotate(360deg) }
}
</style>
EOT
});
+if (my $gridsize = $get{grid}) {
+ printf "<style>#quiz {grid: repeat(%d, 1fr) / repeat(%d, 1fr)}</style>",
+ reverse split /\D+/, $gridsize;
+ say '';
+}
say '<h1>memory</h1><p id="quiz"></p>';
+say "<script>new WordMemory('/$wordlistbase.json')</script>";