Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## [Unreleased]

### Changed
- Indentation of ingredients depends on existence of subgroups
[#512](https://github.com/nextcloud/cookbook/pull/512/) @seyfeb


### Fixed
- Fixed keywords of shared recipes counted multiple times, fixes #491
[#493](https://github.com/nextcloud/cookbook/pull/493/) @seyfeb
Expand Down
35 changes: 24 additions & 11 deletions src/components/RecipeIngredient.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<li :class="{ 'header': isHeader() }" @click="toggleDone">
<li :class="{ 'header': isHeader(), 'unindented': !recipeIngredientsHaveSubgroups}" @click="toggleDone">
<div class="checkmark" :class="{ 'done': isDone }">✔</div>
{{ displayIngredient }}
<div class="ingredient">{{ displayIngredient }}</div>
</li>
</template>

<script>
export default {
name: 'RecipeIngredient',
props: ['ingredient'],
props: ['ingredient','recipeIngredientsHaveSubgroups'],
data () {
return {
headerPrefix: "## ",
Expand Down Expand Up @@ -41,7 +41,7 @@ export default {
<style scoped>

li {
margin-left: 1.25em;
display: flex;
}
li.header {
position: relative;
Expand All @@ -50,19 +50,32 @@ li {
list-style-type: none;
font-variant: small-caps;
}


li.unindented {
position: relative;
left: -1.25em;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can cause trouble. After #515 it might be better to do margin-left: 0px; instead.

}

li > div.checkmark {
display: inline;
visibility: hidden;
}

li > div.done {
visibility: visible;
visibility: visible;
}

li:hover > div.checkmark {
visibility: visible;
opacity: 0.5;
color: var(--color-primary-element);
visibility: visible;
opacity: 0.5;
color: var(--color-primary-element);
}


li > div.ingredient {
display: inline;
margin-left: .3em;
padding-left: 1em;
text-indent: -1em;
}

</style>
13 changes: 12 additions & 1 deletion src/components/RecipeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<section>
<h3 v-if="ingredients.length">{{ t('cookbook', 'Ingredients') }}</h3>
<ul v-if="ingredients.length">
<RecipeIngredient v-for="(ingredient,idx) in ingredients" :key="'ingr'+idx" :ingredient="ingredient" />
<RecipeIngredient v-for="(ingredient,idx) in ingredients" :key="'ingr'+idx" :ingredient="ingredient" :recipeIngredientsHaveSubgroups="recipeIngredientsHaveSubgroups" />
</ul>
</section>

Expand Down Expand Up @@ -110,6 +110,7 @@ export default {
},
data () {
return {
headerPrefix: "## ",
// Own properties
ingredients: [],
instructions: [],
Expand All @@ -124,6 +125,16 @@ export default {
}
},
computed: {
recipeIngredientsHaveSubgroups: function() {
if (this.ingredients && this.ingredients.length > 0) {
for (let idx = 0; idx < this.ingredients.length; ++idx) {
if (this.ingredients[idx].startsWith(this.headerPrefix)) {
return true
}
}
}
return false
},
showModifiedDate: function() {
if (!this.dateModified) {
return false
Expand Down