From: Marc Foley Date: Wed, 25 Jun 2025 15:03:33 +0000 (+0100) Subject: add filtering for whole collection X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb996de6dcbeb31af8c5a5239e84ec1369ab5aa4;p=thirdparty%2Fgoogle%2Ffonts.git add filtering for whole collection --- diff --git a/.ci/ds.html b/.ci/ds.html index 5577eff5b..e522224ab 100644 --- a/.ci/ds.html +++ b/.ci/ds.html @@ -26,6 +26,21 @@ pt +
+ + + + +
', + filterValue: '', + allAxes: [], }}, async created() { this.familyData = await this.getFamilyData(); this.loadFonts(); this.restorePanelsFromUrl(); if (this.panels.length === 0) this.addPanel(); + this.allAxes = this.getAllAxes(); this.$watch('panels', this.updateUrlFromPanels, { deep: true }); console.log('Vue instance mounted'); }, @@ -200,6 +220,42 @@ new Vue({ text, }); }, + getAllAxes() { + const axesSet = new Set(); + Object.values(this.familyData).forEach(fam => { + fam.axes.forEach(ax => axesSet.add(ax.tag)); + }); + return Array.from(axesSet).sort(); + }, + addFilteredPanels() { + if (!this.filterAxis || this.filterValue === '') return; + const op = this.filterOp; + const val = Number(this.filterValue); + const axis = this.filterAxis; + const families = Object.values(this.familyData).filter(fam => { + const ax = fam.axes.find(a => a.tag === axis); + if (!ax) return false; + const min = Number(ax.min); + const max = Number(ax.max); + if (op === '>') return max > val; + if (op === '>=') return max >= val; + if (op === '<') return min < val; + if (op === '<=') return min <= val; + if (op === '==') return min <= val && max >= val; + return false; + }); + families.forEach(fam => { + // Default positions for axes + const positions = {}; + fam.axes.forEach(ax => { positions[ax.tag] = ax.defaultValue || ax.min; }); + this.panels.push({ + id: this.nextPanelId++, + currentFamily: fam.family, + positions: { ...positions }, + text: this.selectedSampleText, + }); + }); + }, updateUrlFromPanels() { if (this.restoring) return; const panelsForUrl = this.panels.map(p => ({