Skip to content

Commit 44c3a2c

Browse files
authored
Include Relationship section in minimized mode (#868) rdar://81022077
Include Relationship section in minimized mode (#868) rdar://81022077
1 parent f759fef commit 44c3a2c

File tree

6 files changed

+51
-19
lines changed

6 files changed

+51
-19
lines changed

src/components/DocumentationTopic.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
:source="remoteSource"
130130
:sections="primaryContentSectionsSanitized"
131131
/>
132-
<ViewMore v-if="shouldShowViewMoreLink" :url="viewMoreLink" />
133132
</div>
134133
<Topics
135134
v-if="shouldRenderTopicSection"
@@ -145,15 +144,21 @@
145144
:isSymbolBeta="isSymbolBeta"
146145
/>
147146
<Relationships
148-
v-if="relationshipsSections && !enableMinimized"
147+
v-if="relationshipsSections"
149148
:sections="relationshipsSections"
149+
:enableMinimized="enableMinimized"
150150
/>
151151
<!-- NOTE: see also may contain information about other apis, so we cannot
152152
pass deprecation and beta information -->
153153
<SeeAlso
154154
v-if="seeAlsoSections && !enableMinimized"
155155
:sections="seeAlsoSections"
156156
/>
157+
<ViewMore
158+
v-if="shouldShowViewMoreLink"
159+
:url="viewMoreLink"
160+
class="minimized-container"
161+
/>
157162
</div>
158163
<template v-if="enableOnThisPageNav">
159164
<OnThisPageStickyContainer v-show="isOnThisPageNavVisible">
@@ -831,6 +836,11 @@ $space-size: 15px;
831836
--aside-border-radius: 6px;
832837
--code-border-radius: 6px;
833838
839+
&:not(.declarations-container) {
840+
padding-left: 1.4rem;
841+
padding-right: 1.4rem;
842+
}
843+
834844
.description {
835845
margin-bottom: 1.5em;
836846
}
@@ -904,11 +914,6 @@ $space-size: 15px;
904914
}
905915
}
906916
907-
.full-width-container .doc-content .minimized-container {
908-
padding-left: 1.4rem;
909-
padding-right: 1.4rem;
910-
}
911-
912917
:deep() {
913918
.no-primary-content {
914919
// remove border-top for first section of the page

src/components/DocumentationTopic/ContentTable.vue

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33
4-
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
77
See https://swift.org/LICENSE.txt for license information
@@ -10,7 +10,7 @@
1010

1111
<template>
1212
<section class="contenttable alt-light">
13-
<div class="container">
13+
<div :class="['container', { 'minimized-container': enableMinimized }]">
1414
<LinkableHeading class="title" :anchor="anchor">{{ title }}</LinkableHeading>
1515
<slot />
1616
</div>
@@ -32,21 +32,36 @@ export default {
3232
type: String,
3333
required: true,
3434
},
35+
enableMinimized: {
36+
type: Boolean,
37+
default: false,
38+
},
3539
},
3640
};
3741
</script>
3842

3943
<style scoped lang="scss">
4044
@import 'docc-render/styles/_core.scss';
4145
42-
.container {
46+
.container:not(.minimized-container) {
4347
@include dynamic-content-container;
44-
padding-bottom: $section-spacing-single-side;
48+
}
49+
50+
.container {
51+
--section-spacing-single-side: #{$section-spacing-single-side};
52+
&.minimized-container {
53+
--section-spacing-single-side: 1.5em;
54+
55+
.contenttable-section {
56+
padding-top: var(--section-spacing-single-side);
57+
}
58+
}
59+
padding-bottom: var(--section-spacing-single-side);
4560
}
4661
4762
.title {
4863
@include font-styles(heading-2-reduced);
49-
padding-top: $section-spacing-single-side;
64+
padding-top: var(--section-spacing-single-side);
5065
border-top-color: var(--color-grid);
5166
border-top-style: solid;
5267
border-top-width: var(--content-table-title-border-width, 1px);

src/components/DocumentationTopic/Relationships.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33
4-
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
77
See https://swift.org/LICENSE.txt for license information
@@ -12,6 +12,7 @@
1212
<ContentTable
1313
:anchor="contentSectionData.anchor"
1414
:title="$t(contentSectionData.title)"
15+
:enableMinimized="enableMinimized"
1516
>
1617
<Section
1718
v-for="section in sectionsWithSymbols"
@@ -44,6 +45,10 @@ export default {
4445
type: Array,
4546
required: true,
4647
},
48+
enableMinimized: {
49+
type: Boolean,
50+
default: false,
51+
},
4752
},
4853
computed: {
4954
contentSectionData: () => MainContentSectionAnchors.relationships,

tests/unit/components/DocumentationTopic.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ describe('DocumentationTopic', () => {
692692
const viewMore = wrapper.find(ViewMore);
693693
expect(viewMore.exists()).toBe(true);
694694
expect(viewMore.props('url')).toEqual('/documentation/swift'); // normalized path
695+
expect(viewMore.classes()).toContain('minimized-container');
695696

696697
// should not render `ViewMore` in non-minimized mode
697698
wrapper.setProps({ enableMinimized: false });
@@ -984,10 +985,7 @@ describe('DocumentationTopic', () => {
984985
const relationships = wrapper.find(Relationships);
985986
expect(relationships.exists()).toBe(true);
986987
expect(relationships.props('sections')).toBe(relationshipsSections);
987-
988-
// Minimized view should not render Relationships
989-
wrapper.setProps({ enableMinimized: true });
990-
expect(wrapper.find(Relationships).exists()).toBe(false);
988+
expect(relationships.props('enableMinimized')).toBe(false);
991989
});
992990

993991
it('renders `Relationships` before `SeeAlso`', () => {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This source file is part of the Swift.org open source project
33
*
4-
* Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
* Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
* Licensed under Apache License v2.0 with Runtime Library Exception
66
*
77
* See https://swift.org/LICENSE.txt for license information
@@ -45,4 +45,12 @@ describe('ContentTable', () => {
4545
expect(p.exists()).toBe(true);
4646
expect(p.html()).toBe(slots.default);
4747
});
48+
49+
it('renders `minimized-container` class if in minimized mode', () => {
50+
const container = wrapper.find('.container');
51+
expect(container.classes()).not.toContain('minimized-container');
52+
53+
wrapper.setProps({ enableMinimized: true });
54+
expect(container.classes()).toContain('minimized-container');
55+
});
4856
});

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This source file is part of the Swift.org open source project
33
*
4-
* Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
* Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
* Licensed under Apache License v2.0 with Runtime Library Exception
66
*
77
* See https://swift.org/LICENSE.txt for license information
@@ -79,6 +79,7 @@ describe('Relationships', () => {
7979
expect(table.props()).toEqual({
8080
anchor: 'relationships',
8181
title: 'sections.relationships',
82+
enableMinimized: false,
8283
});
8384
});
8485

0 commit comments

Comments
 (0)