Skip to content

Commit

Permalink
tags.html: Add ability to add a tag
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rc1e committed Oct 24, 2024
1 parent 8e28180 commit 910734b
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions .ci/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ <h1>Google Fonts Tagger</h1>

<label>Current tag:</label>
<select v-model="CurrentCategory" style="max-width: 300px;">
<option v-for="category in sortedCategories" :key="category" :value="category">
<option v-for="category in sortedCategories()" :key="category" :value="category">
{{ category }}
</option>
</select>
</div>
<div class="panel-tile">
<form @submit.prevent="AddTag">
<label>Add Tag:</label>
<input v-model="newTag" required placeholder="Tag Name">
<button>Add</button>
</form>
</div>
<div style="border: 0.1px solid rgb(161, 161, 161); margin-bottom: 10pt; margin-top: 10pt;"></div>

<div class="panel-tile">
<form @submit.prevent="AddFamily">
Expand All @@ -49,13 +57,17 @@ <h1>Google Fonts Tagger</h1>
</div>
</div>
<div style="border: 0.1px solid rgb(161, 161, 161); margin-bottom: 10pt; margin-top: 10pt;"></div>
<div style="border: 0.1px solid rgb(161, 161, 161); margin-bottom: 10pt; margin-top: 10pt;"></div>
<div class="panel-tile">
<button @click="prCSV">Open Pull Request</button>
<button style="float: right;" @click="saveCSV">Save CSV</button>
</div>

</div>

<div v-if="sortedFamilies.length === 0">
<p>No families found for this tag. Please add some</p>
</div>
<div class="item" v-for="family in sortedFamilies" :key="family.Family">
<div style="float: left; width: 150px;">
<b>{{ family.Family }}</b>
Expand Down Expand Up @@ -84,6 +96,7 @@ <h1>Google Fonts Tagger</h1>
ready: false,
isEdited: false,
commit: "refs/heads/main",
newTag: "",
newFamily: '',
newWeight: '',
CurrentCategory: "/Expressive/Calm",
Expand Down Expand Up @@ -116,7 +129,7 @@ <h1>Google Fonts Tagger</h1>
},
CurrentCategory(newCategory) {
this.updateURL();
}
},
},
created() {
this.loadCSV();
Expand Down Expand Up @@ -144,11 +157,11 @@ <h1>Google Fonts Tagger</h1>
uniqueFamilies() {
return Array.from(new Set(this.Families.map((family) => family.Family)));
},
sortedCategories() {
return Array.from(this.Categories).sort();
}
},
methods: {
sortedCategories() {
return Array.from(this.Categories).sort();
},
updateURL() {
const url = new URL(window.location);
if (this.commit && this.commit !== "refs/heads/main") {
Expand Down Expand Up @@ -230,6 +243,12 @@ <h1>Google Fonts Tagger</h1>
familyStyle(Family) {
return `font-family: "${Family.Family}", "Adobe NotDef"; font-size: 32pt;`
},
AddTag() {
this.isEdited = true;
this.Categories.add(this.newTag);
this.history.push(`+ Tag added "${this.newTag}"`);
this.CurrentCategory = this.newTag;
},
AddFamily() {
this.isEdited = true;
let newFamily = { Weight: this.newWeight, Family: this.newFamily, "Group/Tag": this.CurrentCategory }
Expand Down

0 comments on commit 910734b

Please sign in to comment.