77059bba9d223ccb88c88bb20da3fe29d3173af8
[vchess.git] / client / src / App.vue
1 <template lang="pug">
2 #app
3 Settings
4 ContactForm
5 UpsertUser
6 .container
7 .row
8 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
9 // Menu (top of page):
10 // Left: hall, variants, problems, mygames
11 // Right: usermenu, settings
12 nav
13 label.drawer-toggle(for="drawerControl")
14 input#drawerControl.drawer(type="checkbox")
15 #menuBar(@click="hideDrawer($event)")
16 label.drawer-close(for="drawerControl")
17 #leftMenu
18 router-link(to="/")
19 | {{ st.tr["Hall"] }}
20 router-link(to="/mygames")
21 | {{ st.tr["My games"] }}
22 router-link(to="/variants")
23 | {{ st.tr["Variants"] }}
24 router-link(to="/problems")
25 | {{ st.tr["Problems"] }}
26 #rightMenu
27 .clickable(onClick="window.doClick('modalUser')")
28 | {{ st.user.id > 0 ? (st.user.name || "@nonymous") : "Login" }}
29 #divSettings.clickable(onClick="window.doClick('modalSettings')")
30 span {{ st.tr["Settings"] }}
31 img(src="/images/icons/settings.svg")
32 router-view
33 .row
34 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
35 footer
36 router-link.menuitem(to="/about") {{ st.tr["About"] }}
37 router-link.menuitem#newsMenu(to="/news") {{ st.tr["News"] }}
38 a.menuitem(href="https://discord.gg/a9ZFKBe")
39 span Discord
40 img(src="/images/icons/discord.svg")
41 a.menuitem(href="https://github.com/yagu0/vchess")
42 span {{ st.tr["Code"] }}
43 img(src="/images/icons/github.svg")
44 p.clickable(onClick="window.doClick('modalContact')")
45 | {{ st.tr["Contact"] }}
46 </template>
47
48 <script>
49 import ContactForm from "@/components/ContactForm.vue";
50 import Settings from "@/components/Settings.vue";
51 import UpsertUser from "@/components/UpsertUser.vue";
52 import { store } from "@/store.js";
53 import { ajax } from "@/utils/ajax.js";
54 export default {
55 components: {
56 ContactForm,
57 Settings,
58 UpsertUser
59 },
60 data: function() {
61 return { st: store.state };
62 },
63 mounted: function() {
64 ajax(
65 "/newsts",
66 "GET",
67 {
68 success: (res) => {
69 if (this.st.user.newsRead < res.timestamp)
70 document.getElementById("newsMenu").classList.add("somenews");
71 }
72 }
73 );
74 },
75 methods: {
76 hideDrawer: function(e) {
77 e.preventDefault(); //TODO: why is this needed?
78 document.getElementsByClassName("drawer")[0].checked = false;
79 }
80 }
81 };
82 </script>
83
84 <style lang="sass">
85 html, *
86 font-family: "Open Sans", Arial, sans-serif
87 --a-link-color: darkred
88 --a-visited-color: darkred
89
90 body
91 padding: 0
92 min-width: 320px
93 --fore-color: #1c1e10 //#2c3e50
94 //--back-color: #f2f2f2
95 background-image: radial-gradient(white, #e6e6ff) //lavender)
96
97 #app
98 -webkit-font-smoothing: antialiased
99 -moz-osx-font-smoothing: grayscale
100
101 .container
102 // 45px is footer height
103 min-height: calc(100vh - 45px)
104 overflow: hidden
105 padding: 0
106 margin: 0
107
108 .row > div
109 padding: 0
110
111 header
112 width: 100%
113 display: flex
114 align-items: center
115 justify-content: center
116 margin: 0 auto
117
118 .clickable
119 cursor: pointer
120
121 .text-center
122 text-align: center
123
124 .bold
125 font-weight: bold
126
127 .clearer
128 clear: both
129
130 .button-group
131 margin: 0
132
133 input[type="checkbox"]:focus
134 outline: 0
135
136 input[type=checkbox]:checked:before
137 top: -5px;
138 height: 18px
139
140 table
141 display: block
142 padding: 0
143 tr > td
144 cursor: pointer
145 th, td
146 padding: 5px
147
148 #divSettings
149 padding: 0 10px 0 0
150 height: 100%
151 & > span
152 padding-right: 5px
153 vertical-align: middle
154 & > img
155 padding: 0
156 height: 1.2em
157 vertical-align: middle
158
159 @media screen and (max-width: 767px)
160 table
161 tr > th, td
162 font-size: 14px
163
164 nav
165 width: 100%
166 margin: 0
167 padding: 0
168 & > #menuBar
169 width: 100%
170 padding: 0
171 @media screen and (min-width: 768px)
172 & > #leftMenu
173 padding: 0
174 width: 50%
175 display: inline-flex
176 align-items: center
177 justify-content: flex-start
178 & > a
179 display: inline-block
180 color: #2c3e50
181 &.router-link-exact-active
182 color: #42b983
183 & > #rightMenu
184 padding: 0
185 width: 50%
186 display: inline-flex
187 align-items: center
188 justify-content: flex-end
189 & > div
190 display: inline-block
191 @media screen and (max-width: 767px)
192 & > #leftMenu
193 margin-top: 42px
194 padding-bottom: 5px
195 & > a
196 color: #2c3e50
197 &.router-link-exact-active
198 color: #42b983
199 & > #rightMenu
200 padding-top: 5px
201 border-top: 1px solid darkgrey
202
203 @media screen and (max-width: 767px)
204 nav
205 height: 42px
206 border: none
207 & > label.drawer-toggle
208 cursor: pointer
209 position: absolute
210 top: 0
211 left: 5px
212 line-height: 42px
213 height: 42px
214 padding: 0
215 & > label.drawer-toggle:before
216 font-size: 42px
217 & > #menuBar
218 z-index: 5000 //to hide currently selected piece if any
219
220 [type="checkbox"].drawer+*
221 right: -767px
222
223 [type=checkbox].drawer+* .drawer-close
224 top: 0
225 left: 5px
226 padding: 0
227 height: 50px
228 width: 50px
229 line-height: 50px
230
231 [type=checkbox].drawer+* .drawer-close:before
232 font-size: 50px
233
234 @media screen and (max-width: 767px)
235 .button-group
236 flex-direction: row
237 button:not(:first-child)
238 border-left: 1px solid var(--button-group-border-color)
239 border-top: 0
240
241 footer
242 height: 45px
243 border: 1px solid #ddd
244 box-sizing: border-box
245 //background-color: #000033
246 font-size: 1rem
247 width: 100%
248 padding: 0
249 display: inline-flex
250 align-items: center
251 justify-content: center
252 & > .router-link-exact-active
253 color: #42b983 !important
254 text-decoration: none
255 & > .menuitem
256 margin: 0 12px
257 display: inline-flex;
258 align-self: center;
259 &:link
260 color: #2c3e50
261 &:visited, &:hover
262 color: #2c3e50
263 text-decoration: none
264 & > img
265 height: 1.2em
266 display: inline-block
267 margin-left: 5px
268 & > p
269 display: inline-block
270 margin: 0 12px
271
272 @media screen and (max-width: 767px)
273 footer
274 border: none
275
276 @media screen and (max-width: 420px)
277 .container
278 min-height: calc(100vh - 55px)
279 footer
280 height: 55px
281 display: block
282 padding: 5px 0
283
284 .menuitem.somenews
285 color: red
286 &:link, &:visited, &:hover
287 color: red
288
289 // Styles for diagrams and board (partial).
290 // TODO: where to put that ?
291
292 .light-square-diag
293 background-color: #e5e5ca
294
295 .dark-square-diag
296 background-color: #6f8f57
297
298 div.board
299 float: left
300 height: 0
301 display: inline-block
302 position: relative
303
304 div.board8
305 width: 12.5%
306 padding-bottom: 12.5%
307
308 div.board9
309 width: 11.1%
310 padding-bottom: 11.1%
311
312 div.board10
313 width: 10%
314 padding-bottom: 10%
315
316 div.board11
317 width: 9.09%
318 padding-bottom: 9.1%
319
320 img.piece
321 width: 100%
322
323 img.piece, img.mark-square
324 max-width: 100%
325 height: auto
326 display: block
327
328 img.mark-square
329 opacity: 0.6
330 width: 76%
331 position: absolute
332 top: 12%
333 left: 12%
334 opacity: .7
335
336 .in-shadow
337 filter: brightness(50%)
338 </style>