From 797efe0a60380cfe68cbc63adbcad31e5d8560ff Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Tue, 7 Apr 2020 13:34:48 +0200 Subject: [PATCH] use CounterIcon component to show counts - also adds a 'soft' variant to CounterIcon to make it more adaptable --- .../generic/CounterIcon/CounterIcon.story.js | 7 ++++ .../_new/generic/CounterIcon/CounterIcon.vue | 9 +++- .../generic/SearchPost/SearchPost.spec.js | 4 +- .../generic/SearchPost/SearchPost.vue | 41 +++++++------------ 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/webapp/components/_new/generic/CounterIcon/CounterIcon.story.js b/webapp/components/_new/generic/CounterIcon/CounterIcon.story.js index 85b49f631..4bc685d62 100644 --- a/webapp/components/_new/generic/CounterIcon/CounterIcon.story.js +++ b/webapp/components/_new/generic/CounterIcon/CounterIcon.story.js @@ -26,6 +26,13 @@ storiesOf('Generic/CounterIcon', module) `, })) + .add('soft', () => ({ + components: { CounterIcon }, + template: ` + + `, + })) + .add('count is 0', () => ({ components: { CounterIcon }, template: ` diff --git a/webapp/components/_new/generic/CounterIcon/CounterIcon.vue b/webapp/components/_new/generic/CounterIcon/CounterIcon.vue index 00b4b9c53..0d97921ce 100644 --- a/webapp/components/_new/generic/CounterIcon/CounterIcon.vue +++ b/webapp/components/_new/generic/CounterIcon/CounterIcon.vue @@ -11,6 +11,7 @@ export default { icon: { type: String, required: true }, count: { type: Number, required: true }, danger: { type: Boolean, default: false }, + soft: { type: Boolean, default: false }, }, computed: { cappedCount() { @@ -18,7 +19,8 @@ export default { }, counterClass() { let counterClass = 'count' - if (this.danger) counterClass += ' --danger' + if (this.soft) counterClass += ' --soft' + else if (this.danger) counterClass += ' --danger' if (this.count === 0) counterClass += ' --inactive' return counterClass @@ -58,6 +60,11 @@ export default { &.--inactive { background-color: $color-neutral-60; } + + &.--soft { + background-color: $color-neutral-90; + color: $text-color-soft; + } } } diff --git a/webapp/components/generic/SearchPost/SearchPost.spec.js b/webapp/components/generic/SearchPost/SearchPost.spec.js index c8372bb8d..6128c006e 100644 --- a/webapp/components/generic/SearchPost/SearchPost.spec.js +++ b/webapp/components/generic/SearchPost/SearchPost.spec.js @@ -1,4 +1,4 @@ -import { shallowMount } from '@vue/test-utils' +import { mount } from '@vue/test-utils' import SearchPost from './SearchPost.vue' const localVue = global.localVue @@ -26,7 +26,7 @@ describe('SearchPost.vue', () => { }) const Wrapper = () => { - return shallowMount(SearchPost, { mocks, localVue, propsData }) + return mount(SearchPost, { mocks, localVue, propsData }) } describe('shallowMount', () => { diff --git a/webapp/components/generic/SearchPost/SearchPost.vue b/webapp/components/generic/SearchPost/SearchPost.vue index 23d7e7a69..079322097 100644 --- a/webapp/components/generic/SearchPost/SearchPost.vue +++ b/webapp/components/generic/SearchPost/SearchPost.vue @@ -1,22 +1,23 @@ +