Skip to content

Commit db887fc

Browse files
author
Dobromir Hristov
committed
refactor: rename TopicStyles.js to TopicSectionsStyle.js
1 parent d5d3b3b commit db887fc

12 files changed

+35
-35
lines changed

src/components/DocumentationTopic.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ import BetaLegalText from 'theme/components/DocumentationTopic/BetaLegalText.vue
107107
import LanguageSwitcher from 'theme/components/DocumentationTopic/Summary/LanguageSwitcher.vue';
108108
import DocumentationHero from 'docc-render/components/DocumentationTopic/DocumentationHero.vue';
109109
import WordBreak from 'docc-render/components/WordBreak.vue';
110-
import { TopicStyles } from 'docc-render/constants/TopicStyles';
110+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
111111
import Abstract from './DocumentationTopic/Description/Abstract.vue';
112112
import ContentNode from './DocumentationTopic/ContentNode.vue';
113113
import CallToActionButton from './CallToActionButton.vue';
@@ -231,7 +231,7 @@ export default {
231231
},
232232
topicSectionsStyle: {
233233
type: String,
234-
default: TopicStyles.list,
234+
default: TopicSectionsStyle.list,
235235
},
236236
sampleCodeDownload: {
237237
type: Object,
@@ -373,7 +373,7 @@ export default {
373373
shouldRenderTopicSection: ({
374374
topicSectionsStyle,
375375
topicSections,
376-
}) => topicSections && topicSectionsStyle !== TopicStyles.hidden,
376+
}) => topicSections && topicSectionsStyle !== TopicSectionsStyle.hidden,
377377
},
378378
methods: {
379379
normalizePath(path) {

src/components/DocumentationTopic/Topics.vue

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

2222
<script>
23-
import { TopicStyles } from '@/constants/TopicStyles';
23+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
2424
import TopicsTable from './TopicsTable.vue';
2525

2626
export default {
@@ -33,7 +33,7 @@ export default {
3333
topicStyle: {
3434
type: String,
3535
required: true,
36-
validator: v => Object.hasOwnProperty.call(TopicStyles, v),
36+
validator: v => Object.hasOwnProperty.call(TopicSectionsStyle, v),
3737
},
3838
},
3939
};

src/components/DocumentationTopic/TopicsLinkCardGrid.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<script>
2525
import Row from 'docc-render/components/ContentNode/Row.vue';
2626
import Column from 'docc-render/components/ContentNode/Column.vue';
27-
import { TopicStyles } from 'docc-render/constants/TopicStyles';
27+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
2828
import TopicsLinkCardGridItem from './TopicsLinkCardGridItem.vue';
2929

3030
export default {
@@ -37,12 +37,12 @@ export default {
3737
},
3838
topicStyle: {
3939
type: String,
40-
default: TopicStyles.compactGrid,
41-
validator: v => v === TopicStyles.compactGrid || v === TopicStyles.detailedGrid,
40+
default: TopicSectionsStyle.compactGrid,
41+
validator: v => v === TopicSectionsStyle.compactGrid || v === TopicSectionsStyle.detailedGrid,
4242
},
4343
},
4444
computed: {
45-
compactCards: ({ topicStyle }) => topicStyle === TopicStyles.compactGrid,
45+
compactCards: ({ topicStyle }) => topicStyle === TopicSectionsStyle.compactGrid,
4646
},
4747
};
4848
</script>

src/components/DocumentationTopic/TopicsTable.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<script>
5151
import ContentNode from 'docc-render/components/DocumentationTopic/ContentNode.vue';
5252
import WordBreak from 'docc-render/components/WordBreak.vue';
53-
import { TopicStyles } from 'docc-render/constants/TopicStyles';
53+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
5454
import TopicsLinkCardGrid from 'docc-render/components/DocumentationTopic/TopicsLinkCardGrid.vue';
5555
import LinkableHeading from 'docc-render/components/ContentNode/LinkableHeading.vue';
5656
import ContentTable from './ContentTable.vue';
@@ -102,11 +102,11 @@ export default {
102102
},
103103
topicStyle: {
104104
type: String,
105-
default: TopicStyles.list,
105+
default: TopicSectionsStyle.list,
106106
},
107107
},
108108
computed: {
109-
shouldRenderList: ({ topicStyle }) => topicStyle === TopicStyles.list,
109+
shouldRenderList: ({ topicStyle }) => topicStyle === TopicSectionsStyle.list,
110110
sectionsWithTopics() {
111111
return this.sections.map(section => ({
112112
...section,

src/constants/TopicStyles.js renamed to src/constants/TopicSectionsStyle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
/* eslint-disable import/prefer-default-export */
12-
export const TopicStyles = {
12+
export const TopicSectionsStyle = {
1313
list: 'list',
1414
compactGrid: 'compactGrid',
1515
detailedGrid: 'detailedGrid',

tests/unit/components/DocumentationTopic.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import DocumentationTopic from 'docc-render/components/DocumentationTopic.vue';
1313
import Language from 'docc-render/constants/Language';
1414
import { TopicTypes } from '@/constants/TopicTypes';
1515
import DocumentationHero from '@/components/DocumentationTopic/DocumentationHero.vue';
16-
import { TopicStyles } from '@/constants/TopicStyles';
16+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
1717

1818
const {
1919
Abstract,
@@ -477,12 +477,12 @@ describe('DocumentationTopic', () => {
477477
identifiers: ['baz'],
478478
},
479479
];
480-
wrapper.setProps({ topicSections, topicSectionsStyle: TopicStyles.detailedGrid });
480+
wrapper.setProps({ topicSections, topicSectionsStyle: TopicSectionsStyle.detailedGrid });
481481

482482
const topics = wrapper.find(Topics);
483483
expect(topics.exists()).toBe(true);
484484
expect(topics.props('sections')).toBe(topicSections);
485-
expect(topics.props('topicStyle')).toBe(TopicStyles.detailedGrid);
485+
expect(topics.props('topicStyle')).toBe(TopicSectionsStyle.detailedGrid);
486486
});
487487

488488
it('does not render the `Topics` if the `topicSectionsStyle` is `hidden`', () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import { shallowMount } from '@vue/test-utils';
1212
import DefaultImplementations from 'docc-render/components/DocumentationTopic/DefaultImplementations.vue';
13-
import { TopicStyles } from '@/constants/TopicStyles';
13+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
1414

1515
const { TopicsTable } = DefaultImplementations.components;
1616

@@ -42,7 +42,7 @@ describe('DefaultImplementations', () => {
4242
isSymbolBeta: false,
4343
title: 'Default Implementations',
4444
wrapTitle: true,
45-
topicStyle: TopicStyles.list,
45+
topicStyle: TopicSectionsStyle.list,
4646
});
4747
});
4848
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import { shallowMount } from '@vue/test-utils';
1212
import SeeAlso from 'docc-render/components/DocumentationTopic/SeeAlso.vue';
13-
import { TopicStyles } from '@/constants/TopicStyles';
13+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
1414

1515
const { TopicsTable } = SeeAlso.components;
1616

@@ -27,7 +27,7 @@ describe('SeeAlso', () => {
2727
sections: [],
2828
title: 'See Also',
2929
wrapTitle: false,
30-
topicStyle: TopicStyles.list,
30+
topicStyle: TopicSectionsStyle.list,
3131
});
3232
});
3333
});

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import { shallowMount } from '@vue/test-utils';
1212
import Topics from 'docc-render/components/DocumentationTopic/Topics.vue';
13-
import { TopicStyles } from '@/constants/TopicStyles';
13+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
1414

1515
const { TopicsTable } = Topics.components;
1616

@@ -19,7 +19,7 @@ describe('Topics', () => {
1919
const wrapper = shallowMount(Topics, {
2020
propsData: {
2121
sections: [],
22-
topicStyle: TopicStyles.list,
22+
topicStyle: TopicSectionsStyle.list,
2323
},
2424
});
2525

@@ -32,13 +32,13 @@ describe('Topics', () => {
3232
sections: [],
3333
title: 'Topics',
3434
wrapTitle: false,
35-
topicStyle: TopicStyles.list,
35+
topicStyle: TopicSectionsStyle.list,
3636
});
3737
table.setProps({ isSymbolDeprecated: true });
3838
expect(table.props('isSymbolDeprecated')).toBe(true);
3939
table.setProps({ isSymbolBeta: true });
4040
expect(table.props('isSymbolBeta')).toBe(true);
41-
table.setProps({ topicStyle: TopicStyles.compactGrid });
42-
expect(table.props('topicStyle')).toBe(TopicStyles.compactGrid);
41+
table.setProps({ topicStyle: TopicSectionsStyle.compactGrid });
42+
expect(table.props('topicStyle')).toBe(TopicSectionsStyle.compactGrid);
4343
});
4444
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import TopicsLinkCardGrid from '@/components/DocumentationTopic/TopicsLinkCardGrid.vue';
1212
import { shallowMount } from '@vue/test-utils';
13-
import { TopicStyles } from '@/constants/TopicStyles';
13+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
1414
import Row from '@/components/ContentNode/Row.vue';
1515
import Column from '@/components/ContentNode/Column.vue';
1616
import TopicsLinkCardGridItem from '@/components/DocumentationTopic/TopicsLinkCardGridItem.vue';
@@ -48,7 +48,7 @@ describe('TopicsLinkCardGrid', () => {
4848
const wrapper = createWrapper({
4949
propsData: {
5050
...defaultProps,
51-
topicStyle: TopicStyles.detailedGrid,
51+
topicStyle: TopicSectionsStyle.detailedGrid,
5252
},
5353
});
5454
expect(wrapper.find(Row).props()).toEqual({

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import { shallowMount } from '@vue/test-utils';
1212
import TopicsTable from 'docc-render/components/DocumentationTopic/TopicsTable.vue';
13-
import { TopicStyles } from '@/constants/TopicStyles';
13+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
1414
import TopicsLinkCardGrid from '@/components/DocumentationTopic/TopicsLinkCardGrid.vue';
1515

1616
const {
@@ -112,21 +112,21 @@ describe('TopicsTable', () => {
112112
});
113113

114114
it('renders a `TopicsLinkCardGrid` if `topicStyle` is not `list`', () => {
115-
wrapper.setProps({ topicStyle: TopicStyles.compactGrid });
115+
wrapper.setProps({ topicStyle: TopicSectionsStyle.compactGrid });
116116
expect(wrapper.findAll(TopicsLinkBlock)).toHaveLength(0);
117117
const sections = wrapper.findAll(ContentTableSection);
118118

119119
const firstGrid = sections.at(0).find(TopicsLinkCardGrid);
120120
expect(firstGrid.classes('topic')).toBe(true);
121121
expect(firstGrid.props()).toEqual({
122-
topicStyle: TopicStyles.compactGrid,
122+
topicStyle: TopicSectionsStyle.compactGrid,
123123
items: [foo],
124124
});
125125

126126
const secondGrid = sections.at(1).find(TopicsLinkCardGrid);
127127
expect(secondGrid.classes('topic')).toBe(true);
128128
expect(secondGrid.props()).toEqual({
129-
topicStyle: TopicStyles.compactGrid,
129+
topicStyle: TopicSectionsStyle.compactGrid,
130130
items: [baz],
131131
});
132132
});

tests/unit/views/DocumentationTopic.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import AdjustableSidebarWidth from '@/components/AdjustableSidebarWidth.vue';
1717
import NavigatorDataProvider from '@/components/Navigator/NavigatorDataProvider.vue';
1818
import Language from '@/constants/Language';
1919
import Navigator from '@/components/Navigator.vue';
20-
import { TopicStyles } from '@/constants/TopicStyles';
20+
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
2121
import { storage } from '@/utils/storage';
2222
import { BreakpointName } from 'docc-render/utils/breakpoints';
2323
import StaticContentWidth from 'docc-render/components/DocumentationTopic/StaticContentWidth.vue';
@@ -541,20 +541,20 @@ describe('DocumentationTopic', () => {
541541
occ: ['documentation/objc'],
542542
swift: ['documentation/swift'],
543543
},
544-
topicSectionsStyle: TopicStyles.list, // default value
544+
topicSectionsStyle: TopicSectionsStyle.list, // default value
545545
});
546546
});
547547

548548
it('passes `topicSectionsStyle`', () => {
549549
wrapper.setData({
550550
topicData: {
551551
...topicData,
552-
topicSectionsStyle: TopicStyles.detailedGrid,
552+
topicSectionsStyle: TopicSectionsStyle.detailedGrid,
553553
},
554554
});
555555

556556
const topic = wrapper.find(Topic);
557-
expect(topic.props('topicSectionsStyle')).toEqual(TopicStyles.detailedGrid);
557+
expect(topic.props('topicSectionsStyle')).toEqual(TopicSectionsStyle.detailedGrid);
558558
});
559559

560560
it('provides an empty languagePaths, even if no variants', () => {

0 commit comments

Comments
 (0)