From 424eaa9e8098cef762b1a2a7565d37944bb25306 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Mon, 21 Oct 2019 18:25:12 +0200 Subject: Add storybook --- package.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'package.json') diff --git a/package.json b/package.json index e6ceb92..4c6ff52 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "build": "nuxt generate", "postbuild": "./scripts/postbuild.sh", "start": "nuxt start", - "test": "jest" + "test": "jest", + "storybook": "start-storybook -p 6006", + "build-storybook": "build-storybook" }, "dependencies": { "@nuxtjs/axios": "^5.3.6", @@ -24,13 +26,23 @@ "raw-loader": "^3.1.0" }, "devDependencies": { + "@babel/core": "^7.6.4", + "@storybook/addon-actions": "^5.2.4", + "@storybook/addon-links": "^5.2.4", + "@storybook/addon-storyshots": "^5.2.4", + "@storybook/addons": "^5.2.4", + "@storybook/vue": "^5.2.4", "@vue/test-utils": "^1.0.0-beta.27", "babel-jest": "^24.1.0", + "babel-loader": "^8.0.6", + "babel-plugin-require-context-hook": "^1.0.0", + "babel-preset-vue": "^2.0.2", "coveralls": "^3.0.6", "eslint-config-prettier": "^4.1.0", "eslint-plugin-prettier": "^3.0.1", "jest": "^24.1.0", "jest-serializer-vue": "^2.0.2", + "jest-vue-preprocessor": "^1.7.0", "prettier": "^1.16.4", "vue-jest": "^4.0.0-0" }, -- cgit 1.4.1 From 82cd395bf7deb8f1df95be5a0bb3f59d0b1108e1 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Mon, 21 Oct 2019 20:06:48 +0200 Subject: Add Facebook components --- .storybook/decorators/index.js | 2 +- components/Facebook/FacebookFeed.stories.js | 13 ++++++++ components/Facebook/FacebookFeed.vue | 29 ++++++++++++++++++ .../Facebook/FacebookFindUsButton.stories.js | 13 ++++++++ components/Facebook/FacebookFindUsButton.vue | 35 ++++++++++++++++++++++ components/FacebookFeed.vue | 25 ---------------- components/FacebookFindUsButton.vue | 35 ---------------------- components/PostList/PurePostList.stories.js | 3 -- package.json | 2 +- pages/index.vue | 2 +- 10 files changed, 93 insertions(+), 66 deletions(-) create mode 100644 components/Facebook/FacebookFeed.stories.js create mode 100644 components/Facebook/FacebookFeed.vue create mode 100644 components/Facebook/FacebookFindUsButton.stories.js create mode 100644 components/Facebook/FacebookFindUsButton.vue delete mode 100644 components/FacebookFeed.vue delete mode 100644 components/FacebookFindUsButton.vue (limited to 'package.json') diff --git a/.storybook/decorators/index.js b/.storybook/decorators/index.js index acea431..518f966 100644 --- a/.storybook/decorators/index.js +++ b/.storybook/decorators/index.js @@ -1,6 +1,6 @@ export const center = () => { return { template: - '
' + '
' } } diff --git a/components/Facebook/FacebookFeed.stories.js b/components/Facebook/FacebookFeed.stories.js new file mode 100644 index 0000000..4eced7f --- /dev/null +++ b/components/Facebook/FacebookFeed.stories.js @@ -0,0 +1,13 @@ +import { storiesOf } from '@storybook/vue' +import { center } from '../../.storybook/decorators' + +import FacebookFeed from './FacebookFeed' + +storiesOf('FacebookFeed', module) + .addDecorator(center) + .add('default', () => { + return { + components: { FacebookFeed }, + template: `` + } + }) diff --git a/components/Facebook/FacebookFeed.vue b/components/Facebook/FacebookFeed.vue new file mode 100644 index 0000000..56172f4 --- /dev/null +++ b/components/Facebook/FacebookFeed.vue @@ -0,0 +1,29 @@ + + + + + \ No newline at end of file diff --git a/components/Facebook/FacebookFindUsButton.stories.js b/components/Facebook/FacebookFindUsButton.stories.js new file mode 100644 index 0000000..e76f8f9 --- /dev/null +++ b/components/Facebook/FacebookFindUsButton.stories.js @@ -0,0 +1,13 @@ +import { storiesOf } from '@storybook/vue' +import { center } from '../../.storybook/decorators' + +import FacebookFindUsButton from './FacebookFindUsButton' + +storiesOf('FacebookFindUsButton', module) + .addDecorator(center) + .add('default', () => { + return { + components: { FacebookFindUsButton }, + template: `` + } + }) diff --git a/components/Facebook/FacebookFindUsButton.vue b/components/Facebook/FacebookFindUsButton.vue new file mode 100644 index 0000000..9a27c11 --- /dev/null +++ b/components/Facebook/FacebookFindUsButton.vue @@ -0,0 +1,35 @@ + + + \ No newline at end of file diff --git a/components/FacebookFeed.vue b/components/FacebookFeed.vue deleted file mode 100644 index 9d2d251..0000000 --- a/components/FacebookFeed.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - - - \ No newline at end of file diff --git a/components/FacebookFindUsButton.vue b/components/FacebookFindUsButton.vue deleted file mode 100644 index 9a27c11..0000000 --- a/components/FacebookFindUsButton.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - \ No newline at end of file diff --git a/components/PostList/PurePostList.stories.js b/components/PostList/PurePostList.stories.js index cf812f7..00516f8 100644 --- a/components/PostList/PurePostList.stories.js +++ b/components/PostList/PurePostList.stories.js @@ -1,15 +1,12 @@ import { storiesOf } from '@storybook/vue' -import { center } from '../../.storybook/decorators' import { postLink } from '../PostLink.stories' import PurePostList from './PurePostList' export const posts = Array(5).fill(postLink) -console.log(posts) storiesOf('PurePostList', module) - .addDecorator(center) .add('default', () => { return { components: { PurePostList }, diff --git a/package.json b/package.json index 4c6ff52..63620e0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "postbuild": "./scripts/postbuild.sh", "start": "nuxt start", "test": "jest", - "storybook": "start-storybook -p 6006", + "storybook": "start-storybook -p 6006 -s static", "build-storybook": "build-storybook" }, "dependencies": { diff --git a/pages/index.vue b/pages/index.vue index 8b093df..12caa0c 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -11,7 +11,7 @@ +``` + +Or by using the mixin + +```html + + + +``` diff --git a/components/Posts/PostList/index.js b/components/Posts/PostList/index.js index dbb515e..11d44ff 100644 --- a/components/Posts/PostList/index.js +++ b/components/Posts/PostList/index.js @@ -1,3 +1,22 @@ +import axios from 'axios' + +import k from '~/api' import PostList from './PostList' +export const getPosts = async () => { + if (process.client) { + let posts = await axios.get(`${window.location.origin}/api/posts.json`) + return parsePosts(posts.data) + } else { + return parsePosts(k.getPosts()) + } +} + +export const parsePosts = posts => + posts.map(post => ({ + title: post.content.meta.title, + description: post.content.description, + route: post.route + })) + export default PostList diff --git a/components/Posts/PostList/parentMixin.js b/components/Posts/PostList/parentMixin.js new file mode 100644 index 0000000..e5b06ed --- /dev/null +++ b/components/Posts/PostList/parentMixin.js @@ -0,0 +1,9 @@ +import { getPosts } from './index' + +export default { + async asyncData() { + return { + posts: await getPosts() + } + } +} diff --git a/package-lock.json b/package-lock.json index dc75e41..3c259df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4150,7 +4150,7 @@ "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", "requires": { "follow-redirects": "1.5.10", - "is-buffer": "2.0.3" + "is-buffer": "2.0.4" }, "dependencies": { "debug": { @@ -4170,9 +4170,9 @@ } }, "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" }, "ms": { "version": "2.0.0", diff --git a/package.json b/package.json index d7925a2..6522e9d 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dependencies": { "@nuxtjs/axios": "^5.3.6", "@nuxtjs/pwa": "^3.0.0-0", + "axios": "^0.19.0", "esm": "^3.2.25", "front-matter": "^3.0.2", "jsdom": "^15.1.1", diff --git a/pages/index.vue b/pages/index.vue index 3a19237..045025d 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -3,7 +3,7 @@

Ostatnie wpisy z kroniki

- +
@@ -13,9 +13,11 @@ import JoinUs from '~/components/JoinUs.vue' import FacebookFeed from '~/components/Facebook/FacebookFeed.vue' import PostList from '~/components/Posts/PostList' +import postListParentMixin from '~/components/Posts/PostList/parentMixin' export default { name: 'HomeView', - components: { JoinUs, FacebookFeed, PostList } + components: { JoinUs, FacebookFeed, PostList }, + mixins: [postListParentMixin] } diff --git a/pages/kronika/index.vue b/pages/kronika/index.vue index 86344c3..8142a6c 100644 --- a/pages/kronika/index.vue +++ b/pages/kronika/index.vue @@ -1,16 +1,18 @@ -- cgit 1.4.1