thelounge/client/components/App.vue

127 lines
3.4 KiB
Vue
Raw Normal View History

<template>
2019-07-17 09:33:59 +00:00
<div id="viewport" role="tablist">
<aside id="sidebar">
<div class="scrollable-area">
<div class="logo-container">
<img
:src="`img/logo-${isPublic() ? 'horizontal-' : ''}transparent-bg.svg`"
class="logo"
alt="The Lounge"
2019-07-17 09:33:59 +00:00
/>
<img
2019-07-17 09:33:59 +00:00
:src="
`img/logo-${isPublic() ? 'horizontal-' : ''}transparent-bg-inverted.svg`
"
class="logo-inverted"
alt="The Lounge"
2019-07-17 09:33:59 +00:00
/>
</div>
2019-07-17 09:33:59 +00:00
<NetworkList :networks="networks" :active-channel="activeChannel" />
</div>
<footer id="footer">
2019-02-20 09:10:18 +00:00
<span
class="tooltipped tooltipped-n tooltipped-no-touch"
aria-label="Sign in"><button
2019-07-17 09:33:59 +00:00
class="icon sign-in"
2019-02-20 09:10:18 +00:00
data-target="SignIn"
2019-07-17 09:33:59 +00:00
aria-label="Sign in"
role="tab"
aria-controls="sign-in"
2019-02-20 09:10:18 +00:00
aria-selected="false" /></span>
<span
class="tooltipped tooltipped-n tooltipped-no-touch"
2019-02-20 09:10:18 +00:00
aria-label="Connect to network"><button
2019-07-17 09:33:59 +00:00
class="icon connect"
2019-02-20 09:10:18 +00:00
data-target="Connect"
2019-07-17 09:33:59 +00:00
aria-label="Connect to network"
role="tab"
aria-controls="connect"
2019-02-20 09:10:18 +00:00
aria-selected="false" /></span>
<span
class="tooltipped tooltipped-n tooltipped-no-touch"
aria-label="Settings"><button
2019-07-17 09:33:59 +00:00
class="icon settings"
2019-02-20 09:10:18 +00:00
data-target="Settings"
2019-07-17 09:33:59 +00:00
aria-label="Settings"
role="tab"
aria-controls="settings"
2019-02-20 09:10:18 +00:00
aria-selected="false" /></span>
<span
class="tooltipped tooltipped-n tooltipped-no-touch"
aria-label="Help"><button
2019-07-17 09:33:59 +00:00
class="icon help"
2019-02-20 09:10:18 +00:00
data-target="Help"
2019-07-17 09:33:59 +00:00
aria-label="Help"
role="tab"
aria-controls="help"
2019-02-20 09:10:18 +00:00
aria-selected="false" /></span>
</footer>
</aside>
2018-07-29 17:57:14 +00:00
<div id="sidebar-overlay" />
<article id="windows">
2018-07-08 13:42:54 +00:00
<Chat
v-if="activeChannel"
:network="activeChannel.network"
2019-02-18 09:18:32 +00:00
:channel="activeChannel.channel" />
<component
:is="activeWindow"
ref="window" />
</article>
</div>
</template>
<script>
const throttle = require("lodash/throttle");
import NetworkList from "./NetworkList.vue";
import Chat from "./Chat.vue";
2019-02-18 09:18:32 +00:00
import SignIn from "./Windows/SignIn.vue";
2019-02-20 09:10:18 +00:00
import Settings from "./Windows/Settings.vue";
export default {
name: "App",
components: {
NetworkList,
Chat,
2019-02-18 09:18:32 +00:00
SignIn,
2019-02-20 09:10:18 +00:00
Settings,
},
props: {
2019-02-18 09:18:32 +00:00
activeWindow: String,
activeChannel: Object,
networks: Array,
},
mounted() {
// Make a single throttled resize listener available to all components
this.debouncedResize = throttle(() => {
this.$root.$emit("resize");
}, 100);
window.addEventListener("resize", this.debouncedResize, {passive: true});
// Emit a daychange event every time the day changes so date markers know when to update themselves
const emitDayChange = () => {
this.$root.$emit("daychange");
// This should always be 24h later but re-computing exact value just in case
this.dayChangeTimeout = setTimeout(emitDayChange, this.msUntilNextDay());
};
this.dayChangeTimeout = setTimeout(emitDayChange, this.msUntilNextDay());
},
beforeDestroy() {
window.removeEventListener("resize", this.debouncedResize);
clearTimeout(this.dayChangeTimeout);
},
methods: {
isPublic: () => document.body.classList.contains("public"),
msUntilNextDay() {
// Compute how many milliseconds are remaining until the next day starts
const today = new Date();
const tommorow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1);
return tommorow - today;
},
},
};
</script>