From: Marc Foley Date: Wed, 16 Jul 2025 09:01:12 +0000 (+0100) Subject: add more components X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dc024dc6c95badce7bd2cc5164e0e16cb8a391a;p=thirdparty%2Fgoogle%2Ffonts.git add more components --- diff --git a/tagger2/AddTag.js b/tagger2/AddTag.js new file mode 100644 index 000000000..2ba29253c --- /dev/null +++ b/tagger2/AddTag.js @@ -0,0 +1,105 @@ +import {FontTag} from "./models.js"; + +export default { + props: ["categories"], + data: function() { + return { + category: "", + newFamily: "", + newScore: 0, + isVF: false, + axes: [], + axisName: "", + axisPositions: 2, + } + }, + methods: { + addTag() { + const tag = new FontTag(this.category, this.newFamily, [], this.newScore) + this.$emit('tag-added', tag); + }, + addVFTags() { + // perform a cross product of the axes and their positions and create a new VF tag for each combination + const solved = this.axesCombos(this.axes); + for (let coordinateSet of solved) { + const vfTag = new FontTag(this.category, this.newFamily, coordinateSet.axes, coordinateSet.score); + this.$emit('tag-added', vfTag); + } + }, + addAxis() { + console.log("Adding axis", this.axisName, this.axisPositions); + const positions = []; + for (let i = 0; i < this.axisPositions; i++) { + positions.push({"coordinate": 0, "score": 0}); // Default position for each axis + } + this.axes.push({ + tag: this.axisName, + positions: positions + }) + }, + deleteAxis(axis) { + const index = this.axes.indexOf(axis); + if (index > -1) { + this.axes.splice(index, 1); + } + }, + _axesCombos(axes, current = [], res = []) { + if (current.length === axes.length) { + const axisSet = {score: 0, axes: []}; + for (let i = 0; i < current.length; i++) { + axisSet.score += Number(current[i].score); + axisSet.axes.push({tag: axes[i].tag, coords: current[i].coordinate}); + } + res.push(axisSet); + return res; + } + for (let i = 0; i < axes[current.length].positions.length; i++) { + this._axesCombos(axes, [...current, axes[current.length].positions[i]], res); + } + return res; + }, + axesCombos(axes) { + let axisSets = this._axesCombos(axes); + axisSets.forEach((axisSet) => { + axisSet.axes.forEach((axis) => { + delete axis.score; + }); + }); + return axisSets; + } + }, + template: ` +
+

Add Tag

+ Variable Font +

Category

+ +

Family

+ +
+ + + +
+

{{ axis.tag }}

+ +
+ Coordinate: + + Score: + +
+
+ +
+
+ + +
+
+ `, +} \ No newline at end of file diff --git a/tagger2/Panel.js b/tagger2/Panel.js new file mode 100644 index 000000000..620ca20cb --- /dev/null +++ b/tagger2/Panel.js @@ -0,0 +1,15 @@ +export default { + props: ['panel', 'tags'], + methods: { + remove() { + this.$emit('remove'); + } + }, + template: ` +
+ + + +
+ ` +}; diff --git a/tagger2/TagView.js b/tagger2/TagView.js new file mode 100644 index 000000000..f732888a5 --- /dev/null +++ b/tagger2/TagView.js @@ -0,0 +1,16 @@ +export default { + props: ["tag"], + template: ` +
+
+ {{ tag.tagName }} + {{ tag.family.name }} + Score: {{ tag.score }} +
+
+ Hello world +
+
+ + `, +} \ No newline at end of file diff --git a/tagger2/TagsByCategories.js b/tagger2/TagsByCategories.js new file mode 100644 index 000000000..38ab87395 --- /dev/null +++ b/tagger2/TagsByCategories.js @@ -0,0 +1,56 @@ +export default { + props: ['tags', 'categories'], + data() { + return { + selectedCategories: [...this.categories], + sortBy: 'family' // Default sorting option + }; + }, + watch: { + categories(newVal) { + this.selectedCategories = [...newVal]; + } + }, + computed: { + filteredTags() { + // Use selectedCategories for filtering + const filtered = this.tags.filter(tag => this.selectedCategories.includes(tag.tagName)); + // Sort by family name and tag name + if (this.sortBy === 'score') { + return filtered.sort((a, b) => b.score - a.score); + } + if (this.sortBy === 'family') { + return filtered.sort((a, b) => { + if (a.family.name < b.family.name) return -1; + if (a.family.name > b.family.name) return 1; + if (a.tagName < b.tagName) return -1; + if (a.tagName > b.tagName) return 1; + return 0; + }); + } + }, + sortedCategories() { + const res = this.tags.map(tag => tag.tagName) + .filter((value, index, self) => self.indexOf(value) === index) + .sort(); + return res; + } + }, + template: ` +
+

Tags for categories:

+ + +
+ +
+
+ ` +};