-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The marathon header so that it spans the page
Removes the name from the sidebar When sidebar collapses, it joins the name in the header Related to Issue #44
- Loading branch information
Showing
3 changed files
with
138 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<template> | ||
<div class="box"> | ||
<div class="main-header"> | ||
<h3 class="title is-3"> | ||
{{ marathonName }} | ||
</h3> | ||
<button v-if="collapsed" class="button navbar-burger" :class="buttonClass" @click="toggleSidebar"> | ||
<span /> | ||
<span /> | ||
<span /> | ||
</button> | ||
</div> | ||
|
||
<div v-if="collapsed" class="menu-sections"> | ||
<MarathonSidebarOverview :marathon-id="marathonId" collapsed /> | ||
<MarathonSidebarTracker :marathon-id="marathonId" collapsed /> | ||
<MarathonSidebarAdmin :marathon-id="marathonId" collapsed /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import { mapActions } from 'vuex'; | ||
import { FullMarathon, MarathonState } from '~/types/api/marathon'; | ||
import { IsActive } from '~/types/components/is-active'; | ||
export default Vue.extend({ | ||
props: { | ||
marathonId: { | ||
type: String, | ||
default: '', | ||
}, | ||
collapsed: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
async fetch(): Promise<void> { | ||
await Promise.allSettled([ | ||
this.getMarathon(this.marathonId), | ||
]); | ||
}, | ||
computed: { | ||
marathon(): FullMarathon|undefined { | ||
return (this.$store.state.api.marathon as MarathonState).marathons[this.marathonId]; | ||
}, | ||
marathonName(): string { | ||
let marathonName = ''; | ||
if (this.marathon) { | ||
marathonName = this.marathon.name; | ||
} | ||
if (!marathonName && this.marathonId) { | ||
const frontPage = (this.$store.state.api.marathon as MarathonState).frontPage; | ||
if (frontPage) { | ||
marathonName = [ ...frontPage.live, ...frontPage.next, ...frontPage.open ].find(marathon => marathon.id === this.marathonId)?.name ?? marathonName; | ||
} | ||
} | ||
return marathonName; | ||
}, | ||
buttonClass(): IsActive { | ||
return { | ||
'is-active': !this.collapsed, | ||
}; | ||
}, | ||
}, | ||
methods: { | ||
toggleSidebar(): void { | ||
this.$emit('update:collapsed', !this.collapsed); | ||
}, | ||
...mapActions({ | ||
getMarathon: 'api/marathon/get', | ||
}), | ||
}, | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.main-header { | ||
display: grid; | ||
grid-template-columns: auto min-content; | ||
column-gap: var(--spacing); | ||
// Force this element to always display, Bulma wants to hide it by default | ||
@media (min-width: 1024px) { | ||
.navbar-burger { | ||
display: block; | ||
} | ||
} | ||
} | ||
.menu-sections { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters