Skip to content

Commit 4e3a9b1

Browse files
authored
Merge pull request #10 from hqhhuang/remove-hero-from-symbol
New Hero/Introduction section design: Remove Dark Hero from symbol pages Fixes: rdar://89970711
2 parents d557ab1 + fcf7b70 commit 4e3a9b1

File tree

6 files changed

+82
-13
lines changed

6 files changed

+82
-13
lines changed

src/components/DocumentationTopic.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<template>
1212
<div class="doc-topic">
1313
<main class="main" id="main" role="main" tabindex="0">
14-
<DocumentationHero :type="symbolKind || role">
14+
<DocumentationHero :type="symbolKind || role" :enhanceBackground="enhanceBackground">
1515
<slot name="above-title" />
1616
<Title :eyebrow="roleHeading">{{ title }}</Title>
1717
<Abstract v-if="abstract" :content="abstract" />
@@ -52,6 +52,7 @@
5252
</Summary>
5353
<PrimaryContent
5454
v-if="primaryContentSections && primaryContentSections.length"
55+
:class="{ 'with-border': !enhanceBackground }"
5556
:conformance="conformance"
5657
:sections="primaryContentSections"
5758
/>
@@ -300,6 +301,7 @@ export default {
300301
),
301302
shouldShowLanguageSwitcher: ({ objcPath, swiftPath }) => objcPath && swiftPath,
302303
hideSummary: () => getSetting(['features', 'docs', 'summary', 'hide'], false),
304+
enhanceBackground: ({ symbolKind }) => (symbolKind ? (symbolKind === 'module') : true),
303305
},
304306
methods: {
305307
normalizePath(path) {

src/components/DocumentationTopic/DocumentationHero.vue

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@
99
-->
1010

1111
<template>
12-
<div class="documentation-hero" :style="styles">
13-
<NavigatorLeafIcon :type="type" key="first" class="background-icon first-icon" with-colors />
14-
<NavigatorLeafIcon :type="type" key="second" class="background-icon second-icon" with-colors />
12+
<div
13+
:class="['documentation-hero', { 'documentation-hero--disabled': !enhanceBackground }]"
14+
:style="styles"
15+
>
16+
<NavigatorLeafIcon
17+
v-if="enhanceBackground" :type="type"
18+
key="first" class="background-icon first-icon" with-colors
19+
/>
20+
<NavigatorLeafIcon
21+
v-if="enhanceBackground" :type="type"
22+
key="second" class="background-icon second-icon" with-colors
23+
/>
1524
<div class="documentation-hero__content">
1625
<slot />
1726
</div>
@@ -31,6 +40,10 @@ export default {
3140
type: String,
3241
required: true,
3342
},
43+
enhanceBackground: {
44+
type: Boolean,
45+
required: true,
46+
},
3447
},
3548
computed: {
3649
// get the alias, if any, and fallback to the `teal` color
@@ -53,7 +66,7 @@ $doc-hero-icon-color: dark-color(fill-secondary) !default;
5366
5467
.documentation-hero {
5568
background: dark-color(fill);
56-
color: light-color(fill);
69+
color: dark-color(figure-gray);
5770
overflow: hidden;
5871
text-align: left;
5972
padding-top: rem(40px);
@@ -127,4 +140,17 @@ $doc-hero-icon-color: dark-color(fill-secondary) !default;
127140
@include dynamic-content-container;
128141
}
129142
}
143+
144+
.documentation-hero--disabled {
145+
background: none;
146+
color: var(--colors-text, var(--color-text));
147+
148+
&:before {
149+
content: none;
150+
}
151+
152+
&:after {
153+
content: none;
154+
}
155+
}
130156
</style>

src/components/DocumentationTopic/PrimaryContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default {
150150
}
151151
152152
.primary-content {
153-
&::before {
153+
&.with-border::before {
154154
border-top-color: var(--colors-grid, var(--color-grid));
155155
border-top-style: solid;
156156
border-top-width: 1px;

src/components/DocumentationTopic/Title.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ export default {
3535
3636
.eyebrow {
3737
@include font-styles(eyebrow-reduced);
38-
color: light-color(fill-gray-tertiary);
38+
color: dark-color(figure-gray-secondary);
3939
display: block;
4040
margin-bottom: rem(20px);
41+
42+
.documentation-hero--disabled & {
43+
color: var(--colors-secondary-label, var(--color-secondary-label));
44+
}
4145
}
4246
4347
.title {
4448
@include font-styles(headline-reduced);
45-
color: light-color(fill);
49+
color: dark-color(figure-gray);
4650
margin-bottom: rem(12px);
51+
52+
.documentation-hero--disabled & {
53+
color: var(--colors-header-text, var(--color-header-text));
54+
}
4755
}
4856
</style>

tests/unit/components/DocumentationTopic.spec.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,36 @@ describe('DocumentationTopic', () => {
205205
expect(main.attributes('tabindex')).toBe('0');
206206
});
207207

208-
it('renders a `DocumentationHero`', () => {
208+
it('renders a `DocumentationHero`, enabled', () => {
209209
const hero = wrapper.find(DocumentationHero);
210210
expect(hero.exists()).toBe(true);
211-
expect(hero.props()).toEqual({ type: propsData.symbolKind });
211+
expect(hero.props()).toEqual({ type: propsData.symbolKind, enhanceBackground: true });
212212
});
213213

214-
it('renders a `DocumentationHero`, with a the `role`, if no symbolKind', () => {
214+
it('renders a `DocumentationHero`, enabled, with a the `role`, if no symbolKind', () => {
215215
wrapper.setProps({
216216
role: TopicTypes.article,
217217
symbolKind: '',
218218
});
219219
const hero = wrapper.find(DocumentationHero);
220-
expect(hero.props()).toEqual({ type: TopicTypes.article });
220+
expect(hero.props()).toEqual({ type: TopicTypes.article, enhanceBackground: true });
221+
});
222+
223+
it('render a `DocumentationHero`, enabled, if top-level technology page', () => {
224+
wrapper.setProps({
225+
role: TopicTypes.collection,
226+
symbolKind: 'module',
227+
});
228+
const hero = wrapper.find(DocumentationHero);
229+
expect(hero.props()).toEqual({ type: TopicTypes.module, enhanceBackground: true });
230+
});
231+
232+
it('render a `DocumentationHero`, disabled, if symbol page', () => {
233+
wrapper.setProps({
234+
symbolKind: 'protocol',
235+
});
236+
const hero = wrapper.find(DocumentationHero);
237+
expect(hero.props()).toEqual({ type: TopicTypes.protocol, enhanceBackground: false });
221238
});
222239

223240
it('renders a `Title`', () => {

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import NavigatorLeafIcon from '@/components/Navigator/NavigatorLeafIcon.vue';
2020

2121
const defaultProps = {
2222
type: TopicTypes.class,
23+
enhanceBackground: true,
2324
};
2425

2526
const createWrapper = ({ propsData, ...others } = {}) => shallowMount(DocumentationHero, {
@@ -34,7 +35,7 @@ const createWrapper = ({ propsData, ...others } = {}) => shallowMount(Documentat
3435
});
3536

3637
describe('DocumentationHero', () => {
37-
it('renders the DocumentationHero', () => {
38+
it('renders the DocumentationHero, enabled', () => {
3839
const wrapper = createWrapper();
3940
const allIcons = wrapper.findAll(NavigatorLeafIcon);
4041
expect(allIcons).toHaveLength(2);
@@ -73,4 +74,19 @@ describe('DocumentationHero', () => {
7374
'--accent-color': `var(--color-type-icon-${TopicTypeColors.teal}, var(--color-figure-gray-secondary))`,
7475
});
7576
});
77+
78+
it('renders the DocumentationHero, disabled', () => {
79+
const wrapper = createWrapper();
80+
wrapper.setProps({
81+
enhanceBackground: false,
82+
});
83+
// assert no icon
84+
const allIcons = wrapper.findAll(NavigatorLeafIcon);
85+
expect(allIcons).toHaveLength(0);
86+
// assert slot
87+
expect(wrapper.find('.default-slot').text()).toBe('Default Slot');
88+
expect(wrapper.vm.styles).toEqual({
89+
'--accent-color': `var(--color-type-icon-${TopicTypeColorsMap[defaultProps.type]}, var(--color-figure-gray-secondary))`,
90+
});
91+
});
7692
});

0 commit comments

Comments
 (0)