From ded6f9e49570088fb4318d500fdded05ab2db67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20Miku=C5=A1?= Date: Sat, 14 Oct 2023 10:13:55 +0200 Subject: [PATCH] Fix image gen unit handling --- src/assets/base.css | 3 +-- src/components/Cocktail/CocktailForm.vue | 17 ++++++++--------- .../Cocktail/GenerateImageDialog.vue | 7 +------ src/components/Cocktail/PublicRecipe.vue | 19 ++++++++++--------- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/assets/base.css b/src/assets/base.css index 9afbf395..5ed7a0e7 100644 --- a/src/assets/base.css +++ b/src/assets/base.css @@ -1,5 +1,4 @@ -@import url('https://fonts.googleapis.com/css2?family=Alice&family=Inter:wght@400;700&family=Space+Mono&display=swap'); -/* @import url('https://api.fonts.coollabs.io/css2?family=Alice&family=Inter:wght@400;700&family=Space+Mono&display=swap'); */ +@import url('https://api.fonts.coollabs.io/css2?family=Alice&family=Inter:wght@400;700&family=Space+Mono&display=swap'); :root { /* Base color scheme */ diff --git a/src/components/Cocktail/CocktailForm.vue b/src/components/Cocktail/CocktailForm.vue index 285809d1..338c6521 100644 --- a/src/components/Cocktail/CocktailForm.vue +++ b/src/components/Cocktail/CocktailForm.vue @@ -128,7 +128,6 @@ import Utils from './../../Utils.js' import UnitHandler from './../../UnitHandler' import ApiRequests from './../../ApiRequests.js' -import Unitz from 'unitz' import OverlayLoader from './../OverlayLoader.vue' import IngredientModal from './../Cocktail/IngredientModal.vue' import ImageUpload from './../ImageUpload.vue' @@ -394,17 +393,17 @@ export default { .map((cIngredient) => { // Convert oz to ml if (cIngredient.units == 'oz') { - cIngredient.amount = UnitHandler.oz2ml(cIngredient.amount); + cIngredient.amount = UnitHandler.oz2ml(cIngredient.amount) if (cIngredient.amount_max) { - cIngredient.amount_max = UnitHandler.oz2ml(cIngredient.amount_max); + cIngredient.amount_max = UnitHandler.oz2ml(cIngredient.amount_max) } cIngredient.units = 'ml' } // Convert cl to ml if (cIngredient.units == 'cl') { - cIngredient.amount = UnitHandler.cl2ml(cIngredient.amount); + cIngredient.amount = UnitHandler.cl2ml(cIngredient.amount) if (cIngredient.amount_max) { - cIngredient.amount_max = UnitHandler.cl2ml(cIngredient.amount_max); + cIngredient.amount_max = UnitHandler.cl2ml(cIngredient.amount_max) } cIngredient.units = 'ml' } @@ -414,17 +413,17 @@ export default { // Handle substitutes cIngredient.substitutes.filter(sub => sub.units).map(sub => { if (sub.units == 'oz') { - sub.amount = UnitHandler.oz2ml(sub.amount); + sub.amount = UnitHandler.oz2ml(sub.amount) if (sub.amount_max) { - sub.amount_max = UnitHandler.oz2ml(sub.amount_max); + sub.amount_max = UnitHandler.oz2ml(sub.amount_max) } sub.units = 'ml' } if (sub.units == 'cl') { - sub.amount = UnitHandler.cl2ml(sub.amount); + sub.amount = UnitHandler.cl2ml(sub.amount) if (sub.amount_max) { - sub.amount_max = UnitHandler.cl2ml(sub.amount_max); + sub.amount_max = UnitHandler.cl2ml(sub.amount_max) } sub.units = 'ml' } diff --git a/src/components/Cocktail/GenerateImageDialog.vue b/src/components/Cocktail/GenerateImageDialog.vue index 454a66f8..46ca5042 100644 --- a/src/components/Cocktail/GenerateImageDialog.vue +++ b/src/components/Cocktail/GenerateImageDialog.vue @@ -5,7 +5,7 @@
- +
@@ -20,7 +20,6 @@ import * as htmlToImage from 'html-to-image' import OverlayLoader from './../OverlayLoader.vue' import PublicRecipe from './PublicRecipe.vue' -import AppState from './../../AppState' export default { components: { @@ -40,7 +39,6 @@ export default { return { isLoading: false, imagePayload: null, - currentUnit: 'ml', shareEnabled: false, features: { hideHeader: true, @@ -54,9 +52,6 @@ export default { } }, mounted() { - const appState = new AppState() - this.currentUnit = appState.defaultUnit - if ('share' in navigator) { this.shareEnabled = true } diff --git a/src/components/Cocktail/PublicRecipe.vue b/src/components/Cocktail/PublicRecipe.vue index d3785829..ed8041d8 100644 --- a/src/components/Cocktail/PublicRecipe.vue +++ b/src/components/Cocktail/PublicRecipe.vue @@ -10,9 +10,9 @@

{{ cocktail.name }}

- - - + + +

{{ $t('ingredients.title') }}

@@ -41,6 +41,7 @@ import {micromark} from 'micromark' import SiteLogo from '@/components/Layout/SiteLogo.vue' import UnitHandler from '../../UnitHandler' +import AppState from '../../AppState' export default { components: { @@ -55,10 +56,6 @@ export default { } } }, - currentUnit: { - type: String, - default: 'ml' - }, hideUnits: { type: Boolean, default: false @@ -75,7 +72,7 @@ export default { data() { return { isLoading: false, - scopedUnit: this.currentUnit + currentUnit: 'ml' } }, computed: { @@ -111,9 +108,13 @@ export default { return micromark(this.cocktail.garnish) }, }, + created() { + const appState = new AppState() + this.currentUnit = appState.defaultUnit + }, methods: { parseIngredientAmount(ingredient) { - return UnitHandler.print(ingredient, this.scopedUnit) + return UnitHandler.print(ingredient, this.currentUnit) }, } }