Skip to content

Commit d476324

Browse files
committed
feat: translate the name of the categories
1 parent c381b9e commit d476324

File tree

3 files changed

+55
-31
lines changed

3 files changed

+55
-31
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<uikit-accordion
3+
:key="index"
4+
headerClass="px-3 py-3 mb-3 bg-editor-primary text-white rounded-sm"
5+
>
6+
<div slot="header" class="flex items-center">
7+
<div class="capitalize-first">{{ name }}</div>
8+
<div class="ml-2 px-3 bg-white bg-opacity-25 text-xs rounded-full">
9+
{{ category.children.length }}
10+
</div>
11+
</div>
12+
<div class="pt-1">
13+
<list-item
14+
v-for="section in category.children"
15+
:key="section.id"
16+
:section="section"
17+
:insertAfter="insertAfter"
18+
/>
19+
20+
<div
21+
class="text-center pt-2 pb-6"
22+
v-if="category.children.length === 0"
23+
>
24+
{{ $t('themeSectionList.emptyCategory') }}
25+
</div>
26+
</div>
27+
</uikit-accordion>
28+
</template>
29+
30+
<script>
31+
import ListItem from './list-item.vue'
32+
33+
export default {
34+
name: 'ThemeSectionListCategory',
35+
components: { ListItem },
36+
props: {
37+
index: { type: Number, required: true },
38+
category: { type: Object, required: true },
39+
insertAfter: { type: String },
40+
},
41+
computed: {
42+
name() {
43+
return this.$st(`${this.currentI18nScope}.categories.${this.category.id}.name`) ?? this.category.name
44+
},
45+
},
46+
}
47+
</script>

app/frontend/editor/components/theme-section-list/index.vue

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,23 @@
11
<template>
22
<div>
3-
<uikit-accordion
3+
<category
44
v-for="(category, index) in categories"
5-
:key="index"
6-
headerClass="px-3 py-3 mb-3 bg-editor-primary text-white rounded-sm"
7-
>
8-
<div slot="header" class="flex items-center">
9-
<div class="capitalize-first">{{ category.name }}</div>
10-
<div class="ml-2 px-3 bg-white bg-opacity-25 text-xs rounded-full">
11-
{{ category.children.length }}
12-
</div>
13-
</div>
14-
<div class="pt-1">
15-
<list-item
16-
v-for="section in category.children"
17-
:key="section.id"
18-
:section="section"
19-
:insertAfter="insertAfter"
20-
/>
21-
22-
<div
23-
class="text-center pt-2 pb-6"
24-
v-if="category.children.length === 0"
25-
>
26-
{{ $t('themeSectionList.emptyCategory') }}
27-
</div>
28-
</div>
29-
</uikit-accordion>
5+
:index="index"
6+
:category="category"
7+
:insert-after="insertAfter"
8+
/>
309
</div>
3110
</template>
3211

3312
<script>
34-
import ListItem from './list-item.vue'
13+
import Category from './category.vue'
3514
3615
export default {
3716
name: 'ThemeSectionList',
38-
components: { ListItem },
17+
components: { Category },
3918
props: {
4019
insertAfter: { type: String },
4120
},
42-
data() {
43-
return { activeCategory: null }
44-
},
4521
computed: {
4622
categories() {
4723
return this.services.theme.buildCategories(this.currentTheme)

app/frontend/editor/services/theme.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const buildCategories = (theme) => {
22
return theme.sectionCategories.map((category) => ({
3+
id: category.id,
34
name: category.name,
45
children: theme.sections
56
.filter((section) => section.category == category.id)

0 commit comments

Comments
 (0)