From 14c2be9277382c3284f72ec01ad39771f33e47dc Mon Sep 17 00:00:00 2001 From: tomtjes Date: Wed, 7 Feb 2024 16:51:19 -0500 Subject: [PATCH 1/6] add classes to scalable numbers apply "scalable" to all apply "scaled-up" when ingredient factor is >1 apply "unscaled" when ingredient factor is 1 apply "scaled-down" when factor is <1 --- vue/src/components/ScalableNumber.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vue/src/components/ScalableNumber.vue b/vue/src/components/ScalableNumber.vue index 2054c6c1..6dcc47d8 100644 --- a/vue/src/components/ScalableNumber.vue +++ b/vue/src/components/ScalableNumber.vue @@ -1,6 +1,5 @@ diff --git a/vue/src/utils/utils.js b/vue/src/utils/utils.js index 00cc3735..b4fb2e2e 100644 --- a/vue/src/utils/utils.js +++ b/vue/src/utils/utils.js @@ -317,6 +317,10 @@ export function calculateAmount(amount, factor) { } } +export function escapeCSS(classname) { + return classname.replace(/\s+/g, "-").toLowerCase() +} + export function roundDecimals(num) { let decimals = getUserPreference("user_fractions") ? getUserPreference("user_fractions") : 2 return +(Math.round(num + `e+${decimals}`) + `e-${decimals}`) @@ -748,4 +752,4 @@ export const formFunctions = { } return form }, -} +} \ No newline at end of file From b5a204265af0f65bd7a4d6b737abe0747f283148 Mon Sep 17 00:00:00 2001 From: tomtjes Date: Wed, 14 Feb 2024 17:18:26 -0500 Subject: [PATCH 5/6] fix CSS escape (remove HTML sanitize) --- vue/src/components/IngredientComponent.vue | 2 +- vue/src/components/KeywordsComponent.vue | 7 +------ vue/src/components/StepComponent.vue | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/vue/src/components/IngredientComponent.vue b/vue/src/components/IngredientComponent.vue index dd214700..1403840e 100644 --- a/vue/src/components/IngredientComponent.vue +++ b/vue/src/components/IngredientComponent.vue @@ -127,7 +127,7 @@ export default { this.$emit("checked-state-changed", this.ingredient) }, escapeCSS: function (classname) { - return CSS.escape(this.$sanitize(escapeCSS(classname))) + return CSS.escape(escapeCSS(classname)) } }, } diff --git a/vue/src/components/KeywordsComponent.vue b/vue/src/components/KeywordsComponent.vue index 7c1f87be..3cc3ce23 100644 --- a/vue/src/components/KeywordsComponent.vue +++ b/vue/src/components/KeywordsComponent.vue @@ -17,11 +17,6 @@ import {ResolveUrlMixin, escapeCSS} from "@/utils/utils"; -import Vue from "vue" -import VueSanitize from "vue-sanitize" - -Vue.use(VueSanitize) - export default { name: 'KeywordsComponent', mixins: [ResolveUrlMixin], @@ -43,7 +38,7 @@ export default { return this.escapeCSS('_keywordname-' + k.label) }, escapeCSS: function (classname) { - return CSS.escape(this.$sanitize(escapeCSS(classname))) + return CSS.escape(escapeCSS(classname)) } } } diff --git a/vue/src/components/StepComponent.vue b/vue/src/components/StepComponent.vue index 63a02406..4a9e901b 100644 --- a/vue/src/components/StepComponent.vue +++ b/vue/src/components/StepComponent.vue @@ -128,9 +128,7 @@ import IngredientsCard from "@/components/IngredientsCard" import Vue from "vue" import moment from "moment" import {ResolveUrlMixin, calculateHourMinuteSplit} from "@/utils/utils" -import VueSanitize from "vue-sanitize" -Vue.use(VueSanitize) Vue.prototype.moment = moment export default { @@ -200,7 +198,7 @@ export default { this.$refs[`id_reactive_popover_${this.step.id}`].$emit("open") }, escapeCSS: function (classname) { - return CSS.escape(this.$sanitize(escapeCSS(classname))) + return CSS.escape(escapeCSS(classname)) } }, } From f34dc4d242255b9e3b9a19232c92747eafcb92ba Mon Sep 17 00:00:00 2001 From: tomtjes Date: Thu, 15 Feb 2024 14:56:04 -0500 Subject: [PATCH 6/6] move escapeCSS function to mixins --- vue/src/components/IngredientComponent.vue | 7 ++----- vue/src/components/KeywordsComponent.vue | 7 ++----- vue/src/components/StepComponent.vue | 12 +++++------- vue/src/utils/utils.js | 9 +++++++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/vue/src/components/IngredientComponent.vue b/vue/src/components/IngredientComponent.vue index 1403840e..d8e130ee 100644 --- a/vue/src/components/IngredientComponent.vue +++ b/vue/src/components/IngredientComponent.vue @@ -43,7 +43,7 @@