Skip to content

feat: 🍰 Add Group To User Teaser, On Post Page, And On News Feed Etc. #5502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webapp/components/PostTeaser/PostTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img :src="post.image | proxyApiUrl" class="image" />
</template>
<client-only>
<user-teaser :user="post.author" :date-time="post.createdAt" />
<user-teaser :user="post.author" :group="post.group" :date-time="post.createdAt" />
</client-only>
<h2 class="title hyphenate-text">{{ post.title }}</h2>
<!-- TODO: replace editor content with tiptap render view -->
Expand Down
55 changes: 54 additions & 1 deletion webapp/components/UserTeaser/UserTeaser.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ export const user = {
followedBy: [],
socialMedia: [],
}
export const group = {
id: 'g2',
name: 'Yoga Practice',
slug: 'yoga-practice',
about: null,
description: `<h3>What Is yoga?</h3><p>Yoga is not just about practicing asanas. It's about how we do it.</p><p class="">And practicing asanas doesn't have to be yoga, it can be more athletic than yogic.</p><h3>What makes practicing asanas yogic?</h3><p class="">The important thing is:</p><ul><li><p>Use the exercises (consciously) for your personal development.</p></li></ul>`,
descriptionExcerpt: `<h3>What Is yoga?</h3><p>Yoga is not just about practicing asanas. It's about how we do it.</p><p>And practicing asanas doesn't have to be yoga, it can be more athletic than yogic.</p><h3>What makes practicing asanas yogic?</h3><p>The important thing is:</p><ul><li><p>Use the exercises …</p></li></ul>`,
groupType: 'public',
actionRadius: 'interplanetary',
categories: [
{
id: 'cat4',
icon: 'psyche',
name: 'psyche',
slug: 'psyche',
description: 'Seele, Gefühle, Glück',
},
{
id: 'cat5',
icon: 'movement',
name: 'body-and-excercise',
slug: 'body-and-excercise',
description: 'Sport, Yoga, Massage, Tanzen, Entspannung',
},
{
id: 'cat17',
icon: 'spirituality',
name: 'spirituality',
slug: 'spirituality',
description: 'Religion, Werte, Ethik',
},
],
locationName: null,
location: null,
}

