Skip to content

Commit af9423e

Browse files
author
Dobromir Hristov
committed
refactor: do rename the ContentTableSection title to reduce polluting child .title classes.
1 parent 492c05d commit af9423e

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/components/DocumentationTopic/ContentTableSection.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<template>
1212
<div class="contenttable-section">
1313
<div class="section-title">
14-
<slot name="title">
14+
<slot name="title" :className="className">
1515
<LinkableHeading
1616
:level="3"
17-
class="title"
17+
:class="className"
1818
:anchor="anchorComputed"
1919
>{{ title }}</LinkableHeading>
2020
</slot>
@@ -46,6 +46,7 @@ export default {
4646
},
4747
computed: {
4848
anchorComputed: ({ title, anchor }) => anchor || anchorize(title),
49+
className: () => 'contenttable-title',
4950
},
5051
};
5152
</script>
@@ -66,7 +67,7 @@ export default {
6667
}
6768
}
6869

69-
/deep/ .title {
70+
/deep/ .contenttable-title {
7071
@include font-styles(label);
7172
}
7273

@@ -85,7 +86,7 @@ export default {
8586
}
8687
}
8788

88-
/deep/ .title {
89+
/deep/ .contenttable-title {
8990
margin: 0 0 $contenttable-spacing-single-side 0;
9091
padding-bottom: 0.5rem;
9192
}

src/components/DocumentationTopic/TopicsTable.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
:title="section.title"
1717
:anchor="section.anchor"
1818
>
19-
<template v-if="wrapTitle" slot="title">
20-
<LinkableHeading :level="3" :anchor="section.anchor" class="title">
19+
<template v-if="wrapTitle" #title="{ className }">
20+
<LinkableHeading :level="3" :anchor="section.anchor" :class="className">
2121
<WordBreak>{{ section.title }}</WordBreak>
2222
</LinkableHeading>
2323
</template>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('ContentTableSection', () => {
3333
const title = div.find(LinkableHeading);
3434
expect(title.exists()).toBe(true);
3535
expect(title.props('level')).toBe(3);
36-
expect(title.classes('title')).toBe(true);
36+
expect(title.classes()).toContain('contenttable-title');
3737
expect(title.text()).toContain(propsData.title);
3838
});
3939

@@ -49,12 +49,12 @@ describe('ContentTableSection', () => {
4949
it('renders a slot for a title', () => {
5050
wrapper = shallowMount(ContentTableSection, {
5151
propsData,
52-
slots: {
53-
title: '<div class="title">Title Text</div>',
52+
scopedSlots: {
53+
title: '<div :class="props.className">Title Text</div>',
5454
},
5555
});
5656
const div = wrapper.find('.section-title');
57-
const title = div.find('.title');
57+
const title = div.find('.contenttable-title');
5858
expect(title.text()).toEqual('Title Text');
5959
});
6060

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ describe('TopicsTable', () => {
6666
wrapper = shallowMount(TopicsTable, {
6767
propsData,
6868
provide,
69+
stubs: {
70+
ContentTableSection,
71+
},
6972
});
7073
});
7174

@@ -172,5 +175,6 @@ describe('TopicsTable', () => {
172175
expect(linkableHeading.exists()).toBe(true);
173176
expect(linkableHeading.props('level')).toBe(3);
174177
expect(linkableHeading.attributes('anchor')).toBe(propsData.sections[0].anchor);
178+
expect(linkableHeading.classes()).toContain('contenttable-title');
175179
});
176180
});

0 commit comments

Comments
 (0)