Restore styling on instrument filters

This commit is contained in:
Ramon Wenger 2022-09-15 15:10:09 +02:00
parent ce5d8603ff
commit bd87999487
3 changed files with 38 additions and 6 deletions

View File

@ -2,10 +2,17 @@
<a
:class="typeClass"
class="filter-entry"
:style="categoryStyle"
>
<span class="filter-entry__text">{{ text }}</span>
<span class="filter-entry__icon-wrapper">
<chevron-right class="filter-entry__icon" />
<span
:style="activeStyle"
class="filter-entry__icon-wrapper"
>
<chevron-right
:style="{fill: category.foreground}"
class="filter-entry__icon"
/>
</span>
</a>
@ -13,6 +20,7 @@
<script>
import INSTRUMENT_FILTER_QUERY from 'gql/local/instrumentFilter.gql';
const ChevronRight = () => import(/* webpackChunkName: "icons" */'@/components/icons/ChevronRight');
export default {
@ -41,8 +49,8 @@
apollo: {
instrumentFilter: {
query: INSTRUMENT_FILTER_QUERY
}
query: INSTRUMENT_FILTER_QUERY,
},
},
data() {
@ -56,11 +64,27 @@
computed: {
isActive() {
if (!this.instrumentFilter.currentFilter) {
return this.type === '';
return this.id === '';
}
// eslint-disable-next-line
const [_, identifier] = this.instrumentFilter.currentFilter.split(':');
return this.type === identifier;
return this.id === identifier;
},
activeStyle() {
if (this.isActive) {
return {
backgroundColor: this.category.background,
};
}
return {};
},
categoryStyle() {
if (this.isCategory) {
return {
color: this.category.foreground,
};
}
return {};
},
typeClass() {
return {

View File

@ -3,6 +3,12 @@ fragment ContentBlockParts on ContentBlockNode {
slug
userCreated
mine
instrumentCategory {
id
foreground
background
name
}
bookmarks {
uuid
note {

View File

@ -2,6 +2,8 @@ query InstrumentCategoriesQuery {
instrumentCategories {
name
id
foreground
background
types {
name
id