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

View File

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

View File

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