From 028cb4e1af9b0bdcdbecec5e0467620cbb4b70f1 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Wed, 21 Jul 2021 16:19:18 +0100 Subject: [PATCH] Player list search --- index.html | 7 ++- src/components/sidebar/PlayerList.vue | 82 ++++++++++++++++++++------- src/index.d.ts | 3 + src/scss/style.scss | 2 +- src/store/mutations.ts | 6 ++ src/store/state.ts | 5 ++ 6 files changed, 84 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 185867d..1f259ef 100644 --- a/index.html +++ b/index.html @@ -98,6 +98,8 @@ 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', 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', followingUnfollow: 'Unfollow', followingTitleUnfollow: 'Stop following this player', @@ -117,7 +119,10 @@ ui: { // 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 } }; diff --git a/src/components/sidebar/PlayerList.vue b/src/components/sidebar/PlayerList.vue index b778e6e..6c74261 100644 --- a/src/components/sidebar/PlayerList.vue +++ b/src/components/sidebar/PlayerList.vue @@ -15,23 +15,30 @@ --> + + diff --git a/src/index.d.ts b/src/index.d.ts index b3aa086..2488964 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -64,6 +64,8 @@ interface LiveAtlasGlobalMessageConfig { playersTitle: string; playersTitleHidden: string; playersTitleOtherWorld: string; + playersSearchPlaceholder: string; + playersSearchSkeleton: string; followingHeading: string; followingUnfollow: string; followingTitleUnfollow: string; @@ -98,6 +100,7 @@ type LiveAtlasMessageConfig = LiveAtlasGlobalMessageConfig & LiveAtlasServerMess interface LiveAtlasUIConfig { playersAboveMarkers: boolean; + playersSearch: boolean; } export type LiveAtlasUIElement = 'layers' | 'chat' | 'players' | 'maps' | 'settings'; diff --git a/src/scss/style.scss b/src/scss/style.scss index 0a31339..73fa00d 100644 --- a/src/scss/style.scss +++ b/src/scss/style.scss @@ -71,7 +71,7 @@ input { font-size: 1.6rem; padding: 1rem; border: 0.2rem solid var(--border-color); - border-radius: 0; + border-radius: 0.3rem; @include focus { color: var(--text-emphasis); diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 96dbcd5..597a1df 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -123,6 +123,8 @@ export const mutations: MutationTree & Mutations = { playersTitle: messageConfig.playersTitle || '', playersTitleHidden: messageConfig.playersTitleHidden || '', playersTitleOtherWorld: messageConfig.playersTitleOtherWorld || '', + playersSearchPlaceholder: messageConfig.playersSearchPlaceholder || '', + playersSearchSkeleton: messageConfig.playersSearchSkeleton || '', followingHeading: messageConfig.followingHeading || '', followingHidden: messageConfig.followingHidden || '', followingUnfollow: messageConfig.followingUnfollow || '', @@ -146,6 +148,10 @@ export const mutations: MutationTree & Mutations = { state.ui.playersAboveMarkers = uiConfig.playersAboveMarkers; } + if(typeof uiConfig.playersSearch === 'boolean') { + state.ui.playersSearch = uiConfig.playersSearch; + } + state.servers = config.servers; if(state.currentServer && !state.servers.has(state.currentServer.id)) { diff --git a/src/store/state.ts b/src/store/state.ts index e9f6f62..27b5709 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -74,6 +74,8 @@ export type State = { ui: { playersAboveMarkers: boolean; + playersSearch: boolean; + smallScreen: boolean; visibleElements: Set; previouslyVisibleElements: Set; @@ -132,6 +134,8 @@ export const state: State = { playersTitle: '', playersTitleHidden: '', playersTitleOtherWorld: '', + playersSearchPlaceholder: '', + playersSearchSkeleton: '', followingHeading: '', followingUnfollow: '', followingTitleUnfollow: '', @@ -227,6 +231,7 @@ export const state: State = { ui: { playersAboveMarkers: true, + playersSearch: true, smallScreen: false, visibleElements: new Set(),