Skip to content

Commit 940167c

Browse files
authored
Remove ability to override icons in "Topics" section (#774)
Due to limitations with remote SVG assets, there can be an issue where the color of a custom icon may be present in multiple locations using the same color, which results in a less than ideal experience. Current known workarounds for this issue would necessitate server side headers for cross origin resource sharing, which DocC-Render can't control since it is a client-side only tool—with that in mind, it makes more sense to remove the ability for overriding the icon here and leaving it as something to customize in the hero element only for now. Resolves: rdar://120670171
1 parent ac9ba6c commit 940167c

File tree

4 files changed

+5
-55
lines changed

4 files changed

+5
-55
lines changed

src/components/DocumentationTopic/TopicLinkBlockIcon.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
-->
1010

1111
<template>
12-
<div class="topic-icon-wrapper" v-if="imageOverride || icon">
13-
<OverridableAsset v-if="imageOverride" :imageOverride="imageOverride" class="topic-icon" />
14-
<component v-else-if="icon" :is="icon" class="topic-icon" />
12+
<div class="topic-icon-wrapper" v-if="icon">
13+
<component :is="icon" class="topic-icon" />
1514
</div>
1615
</template>
1716

@@ -25,7 +24,6 @@ import TechnologyIcon from 'theme/components/Icons/TechnologyIcon.vue';
2524
import TutorialIcon from 'theme/components/Icons/TutorialIcon.vue';
2625
import SVGIcon from 'docc-render/components/SVGIcon.vue';
2726
import { TopicRole } from 'docc-render/constants/roles';
28-
import OverridableAsset from 'docc-render/components/OverridableAsset.vue';
2927
3028
const TopicRoleIcons = {
3129
[TopicRole.article]: ArticleIcon,
@@ -41,16 +39,12 @@ const TopicRoleIcons = {
4139
};
4240
4341
export default {
44-
components: { OverridableAsset, SVGIcon },
42+
components: { SVGIcon },
4543
props: {
4644
role: {
4745
type: String,
4846
required: true,
4947
},
50-
imageOverride: {
51-
type: Object,
52-
default: null,
53-
},
5448
},
5549
5650
computed: {

src/components/DocumentationTopic/TopicsLinkBlock.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<TopicLinkBlockIcon
2121
v-if="topic.role && !change"
2222
:role="topic.role"
23-
:imageOverride="references[iconOverride]"
2423
/>
2524
<DecoratedTopicTitle v-if="topic.fragments" :tokens="topic.fragments" />
2625
<WordBreak v-else :tag="titleTag">{{ topic.title }}</WordBreak>

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { mount } from '@vue/test-utils';
1313
import { TopicRole } from '@/constants/roles';
1414
import ArticleIcon from '@/components/Icons/ArticleIcon.vue';
1515
import TechnologyIcon from '@/components/Icons/TechnologyIcon.vue';
16-
import OverridableAsset from '@/components/OverridableAsset.vue';
1716

1817
const defaultProps = {
1918
role: TopicRole.article,
@@ -33,30 +32,9 @@ describe('TopicLinkBlockIcon', () => {
3332
expect(wrapper.find('.topic-icon').is(ArticleIcon)).toBe(true);
3433
});
3534

36-
it('renders an override icon from an image override', () => {
37-
const imageOverride = {
38-
variants: [{
39-
url: '/foo/bar',
40-
svgID: 'foo',
41-
}],
42-
};
35+
it('renders nothing if no role', () => {
4336
const wrapper = createWrapper({
4437
propsData: {
45-
imageOverride,
46-
},
47-
});
48-
const icon = wrapper.find('.topic-icon');
49-
expect(icon.is(ArticleIcon)).toBe(false);
50-
expect(icon.is(OverridableAsset)).toBe(true);
51-
expect(icon.props()).toMatchObject({
52-
imageOverride,
53-
});
54-
});
55-
56-
it('renders nothing if no role or image override', () => {
57-
const wrapper = createWrapper({
58-
propsData: {
59-
imageOverride: null,
6038
role: TopicRole.devLink, // no icon for this
6139
},
6240
});

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,13 @@ describe('TopicsLinkBlock', () => {
3232
/** @type {import('@vue/test-utils').Wrapper} */
3333
let wrapper;
3434

35-
const iconOverride = {
36-
type: 'icon',
37-
identifier: 'icon-override',
38-
};
39-
40-
const references = {
41-
[iconOverride.identifier]: { foo: 'bar' },
42-
};
43-
4435
const store = {
4536
reset: jest.fn(),
4637
setAPIChanges: jest.fn(),
4738
state: {
4839
onThisPageSections: [],
4940
apiChanges: null,
50-
references,
41+
references: {},
5142
},
5243
};
5344

@@ -135,18 +126,6 @@ describe('TopicsLinkBlock', () => {
135126
expect(link.props('role')).toBe(propsData.topic.role);
136127
});
137128

138-
it('renders a TopicLinkBlockIcon with an override', () => {
139-
const icon = wrapper.find(TopicLinkBlockIcon);
140-
expect(icon.props('imageOverride')).toBe(null);
141-
wrapper.setProps({
142-
topic: {
143-
...propsData.topic,
144-
images: [iconOverride, { type: 'card', identifier: 'foo' }],
145-
},
146-
});
147-
expect(icon.props('imageOverride')).toBe(references[iconOverride.identifier]);
148-
});
149-
150129
it('renders a normal `WordBreak` for the link text', () => {
151130
const wordBreak = wrapper.find('.link').find(WordBreak);
152131
expect(wordBreak.exists()).toBe(true);

0 commit comments

Comments
 (0)