storiesOf('UserTeaser', module)
.addDecorator(withA11y)
Expand All @@ -68,7 +103,7 @@ storiesOf('UserTeaser', module)
}),
template: '<user-teaser :user="user" />',
}))
.add('with Date', () => ({
.add('with date', () => ({
components: { UserTeaser },
store: helpers.store,
data: () => ({
Expand Down Expand Up @@ -98,3 +133,21 @@ storiesOf('UserTeaser', module)
}),
template: '<user-teaser :user="user" :date-time="new Date()" />',
}))
.add('with group and date', () => ({
components: { UserTeaser },
store: helpers.store,
data: () => ({
user,
group,
}),
template: '<user-teaser :user="user" :group="group" :date-time="new Date()" />',
}))
.add('with group and date – wide', () => ({
components: { UserTeaser },
store: helpers.store,
data: () => ({
user,
group,
}),
template: '<user-teaser :user="user" :group="group" wide :date-time="new Date()" />',
}))
83 changes: 65 additions & 18 deletions webapp/components/UserTeaser/UserTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,58 @@
<span class="info anonymous">{{ $t('profile.userAnonym') }}</span>
</div>
<div v-else :class="[{ 'disabled-content': user.disabled }]" placement="top-start">
<nuxt-link :to="userLink" :class="['user-teaser']">
<profile-avatar v-if="showAvatar" :profile="user" size="small" />
<div class="info">
<span class="text">
<span class="slug">{{ userSlug }}</span>
<span v-if="dateTime">{{ userName }}</span>
</span>
<span v-if="dateTime" class="text">
<div :class="['user-teaser']">
<nuxt-link :to="userLink">
<profile-avatar v-if="showAvatar" :profile="user" size="small" />
</nuxt-link>
<div class="info flex-direction-column">
<div :class="wide ? 'flex-direction-row' : 'flex-direction-column'">
<nuxt-link :to="userLink">
<span class="text">
<span class="slug">{{ userSlug }}</span>
<span v-if="!userOnly" class="name">{{ userName }}</span>
</span>
</nuxt-link>
<span v-if="wide">&nbsp;</span>
<span v-if="group">
<span class="text">
{{ $t('group.in') }}
</span>
<nuxt-link :to="groupLink">
<span class="text">
<span class="slug">{{ groupSlug }}</span>
<span v-if="!userOnly" class="name">{{ groupName }}</span>
</span>
</nuxt-link>
</span>
</div>
<span v-if="!userOnly" class="text">
<base-icon name="clock" />
<hc-relative-date-time :date-time="dateTime" />
<relative-date-time :date-time="dateTime" />
<slot name="dateTime"></slot>
</span>
<span v-else class="text">{{ userName }}</span>
</div>
</nuxt-link>
</div>
</div>
</template>

<script>
import { mapGetters } from 'vuex'

import HcRelativeDateTime from '~/components/RelativeDateTime'
import RelativeDateTime from '~/components/RelativeDateTime'
import ProfileAvatar from '~/components/_new/generic/ProfileAvatar/ProfileAvatar'

export default {
name: 'UserTeaser',
components: {
HcRelativeDateTime,
RelativeDateTime,
ProfileAvatar,
},
props: {
user: { type: Object, default: null },
group: { type: Object, default: null },
wide: { type: Boolean, default: false },
showAvatar: { type: Boolean, default: true },
dateTime: { type: [Date, String], default: null },
showPopover: { type: Boolean, default: true },
Expand Down Expand Up @@ -64,6 +84,22 @@ export default {
const { name } = this.user || {}
return name || this.$t('profile.userAnonym')
},
userOnly() {
return !this.dateTime && !this.group
},
groupLink() {
const { id, slug } = this.group
if (!(id && slug)) return ''
return { name: 'group-id-slug', params: { slug, id } }
},
groupSlug() {
const { slug } = this.group || {}
return slug && `&${slug}`
},
groupName() {
const { name } = this.group || {}
return name || this.$t('profile.userAnonym')
},
},
methods: {
optimisticFollow({ followedByCurrentUser }) {
Expand Down Expand Up @@ -93,17 +129,11 @@ export default {
}

> .info {
display: flex;
flex-direction: column;
justify-content: center;
padding-left: $space-xx-small;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

color: $text-color-soft;
font-size: $font-size-small;

&.anonymous {
font-size: $font-size-base;
}
Expand All @@ -112,6 +142,23 @@ export default {
color: $color-primary;
font-size: $font-size-base;
}

.name {
color: $text-color-soft;
font-size: $font-size-small;
}
}

.flex-direction-column {
display: flex;
flex-direction: column;
justify-content: center;
}

.flex-direction-row {
display: flex;
flex-direction: row;
justify-content: center;
}

.text {
Expand Down
10 changes: 10 additions & 0 deletions webapp/graphql/PostQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ export const filterPosts = (i18n) => {
...userCounts
...locationAndBadges
}
group {
id
name
slug
}
}
}
`
Expand Down Expand Up @@ -99,6 +104,11 @@ export const profilePagePosts = (i18n) => {
...userCounts
...locationAndBadges
}
group {
id
name
slug
}
}
}
`
Expand Down
1 change: 1 addition & 0 deletions webapp/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@
"general": "Allgemein",
"goal": "Ziel der Gruppe",
"groupCreated": "Die Gruppe wurde angelegt!",
"in": "in",
"joinLeaveButton": {
"iAmMember": "Bin Mitglied",
"join": "Beitreten"
Expand Down
1 change: 1 addition & 0 deletions webapp/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@
"general": "General",
"goal": "Goal of group",
"groupCreated": "The group was created!",
"in": "in",
"joinLeaveButton": {
"iAmMember": "I'm a member",
"join": "Join"
Expand Down
48 changes: 24 additions & 24 deletions webapp/pages/group/_id/_slug.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})

describe('displays no(!) group location – because is "null"', () => {
Expand Down Expand Up @@ -397,8 +397,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})

describe('displays no(!) group location – because is "null"', () => {
Expand Down Expand Up @@ -510,8 +510,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})

describe('displays no(!) group location – because is "null"', () => {
Expand Down Expand Up @@ -623,8 +623,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})

describe('displays no(!) group location – because is "null"', () => {
Expand Down Expand Up @@ -740,8 +740,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})

describe('displays group location', () => {
Expand Down Expand Up @@ -857,8 +857,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})

describe('displays group location', () => {
Expand Down Expand Up @@ -974,8 +974,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})

describe('displays group location', () => {
Expand Down Expand Up @@ -1091,8 +1091,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})

describe('displays group location', () => {
Expand Down Expand Up @@ -1212,8 +1212,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&investigative-journalism')
})

describe('displays group location', () => {
Expand Down Expand Up @@ -1332,8 +1332,8 @@ describe('GroupProfileSlug', () => {
})

it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&investigative-journalism')
})

describe('displays group location', () => {
Expand Down Expand Up @@ -1452,8 +1452,8 @@ describe('GroupProfileSlug', () => {
})

it('has no(!) group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('&investigative-journalism')
})

describe('displays not(!) group location', () => {
Expand Down Expand Up @@ -1560,8 +1560,8 @@ describe('GroupProfileSlug', () => {
})

it('has no(!) group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('&investigative-journalism')
})

describe('displays not(!) group location', () => {
Expand Down
Loading