Player list search
This commit is contained in:
parent
ffed2548ba
commit
028cb4e1af
@ -98,6 +98,8 @@
|
|||||||
playersTitle: 'Click to center on player\nDouble-click to follow player',
|
playersTitle: 'Click to center on player\nDouble-click to follow player',
|
||||||
playersTitleHidden: 'This player is currently hidden from the map\nDouble-click to follow player when they become visible',
|
playersTitleHidden: 'This player is currently hidden from the map\nDouble-click to follow player when they become visible',
|
||||||
playersTitleOtherWorld: 'This player is in another world.\nClick to center on player\nDouble-click to follow player',
|
playersTitleOtherWorld: 'This player is in another world.\nClick to center on player\nDouble-click to follow player',
|
||||||
|
playersSearchPlaceholder: 'Search players...',
|
||||||
|
playersSearchSkeleton: 'No matching players found',
|
||||||
followingHeading: 'Following',
|
followingHeading: 'Following',
|
||||||
followingUnfollow: 'Unfollow',
|
followingUnfollow: 'Unfollow',
|
||||||
followingTitleUnfollow: 'Stop following this player',
|
followingTitleUnfollow: 'Stop following this player',
|
||||||
@ -117,7 +119,10 @@
|
|||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
// If true, player markers will always be displayed in front of other marker types
|
// If true, player markers will always be displayed in front of other marker types
|
||||||
playersAboveMarkers: true
|
playersAboveMarkers: true,
|
||||||
|
|
||||||
|
// Whether to enable the player list search box
|
||||||
|
playersSearch: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -15,23 +15,30 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CollapsibleSection name="players">
|
<CollapsibleSection name="players" class="players">
|
||||||
<template v-slot:heading>{{ heading }} [{{ players.length }}/{{ maxPlayers }}]</template>
|
<template v-slot:heading>{{ messageHeading }} [{{ players.length }}/{{ maxPlayers }}]</template>
|
||||||
<template v-slot:default>
|
<template v-slot:default>
|
||||||
<RadioList class="section__content" v-if="players.length" aria-labelledby="players-heading">
|
<div class="section__content">
|
||||||
<PlayerListItem v-for="player in players" :key="player.account" :player="player"></PlayerListItem>
|
<input v-if="players && searchEnabled" id="players__search" type="text" name="search"
|
||||||
|
v-model="searchQuery" :placeholder="messagePlayersSearchPlaceholder" @keydown="onKeydown">
|
||||||
|
<RadioList v-if="filteredPlayers.length" aria-labelledby="players-heading">
|
||||||
|
<PlayerListItem v-for="player in filteredPlayers" :key="player.account"
|
||||||
|
:player="player"></PlayerListItem>
|
||||||
</RadioList>
|
</RadioList>
|
||||||
<div v-else class="section__content section__skeleton">{{ skeletonPlayers }}</div>
|
<div v-else-if="searchQuery" class="section__skeleton">{{ messageSkeletonPlayersSearch }}</div>
|
||||||
|
<div v-else class="section__skeleton">{{ messageSkeletonPlayers }}</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CollapsibleSection>
|
</CollapsibleSection>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import PlayerListItem from "./PlayerListItem.vue";
|
import PlayerListItem from "./PlayerListItem.vue";
|
||||||
import {defineComponent} from "@vue/runtime-core";
|
import {computed, defineComponent} from "@vue/runtime-core";
|
||||||
import {useStore} from "@/store";
|
import {useStore} from "@/store";
|
||||||
import CollapsibleSection from "@/components/sidebar/CollapsibleSection.vue";
|
import CollapsibleSection from "@/components/sidebar/CollapsibleSection.vue";
|
||||||
import RadioList from "@/components/util/RadioList.vue";
|
import RadioList from "@/components/util/RadioList.vue";
|
||||||
|
import {ref} from "vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -40,22 +47,59 @@ export default defineComponent({
|
|||||||
PlayerListItem
|
PlayerListItem
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
setup() {
|
||||||
heading() {
|
const store = useStore(),
|
||||||
return useStore().state.messages.playersHeading;
|
messageHeading = computed(() => store.state.messages.playersHeading),
|
||||||
},
|
messageSkeletonPlayers = computed(() => store.state.messages.playersSkeleton),
|
||||||
|
messageSkeletonPlayersSearch = computed(() => store.state.messages.playersSearchSkeleton),
|
||||||
|
messagePlayersSearchPlaceholder = computed(() => store.state.messages.playersSearchPlaceholder),
|
||||||
|
|
||||||
skeletonPlayers() {
|
searchEnabled = computed(() => store.state.ui.playersSearch),
|
||||||
return useStore().state.messages.playersSkeleton;
|
searchQuery = ref(""),
|
||||||
},
|
|
||||||
|
|
||||||
players() {
|
players = computed(() => store.state.sortedPlayers),
|
||||||
return useStore().state.sortedPlayers;
|
filteredPlayers = computed(() => {
|
||||||
},
|
const query = searchQuery.value.toLowerCase();
|
||||||
|
|
||||||
maxPlayers(): number {
|
return query ? store.state.sortedPlayers.filter(p => {
|
||||||
return useStore().state.configuration.maxPlayers;
|
return p.account.toLowerCase().indexOf(query) > -1;
|
||||||
|
}) : store.state.sortedPlayers;
|
||||||
|
}),
|
||||||
|
maxPlayers = computed(() => store.state.configuration.maxPlayers),
|
||||||
|
|
||||||
|
onKeydown = (e: KeyboardEvent) => {
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
messageHeading,
|
||||||
|
messageSkeletonPlayers,
|
||||||
|
messageSkeletonPlayersSearch,
|
||||||
|
messagePlayersSearchPlaceholder,
|
||||||
|
|
||||||
|
searchEnabled,
|
||||||
|
searchQuery,
|
||||||
|
|
||||||
|
players,
|
||||||
|
filteredPlayers,
|
||||||
|
maxPlayers,
|
||||||
|
onKeydown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.players {
|
||||||
|
#players__search {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
& + .section__skeleton {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
3
src/index.d.ts
vendored
3
src/index.d.ts
vendored
@ -64,6 +64,8 @@ interface LiveAtlasGlobalMessageConfig {
|
|||||||
playersTitle: string;
|
playersTitle: string;
|
||||||
playersTitleHidden: string;
|
playersTitleHidden: string;
|
||||||
playersTitleOtherWorld: string;
|
playersTitleOtherWorld: string;
|
||||||
|
playersSearchPlaceholder: string;
|
||||||
|
playersSearchSkeleton: string;
|
||||||
followingHeading: string;
|
followingHeading: string;
|
||||||
followingUnfollow: string;
|
followingUnfollow: string;
|
||||||
followingTitleUnfollow: string;
|
followingTitleUnfollow: string;
|
||||||
@ -98,6 +100,7 @@ type LiveAtlasMessageConfig = LiveAtlasGlobalMessageConfig & LiveAtlasServerMess
|
|||||||
|
|
||||||
interface LiveAtlasUIConfig {
|
interface LiveAtlasUIConfig {
|
||||||
playersAboveMarkers: boolean;
|
playersAboveMarkers: boolean;
|
||||||
|
playersSearch: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LiveAtlasUIElement = 'layers' | 'chat' | 'players' | 'maps' | 'settings';
|
export type LiveAtlasUIElement = 'layers' | 'chat' | 'players' | 'maps' | 'settings';
|
||||||
|
@ -71,7 +71,7 @@ input {
|
|||||||
font-size: 1.6rem;
|
font-size: 1.6rem;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border: 0.2rem solid var(--border-color);
|
border: 0.2rem solid var(--border-color);
|
||||||
border-radius: 0;
|
border-radius: 0.3rem;
|
||||||
|
|
||||||
@include focus {
|
@include focus {
|
||||||
color: var(--text-emphasis);
|
color: var(--text-emphasis);
|
||||||
|
@ -123,6 +123,8 @@ export const mutations: MutationTree<State> & Mutations = {
|
|||||||
playersTitle: messageConfig.playersTitle || '',
|
playersTitle: messageConfig.playersTitle || '',
|
||||||
playersTitleHidden: messageConfig.playersTitleHidden || '',
|
playersTitleHidden: messageConfig.playersTitleHidden || '',
|
||||||
playersTitleOtherWorld: messageConfig.playersTitleOtherWorld || '',
|
playersTitleOtherWorld: messageConfig.playersTitleOtherWorld || '',
|
||||||
|
playersSearchPlaceholder: messageConfig.playersSearchPlaceholder || '',
|
||||||
|
playersSearchSkeleton: messageConfig.playersSearchSkeleton || '',
|
||||||
followingHeading: messageConfig.followingHeading || '',
|
followingHeading: messageConfig.followingHeading || '',
|
||||||
followingHidden: messageConfig.followingHidden || '',
|
followingHidden: messageConfig.followingHidden || '',
|
||||||
followingUnfollow: messageConfig.followingUnfollow || '',
|
followingUnfollow: messageConfig.followingUnfollow || '',
|
||||||
@ -146,6 +148,10 @@ export const mutations: MutationTree<State> & Mutations = {
|
|||||||
state.ui.playersAboveMarkers = uiConfig.playersAboveMarkers;
|
state.ui.playersAboveMarkers = uiConfig.playersAboveMarkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeof uiConfig.playersSearch === 'boolean') {
|
||||||
|
state.ui.playersSearch = uiConfig.playersSearch;
|
||||||
|
}
|
||||||
|
|
||||||
state.servers = config.servers;
|
state.servers = config.servers;
|
||||||
|
|
||||||
if(state.currentServer && !state.servers.has(state.currentServer.id)) {
|
if(state.currentServer && !state.servers.has(state.currentServer.id)) {
|
||||||
|
@ -74,6 +74,8 @@ export type State = {
|
|||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
playersAboveMarkers: boolean;
|
playersAboveMarkers: boolean;
|
||||||
|
playersSearch: boolean;
|
||||||
|
|
||||||
smallScreen: boolean;
|
smallScreen: boolean;
|
||||||
visibleElements: Set<LiveAtlasUIElement>;
|
visibleElements: Set<LiveAtlasUIElement>;
|
||||||
previouslyVisibleElements: Set<LiveAtlasUIElement>;
|
previouslyVisibleElements: Set<LiveAtlasUIElement>;
|
||||||
@ -132,6 +134,8 @@ export const state: State = {
|
|||||||
playersTitle: '',
|
playersTitle: '',
|
||||||
playersTitleHidden: '',
|
playersTitleHidden: '',
|
||||||
playersTitleOtherWorld: '',
|
playersTitleOtherWorld: '',
|
||||||
|
playersSearchPlaceholder: '',
|
||||||
|
playersSearchSkeleton: '',
|
||||||
followingHeading: '',
|
followingHeading: '',
|
||||||
followingUnfollow: '',
|
followingUnfollow: '',
|
||||||
followingTitleUnfollow: '',
|
followingTitleUnfollow: '',
|
||||||
@ -227,6 +231,7 @@ export const state: State = {
|
|||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
playersAboveMarkers: true,
|
playersAboveMarkers: true,
|
||||||
|
playersSearch: true,
|
||||||
|
|
||||||
smallScreen: false,
|
smallScreen: false,
|
||||||
visibleElements: new Set(),
|
visibleElements: new Set(),
|
||||||
|
Loading…
Reference in New Issue
Block a user