diff --git a/webapp/components/_new/features/SearchResults/SearchResults.story.js b/webapp/components/_new/features/SearchResults/SearchResults.story.js new file mode 100644 index 000000000..1c8c9cb08 --- /dev/null +++ b/webapp/components/_new/features/SearchResults/SearchResults.story.js @@ -0,0 +1,148 @@ +import { storiesOf } from '@storybook/vue' +import { withA11y } from '@storybook/addon-a11y' +import SearchResults from './SearchResults' +import TabNavigation from '~/components/_new/generic/TabNavigation/TabNavigation' +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/features/SearchResults/SearchResults.vue b/webapp/components/_new/features/SearchResults/SearchResults.vue new file mode 100644 index 000000000..e6d575875 --- /dev/null +++ b/webapp/components/_new/features/SearchResults/SearchResults.vue @@ -0,0 +1,88 @@ + + + diff --git a/webapp/components/_new/generic/TabNavigation/TabNavigation.vue b/webapp/components/_new/generic/TabNavigation/TabNavigation.vue index c20a53dba..41544a3e9 100644 --- a/webapp/components/_new/generic/TabNavigation/TabNavigation.vue +++ b/webapp/components/_new/generic/TabNavigation/TabNavigation.vue @@ -1,7 +1,7 @@