forked from directus/v8-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-implement header bar (directus#408)
* Implement new header bar component * rename header-bar to v-header-bar * Make header bar a global component * Remove header bar from main app.vue * Remove header bar from main app.vue parent * Use new header bar on pages * Use store for sidebar nav state * Render header button based on config passed to header bar * Re-style alert * Add button support to header * Add header button to item listing * Re-add buttons to edit view * Fix styling of disabled button
- Loading branch information
1 parent
79660f6
commit ac449d0
Showing
18 changed files
with
244 additions
and
199 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
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 |
---|---|---|
@@ -1,96 +1,149 @@ | ||
<template> | ||
<header class="header-bar"> | ||
<header class="v-header-bar"> | ||
<button | ||
:disabled="navActive" | ||
class="nav-toggle" | ||
@click="$emit('toggleNav', true)"><i class="material-icons">menu</i></button> | ||
|
||
<portal-target | ||
class="title" | ||
name="header-title"><h1 class="style-1"><v-breadcrumb /></h1></portal-target> | ||
|
||
<portal-target | ||
name="header-custom" | ||
class="custom" | ||
slim /> | ||
|
||
<header-button | ||
v-if="showInfoButton" | ||
icon="info" | ||
class="button" | ||
@click="$emit('toggleInfo')"> | ||
{{ $t('info') }} | ||
</header-button> | ||
<portal-target | ||
name="header-buttons" | ||
class="buttons" /> | ||
@click="activateNav"><i class="material-icons">menu</i></button> | ||
<h1 | ||
v-if="title" | ||
class="title">{{ title }}</h1> | ||
<ol | ||
v-else | ||
class="breadcrumb title"> | ||
<li | ||
v-for="({ name, path }, index) in (breadcrumb || defaultBreadcrumb)" | ||
:key="path"> | ||
<template v-if="index !== (breadcrumb || defaultBreadcrumb).length - 1"> | ||
<router-link :to="path">{{ name }}</router-link></template> | ||
<h1 v-else>{{ name }}</h1> | ||
</li> | ||
</ol> | ||
<slot /> | ||
<slot name="buttons" /> | ||
</header> | ||
</template> | ||
|
||
<script> | ||
import { TOGGLE_NAV } from "../../store/mutation-types"; | ||
export default { | ||
name: "header-bar", | ||
name: "v-header-bar", | ||
props: { | ||
showInfoButton: { | ||
type: Boolean, | ||
default: false | ||
title: { | ||
type: String, | ||
default: null | ||
}, | ||
breadcrumb: { | ||
type: Array, | ||
default: null | ||
} | ||
}, | ||
computed: { | ||
defaultBreadcrumb() { | ||
const routeParts = this.$route.path.split("/").filter(name => name); | ||
return routeParts.map((part, i) => { | ||
let url = ""; | ||
for (let x = 0; x < i; x++) { | ||
url += `/${routeParts[x]}`; | ||
} | ||
url += `/${part}`; | ||
return { | ||
name: this.$helpers.formatTitle(part), | ||
path: url | ||
}; | ||
}); | ||
}, | ||
navActive() { | ||
return this.$store.state.sidebars.nav; | ||
} | ||
}, | ||
methods: { | ||
activateNav() { | ||
this.$store.commit(TOGGLE_NAV, true); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.nav-toggle { | ||
background-color: transparent; | ||
border: none; | ||
border-radius: 0; | ||
padding: 0; | ||
margin-right: 20px; | ||
cursor: pointer; | ||
transition: opacity 140ms var(--transition); | ||
&:hover { | ||
opacity: 0.6; | ||
} | ||
} | ||
.header-bar { | ||
background-color: black; | ||
.v-header-bar { | ||
background-color: var(--darkest-gray); | ||
position: fixed; | ||
width: 100%; | ||
right: 0; | ||
top: 0; | ||
height: 4.62rem; | ||
color: white; | ||
color: var(--white); | ||
display: flex; | ||
align-items: center; | ||
z-index: 20; | ||
padding-left: 20px; | ||
.title { | ||
flex-grow: 1; | ||
color: var(--white); | ||
@media (min-width: 800px) { | ||
padding-left: calc(var(--nav-sidebar-width) + 20px); | ||
} | ||
.nav-toggle { | ||
background-color: transparent; | ||
border: none; | ||
border-radius: 0; | ||
padding: 0; | ||
margin-right: 20px; | ||
cursor: pointer; | ||
transition: opacity 140ms var(--transition); | ||
display: flex; | ||
align-items: center; | ||
&:hover { | ||
opacity: 0.6; | ||
} | ||
@media (min-width: 800px) { | ||
display: none; | ||
} | ||
} | ||
.title { | ||
color: var(--gray); | ||
font-size: 1.38em; | ||
line-height: 1.16; | ||
font-weight: 400; | ||
height: 20px; | ||
flex-grow: 1; | ||
} | ||
@media (min-width: 50em) { | ||
width: calc(100% - var(--nav-sidebar-width)); | ||
.breadcrumb { | ||
list-style: none; | ||
padding: 0; | ||
.nav-toggle { | ||
display: none; | ||
li { | ||
display: inline-block; | ||
&:not(:last-child)::after { | ||
content: "chevron_right"; | ||
font-family: "Material Icons"; | ||
color: var(--dark-gray); | ||
display: inline-block; | ||
vertical-align: middle; | ||
margin: 0 5px; | ||
} | ||
} | ||
a { | ||
text-decoration: none; | ||
&:hover, | ||
.user-is-tabbing &:focus { | ||
color: var(--white); | ||
} | ||
} | ||
} | ||
} | ||
.buttons { | ||
display: flex; | ||
height: 100%; | ||
h1.title, | ||
.title h1 { | ||
color: var(--white); | ||
} | ||
} | ||
</style> | ||
|
||
.button { | ||
flex-shrink: 0; | ||
<style> | ||
body { | ||
padding-top: var(--header-height); | ||
} | ||
</style> |
Oops, something went wrong.