Add alert bar

This commit is contained in:
Oliver-Akins 2020-09-27 21:53:43 -06:00
parent 04a5e58e78
commit cd14c0e681
2 changed files with 55 additions and 1 deletions

View file

@ -1,5 +1,14 @@
<template> <template>
<div id="app"> <div id="app">
<transition mode="out-in" name="top-slide">
<div
v-if="alert.message"
class="alert-bar"
:class="alert.classes"
>
<div>{{ alert.message }}</div>
</div>
</transition>
<WS-Test <WS-Test
v-if="state == 'ws-test'" v-if="state == 'ws-test'"
/> />
@ -54,16 +63,41 @@ export default {
get a "Start Game" button that allows them to, well... start get a "Start Game" button that allows them to, well... start
the game. the game.
*/ */
state: `ws-test`, state: `game-type`,
game_code: ``, game_code: ``,
is_host: false, is_host: false,
alert: {
message: ``,
classes: []
},
}}, }},
methods: {}, methods: {},
sockets: {
disconnect() {
this.alert = {
message: `Disconnected from the server. Attempting to reconnect.`,
classes: [`error`]
};
},
connect_error() {
this.alert = {
message: `Error: Failed to connect to the server.`,
classes: [`error`]
}
},
connect() {
this.alert = {
message: ``,
classes: []
}
}
}
} }
</script> </script>
<style lang="stylus"> <style lang="stylus">
@import "theme.styl" @import "theme.styl"
@import "./css/animations.css"
html, body, #app { html, body, #app {
font-family: $fonts font-family: $fonts
@ -75,10 +109,26 @@ html, body, #app {
#app { #app {
background-color: $main-background-colour background-color: $main-background-colour
color: $main-text-colour
height: 100vh height: 100vh
width: 100vw width: 100vw
} }
.alert-bar {
justify-content: center
position: absolute
display: flex
width: 100vw
z-index: 1
left: 0
top: 0
}
.alert-bar.error {
background-color: $error-background-colour
color: $error-text-colour
}
.input { .input {
background-color: $input-background background-color: $input-background
border-radius: $input-border-radius border-radius: $input-border-radius

View file

@ -12,6 +12,10 @@ $main-background-colour = #23272A
$main-text-colour = #99AAB5 $main-text-colour = #99AAB5
$error-background-colour = #FF0000
$error-text-colour = white
/***********************************************************/ /***********************************************************/
/* Styling for inputs (not all input types use all values) */ /* Styling for inputs (not all input types use all values) */