storm: add reload/end buttons

pull/7944/head
Thibault Duplessis 2021-01-27 10:26:58 +01:00
parent 57d9657f72
commit e17ad7c8ff
4 changed files with 45 additions and 4 deletions

View File

@ -2,6 +2,7 @@
&__clock {
@extend %flex-center-nowrap;
margin-bottom: -1em;
font-family: 'storm';
&__time {

View File

@ -2,8 +2,6 @@
&__combo {
display: flex;
flex-flow: row nowrap;
align-items: flex-end;
flex: 0 0 25%;
&__counter {
display: flex;

View File

@ -25,6 +25,25 @@
}
}
&__table {
@extend %flex-column;
flex: 0 0 25%;
justify-content: flex-end;
}
&__control {
@extend %flex-center;
justify-content: flex-end;
height: 2.5em;
margin-bottom: .2em;
.button {
color: $c-font-dim;
padding: .5em 1.5em;
}
}
&__start {
color: $c-brag;
margin: auto;

View File

@ -3,7 +3,7 @@ import config from '../config';
import renderClock from './clock';
import renderEnd from "./end";
import StormCtrl from '../ctrl';
import { getNow } from '../util';
import { getNow, onInsert } from '../util';
import { h } from 'snabbdom'
import { VNode } from 'snabbdom/vnode';
@ -36,10 +36,33 @@ const renderPlay = (ctrl: StormCtrl): VNode[] => [
h('div.storm__side', [
ctrl.vm.run.startAt ? renderSolved(ctrl) : renderStart(ctrl),
renderClock(ctrl),
renderCombo(ctrl)
h('div.storm__table', [
renderControls(ctrl),
renderCombo(ctrl)
])
])
];
const renderControls = (ctrl: StormCtrl): VNode =>
h('div.storm__control', [
h('a.storm__control__reload.button.button-empty', {
attrs: {
href: '/storm',
'data-icon': 'B',
title: 'New run'
}
}),
h('a.storm__control__end.button.button-empty', {
attrs: {
'data-icon': 'b',
title: 'End run',
},
hook: onInsert(el => el.addEventListener('click', () => {
if (ctrl.vm.puzzleStartAt) ctrl.end()
}))
})
]);
const renderCombo = (ctrl: StormCtrl): VNode => {
const level = ctrl.comboLevel();
return h('div.storm__combo', [