From 9712f5e5831e05d64b9a1258add52042df23a4a3 Mon Sep 17 00:00:00 2001 From: J-Lennox10 Date: Wed, 8 Mar 2023 14:40:54 +0000 Subject: [PATCH] Made sidebar into its own component --- src/components/SidebarPanel.vue | 60 ++++++++++++++++++++- src/pages/MapPage.vue | 96 +++++++++------------------------ src/store/store.js | 14 +++++ 3 files changed, 96 insertions(+), 74 deletions(-) diff --git a/src/components/SidebarPanel.vue b/src/components/SidebarPanel.vue index 6b97616..f8b002e 100644 --- a/src/components/SidebarPanel.vue +++ b/src/components/SidebarPanel.vue @@ -1,13 +1,69 @@ \ No newline at end of file diff --git a/src/pages/MapPage.vue b/src/pages/MapPage.vue index cde80f7..08d36ac 100644 --- a/src/pages/MapPage.vue +++ b/src/pages/MapPage.vue @@ -4,21 +4,9 @@ -
-
- Train Icon -
X
-
- -
-

Train Code: {{ selectedDataMap["TrainCode"] }}

-

Date: {{ selectedDataMap["TrainDate"] }}

-

Status: {{ selectedDataMap["TrainStatus"] }}

-

Train Position - Long: {{ selectedDataMap["TrainLongitude"] }} Lat: {{ selectedDataMap["TrainLatitude"] }}

-

Direction: {{ selectedDataMap["Direction"] }}

-

Public Message: {{ selectedDataMap["PublicMessage"] }}

-
-
+
+ +
@@ -54,6 +42,7 @@ import app from '../api/firebase'; import { getFunctions, httpsCallable, connectFunctionsEmulator } from "firebase/functions"; import Navbar from '../components/Navbar.vue' import MarqueeText from 'vue-marquee-text-component' +import SidebarPanel from '../components/SidebarPanel.vue'; export default { name: "MapPage", @@ -81,8 +70,6 @@ export default { coordinates: [], dbLiveTrainData: [], allDataMap: {}, - selectedDataMap: {}, - display: false, store, publicMessages: [], @@ -92,7 +79,8 @@ export default { components: { Navbar, - MarqueeText + MarqueeText, + SidebarPanel }, created() { @@ -110,8 +98,8 @@ export default { methods: { // method to assign a single train's data to the selected hashmap getSelectedTrain(i) { - this.display = true; - this.selectedDataMap = this.allDataMap[i]; + store.setSelectedDataMap(this.allDataMap[i]); + store.setDisplay(true) }, // method to determine whether or not a selected train is late @@ -255,6 +243,22 @@ export default { height: 32px; } +#sidebar{ + position: absolute; + height: 85%; + width: 20%; + left: 2%; + top: 12%; + z-index: 2; + text-align: center; + animation: gradient 15s ease infinite; + background: linear-gradient(45deg, #000000, #111111, #222222, #333333, #444444, #555555); + background-size: 400%, 400%; + box-shadow: 0 0 4px 2px #333333; + overflow: hidden; + font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif +} + .slideLeft-enter-active, .slideLeft-leave-active { transition: opacity .5s; transition: all 0.8s; @@ -277,58 +281,6 @@ export default { } } -#sidebar{ - position: absolute; - height: 85%; - width: 20%; - left: 2%; - top: 12%; - z-index: 2; - text-align: center; - animation: gradient 15s ease infinite; - background: linear-gradient(45deg, #000000, #111111, #222222, #333333, #444444, #555555); - background-size: 400%, 400%; - box-shadow: 0 0 4px 2px #333333; - overflow: hidden; - font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif -} - -#sidebarHeader{ - position: relative; - top:0%; - height: 15%; - width: 100%; - overflow: hidden; -} - -#sidebarDiv{ - position: absolute; - height: 80%; - width: 100%; - color: white; -} - -#headerImage{ - height: 80%; - width: auto; - overflow: hidden; - position: relative; - top: 10px; -} - -#xButton{ - font-size: 80%; - font-family: Georgia; - color: white; - position: absolute; - top:10px; - right:10px; -} - -#xButton:hover{ - color:red; -} - #publicMessageTicker { z-index: 3; position: absolute; diff --git a/src/store/store.js b/src/store/store.js index d4c09b9..c882f8a 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -5,25 +5,39 @@ export const store = reactive({ latestTrain: {}, earliestTrain: {}, orderedTrains: [], + selectedDataMap: {}, rawData: {}, + display: false, setInsights(insights) { this.insights = insights }, + setLatestTrain(latestTrain) { this.latestTrain = latestTrain }, + setEarliestTrain(earliestTrain) { this.earliestTrain = earliestTrain }, + setRawData(rawData) { this.rawData = rawData }, + setOrderedTrains(unorderedTrains) { // sort in ascending order unorderedTrains.sort((a, b) => { return a.time - b.time }) this.orderedTrains = unorderedTrains + }, + + setSelectedDataMap(selectedDataMap) { + this.selectedDataMap = selectedDataMap + }, + + setDisplay(bool) { + this.display = bool } }) \ No newline at end of file