Update some event emitters
This commit is contained in:
parent
39e7d27587
commit
7b0806a207
|
|
@ -14,14 +14,14 @@
|
||||||
>
|
>
|
||||||
<current-class
|
<current-class
|
||||||
class="user-header__current-class"
|
class="user-header__current-class"
|
||||||
@click.stop="openSidebar('profile')"
|
@click="openSidebar('profile')"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<user-widget
|
<user-widget
|
||||||
:avatar-url="me.avatarUrl"
|
:avatar-url="me.avatarUrl"
|
||||||
data-cy="header-user-widget"
|
data-cy="header-user-widget"
|
||||||
@click.stop="openSidebar('profile')"
|
@click="openSidebar('profile')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
||||||
|
|
@ -1,70 +1,82 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="{ 'user-widget--is-profile': isProfile }" class="user-widget">
|
<div
|
||||||
<div class="user-widget__avatar" data-cy="user-widget-avatar">
|
:class="{'user-widget--is-profile': isProfile}"
|
||||||
<avatar :avatar-url="avatarUrl" :icon-highlighted="isProfile" />
|
class="user-widget"
|
||||||
|
@click.stop="$emit('click', $event)"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="user-widget__avatar"
|
||||||
|
data-cy="user-widget-avatar"
|
||||||
|
>
|
||||||
|
<avatar
|
||||||
|
:avatar-url="avatarUrl"
|
||||||
|
:icon-highlighted="isProfile"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Avatar from '@/components/profile/Avatar';
|
import Avatar from '@/components/profile/Avatar';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
avatarUrl: {
|
avatarUrl: {
|
||||||
type: String,
|
type: String
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
|
||||||
components: {
|
emits: ['click'],
|
||||||
Avatar,
|
|
||||||
},
|
components: {
|
||||||
computed: {
|
Avatar
|
||||||
isProfile() {
|
|
||||||
return this.$route.meta.isProfile;
|
|
||||||
},
|
},
|
||||||
},
|
computed: {
|
||||||
};
|
isProfile() {
|
||||||
|
return this.$route.meta.isProfile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import '~styles/helpers';
|
@import "~styles/helpers";
|
||||||
|
|
||||||
.user-widget {
|
.user-widget {
|
||||||
color: $color-silver-dark;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
position: relative;
|
|
||||||
// todo: do we need the margin right always? just do it where needed --> content block actions and objecives override this
|
|
||||||
margin-right: $medium-spacing;
|
|
||||||
|
|
||||||
&__popover {
|
|
||||||
top: 40px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__name {
|
|
||||||
padding: 0px $small-spacing;
|
|
||||||
color: $color-silver-dark;
|
color: $color-silver-dark;
|
||||||
font-family: $sans-serif-font-family;
|
display: flex;
|
||||||
}
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
// todo: do we need the margin right always? just do it where needed --> content block actions and objecives override this
|
||||||
|
margin-right: $medium-spacing;
|
||||||
|
|
||||||
&__date {
|
&__popover {
|
||||||
font-family: $sans-serif-font-family;
|
top: 40px;
|
||||||
}
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
&__avatar {
|
&__name {
|
||||||
width: 30px;
|
padding: 0px $small-spacing;
|
||||||
height: 30px;
|
color: $color-silver-dark;
|
||||||
fill: $color-silver-dark;
|
font-family: $sans-serif-font-family;
|
||||||
cursor: pointer;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&--is-profile {
|
&__date {
|
||||||
& > span {
|
font-family: $sans-serif-font-family;
|
||||||
color: $color-brand;
|
}
|
||||||
|
|
||||||
|
&__avatar {
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
fill: $color-silver-dark;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--is-profile {
|
||||||
|
& > span {
|
||||||
|
color: $color-brand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,29 @@
|
||||||
<template>
|
<template>
|
||||||
<span class="current-class" data-cy="current-class-name">{{ currentClassName }}</span>
|
<span
|
||||||
|
class="current-class"
|
||||||
|
data-cy="current-class-name"
|
||||||
|
@click.stop="$emit('click', $event)"
|
||||||
|
>{{ currentClassName }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import me from '@/mixins/me';
|
import me from '@/mixins/me';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [me],
|
emits: ['click'],
|
||||||
};
|
mixins: [me],
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import '@/styles/_variables.scss';
|
@import "@/styles/_variables.scss";
|
||||||
@import '@/styles/_mixins.scss';
|
@import "@/styles/_mixins.scss";
|
||||||
|
|
||||||
.current-class {
|
.current-class {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
@include regular-text;
|
@include regular-text;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,29 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
todo:
|
||||||
|
there is a special interaction with nested elements where the parent has a @click event:
|
||||||
|
the parent triggers the event, something happens, but the click event bubbles to the child element.
|
||||||
|
If the event is then used to open some kind of sidebar or modal that has the `click-outside` propert, t
|
||||||
|
he bubbled event will be outside of it, thereby closing it.
|
||||||
|
|
||||||
|
example:
|
||||||
|
<div
|
||||||
|
class="sidebar"
|
||||||
|
v-if="showSidebar"
|
||||||
|
v-click-outside="showSidebar=false"
|
||||||
|
>
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a class="sidebar-toggle" @click="showSidebar=true">
|
||||||
|
<span>Hello</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
FIX:
|
||||||
|
In this example, setting the event on the a-tag as `@click.stop` will solve the problem
|
||||||
|
*/
|
||||||
export default {
|
export default {
|
||||||
unmounted(el: HTMLElement) {
|
unmounted(el: HTMLElement) {
|
||||||
document.body.removeEventListener('click', el.clickOutsideEvent);
|
document.body.removeEventListener('click', el.clickOutsideEvent);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue