diff --git a/webapp/components/_new/features/SearchResults/SearchResults.story.js b/webapp/components/_new/features/SearchResults/SearchResults.story.js deleted file mode 100644 index b533e882f..000000000 --- a/webapp/components/_new/features/SearchResults/SearchResults.story.js +++ /dev/null @@ -1,148 +0,0 @@ -import { storiesOf } from '@storybook/vue' -import { withA11y } from '@storybook/addon-a11y' -import SearchResults from './SearchResults' -import TabNavigation from '~/components/_new/generic/TabNavigation/OldTabNavigation' -import PostTeaser from '~/components/PostTeaser/PostTeaser' -import UserTeaser from '~/components/UserTeaser/UserTeaser' -import helpers from '~/storybook/helpers' -import faker from 'faker' -import { post } from '~/components/PostTeaser/PostTeaser.story.js' -import { user } from '~/components/UserTeaser/UserTeaser.story.js' - -helpers.init() - -const postMock = (fields) => { - return { - ...post, - id: faker.random.uuid(), - createdAt: faker.date.past(), - updatedAt: faker.date.recent(), - deleted: false, - disabled: false, - typename: 'Post', - ...fields, - } -} - -const userMock = (fields) => { - return { - ...user, - id: faker.random.uuid(), - createdAt: faker.date.past(), - updatedAt: faker.date.recent(), - deleted: false, - disabled: false, - typename: 'User', - ...fields, - } -} - -const posts = [ - postMock(), - postMock({ author: user }), - postMock({ title: faker.lorem.sentence() }), - postMock({ contentExcerpt: faker.lorem.paragraph() }), - postMock({ author: user }), - postMock({ title: faker.lorem.sentence() }), - postMock({ author: user }), -] - -const users = [ - userMock(), - userMock({ slug: 'louie-rider', name: 'Louie Rider' }), - userMock({ slug: 'louicinda-johnson', name: 'Louicinda Jonhson' }), - userMock({ slug: 'sam-louie', name: 'Sam Louie' }), - userMock({ slug: 'loucette', name: 'Loucette Rider' }), - userMock({ slug: 'louis', name: 'Louis' }), - userMock({ slug: 'louanna', name: 'Louanna' }), -] - -storiesOf('SearchResults', module) - .addDecorator(withA11y) - .addDecorator(helpers.layout) - .add('given users', () => ({ - components: { TabNavigation, PostTeaser, UserTeaser }, - store: helpers.store, - data: () => ({ - searchResults: users, - activeTab: 'users', - }), - computed: { - posts() { - return [] - }, - users() { - return this.searchResults - }, - activeResources() { - if (this.activeTab === 'posts') return this.posts - else if (this.activeTab === 'users') return this.users - }, - tabOptions() { - return [ - { type: 'posts', title: `0 Posts` }, - { type: 'users', title: `${users.length} Users` }, - ] - }, - }, - template: `
- -
-
    -
  • - - - - -
  • -
-
-
`, - })) - .add('given posts', () => ({ - components: { TabNavigation, PostTeaser, UserTeaser, SearchResults }, - store: helpers.store, - data: () => ({ - searchResults: posts, - activeTab: 'posts', - }), - computed: { - posts() { - return this.searchResults - }, - users() { - return [] - }, - activeResources() { - if (this.activeTab === 'posts') return this.posts - else if (this.activeTab === 'users') return this.users - }, - tabOptions() { - return [ - { type: 'posts', title: `${posts.length} Posts` }, - { type: 'users', title: `0 Users` }, - ] - }, - }, - template: `
- -
-
    -
  • - - - - -
  • -
-
-
`, - })) diff --git a/webapp/components/_new/generic/TabNavigation/OldTabNavigation.vue b/webapp/components/_new/generic/TabNavigation/OldTabNavigation.vue deleted file mode 100644 index d0f0d51b5..000000000 --- a/webapp/components/_new/generic/TabNavigation/OldTabNavigation.vue +++ /dev/null @@ -1,74 +0,0 @@ - - - - - diff --git a/webapp/components/_new/generic/TabNavigation/TabNavigation.spec.js b/webapp/components/_new/generic/TabNavigation/TabNavigation.spec.js index 8ab7dfe05..76ce9665a 100644 --- a/webapp/components/_new/generic/TabNavigation/TabNavigation.spec.js +++ b/webapp/components/_new/generic/TabNavigation/TabNavigation.spec.js @@ -19,19 +19,19 @@ describe('TabNavigation', () => { tabs: [ { type: 'Post', - title: 'Post', + title: 'Posts', count: 12, disabled: false, }, { type: 'User', - title: 'User', + title: 'Users', count: 9, disabled: false, }, { type: 'Hashtag', - title: 'Hashtag', + title: 'Hashtags', count: 0, disabled: true, }, diff --git a/webapp/components/_new/generic/TabNavigation/TabNavigator.story.js b/webapp/components/_new/generic/TabNavigation/TabNavigator.story.js new file mode 100644 index 000000000..498ead5a4 --- /dev/null +++ b/webapp/components/_new/generic/TabNavigation/TabNavigator.story.js @@ -0,0 +1,187 @@ +import { storiesOf } from '@storybook/vue' +import { withA11y } from '@storybook/addon-a11y' +import HcEmpty from '~/components/Empty/Empty' +import MasonryGrid from '~/components/MasonryGrid/MasonryGrid' +import MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem' +import PostTeaser from '~/components/PostTeaser/PostTeaser' +import TabNavigation from '~/components/_new/generic/TabNavigation/TabNavigation' +import UserTeaser from '~/components/UserTeaser/UserTeaser' +import HcHashtag from '~/components/Hashtag/Hashtag' +import helpers from '~/storybook/helpers' +import faker from 'faker' +import { post } from '~/components/PostTeaser/PostTeaser.story.js' +import { user } from '~/components/UserTeaser/UserTeaser.story.js' + +helpers.init() + +const postMock = (fields) => { + return { + ...post, + id: faker.random.uuid(), + createdAt: faker.date.past(), + updatedAt: faker.date.recent(), + deleted: false, + disabled: false, + typename: 'Post', + ...fields, + } +} + +const userMock = (fields) => { + return { + ...user, + id: faker.random.uuid(), + createdAt: faker.date.past(), + updatedAt: faker.date.recent(), + deleted: false, + disabled: false, + typename: 'User', + ...fields, + } +} + +const posts = [ + postMock(), + postMock({ author: user }), + postMock({ title: faker.lorem.sentence() }), + postMock({ contentExcerpt: faker.lorem.paragraph() }), + postMock({ author: user }), + postMock({ title: faker.lorem.sentence() }), + postMock({ author: user }), +] + +const users = [ + userMock(), + userMock({ slug: 'louie-rider', name: 'Louie Rider' }), + userMock({ slug: 'louicinda-johnson', name: 'Louicinda Jonhson' }), + userMock({ slug: 'sam-louie', name: 'Sam Louie' }), + userMock({ slug: 'loucette', name: 'Loucette Rider' }), + userMock({ slug: 'louis', name: 'Louis' }), + userMock({ slug: 'louanna', name: 'Louanna' }), +] + +storiesOf('TabNavigator', module) + .addDecorator(withA11y) + .addDecorator(helpers.layout) + .add('given search results of posts, users, hashtags', () => ({ + components: { + TabNavigation, + HcEmpty, + MasonryGrid, + MasonryGridItem, + PostTeaser, + UserTeaser, + HcHashtag, + }, + store: helpers.store, + data: () => ({ + posts: posts, + users: users, + hashtags: [], + + postCount: posts.length, + userCount: users.length, + hashtagCount: 0, + + activeTab: 'Post', + }), + computed: { + activeResources() { + if (this.activeTab === 'Post') return this.posts + if (this.activeTab === 'User') return this.users + if (this.activeTab === 'Hashtag') return this.hashtags + return [] + }, + activeResourceCount() { + if (this.activeTab === 'Post') return this.postCount + if (this.activeTab === 'User') return this.userCount + if (this.activeTab === 'Hashtag') return this.hashtagCount + return 0 + }, + tabOptions() { + return [ + { + type: 'Post', + title: this.$t('search.heading.Post', {}, this.postCount), + count: this.postCount, + disabled: this.postCount === 0, + }, + { + type: 'User', + title: this.$t('search.heading.User', {}, this.userCount), + count: this.userCount, + disabled: this.userCount === 0, + }, + { + type: 'Hashtag', + title: this.$t('search.heading.Tag', {}, this.hashtagCount), + count: this.hashtagCount, + disabled: this.hashtagCount === 0, + }, + ] + }, + searchCount() { + return this.postCount + this.userCount + this.hashtagCount + }, + }, + methods: { + switchTab(tabType) { + if (this.activeTab !== tabType) { + this.activeTab = tabType + } + }, + }, + template: ` +
+ + + + + + + + + + + + + + + + + +
`, + }))