From fdf00fc0c68dc2f7eb0237160194fd7077d2e8c0 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Mon, 13 Jan 2020 17:29:15 +0100 Subject: [PATCH] Follow @alina-beck's PR review suggestions - Update styling - Avoid nested tags - Rename components with two names - Add story - Co-authored-by: Alina Beck --- webapp/assets/_new/styles/tokens.scss | 4 +- webapp/components/Comment/Comment.vue | 8 +-- .../ContributionForm/ContributionForm.vue | 6 +- .../components/Notification/Notification.vue | 6 +- .../NotificationsTable.story.js | 2 +- .../NotificationsTable/NotificationsTable.vue | 6 +- webapp/components/PostCard/PostCard.story.js | 2 +- webapp/components/PostCard/PostCard.vue | 12 ++-- .../UserTeaser.spec.js} | 0 .../UserTeaser.story.js} | 16 ++--- .../User.vue => UserTeaser/UserTeaser.vue} | 61 +++++++++---------- .../generic/UserAvatar/UserAvatar.story.js | 57 +++++++++++++++++ .../_new/generic/UserAvatar/UserAvatar.vue | 44 ++++--------- .../FiledReportsTable/FiledReportsTable.vue | 6 +- .../features/ReportList/ReportList.story.js | 2 +- .../features/ReportRow/ReportRow.vue | 15 +++-- webapp/pages/post/_id/_slug/index.vue | 8 +-- webapp/pages/profile/_id/_slug.vue | 14 ++--- 18 files changed, 153 insertions(+), 116 deletions(-) rename webapp/components/{User/User.spec.js => UserTeaser/UserTeaser.spec.js} (100%) rename webapp/components/{User/User.story.js => UserTeaser/UserTeaser.story.js} (81%) rename webapp/components/{User/User.vue => UserTeaser/UserTeaser.vue} (84%) create mode 100644 webapp/components/_new/generic/UserAvatar/UserAvatar.story.js diff --git a/webapp/assets/_new/styles/tokens.scss b/webapp/assets/_new/styles/tokens.scss index 71114cf21..a6f0a8a70 100644 --- a/webapp/assets/_new/styles/tokens.scss +++ b/webapp/assets/_new/styles/tokens.scss @@ -254,8 +254,7 @@ $size-width-paginate: 100px; $size-avatar-small: 34px; $size-avatar-base: 44px; -$size-avatar-large: 64px; -$size-avatar-x-large: 114px; +$size-avatar-large: 114px; /** * @tokens Size Buttons @@ -316,6 +315,7 @@ $z-index-dropdown: 8888; $z-index-page-submenu: 2500; $z-index-page-header: 2000; $z-index-page-sidebar: 1500; +$z-index-hc-post-card-link: 5; $z-index-sticky: 100; $z-index-post-card-link: 5; diff --git a/webapp/components/Comment/Comment.vue b/webapp/components/Comment/Comment.vue index cc7f815b9..b413e03f6 100644 --- a/webapp/components/Comment/Comment.vue +++ b/webapp/components/Comment/Comment.vue @@ -12,13 +12,13 @@
- + - + import { mapGetters } from 'vuex' import { COMMENT_MAX_UNTRUNCATED_LENGTH, COMMENT_TRUNCATE_TO_LENGTH } from '~/constants/comment' -import HcUser from '~/components/User/User' +import UserTeaser from '~/components/UserTeaser/UserTeaser' import ContentMenu from '~/components/ContentMenu/ContentMenu' import ContentViewer from '~/components/Editor/ContentViewer' import HcCommentForm from '~/components/CommentForm/CommentForm' @@ -82,7 +82,7 @@ export default { } }, components: { - HcUser, + UserTeaser, ContentMenu, ContentViewer, HcCommentForm, diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 80b52b61c..8cb42a85d 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -38,7 +38,7 @@ - + {} }, diff --git a/webapp/components/Notification/Notification.vue b/webapp/components/Notification/Notification.vue index 446c5321a..761c806d2 100644 --- a/webapp/components/Notification/Notification.vue +++ b/webapp/components/Notification/Notification.vue @@ -2,7 +2,7 @@ - + {{ $t(`notifications.reason.${notification.reason}`) }} @@ -35,12 +35,12 @@ diff --git a/webapp/components/_new/generic/UserAvatar/UserAvatar.story.js b/webapp/components/_new/generic/UserAvatar/UserAvatar.story.js new file mode 100644 index 000000000..0748a6266 --- /dev/null +++ b/webapp/components/_new/generic/UserAvatar/UserAvatar.story.js @@ -0,0 +1,57 @@ +import { storiesOf } from '@storybook/vue' +import { withA11y } from '@storybook/addon-a11y' +import StoryRouter from 'storybook-vue-router' +import UserAvatar from '~/components/_new/generic/UserAvatar/UserAvatar' +import helpers from '~/storybook/helpers' +import { user } from '~/components/UserTeaser/UserTeaser.story.js' + +helpers.init() +const anonymousUser = { + ...user, + name: 'Anonymous', + avatar: null, +} +const userWithoutAvatar = { + ...user, + avatar: null, + name: 'Ana Paula Nunes Marques', +} +storiesOf('UserAvatar', module) + .addDecorator(withA11y) + .addDecorator(helpers.layout) + .addDecorator(StoryRouter()) + .add('with image', () => ({ + components: { UserAvatar }, + data: () => ({ + user, + }), + template: '', + })) + .add('without image, anonymous user', () => ({ + components: { UserAvatar }, + data: () => ({ + user: anonymousUser, + }), + template: '', + })) + .add('without image, user initials', () => ({ + components: { UserAvatar }, + data: () => ({ + user: userWithoutAvatar, + }), + template: '', + })) + .add('small', () => ({ + components: { UserAvatar }, + data: () => ({ + user, + }), + template: '', + })) + .add('large', () => ({ + components: { UserAvatar }, + data: () => ({ + user, + }), + template: '', + })) diff --git a/webapp/components/_new/generic/UserAvatar/UserAvatar.vue b/webapp/components/_new/generic/UserAvatar/UserAvatar.vue index bffc9694e..69890bf66 100644 --- a/webapp/components/_new/generic/UserAvatar/UserAvatar.vue +++ b/webapp/components/_new/generic/UserAvatar/UserAvatar.vue @@ -1,16 +1,8 @@ @@ -22,7 +14,7 @@ export default { type: String, default: 'base', validator: value => { - return value.match(/(small|base|large|x-large)/) + return value.match(/(small|base|large)/) }, }, user: { type: Object, default: null }, @@ -37,7 +29,7 @@ export default { return !this.user || !this.user.name || this.user.name.toLowerCase() === 'anonymous' }, hasImage() { - return Boolean(this.user && this.user.avatar) && !this.error + return Boolean(this.user && this.user.avatar) }, userInitials() { const { name } = this.user || 'Anonymous' @@ -69,38 +61,28 @@ export default { margin-top: -0.1em; } - &.size-small { + &.--small { width: $size-avatar-small; height: $size-avatar-small; } - &.size-base { + &.--base { border-width: 1px; width: $size-avatar-base; height: $size-avatar-base; } - &.size-large { + &.--large { width: $size-avatar-large; height: $size-avatar-large; + font-size: $font-size-xx-large; } - &.size-x-large { - width: $size-avatar-x-large; - height: $size-avatar-x-large; - } - .no-image { - height: 100%; + &.no-image { display: flex; flex-wrap: wrap; border-radius: 50%; + align-items: center; + justify-content: center; background-color: $background-color-secondary; color: $text-color-primary-inverse; } - - .no-image .flex-item { - box-sizing: border-box; - padding: 0; - margin: 0 auto; - align-self: center; - display: table; - } } diff --git a/webapp/components/features/FiledReportsTable/FiledReportsTable.vue b/webapp/components/features/FiledReportsTable/FiledReportsTable.vue index 71c7d39a5..86172edbc 100644 --- a/webapp/components/features/FiledReportsTable/FiledReportsTable.vue +++ b/webapp/components/features/FiledReportsTable/FiledReportsTable.vue @@ -7,7 +7,7 @@ condensed >