Using teleport for tooltips. Moved theme class to body tag with UI observer.

This commit is contained in:
DebaucheryLibrarian 2020-12-27 02:15:06 +01:00
parent 12f247a927
commit 229d74d266
9 changed files with 172 additions and 160 deletions

View File

@ -1,8 +1,5 @@
<template> <template>
<div <div class="container">
class="container"
:class="theme"
>
<Warning <Warning
v-if="showWarning" v-if="showWarning"
class="warning-container" class="warning-container"
@ -26,16 +23,10 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex';
import Warning from './warning.vue'; import Warning from './warning.vue';
import Header from '../header/header.vue'; import Header from '../header/header.vue';
import Sidebar from '../sidebar/sidebar.vue'; import Sidebar from '../sidebar/sidebar.vue';
function theme(state) {
return state.ui.theme;
}
function toggleSidebar(state) { function toggleSidebar(state) {
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar; this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
} }
@ -59,11 +50,6 @@ export default {
showWarning: localStorage.getItem('consent') !== window.env.sessionId, showWarning: localStorage.getItem('consent') !== window.env.sessionId,
}; };
}, },
computed: {
...mapState({
theme,
}),
},
methods: { methods: {
toggleSidebar, toggleSidebar,
setConsent, setConsent,

View File

@ -1,5 +1,5 @@
<template> <template>
<v-popover class="filter-container"> <Tooltip class="filter-container">
<div class="filter"> <div class="filter">
<Icon icon="users" /> <Icon icon="users" />
@ -14,7 +14,8 @@
>Actors</div> >Actors</div>
</div> </div>
<div slot="popover"> <template v-slot:tooltip>
<div>
<router-link <router-link
class="filter-clear" class="filter-clear"
:to="{ query: { ...$route.query, actors: undefined } }" :to="{ query: { ...$route.query, actors: undefined } }"
@ -53,7 +54,8 @@
</li> </li>
</ul> </ul>
</div> </div>
</v-popover> </template>
</Tooltip>
</template> </template>
<script> <script>

View File

@ -1,5 +1,5 @@
<template> <template>
<v-popover class="filter-container"> <Tooltip class="filter-container">
<div class="filter"> <div class="filter">
<Icon icon="antenna" /> <Icon icon="antenna" />
@ -14,6 +14,7 @@
>Channels</div> >Channels</div>
</div> </div>
<template v-slot:popover>
<div slot="popover"> <div slot="popover">
<router-link <router-link
class="filter-clear" class="filter-clear"
@ -67,7 +68,8 @@
</li> </li>
</ul> </ul>
</div> </div>
</v-popover> </template>
</Tooltip>
</template> </template>
<script> <script>

View File

@ -20,7 +20,6 @@
>New</router-link> >New</router-link>
</div> </div>
<!--
<div class="filters"> <div class="filters">
<ActorFilter <ActorFilter
class="filters-filter" class="filters-filter"
@ -40,7 +39,6 @@
:available-tags="availableTags" :available-tags="availableTags"
/> />
</div> </div>
-->
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<v-popover class="filter-container"> <Tooltip class="filter-container">
<div class="filter"> <div class="filter">
<Icon icon="price-tag4" /> <Icon icon="price-tag4" />
@ -14,7 +14,8 @@
>Tags</div> >Tags</div>
</div> </div>
<div slot="popover"> <template v-slot:tooltip>
<div>
<select <select
v-model="mode" v-model="mode"
class="filter-mode" class="filter-mode"
@ -59,7 +60,8 @@
</li> </li>
</ul> </ul>
</div> </div>
</v-popover> </template>
</Tooltip>
</template> </template>
<script> <script>

View File

@ -82,7 +82,7 @@
@click.stop="toggleSidebar" @click.stop="toggleSidebar"
><Icon icon="menu" /></div> ><Icon icon="menu" /></div>
<v-popover> <Tooltip>
<div class="header-account"> <div class="header-account">
<div class="account"> <div class="account">
<Icon <Icon
@ -92,7 +92,7 @@
</div> </div>
</div> </div>
<template v-slot:popover> <template v-slot:tooltip>
<div class="menu"> <div class="menu">
<ul class="menu-items noselect"> <ul class="menu-items noselect">
<li class="menu-item disabled"> <li class="menu-item disabled">
@ -149,11 +149,11 @@
</ul> </ul>
</div> </div>
</template> </template>
</v-popover> </Tooltip>
<Search class="search-full" /> <Search class="search-full" />
<v-popover <Tooltip
class="search-compact" class="search-compact"
:open="searching" :open="searching"
@show="searching = true" @show="searching = true"
@ -167,12 +167,12 @@
/></button> /></button>
<Search <Search
slot="popover" slot="tooltip"
:searching="searching" :searching="searching"
class="compact" class="compact"
@search="searching = false" @search="searching = false"
/> />
</v-popover> </Tooltip>
</div> </div>
</header> </header>
</template> </template>

View File

@ -4,24 +4,34 @@
<slot /> <slot />
</div> </div>
<teleport to="body">
<div class="tooltip"> <div class="tooltip">
<div class="tooltip-wrapper"> <div class="tooltip-wrapper">
<slot name="popover" /> <slot name="tooltip" />
</div> </div>
</div> </div>
</teleport>
</div> </div>
</template> </template>
<script>
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
.tooltip-container { .tooltip-container {
position: relative; position: relative;
font-size: 1rem; font-size: 1rem;
} }
.tooltip-frame {
position: fixed;
}
.tooltip { .tooltip {
position: absolute; position: absolute;
z-index: 10; z-index: 10;
top: 2rem; top: 2rem;
background: var(--background); background: var(--background-light);
} }
</style> </style>

View File

@ -12,6 +12,9 @@ $breakpoint4: 1500px;
--text-dark: #222; --text-dark: #222;
--text-light: #fff; --text-light: #fff;
--background-light: #fff;
--background-dark: #222;
--darken: rgba(0, 0, 0, .5); --darken: rgba(0, 0, 0, .5);
--darken-strong: rgba(0, 0, 0, .7); --darken-strong: rgba(0, 0, 0, .7);
--darken-extreme: rgba(0, 0, 0, .9); --darken-extreme: rgba(0, 0, 0, .9);
@ -40,7 +43,7 @@ $breakpoint4: 1500px;
--text: #222; --text: #222;
--text-contrast: #fff; --text-contrast: #fff;
--background: #fff; --background: var(--background-light);
--background-dim: #fafafa; --background-dim: #fafafa;
--background-soft: #fdfdfd; --background-soft: #fdfdfd;
@ -71,7 +74,7 @@ $breakpoint4: 1500px;
--text: #fff; --text: #fff;
--text-contrast: #222; --text-contrast: #222;
--background: #222; --background: var(--background-dark);
--background-dim: #181818; --background-dim: #181818;
--background-soft: #111; --background-soft: #111;

View File

@ -1,4 +1,13 @@
function initUiObservers(store, _router) { function initUiObservers(store, _router) {
const body = document.querySelector('body');
body.classList.add(store.state.ui.theme);
store.watch(state => state.ui.theme, (newTheme, oldTheme) => {
body.classList.add(newTheme);
body.classList.remove(oldTheme);
});
document.addEventListener('keypress', (event) => { document.addEventListener('keypress', (event) => {
if (event.target.tagName === 'INPUT') { if (event.target.tagName === 'INPUT') {
return; return;