Add a toggle between dark and light theme

This commit is contained in:
Greg Burri 2025-03-31 15:31:06 +02:00
parent d22617538e
commit 559ed139aa
34 changed files with 640 additions and 469 deletions

View file

@ -5,13 +5,13 @@
<div class="content" id="recipe-view">
<h2 class="recipe-title" >{{ recipe.title }}</h2>
{% if let Some(user) = user %}
{% if let Some(user) = context.user %}
{% if crate::data::model::can_user_edit_recipe(user, recipe) %}
<a class="edit-recipe" href="/{{ tr.current_lang_code() }}/recipe/edit/{{ recipe.id }}" >Edit</a>
<a class="edit-recipe" href="/{{ context.tr.current_lang_code() }}/recipe/edit/{{ recipe.id }}" >Edit</a>
{% endif %}
{% endif %}
<span class="add-to-planner">{{ tr.t(Sentence::CalendarAddToPlanner) }}</span>
<span class="add-to-planner">{{ context.tr.t(Sentence::CalendarAddToPlanner) }}</span>
<div class="tags">
{% for tag in recipe.tags %}
@ -23,9 +23,9 @@
{% when Some(servings) %}
<span class="servings">
{% if *servings == 1 %}
{{ tr.t(Sentence::RecipeOneServing) }}
{{ context.tr.t(Sentence::RecipeOneServing) }}
{% else %}
{{ tr.tp(Sentence::RecipeSomeServings, [Box::new(**servings)]) }}
{{ context.tr.tp(Sentence::RecipeSomeServings, [Box::new(**servings)]) }}
{% endif %}
</span>
{% else %}
@ -33,7 +33,7 @@
{% match recipe.estimated_time %}
{% when Some(time) %}
{{ time ~}} {{~ tr.t(Sentence::RecipeEstimatedTimeMinAbbreviation) }}
{{ time ~}} {{~ context.tr.t(Sentence::RecipeEstimatedTimeMinAbbreviation) }}
{% else %}
{% endmatch %}
@ -41,11 +41,11 @@
{% match recipe.difficulty %}
{% when common::ron_api::Difficulty::Unknown %}
{% when common::ron_api::Difficulty::Easy %}
{{ tr.t(Sentence::RecipeDifficultyEasy) }}
{{ context.tr.t(Sentence::RecipeDifficultyEasy) }}
{% when common::ron_api::Difficulty::Medium %}
{{ tr.t(Sentence::RecipeDifficultyMedium) }}
{{ context.tr.t(Sentence::RecipeDifficultyMedium) }}
{% when common::ron_api::Difficulty::Hard %}
{{ tr.t(Sentence::RecipeDifficultyHard) }}
{{ context.tr.t(Sentence::RecipeDifficultyHard) }}
{% endmatch %}
</span>
@ -86,13 +86,13 @@
<div class="date-and-servings" >
{% include "calendar.html" %}
<label for="input-servings">{{ tr.t(Sentence::RecipeServings) }}</label>
<label for="input-servings">{{ context.tr.t(Sentence::RecipeServings) }}</label>
<input
id="input-servings"
type="number"
step="1" min="1" max="100"
value="
{% if let Some(user) = user %}
{% if let Some(user) = context.user %}
{{ user.default_servings }}
{% else %}
4
@ -106,13 +106,13 @@
checked
>
<label for="input-add-ingredients-to-shopping-list">
{{ tr.t(Sentence::CalendarAddIngredientsToShoppingList) }}
{{ context.tr.t(Sentence::CalendarAddIngredientsToShoppingList) }}
</label>
</div>
<span class="calendar-add-to-planner-success">{{ tr.t(Sentence::CalendarAddToPlannerSuccess) }}</span>
<span class="calendar-add-to-planner-already-exists">{{ tr.t(Sentence::CalendarAddToPlannerAlreadyExists) }}</span>
<span class="calendar-date-format">{{ tr.t(Sentence::CalendarDateFormat) }}</span>
<span class="calendar-add-to-planner-success">{{ context.tr.t(Sentence::CalendarAddToPlannerSuccess) }}</span>
<span class="calendar-add-to-planner-already-exists">{{ context.tr.t(Sentence::CalendarAddToPlannerAlreadyExists) }}</span>
<span class="calendar-date-format">{{ context.tr.t(Sentence::CalendarDateFormat) }}</span>
</div>
{% endblock %}