Skip to content

Commit a66ef9f

Browse files
author
Dobromir Hristov
committed
refactor: TopicsGrid to user ContentTableSection
1 parent baaf872 commit a66ef9f

File tree

2 files changed

+26
-38
lines changed

2 files changed

+26
-38
lines changed

src/components/DocumentationTopic/TopicsGrid.vue

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,32 @@
1010

1111
<template>
1212
<div class="TopicsGrid">
13-
<OnThisPageSection
14-
v-for="(section, i) in sections"
15-
:key="i"
16-
:title="section.title || ''"
17-
:anchor="anchorize(section.title || '')"
18-
:level="3"
19-
class="topic-grid"
20-
>
21-
<div class="container">
22-
<h3 class="title" v-if="section.title">
23-
{{ section.title }}
24-
</h3>
25-
<TopicsLinkCardGrid :identifiers="section.identifiers" :topicStyle="topicStyle" />
26-
</div>
27-
</OnThisPageSection>
13+
<ContentTable anchor="topics" title="Topics">
14+
<ContentTableSection
15+
v-for="section in sections"
16+
:key="section.title"
17+
:title="section.title || ''"
18+
>
19+
<TopicsLinkCardGrid
20+
:identifiers="section.identifiers"
21+
:topicStyle="topicStyle"
22+
class="topic-grid"
23+
/>
24+
</ContentTableSection>
25+
</ContentTable>
2826
</div>
2927
</template>
3028

3129
<script>
3230
import { anchorize } from 'docc-render/utils/strings';
3331
3432
import TopicsLinkCardGrid from 'docc-render/components/DocumentationTopic/TopicsLinkCardGrid.vue';
35-
import OnThisPageSection from 'docc-render/components/DocumentationTopic/OnThisPageSection.vue';
33+
import ContentTable from 'docc-render/components/DocumentationTopic/ContentTable.vue';
34+
import ContentTableSection from 'docc-render/components/DocumentationTopic/ContentTableSection.vue';
3635
3736
export default {
3837
name: 'TopicsGrid',
39-
components: { OnThisPageSection, TopicsLinkCardGrid },
38+
components: { ContentTableSection, ContentTable, TopicsLinkCardGrid },
4039
props: {
4140
sections: {
4241
type: Array,
@@ -56,15 +55,7 @@ export default {
5655
<style scoped lang='scss'>
5756
@import 'docc-render/styles/_core.scss';
5857
59-
.container {
60-
@include dynamic-content-container
61-
}
62-
63-
.title {
64-
@include font-styles(label);
65-
}
66-
67-
.topic-grid + .topic-grid {
68-
margin-top: $stacked-margin-large;
58+
.topic-grid {
59+
margin-top: $stacked-margin-xlarge;
6960
}
7061
</style>

tests/unit/components/DocumentationTopic/TopicsGrid.spec.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import TopicsGrid from '@/components/DocumentationTopic/TopicsGrid.vue';
1212
import { shallowMount } from '@vue/test-utils';
1313
import { TopicStyles } from '@/constants/TopicStyles';
14-
import OnThisPageSection from '@/components/DocumentationTopic/OnThisPageSection.vue';
14+
import ContentTableSection from '@/components/DocumentationTopic/ContentTableSection.vue';
1515
import TopicsLinkCardGrid from '@/components/DocumentationTopic/TopicsLinkCardGrid.vue';
16+
import ContentTable from '@/components/DocumentationTopic/ContentTable.vue';
1617

1718
const defaultProps = {
1819
sections: [
@@ -39,20 +40,19 @@ const createWrapper = ({ propsData, ...others } = {}) => shallowMount(TopicsGrid
3940
describe('TopicsGrid', () => {
4041
it('renders the TopicsGrid', () => {
4142
const wrapper = createWrapper();
42-
const sections = wrapper.findAll(OnThisPageSection);
43+
expect(wrapper.find(ContentTable).props()).toEqual({
44+
anchor: 'topics',
45+
title: 'Topics',
46+
});
47+
const sections = wrapper.findAll(ContentTableSection);
4348
expect(sections).toHaveLength(2);
4449
expect(sections.at(0).props()).toEqual({
4550
title: defaultProps.sections[0].title,
46-
anchor: 'foo',
47-
// level: 3,
4851
});
4952
expect(sections.at(1).props()).toEqual({
5053
title: defaultProps.sections[1].title,
51-
anchor: 'bar',
52-
// level: 3,
5354
});
5455
// assert contents
55-
expect(sections.at(0).find('h3.title').text()).toBe(defaultProps.sections[0].title);
5656
expect(sections.at(0).find(TopicsLinkCardGrid).props()).toEqual({
5757
identifiers: defaultProps.sections[0].identifiers,
5858
topicStyle: defaultProps.topicStyle,
@@ -68,14 +68,11 @@ describe('TopicsGrid', () => {
6868
}],
6969
},
7070
});
71-
const sections = wrapper.findAll(OnThisPageSection);
71+
const sections = wrapper.findAll(ContentTableSection);
7272
expect(sections).toHaveLength(1);
7373
expect(sections.at(0).props()).toEqual({
7474
title: '',
75-
anchor: '',
76-
// level: 3,
7775
});
78-
expect(sections.at(0).find('.title').exists()).toBe(false);
7976
expect(sections.at(0).find(TopicsLinkCardGrid).exists()).toBe(true);
8077
});
8178
});

0 commit comments

Comments
 (0)