Merge pull request #5943 from Ocelot-Social-Community/5907-button-for-writing-new-post-more-to-the-top

refactor(webapp): refacchange postion add content button, refactor mobile filter menu
This commit is contained in:
Moriz Wahl 2023-02-08 16:44:00 +01:00 committed by GitHub
commit 3dfcf4df9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 168 additions and 88 deletions

View File

@ -6,7 +6,7 @@
:filled="!filteredCategoryIds.length"
:label="$t('filter-menu.all')"
icon="check"
@click="resetCategories"
@click="setResetCategories"
/>
</li>
<li class="item item-save-topics">
@ -47,9 +47,6 @@ export default {
LabeledButton,
},
mixins: [SortCategories],
props: {
showMobileMenu: { type: Boolean, default: false },
},
data() {
return {
categories: [],
@ -65,6 +62,10 @@ export default {
resetCategories: 'posts/RESET_CATEGORIES',
toggleCategory: 'posts/TOGGLE_CATEGORY',
}),
setResetCategories() {
this.resetCategories()
this.$emit('showFilterMenu')
},
saveCategories() {
this.$apollo
.mutate({
@ -72,6 +73,7 @@ export default {
variables: { activeCategories: this.filteredCategoryIds },
})
.then(() => {
this.$emit('showFilterMenu')
this.$toast.success(this.$t('filter-menu.save.success'))
})
.catch(() => {

View File

@ -11,7 +11,7 @@
<base-icon class="dropdown-arrow" name="angle-down" />
</base-button>
<template slot="popover">
<filter-menu-component :showMobileMenu="showMobileMenu" />
<filter-menu-component />
</template>
</dropdown>
</template>
@ -29,7 +29,6 @@ export default {
props: {
placement: { type: String },
offset: { type: [String, Number] },
showMobileMenu: { type: Boolean, default: false },
},
computed: {
...mapGetters({

View File

@ -3,7 +3,7 @@
<div class="filter-menu-options">
<h2 class="title">{{ $t('filter-menu.filter-by') }}</h2>
<following-filter />
<categories-filter v-if="categoriesActive" :showMobileMenu="showMobileMenu" />
<categories-filter v-if="categoriesActive" @showFilterMenu="$emit('showFilterMenu')" />
</div>
<div class="filter-menu-options">
<h2 class="title">{{ $t('filter-menu.order-by') }}</h2>
@ -28,9 +28,6 @@ export default {
categoriesActive: this.$env.CATEGORIES_ACTIVE,
}
},
props: {
showMobileMenu: { type: Boolean, default: false },
},
}
</script>

View File

@ -149,7 +149,7 @@
style="flex-grow: 0; flex-basis: auto; padding: 20px 0"
>
<client-only>
<filter-menu v-show="showFilterMenuDropdown" :showMobileMenu="showMobileMenu" />
<filter-menu v-if="showFilterMenuDropdown && SHOW_CONTENT_FILTER_HEADER_MENU" />
</client-only>
</ds-flex-item>
</ds-flex>
@ -179,7 +179,9 @@
style="text-align: center"
>
<client-only>
<group-button />
<div @click="toggleMobileMenuView">
<group-button />
</div>
</client-only>
</ds-flex-item>
<!-- map button -->

View File

@ -1,2 +1,3 @@
export const first = 12
export const offset = 0
export const POST_ADD_BUTTON_POSITION_TOP = true

View File

@ -5,7 +5,7 @@
</div>
<ds-container>
<div class="main-container">
<nuxt :showMobileMenu="showMobileMenu" />
<nuxt />
</div>
</ds-container>
<page-footer v-if="!isMobile" />

View File

@ -1,64 +1,89 @@
<template>
<div>
<!-- create post -->
<div :class="POST_ADD_BUTTON_POSITION_TOP ? 'box-add-button-top' : ''">
<client-only>
<nuxt-link :to="{ name: 'post-create' }" :class="{ 'hide-filter': hideByScroll }">
<base-button
v-tooltip="{
content: $t('contribution.newPost'),
placement: 'left',
}"
class="post-add-button"
:class="POST_ADD_BUTTON_POSITION_TOP ? 'post-add-button-top' : 'post-add-button-bottom'"
icon="plus"
filled
circle
/>
</nuxt-link>
</client-only>
</div>
<masonry-grid>
<ds-grid-item v-if="hashtag" :row-span="2" column-span="fullWidth">
<hashtags-filter :hashtag="hashtag" @clearSearch="clearSearch" />
</ds-grid-item>
<!--Filter Button-->
<ds-grid-item
v-if="categoriesActive && SHOW_CONTENT_FILTER_MASONRY_GRID"
:row-span="1"
column-span="fullWidth"
class="filterButtonMenu"
:class="{ 'hide-filter': hideFilter }"
class="top-filter-menu"
>
<base-button
class="my-filter-button"
v-if="!postsFilter['categories_some'] && !postsFilter['author']"
right
@click="showFilter = !showFilter"
filled
>
{{ $t('contribution.filterMasonryGrid.noFilter') }}
&nbsp;
<base-icon class="my-filter-button" :name="filterButtonIcon"></base-icon>
</base-button>
<span v-if="postsFilter['categories_some']">
<base-button class="my-filter-button" right @click="showFilter = !showFilter" filled>
{{ $t('contribution.filterMasonryGrid.myTopics') }}
</base-button>
<base-button
class="filter-remove"
@click="resetCategories"
icon="close"
:title="$t('filter-menu.deleteFilter')"
style="margin-left: -8px"
filled
/>
</span>
<span v-if="postsFilter['author']">
<base-button class="my-filter-button" right @click="showFilter = !showFilter" filled>
{{ $t('contribution.filterMasonryGrid.myFriends') }}
</base-button>
<base-button
class="filter-remove"
@click="resetByFollowed"
icon="close"
:title="$t('filter-menu.deleteFilter')"
style="margin-left: -8px"
filled
/>
</span>
<div class="filterButtonBox">
<div class="filterButtonMenu" :class="{ 'hide-filter': hideByScroll }">
<base-button
class="my-filter-button"
v-if="!postsFilter['categories_some'] && !postsFilter['author']"
right
@click="showFilter = !showFilter"
filled
>
{{ $t('contribution.filterMasonryGrid.noFilter') }}
&nbsp;
<base-icon class="my-filter-button" :name="filterButtonIcon"></base-icon>
</base-button>
<span v-if="postsFilter['categories_some']">
<base-button class="my-filter-button" right @click="showFilter = !showFilter" filled>
{{ $t('contribution.filterMasonryGrid.myTopics') }}
</base-button>
<base-button
class="filter-remove"
@click="resetCategories"
icon="close"
:title="$t('filter-menu.deleteFilter')"
style="margin-left: -8px"
filled
/>
</span>
<span v-if="postsFilter['author']">
<base-button class="my-filter-button" right @click="showFilter = !showFilter" filled>
{{ $t('contribution.filterMasonryGrid.myFriends') }}
</base-button>
<base-button
class="filter-remove"
@click="resetByFollowed"
icon="close"
:title="$t('filter-menu.deleteFilter')"
style="margin-left: -8px"
filled
/>
</span>
<div id="my-filter" v-if="showFilter">
<filter-menu-component :showMobileMenu="showMobileMenu" />
<div id="my-filter" v-if="showFilter">
<div @mouseleave="showFilter = false">
<filter-menu-component @showFilterMenu="showFilterMenu" />
</div>
</div>
</div>
</div>
</ds-grid-item>
<ds-space :margin-bottom="{ base: 'small', md: 'base', lg: 'large' }" />
<ds-grid-item v-if="hashtag" :row-span="2" column-span="fullWidth">
<hashtags-filter :hashtag="hashtag" @clearSearch="clearSearch" />
</ds-grid-item>
<ds-space :margin-bottom="{ base: 'small', md: 'base', lg: 'large' }" />
<!-- donation info -->
<ds-grid-item v-if="showDonations" class="top-info-bar" :row-span="1" column-span="fullWidth">
<donation-info :goal="goal" :progress="progress" />
</ds-grid-item>
<ds-space :margin-bottom="{ base: 'small', md: 'base', lg: 'large' }" />
<!-- news feed -->
<template v-if="hasResults">
<masonry-grid-item
@ -82,21 +107,7 @@
</ds-grid-item>
</template>
</masonry-grid>
<!-- create post -->
<client-only>
<nuxt-link :to="{ name: 'post-create' }">
<base-button
v-tooltip="{
content: $t('contribution.newPost'),
placement: 'left',
}"
class="post-add-button"
icon="plus"
filled
circle
/>
</nuxt-link>
</client-only>
<!-- infinite loading -->
<client-only>
<infinite-loading v-if="hasMore" @infinite="showMoreContributions" />
@ -118,6 +129,7 @@ import { filterPosts } from '~/graphql/PostQuery.js'
import UpdateQuery from '~/components/utils/UpdateQuery'
import FilterMenuComponent from '~/components/FilterMenu/FilterMenuComponent'
import { SHOW_CONTENT_FILTER_MASONRY_GRID } from '~/constants/filter.js'
import { POST_ADD_BUTTON_POSITION_TOP } from '~/constants/posts.js'
export default {
components: {
@ -130,13 +142,10 @@ export default {
FilterMenuComponent,
},
mixins: [postListActions],
props: {
showMobileMenu: { type: Boolean, default: false },
},
data() {
const { hashtag = null } = this.$route.query
return {
hideFilter: false,
hideByScroll: false,
revScrollpos: 0,
showFilter: false,
showDonations: true,
@ -150,6 +159,7 @@ export default {
hashtag,
categoriesActive: this.$env.CATEGORIES_ACTIVE,
SHOW_CONTENT_FILTER_MASONRY_GRID,
POST_ADD_BUTTON_POSITION_TOP,
}
},
computed: {
@ -196,7 +206,7 @@ export default {
toggleCategory: 'posts/TOGGLE_CATEGORY',
}),
showFilterMenu(e) {
if (!e.target.closest('#my-filter') && !e.target.closest('.my-filter-button')) {
if (!e || (!e.target.closest('#my-filter') && !e.target.closest('.my-filter-button'))) {
if (!this.showFilter) return
this.showFilter = false
}
@ -204,14 +214,17 @@ export default {
handleScroll() {
const currentScrollPos = window.pageYOffset
if (this.prevScrollpos > currentScrollPos) {
this.hideFilter = false
this.hideByScroll = false
} else {
this.hideFilter = true
if (!this.showFilter) {
this.hideByScroll = true
}
}
this.prevScrollpos = currentScrollPos
},
beforeDestroy() {
document.removeEventListener('click', this.showFilterMenu)
window.removeEventListener('scroll', this.handleScroll)
},
clearSearch() {
this.$router.push({ path: '/' })
@ -283,13 +296,6 @@ export default {
</script>
<style lang="scss">
#my-filter {
background-color: white;
box-shadow: rgb(189 189 189) 1px 9px 15px 1px;
max-height: 480px;
overflow: auto;
}
.masonry-grid {
display: grid;
grid-gap: 10px;
@ -309,7 +315,11 @@ export default {
display: none;
}
.base-button.--circle.post-add-button {
.box-add-button-top {
float: right;
}
.base-button.--circle.post-add-button-bottom {
height: 54px;
width: 54px;
font-size: 26px;
@ -321,7 +331,18 @@ export default {
box-shadow: $box-shadow-x-large;
}
.top-info-bar {
.base-button.--circle.post-add-button-top {
height: 54px;
width: 54px;
font-size: 26px;
z-index: 100;
position: fixed;
top: 80px;
box-shadow: $box-shadow-x-large;
}
.top-info-bar,
.top-filter-menu {
display: flex;
align-items: center;
}
@ -333,4 +354,62 @@ export default {
border-radius: 7px;
background-color: #f5f4f6;
}
#my-filter {
background-color: white;
box-shadow: rgb(189 189 189) 1px 9px 15px 1px;
max-height: 950px;
overflow: auto;
padding-bottom: 0px;
}
@media screen and (min-height: 401px) {
#my-filter {
max-height: 330px;
}
}
@media screen and (min-height: 501px) {
#my-filter {
max-height: 440px;
}
}
@media screen and (min-height: 601px) {
#my-filter {
max-height: 550px;
}
}
@media screen and (min-height: 701px) {
#my-filter {
max-height: 640px;
}
}
@media screen and (min-height: 801px) {
#my-filter {
max-height: 750px;
}
}
@media screen and (min-height: 950px) {
#my-filter {
max-height: 830px;
}
}
@media screen and (min-height: 1025px) {
#my-filter {
max-height: 870px;
}
}
@media screen and (min-width: 800px) and (min-height: 500px) {
#my-filter {
padding-bottom: 80px;
}
}
@media screen and (max-width: 1200px) {
.box-add-button-top {
padding-right: 40px;
}
.base-button.--circle.post-add-button-top {
height: 44px;
width: 44px;
font-size: 23px;
z-index: 10;
}
}
</style>