Skip to content

Commit 46a2da5

Browse files
author
Dobromir Hristov
committed
chore: refactor
1 parent a8cc963 commit 46a2da5

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

src/components/DocumentationTopic/Topics.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</template>
2121

2222
<script>
23+
import { TopicStyles } from '@/constants/TopicStyles';
2324
import TopicsTable from './TopicsTable.vue';
2425
2526
export default {
@@ -32,6 +33,7 @@ export default {
3233
topicStyle: {
3334
type: String,
3435
required: true,
36+
validator: v => Object.hasOwnProperty.call(TopicStyles, v),
3537
},
3638
},
3739
};

src/components/DocumentationTopic/TopicsLinkCardGrid.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<div class="TopicsLinkCardGrid">
1313
<Row :columns="compactCards ? 3 : 2">
1414
<Column
15-
v-for="(item, index) in items"
16-
:key="index"
15+
v-for="item in items"
16+
:key="item.title"
1717
>
1818
<TopicsLinkCardGridItem :item="item" :compact="compactCards" />
1919
</Column>
@@ -38,6 +38,7 @@ export default {
3838
topicStyle: {
3939
type: String,
4040
default: TopicStyles.compactGrid,
41+
validator: v => v === TopicStyles.compactGrid || v === TopicStyles.detailedGrid,
4142
},
4243
},
4344
computed: {

src/components/DocumentationTopic/TopicsLinkCardGridItem.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
:image="imageReferences.card"
1616
:title="item.title"
1717
floating-style
18-
:size="compact ? undefined: 'large'"
19-
:link-text="compact? '': linkText"
18+
:size="cardSize"
19+
:link-text="linkText"
2020
>
21-
<template #cover="{ classes }" v-if="!imageReferences.card">
21+
<template v-if="!imageReferences.card" #cover="{ classes }">
2222
<div :class="classes" class="reference-card-grid-item__image">
2323
<TopicTypeIcon
2424
:type="item.role"
@@ -35,6 +35,7 @@
3535
import Card from 'docc-render/components/Card.vue';
3636
import TopicTypeIcon from 'docc-render/components/TopicTypeIcon.vue';
3737
import { TopicRole } from 'docc-render/constants/roles';
38+
import CardSize from 'docc-render/constants/CardSize';
3839
3940
export const ROLE_LINK_TEXT = {
4041
[TopicRole.article]: 'Read article',
@@ -68,7 +69,8 @@ export default {
6869
all[current.type] = current.reference;
6970
return all;
7071
}, { icon: null, card: null }),
71-
linkText: ({ item }) => ROLE_LINK_TEXT[item.role] || 'Learn more',
72+
linkText: ({ compact, item }) => (compact ? '' : (ROLE_LINK_TEXT[item.role] || 'Learn more')),
73+
cardSize: ({ compact }) => (compact ? undefined : CardSize.large),
7274
},
7375
};
7476
</script>

src/components/DocumentationTopic/TopicsTable.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
<template v-if="section.discussion" slot="discussion">
2828
<ContentNode :content="section.discussion.content" />
2929
</template>
30-
<TopicsLinkCardGrid
31-
v-if="!shouldRenderList"
32-
:items="section.topics"
33-
:topicStyle="topicStyle"
34-
class="topic"
35-
/>
36-
<template v-else>
30+
<template v-if="shouldRenderList">
3731
<TopicsLinkBlock
3832
v-for="topic in section.topics"
3933
class="topic"
@@ -43,6 +37,12 @@
4337
:isSymbolBeta="isSymbolBeta"
4438
/>
4539
</template>
40+
<TopicsLinkCardGrid
41+
v-else
42+
:items="section.topics"
43+
:topicStyle="topicStyle"
44+
class="topic"
45+
/>
4646
</ContentTableSection>
4747
</ContentTable>
4848
</template>

0 commit comments

Comments
 (0)