Will remove Welcome div, finally
[vchess.git] / client / src / components / Settings.vue
1 <template lang="pug">
2 div
3 input#modalSettings.modal(type="checkbox")
4 div(role="dialog" data-checkbox="modalSettings")
5 .card(@change="updateSettings($event)")
6 label.modal-close(for="modalSettings")
7 h3.section {{ st.tr["Settings"] }}
8 form
9 fieldset
10 label(for="setHints") {{ st.tr["Show possible moves?"] }}
11 input#setHints(type="checkbox" v-model="st.settings.hints")
12 fieldset
13 label(for="setHighlight")
14 | {{ st.tr["Highlight last move and checks?"] }}
15 input#setHighlight(type="checkbox" v-model="st.settings.highlight")
16 fieldset
17 label(for="setBcolor") {{ st.tr["Board colors"] }}
18 select#setBcolor(v-model="st.settings.bcolor")
19 option(value="lichess") {{ st.tr["brown"] }}
20 option(value="chesscom") {{ st.tr["green"] }}
21 option(value="chesstempo") {{ st.tr["blue"] }}
22 fieldset
23 label(for="setSound") {{ st.tr["Play sounds?"] }}
24 select#setSound(v-model="st.settings.sound")
25 option(value="0") {{ st.tr["None"] }}
26 option(value="1") {{ st.tr["New game"] }}
27 option(value="2") {{ st.tr["All"] }}
28 </template>
29
30 <script>
31 import { store } from "@/store.js";
32 export default {
33 name: "my-settings",
34 data: function() {
35 return {
36 st: store.state,
37 };
38 },
39 methods: {
40 updateSettings: function(event) {
41 const propName =
42 event.target.id.substr(3).replace(/^\w/, c => c.toLowerCase())
43 let value = (["bcolor","sound"].includes(propName)
44 ? event.target.value
45 : event.target.checked);
46 if (propName == "sound")
47 value = parseInt(value);
48 store.updateSetting(propName, value);
49 },
50 },
51 };
52 </script>
53
54 <style lang="sass" scoped>
55 [type="checkbox"].modal+div .card
56 max-width: 767px
57 max-height: 100%
58 </style>