LiveAtlas/src/components/Sidebar.vue

190 lines
4.5 KiB
Vue
Raw Normal View History

2020-12-16 16:54:41 +00:00
<!--
- Copyright 2020 James Lyne
-
- 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
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- 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-11-20 21:44:02 +00:00
<template>
2020-12-01 23:20:38 +00:00
<aside class="sidebar">
<header class="sidebar__buttons">
2020-12-31 13:02:49 +00:00
<button v-if="mapCount > 1" :class="{'button--maps': true, 'active':visibleUIElements.has('maps')}"
@click="toggleElement('maps')" title="Map list" aria-label="Map list">
2020-12-12 21:36:41 +00:00
<SvgIcon name="maps"></SvgIcon>
</button>
2020-12-31 13:02:49 +00:00
<button :class="{'button--players': true, 'active': visibleUIElements.has('players')}"
@click="toggleElement('players')" title="Player list" aria-label="Player list">
2020-12-12 21:36:41 +00:00
<SvgIcon name="players"></SvgIcon>
</button>
2020-12-31 13:02:49 +00:00
<!-- <button :class="{'button&#45;&#45;settings': true, 'active': visibleUIElements.has('settings'))}"-->
<!-- @click="toggleElement('settings')" title="Settings" aria-label="Settings">-->
2020-12-16 16:54:41 +00:00
<!-- <SvgIcon name="settings"></SvgIcon>-->
<!-- </button>-->
2020-12-01 23:20:38 +00:00
</header>
2020-12-31 13:02:49 +00:00
<WorldList v-if="mapCount > 1" v-show="visibleUIElements.has('maps')"></WorldList>
<PlayerList v-show="visibleUIElements.has('players')"></PlayerList>
<FollowTarget v-if="following" v-show="followActive" :target="following"></FollowTarget>
2020-12-01 23:20:38 +00:00
</aside>
2020-11-20 21:44:02 +00:00
</template>
2020-11-23 12:13:28 +00:00
<script lang="ts">
2020-12-31 13:02:49 +00:00
import {defineComponent, computed} from "@vue/runtime-core";
2020-12-01 23:20:38 +00:00
import PlayerList from './sidebar/PlayerList.vue';
import WorldList from './sidebar/WorldList.vue';
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";
import {DynmapUIElement} from "@/dynmap";
2020-12-01 23:20:38 +00:00
export default defineComponent({
components: {
2020-12-12 21:36:41 +00:00
SvgIcon,
2020-12-01 23:20:38 +00:00
PlayerList,
FollowTarget,
WorldList,
},
setup() {
const store = useStore(),
2020-12-31 13:02:49 +00:00
visibleUIElements = computed(() => store.state.ui.visibleElements),
smallScreen = computed(() => store.state.ui.smallScreen),
mapCount = computed(() => store.state.maps.size),
following = computed(() => store.state.followTarget),
2020-12-31 13:02:49 +00:00
toggleElement = (element: DynmapUIElement) => {
store.commit(MutationTypes.TOGGLE_UI_ELEMENT_VISIBILITY, element);
},
2020-12-31 13:02:49 +00:00
followActive = computed(() => {
//Show following alongside playerlist on small screens
2020-12-31 13:02:49 +00:00
return (!smallScreen.value && following)
|| (smallScreen.value && visibleUIElements.value.has('players'));
});
2020-12-01 23:20:38 +00:00
return {
mapCount,
2020-12-31 13:02:49 +00:00
visibleUIElements,
toggleElement,
followActive,
2020-12-31 13:02:49 +00:00
following,
2020-12-01 23:20:38 +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/variables';
@import '../scss/placeholders';
.sidebar {
position: fixed;
z-index: 120;
top: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
padding: 1rem;
width: 23rem;
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;
margin-bottom: 1rem;
2020-12-12 19:06:25 +00:00
pointer-events: auto;
2020-12-01 23:20:38 +00:00
button {
width: 5rem;
height: 5rem;
2020-11-20 21:44:02 +00:00
2020-12-01 23:20:38 +00:00
& + button {
margin-left: 1rem;
}
}
2020-12-20 14:45:04 +00:00
@media (max-width: 30rem) {
flex-direction: column;
align-items: flex-end;
margin: 0;
position: absolute;
2020-12-20 16:18:01 +00:00
right: 1rem;
top: 1rem;
2020-12-20 14:45:04 +00:00
button + button {
margin-left: 0;
margin-top: 1rem;
}
}
2020-12-20 16:18:01 +00:00
@media (max-width: 25rem) {
right: 0.5rem;
top: 0.5rem;
}
2020-12-01 23:20:38 +00:00
}
.sidebar__section {
@extend %panel;
flex: 0 1 auto;
min-height: 10rem;
2020-12-01 23:20:38 +00:00
margin-bottom: 1rem;
2020-12-12 19:06:25 +00:00
pointer-events: auto;
2020-12-01 23:20:38 +00:00
&:last-child {
margin-bottom: 0;
}
.section__heading {
font-size: 2rem;
margin-bottom: 1rem;
}
.section__content {
flex-shrink: 1;
min-height: 0;
overflow: auto;
will-change: transform;
}
}
2020-12-20 14:45:04 +00:00
2020-12-20 16:18:01 +00:00
@media (max-width: 30rem) {
padding-right: 7rem;
}
@media (max-width: 25rem), (max-height: 30rem) {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
padding-left: 0.5rem;
2020-12-20 14:45:04 +00:00
}
2020-12-20 16:18:01 +00:00
@media (max-width: 25rem) {
2020-12-20 14:45:04 +00:00
padding-right: 6.5rem;
}
@media (max-width: 20rem) {
box-sizing: border-box;
width: 100%;
}
2020-12-01 23:20:38 +00:00
}
2020-11-20 21:44:02 +00:00
</style>