2020-12-16 16:54:41 +00:00
|
|
|
<!--
|
2021-07-25 14:12:40 +00:00
|
|
|
- Copyright 2021 James Lyne
|
2020-12-16 16:54:41 +00:00
|
|
|
-
|
2021-07-25 14:12:40 +00:00
|
|
|
- Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
- you may not use this file except in compliance with the License.
|
|
|
|
- You may obtain a copy of the License at
|
2020-12-16 16:54:41 +00:00
|
|
|
-
|
2021-07-25 14:12:40 +00:00
|
|
|
- http://www.apache.org/licenses/LICENSE-2.0
|
2020-12-16 16:54:41 +00:00
|
|
|
-
|
2021-07-25 14:12:40 +00:00
|
|
|
- Unless required by applicable law or agreed to in writing, software
|
|
|
|
- distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
- See the License for the specific language governing permissions and
|
|
|
|
- limitations under the License.
|
2020-12-16 16:54:41 +00:00
|
|
|
-->
|
|
|
|
|
2020-11-20 21:44:02 +00:00
|
|
|
<template>
|
2021-05-28 23:08:43 +00:00
|
|
|
<section class="sidebar" role="none" ref="sidebar">
|
2020-12-01 23:20:38 +00:00
|
|
|
<header class="sidebar__buttons">
|
2021-07-27 01:36:24 +00:00
|
|
|
<button v-if="mapCount > 1 || serverCount > 1" :class="{'button--maps': true}" @click="toggleMaps"
|
|
|
|
:title="messageWorlds" :aria-label="messageWorlds" :aria-expanded="mapsVisible"
|
|
|
|
@keydown="handleMapsKeydown">
|
2020-12-12 21:36:41 +00:00
|
|
|
<SvgIcon name="maps"></SvgIcon>
|
|
|
|
</button>
|
2021-06-23 17:18:42 +00:00
|
|
|
<button v-if="playerMakersEnabled" :class="{'button--players': true}" @click="togglePlayers"
|
2021-07-22 19:47:37 +00:00
|
|
|
:title="messagePlayers" :aria-label="messagePlayers" :aria-expanded="playersVisible"
|
2021-06-23 17:18:42 +00:00
|
|
|
@keydown="handlePlayersKeydown">
|
2020-12-12 21:36:41 +00:00
|
|
|
<SvgIcon name="players"></SvgIcon>
|
|
|
|
</button>
|
2020-12-01 23:20:38 +00:00
|
|
|
</header>
|
2021-05-26 23:00:41 +00:00
|
|
|
<div class="sidebar__content" @keydown="handleSidebarKeydown">
|
2021-05-28 23:08:43 +00:00
|
|
|
<ServerList v-if="serverCount > 1" v-show="mapsVisible"></ServerList>
|
|
|
|
<WorldList v-if="mapCount > 1" v-show="mapsVisible"></WorldList>
|
2021-06-23 17:18:42 +00:00
|
|
|
<PlayerList id="players" v-if="playerMakersEnabled && previouslyVisible.has('players')"
|
|
|
|
v-show="playersVisible"></PlayerList>
|
2021-05-28 23:08:43 +00:00
|
|
|
<FollowTarget v-if="following" v-show="followVisible" :target="following"></FollowTarget>
|
2021-05-25 18:26:51 +00:00
|
|
|
</div>
|
2021-05-26 19:09:00 +00:00
|
|
|
</section>
|
2020-11-20 21:44:02 +00:00
|
|
|
</template>
|
|
|
|
|
2020-11-23 12:13:28 +00:00
|
|
|
<script lang="ts">
|
2021-05-26 23:00:41 +00:00
|
|
|
import {computed, defineComponent} from "@vue/runtime-core";
|
2020-12-01 23:20:38 +00:00
|
|
|
import PlayerList from './sidebar/PlayerList.vue';
|
|
|
|
import WorldList from './sidebar/WorldList.vue';
|
2021-05-17 13:17:52 +00:00
|
|
|
import ServerList from "@/components/sidebar/ServerList.vue";
|
2020-12-01 23:20:38 +00:00
|
|
|
import FollowTarget from './sidebar/FollowTarget.vue';
|
|
|
|
import {useStore} from "@/store";
|
2020-12-12 21:36:41 +00:00
|
|
|
import SvgIcon from "@/components/SvgIcon.vue";
|
2020-12-31 13:02:49 +00:00
|
|
|
import {MutationTypes} from "@/store/mutation-types";
|
2021-05-15 19:25:03 +00:00
|
|
|
import "@/assets/icons/players.svg";
|
|
|
|
import "@/assets/icons/maps.svg";
|
2021-05-28 23:08:43 +00:00
|
|
|
import {nextTick, ref, watch} from "vue";
|
2021-05-28 21:31:08 +00:00
|
|
|
import {handleKeyboardEvent} from "@/util/events";
|
2021-05-28 23:08:43 +00:00
|
|
|
import {focus} from "@/util";
|
2020-12-01 23:20:38 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2021-05-17 13:17:52 +00:00
|
|
|
ServerList,
|
2020-12-12 21:36:41 +00:00
|
|
|
SvgIcon,
|
2020-12-01 23:20:38 +00:00
|
|
|
PlayerList,
|
|
|
|
FollowTarget,
|
|
|
|
WorldList,
|
|
|
|
},
|
|
|
|
|
|
|
|
setup() {
|
2020-12-20 15:29:40 +00:00
|
|
|
const store = useStore(),
|
2021-05-28 23:08:43 +00:00
|
|
|
sidebar = ref<HTMLElement | null>(null),
|
|
|
|
|
2021-01-26 18:20:47 +00:00
|
|
|
currentlyVisible = computed(() => store.state.ui.visibleElements),
|
|
|
|
previouslyVisible = computed(() => store.state.ui.previouslyVisibleElements),
|
2020-12-31 13:02:49 +00:00
|
|
|
smallScreen = computed(() => store.state.ui.smallScreen),
|
|
|
|
mapCount = computed(() => store.state.maps.size),
|
2021-05-17 13:17:52 +00:00
|
|
|
serverCount = computed(() => store.state.servers.size),
|
2020-12-31 13:02:49 +00:00
|
|
|
following = computed(() => store.state.followTarget),
|
2020-12-20 15:29:40 +00:00
|
|
|
|
2021-05-20 15:39:41 +00:00
|
|
|
messageWorlds = computed(() => store.state.messages.worldsHeading),
|
2021-07-29 18:16:37 +00:00
|
|
|
messagePlayers = computed(() => store.getters.playersHeading),
|
2021-05-20 15:39:41 +00:00
|
|
|
|
2021-06-23 17:18:42 +00:00
|
|
|
playerMakersEnabled = computed(() => !!store.state.components.playerMarkers),
|
|
|
|
|
2021-05-28 23:08:43 +00:00
|
|
|
playersVisible = computed(() => currentlyVisible.value.has('players')),
|
|
|
|
mapsVisible = computed(() => currentlyVisible.value.has('maps')),
|
|
|
|
followVisible = computed(() => {
|
2020-12-20 18:52:38 +00:00
|
|
|
//Show following alongside playerlist on small screens
|
2021-05-26 17:49:34 +00:00
|
|
|
return (!smallScreen.value && following.value)
|
2021-05-28 23:08:43 +00:00
|
|
|
|| (smallScreen.value && playersVisible.value);
|
2020-12-20 18:52:38 +00:00
|
|
|
});
|
2020-12-20 15:29:40 +00:00
|
|
|
|
2021-05-28 23:08:43 +00:00
|
|
|
//Arrow key section navigation
|
|
|
|
const handleSidebarKeydown = (e: KeyboardEvent) => {
|
|
|
|
if(!e.target || !(e.target as HTMLElement).matches('.section__heading button')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const sectionHeadings: HTMLElement[] = Array.from(sidebar.value!.querySelectorAll('.section__heading button'));
|
|
|
|
handleKeyboardEvent(e, sectionHeadings);
|
|
|
|
};
|
|
|
|
|
2021-05-28 23:22:31 +00:00
|
|
|
//Show sectinos on ArrowDown from button
|
|
|
|
const handleMapsKeydown = (e: KeyboardEvent) => {
|
|
|
|
if(e.key === 'ArrowDown') {
|
|
|
|
store.commit(MutationTypes.SET_UI_ELEMENT_VISIBILITY, {element: 'maps', state: true});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const handlePlayersKeydown = (e: KeyboardEvent) => {
|
|
|
|
if(e.key === 'ArrowDown') {
|
|
|
|
store.commit(MutationTypes.SET_UI_ELEMENT_VISIBILITY, {element: 'players', state: true});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-28 23:08:43 +00:00
|
|
|
const togglePlayers = () => store.commit(MutationTypes.TOGGLE_UI_ELEMENT_VISIBILITY, 'players');
|
|
|
|
const toggleMaps = () => store.commit(MutationTypes.TOGGLE_UI_ELEMENT_VISIBILITY, 'maps');
|
|
|
|
|
|
|
|
//Move focus when sidebar sections become visible
|
|
|
|
const focusMaps = () => focus('.section__heading button');
|
|
|
|
const focusPlayers = () => focus('#players-heading');
|
|
|
|
|
|
|
|
watch(playersVisible, newValue => newValue && nextTick(() => focusPlayers()));
|
|
|
|
watch(mapsVisible, newValue => newValue && nextTick(() => focusMaps()));
|
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
return {
|
2021-05-28 23:08:43 +00:00
|
|
|
sidebar,
|
|
|
|
|
2020-12-14 15:48:15 +00:00
|
|
|
mapCount,
|
2021-05-17 13:17:52 +00:00
|
|
|
serverCount,
|
2020-12-31 13:02:49 +00:00
|
|
|
following,
|
2021-05-28 23:08:43 +00:00
|
|
|
|
2021-05-20 15:39:41 +00:00
|
|
|
messageWorlds,
|
|
|
|
messagePlayers,
|
2021-05-26 16:43:56 +00:00
|
|
|
|
2021-05-28 23:08:43 +00:00
|
|
|
previouslyVisible,
|
|
|
|
playersVisible,
|
|
|
|
mapsVisible,
|
|
|
|
followVisible,
|
2021-06-23 17:18:42 +00:00
|
|
|
playerMakersEnabled,
|
2021-05-26 16:43:56 +00:00
|
|
|
|
2021-05-28 23:08:43 +00:00
|
|
|
handleSidebarKeydown,
|
2021-05-28 23:22:31 +00:00
|
|
|
handleMapsKeydown,
|
|
|
|
handlePlayersKeydown,
|
|
|
|
|
2021-05-28 23:08:43 +00:00
|
|
|
togglePlayers,
|
|
|
|
toggleMaps
|
2021-05-26 16:43:56 +00:00
|
|
|
}
|
2021-05-28 23:08:43 +00:00
|
|
|
},
|
|
|
|
});
|
2020-11-23 12:13:28 +00:00
|
|
|
|
2020-11-20 21:44:02 +00:00
|
|
|
</script>
|
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
<style lang="scss">
|
|
|
|
@import '../scss/placeholders';
|
|
|
|
|
|
|
|
.sidebar {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 120;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2021-08-24 14:59:31 +00:00
|
|
|
padding: var(--ui-element-spacing);
|
2020-12-15 22:12:57 +00:00
|
|
|
font-size: 1.5rem;
|
2020-12-01 23:20:38 +00:00
|
|
|
will-change: transform;
|
2020-12-12 19:06:25 +00:00
|
|
|
pointer-events: none;
|
|
|
|
|
|
|
|
ul, ol, li {
|
|
|
|
padding: 0;
|
|
|
|
list-style: none;
|
|
|
|
margin: 0;
|
|
|
|
}
|
2020-12-01 23:20:38 +00:00
|
|
|
|
|
|
|
.sidebar__buttons {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
2021-08-24 14:59:31 +00:00
|
|
|
margin-bottom: var(--ui-element-spacing);
|
2020-12-12 19:06:25 +00:00
|
|
|
pointer-events: auto;
|
2021-05-24 18:19:35 +00:00
|
|
|
align-self: flex-end;
|
2020-12-01 23:20:38 +00:00
|
|
|
|
|
|
|
button {
|
2021-08-24 14:59:31 +00:00
|
|
|
width: var(--ui-button-size);
|
|
|
|
height: var(--ui-button-size);
|
2021-05-24 20:57:53 +00:00
|
|
|
box-shadow: var(--box-shadow);
|
2020-11-20 21:44:02 +00:00
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
& + button {
|
2021-08-24 14:59:31 +00:00
|
|
|
margin-left: var(--ui-element-spacing);
|
2020-12-01 23:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-20 14:45:04 +00:00
|
|
|
|
2021-01-25 02:27:35 +00:00
|
|
|
@media (max-width: 480px) {
|
2020-12-20 14:45:04 +00:00
|
|
|
flex-direction: column;
|
|
|
|
align-items: flex-end;
|
|
|
|
margin: 0;
|
|
|
|
position: absolute;
|
2021-08-24 14:59:31 +00:00
|
|
|
right: var(--ui-element-spacing);
|
|
|
|
top: var(--ui-element-spacing);
|
2020-12-20 14:45:04 +00:00
|
|
|
|
|
|
|
button + button {
|
|
|
|
margin-left: 0;
|
2021-08-24 14:59:31 +00:00
|
|
|
margin-top: var(--ui-element-spacing);
|
2020-12-20 14:45:04 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-01 23:20:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-25 18:26:51 +00:00
|
|
|
.sidebar__content {
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
flex-shrink: 1;
|
|
|
|
min-height: 0;
|
|
|
|
overflow: auto;
|
|
|
|
pointer-events: auto;
|
|
|
|
margin-right: -0.5rem;
|
|
|
|
padding: 0.2rem 0.5rem 0 0.2rem;
|
2021-06-23 21:57:47 +00:00
|
|
|
width: 25rem;
|
2021-05-25 18:26:51 +00:00
|
|
|
align-items: flex-end;
|
2021-05-28 14:10:11 +00:00
|
|
|
overscroll-behavior: contain;
|
2021-05-25 20:23:12 +00:00
|
|
|
|
|
|
|
&:not(:hover):not(:focus-within) {
|
|
|
|
scrollbar-color: var(--background-base) transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(:hover):not(:focus-within)::-webkit-scrollbar-thumb {
|
|
|
|
background-color: var(--background-base);
|
|
|
|
}
|
2021-05-25 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
.sidebar__section {
|
|
|
|
@extend %panel;
|
2021-08-24 14:59:31 +00:00
|
|
|
margin-bottom: var(--ui-element-spacing);
|
2021-05-25 18:26:51 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
width: 100%;
|
2021-06-23 21:57:47 +00:00
|
|
|
max-width: 25rem;
|
2021-05-25 19:38:51 +00:00
|
|
|
flex: 0 0 auto;
|
2020-12-01 23:20:38 +00:00
|
|
|
|
|
|
|
.section__heading {
|
2021-05-25 18:26:14 +00:00
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
text-align: left;
|
2021-05-26 01:10:34 +00:00
|
|
|
align-items: center;
|
2021-05-26 22:28:03 +00:00
|
|
|
margin: 0;
|
2021-05-25 18:26:14 +00:00
|
|
|
|
2021-05-26 22:28:03 +00:00
|
|
|
button {
|
|
|
|
display: flex;
|
|
|
|
font-size: 2rem;
|
|
|
|
padding: 1.5rem 1.5rem 1rem;
|
|
|
|
margin: -1.5rem -1.5rem 0;
|
2021-05-25 18:26:14 +00:00
|
|
|
background-color: transparent;
|
|
|
|
color: inherit;
|
2021-05-26 22:28:03 +00:00
|
|
|
width: calc(100% + 3rem);
|
2021-05-28 13:43:07 +00:00
|
|
|
align-items: center;
|
2021-05-26 22:28:03 +00:00
|
|
|
|
|
|
|
.svg-icon {
|
|
|
|
margin-left: auto;
|
|
|
|
width: 1.5rem;
|
|
|
|
height: 1.5rem;
|
|
|
|
}
|
2021-05-25 18:26:14 +00:00
|
|
|
}
|
2021-05-26 01:10:34 +00:00
|
|
|
|
2021-08-25 19:29:36 +00:00
|
|
|
&:hover, &:focus-visible, &.focus-visible {
|
2021-05-26 22:28:03 +00:00
|
|
|
background-color: transparent;
|
|
|
|
color: inherit;
|
2021-05-26 01:10:34 +00:00
|
|
|
}
|
2020-12-01 23:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.section__content {
|
2021-05-24 16:16:40 +00:00
|
|
|
padding: 0 0.5rem;
|
|
|
|
margin: 0 -.5rem 1rem;
|
2021-06-23 21:57:34 +00:00
|
|
|
min-width: 0;
|
2021-05-17 02:39:25 +00:00
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
2020-12-01 23:20:38 +00:00
|
|
|
}
|
2021-01-24 22:15:07 +00:00
|
|
|
|
|
|
|
.section__skeleton {
|
|
|
|
font-style: italic;
|
2021-05-15 22:24:29 +00:00
|
|
|
color: var(--text-disabled);
|
2021-01-24 22:15:07 +00:00
|
|
|
text-align: center;
|
|
|
|
align-self: center;
|
|
|
|
margin-top: 1rem;
|
|
|
|
}
|
2021-05-25 18:26:14 +00:00
|
|
|
|
|
|
|
&.section--collapsed {
|
2021-05-26 22:28:03 +00:00
|
|
|
.section__heading button {
|
2021-05-25 18:26:14 +00:00
|
|
|
padding-bottom: 1.5rem;
|
|
|
|
margin-bottom: -1.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.section__content {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2021-05-25 18:26:51 +00:00
|
|
|
|
|
|
|
@media (max-width: 320px) {
|
|
|
|
box-sizing: border-box;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2020-12-01 23:20:38 +00:00
|
|
|
}
|
2020-12-20 14:45:04 +00:00
|
|
|
|
2021-01-25 02:27:35 +00:00
|
|
|
@media (max-width: 480px) {
|
2020-12-20 16:18:01 +00:00
|
|
|
padding-right: 7rem;
|
2021-07-21 15:54:53 +00:00
|
|
|
padding-top: 0.8rem;
|
2020-12-20 16:18:01 +00:00
|
|
|
}
|
|
|
|
|
2021-01-25 02:27:35 +00:00
|
|
|
@media (max-width: 400px) {
|
2020-12-20 14:45:04 +00:00
|
|
|
padding-right: 6.5rem;
|
2021-07-22 02:10:29 +00:00
|
|
|
padding-top: 0.3rem;
|
|
|
|
padding-bottom: 0.3rem;
|
2020-12-20 14:45:04 +00:00
|
|
|
}
|
|
|
|
|
2021-01-07 13:49:00 +00:00
|
|
|
@media print {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-12-01 23:20:38 +00:00
|
|
|
}
|
2021-06-22 17:55:39 +00:00
|
|
|
</style>
|