diff --git a/webapp/components/CommentList/CommentList.story.js b/webapp/components/CommentList/CommentList.story.js new file mode 100644 index 000000000..1f96b1ad0 --- /dev/null +++ b/webapp/components/CommentList/CommentList.story.js @@ -0,0 +1,45 @@ +import { storiesOf } from '@storybook/vue' +import { withA11y } from '@storybook/addon-a11y' +import HcCommentList from './CommentList.vue' +import helpers from '~/storybook/helpers' +import faker from 'faker' + +helpers.init() + +const commentMock = fields => { + return { + id: faker.random.uuid(), + title: faker.lorem.sentence(), + content: faker.lorem.paragraph(), + createdAt: faker.date.past(), + updatedAt: faker.date.recent(), + deleted: false, + disabled: false, + ...fields, + } +} + +const comments = [ + commentMock(), + commentMock(), + commentMock(), + commentMock(), + commentMock(), + commentMock(), + commentMock(), + commentMock(), + commentMock(), + commentMock(), +] + +storiesOf('CommentList', module) + .addDecorator(withA11y) + .addDecorator(helpers.layout) + .add('given 10 comments', () => ({ + components: { HcCommentList }, + store: helpers.store, + data: () => ({ + post: { comments }, + }), + template: ``, + })) diff --git a/webapp/components/LoginForm/LoginForm.story.js b/webapp/components/LoginForm/LoginForm.story.js new file mode 100644 index 000000000..618b2556c --- /dev/null +++ b/webapp/components/LoginForm/LoginForm.story.js @@ -0,0 +1,75 @@ +import { storiesOf } from '@storybook/vue' +import { withA11y } from '@storybook/addon-a11y' +import { action } from '@storybook/addon-actions' +import Vuex from 'vuex' +import helpers from '~/storybook/helpers' +import LoginForm from './LoginForm.vue' + +helpers.init() + +const createStore = ({ loginSuccess }) => { + return new Vuex.Store({ + modules: { + auth: { + namespaced: true, + state: () => ({ + pending: false, + }), + mutations: { + SET_PENDING(state, pending) { + state.pending = pending + }, + }, + getters: { + pending(state) { + return !!state.pending + }, + }, + actions: { + async login({ commit, dispatch }, args) { + action('Vuex action `auth/login`')(args) + return new Promise((resolve, reject) => { + commit('SET_PENDING', true) + setTimeout(() => { + commit('SET_PENDING', false) + if (loginSuccess) { + resolve(loginSuccess) + } else { + reject(new Error('Login unsuccessful')) + } + }, 1000) + }) + }, + }, + }, + }, + }) +} + +storiesOf('LoginForm', module) + .addDecorator(withA11y) + .addDecorator(helpers.layout) + .add('successful login', () => { + return { + components: { LoginForm }, + store: createStore({ loginSuccess: true }), + methods: { + handleSuccess() { + action('Login successful!')() + }, + }, + template: ``, + } + }) + .add('unsuccessful login', () => { + return { + components: { LoginForm }, + store: createStore({ loginSuccess: false }), + methods: { + handleSuccess() { + action('Login successful!')() + }, + }, + template: ``, + } + }) diff --git a/webapp/components/LoginForm/LoginForm.vue b/webapp/components/LoginForm/LoginForm.vue new file mode 100644 index 000000000..91693ed4b --- /dev/null +++ b/webapp/components/LoginForm/LoginForm.vue @@ -0,0 +1,121 @@ + + + + + {{ $t('quotes.african.quote') }} + - {{ $t('quotes.african.author') }} + + + + + + + + + + + + + + + + {{ $t('login.moreInfo') }} + + + + {{ $t('login.copy') }} + + + + + + {{ $t('login.forgotPassword') }} + + + {{ $t('login.login') }} + + + {{ $t('login.no-account') }} + {{ $t('login.register') }} + + + + + + + + + + + diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 784a0fcfc..fdbf93e12 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -112,7 +112,8 @@ "moreInfoURL": "https://human-connection.org", "moreInfoHint": "zur Präsentationsseite", "hello": "Hallo", - "success": "Du bist eingeloggt!" + "success": "Du bist eingeloggt!", + "failure": "Fehlerhafte E-Mail-Adresse oder Passwort." }, "editor": { "placeholder": "Schreib etwas Inspirierendes …", diff --git a/webapp/locales/en.json b/webapp/locales/en.json index abfad576d..54709cab8 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -113,7 +113,8 @@ "moreInfoURL": "https://human-connection.org/en/", "moreInfoHint": "to the presentation page", "hello": "Hello", - "success": "You are logged in!" + "success": "You are logged in!", + "failure": "Incorrect email address or password." }, "editor": { "placeholder": "Leave your inspirational thoughts …", diff --git a/webapp/package.json b/webapp/package.json index 4440ba661..2710eee8a 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -12,7 +12,7 @@ "scripts": { "dev": "nuxt", "dev:styleguide": "cross-env STYLEGUIDE_DEV=true yarn run dev", - "storybook": "start-storybook -p 3002 -c storybook/", + "storybook": "start-storybook -p 3002 -s ./static -c storybook/", "build": "nuxt build", "start": "nuxt start", "generate:maintenance": "nuxt generate -c nuxt.config.maintenance.js", @@ -121,6 +121,7 @@ "eslint-plugin-promise": "~4.2.1", "eslint-plugin-standard": "~4.0.1", "eslint-plugin-vue": "~5.2.3", + "faker": "^4.1.0", "flush-promises": "^1.0.2", "fuse.js": "^3.4.5", "identity-obj-proxy": "^3.0.0", diff --git a/webapp/pages/login.vue b/webapp/pages/login.vue index 971754870..e969fe46f 100644 --- a/webapp/pages/login.vue +++ b/webapp/pages/login.vue @@ -1,138 +1,27 @@ - - - - {{ $t('quotes.african.quote') }} - - {{ $t('quotes.african.author') }} - - - - - - - - - - - - - - - - {{ $t('login.moreInfo') }} - - - - {{ $t('login.copy') }} - - - - - - {{ $t('login.forgotPassword') }} - - - {{ $t('login.login') }} - - - {{ $t('login.no-account') }} - {{ $t('login.register') }} - - - - - - + - - diff --git a/webapp/storybook/helpers.js b/webapp/storybook/helpers.js index 790a10f78..de988ab81 100644 --- a/webapp/storybook/helpers.js +++ b/webapp/storybook/helpers.js @@ -3,7 +3,9 @@ import Vuex from 'vuex' import vuexI18n from 'vuex-i18n/dist/vuex-i18n.umd.js' import Styleguide from '@human-connection/styleguide' import Filters from '~/plugins/vue-filters' +import IziToast from '~/plugins/izi-toast' import layout from './layout.vue' +import locales from '~/locales/index.js' import '~/plugins/v-tooltip' @@ -12,10 +14,13 @@ const helpers = { Vue.use(Vuex) Vue.use(Styleguide) Vue.use(Filters) + Vue.use(IziToast) Vue.use(vuexI18n.plugin, helpers.store) - Vue.i18n.add('en', require('~/locales/en.json')) - Vue.i18n.add('de', require('~/locales/de.json')) + locales.forEach(({ code }) => { + Vue.i18n.add(code, require(`~/locales/${code}.json`)) + }) + Vue.i18n.set('en') Vue.i18n.fallback('en') @@ -35,14 +40,6 @@ const helpers = { }, }, }, - editor: { - namespaced: true, - getters: { - placeholder(state) { - return 'Leave your inspirational thoughts ...' - }, - }, - }, }, }), layout(storyFn) { diff --git a/webapp/yarn.lock b/webapp/yarn.lock index 2ce396aed..5073e7ed8 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -7359,6 +7359,11 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= +faker@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" + integrity sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8= + fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
+ {{ $t('quotes.african.quote') }} + - {{ $t('quotes.african.author') }} +
{{ $t('quotes.african.quote') }}
- {{ $t('quotes.african.quote') }} - - {{ $t('quotes.african.author') }} -