Skip to content

Commit 95efff7

Browse files
author
Dobromir Hristov
committed
refactor: move navigator and nav to the view component
1 parent 3b059eb commit 95efff7

File tree

5 files changed

+225
-173
lines changed

5 files changed

+225
-173
lines changed

src/components/DocumentationTopic.vue

Lines changed: 78 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -10,115 +10,72 @@
1010

1111
<template>
1212
<div class="doc-topic">
13-
<Nav
14-
v-if="!isTargetIDE"
15-
:title="title"
16-
:diffAvailability="diffAvailability"
17-
:interfaceLanguage="interfaceLanguage"
18-
:objcPath="objcPath"
19-
:swiftPath="swiftPath"
20-
:parentTopicIdentifiers="parentTopicIdentifiers"
21-
:isSymbolDeprecated="isSymbolDeprecated"
22-
:isSymbolBeta="isSymbolBeta"
23-
:currentTopicTags="tags"
24-
@toggle-sidenav="isSideNavOpen = !isSideNavOpen"
25-
/>
26-
<AdjustableSidebarWidth
27-
class="full-width-container"
28-
:open-externally="isSideNavOpen"
29-
:min-width="320"
30-
:max-width="1800"
31-
:hide-sidebar="isTargetIDE"
32-
@width-change="handleWidthChange"
33-
>
34-
<template #aside>
35-
<aside class="doc-topic-aside">
36-
<NavigatorDataProvider
37-
:interface-language="interfaceLanguage"
38-
:technology="technology"
39-
>
40-
<template #default="{ technology, isFetching }">
41-
<Navigator
42-
v-if="technology"
43-
:show-extra-info="showExtraNavigatorInfo"
44-
:parent-topic-identifiers="navigatorParentTopicIdentifiers"
45-
:technology="technology"
46-
:is_fetching="isFetching"
47-
@close="isSideNavOpen = false"
48-
/>
49-
</template>
50-
</NavigatorDataProvider>
51-
</aside>
52-
</template>
53-
<template #default>
54-
<main class="main" id="main" role="main" tabindex="0">
13+
<main class="main" id="main" role="main" tabindex="0">
5514

56-
<slot name="above-title" />
57-
<Title :eyebrow="roleHeading">{{ title }}</Title>
58-
<div class="container content-grid" :class="{ 'full-width': hideSummary }">
59-
<Description :hasOverview="hasOverview">
60-
<Abstract v-if="abstract" :content="abstract" />
61-
<RequirementMetadata
62-
v-if="isRequirement"
63-
:defaultImplementationsCount="defaultImplementationsCount"
64-
/>
65-
<Aside v-if="deprecationSummary && deprecationSummary.length" kind="deprecated">
66-
<ContentNode :content="deprecationSummary" />
67-
</Aside>
68-
<Aside
69-
v-if="downloadNotAvailableSummary && downloadNotAvailableSummary.length"
70-
kind="note"
71-
>
72-
<ContentNode :content="downloadNotAvailableSummary" />
73-
</Aside>
74-
<DownloadButton v-if="sampleCodeDownload" :action="sampleCodeDownload.action" />
75-
</Description>
76-
<Summary v-if="!hideSummary">
77-
<LanguageSwitcher
78-
v-if="shouldShowLanguageSwitcher"
79-
:interfaceLanguage="interfaceLanguage"
80-
:objcPath="objcPath"
81-
:swiftPath="swiftPath"
82-
/>
83-
<Availability v-if="platforms" :platforms="platforms" />
84-
<TechnologyList v-if="modules" :technologies="modules" />
85-
<TechnologyList
86-
v-if="extendsTechnology"
87-
class="extends-technology"
88-
title="Extends"
89-
:technologies="[{ name: extendsTechnology }]"
90-
/>
91-
<OnThisPageNav v-if="onThisPageSections.length > 1" :sections="onThisPageSections" />
92-
</Summary>
93-
<PrimaryContent
94-
v-if="primaryContentSections && primaryContentSections.length"
95-
:conformance="conformance"
96-
:sections="primaryContentSections"
97-
/>
98-
</div>
99-
<Topics
100-
v-if="topicSections"
101-
:sections="topicSections"
102-
:isSymbolDeprecated="isSymbolDeprecated"
103-
:isSymbolBeta="isSymbolBeta"
15+
<slot name="above-title" />
16+
<Title :eyebrow="roleHeading">{{ title }}</Title>
17+
<div class="container content-grid" :class="{ 'full-width': hideSummary }">
18+
<Description :hasOverview="hasOverview">
19+
<Abstract v-if="abstract" :content="abstract" />
20+
<RequirementMetadata
21+
v-if="isRequirement"
22+
:defaultImplementationsCount="defaultImplementationsCount"
10423
/>
105-
<DefaultImplementations
106-
v-if="defaultImplementationsSections"
107-
:sections="defaultImplementationsSections"
108-
:isSymbolDeprecated="isSymbolDeprecated"
109-
:isSymbolBeta="isSymbolBeta"
24+
<Aside v-if="deprecationSummary && deprecationSummary.length" kind="deprecated">
25+
<ContentNode :content="deprecationSummary" />
26+
</Aside>
27+
<Aside
28+
v-if="downloadNotAvailableSummary && downloadNotAvailableSummary.length"
29+
kind="note"
30+
>
31+
<ContentNode :content="downloadNotAvailableSummary" />
32+
</Aside>
33+
<DownloadButton v-if="sampleCodeDownload" :action="sampleCodeDownload.action" />
34+
</Description>
35+
<Summary v-if="!hideSummary">
36+
<LanguageSwitcher
37+
v-if="shouldShowLanguageSwitcher"
38+
:interfaceLanguage="interfaceLanguage"
39+
:objcPath="objcPath"
40+
:swiftPath="swiftPath"
11041
/>
111-
<Relationships v-if="relationshipsSections" :sections="relationshipsSections" />
112-
<!-- NOTE: see also may contain information about other apis, so we cannot
113-
pass deprecation and beta information -->
114-
<SeeAlso
115-
v-if="seeAlsoSections"
116-
:sections="seeAlsoSections"
42+
<Availability v-if="platforms" :platforms="platforms" />
43+
<TechnologyList v-if="modules" :technologies="modules" />
44+
<TechnologyList
45+
v-if="extendsTechnology"
46+
class="extends-technology"
47+
title="Extends"
48+
:technologies="[{ name: extendsTechnology }]"
11749
/>
118-
<BetaLegalText v-if="!isTargetIDE && hasBetaContent" />
119-
</main>
120-
</template>
121-
</AdjustableSidebarWidth>
50+
<OnThisPageNav v-if="onThisPageSections.length > 1" :sections="onThisPageSections" />
51+
</Summary>
52+
<PrimaryContent
53+
v-if="primaryContentSections && primaryContentSections.length"
54+
:conformance="conformance"
55+
:sections="primaryContentSections"
56+
/>
57+
</div>
58+
<Topics
59+
v-if="topicSections"
60+
:sections="topicSections"
61+
:isSymbolDeprecated="isSymbolDeprecated"
62+
:isSymbolBeta="isSymbolBeta"
63+
/>
64+
<DefaultImplementations
65+
v-if="defaultImplementationsSections"
66+
:sections="defaultImplementationsSections"
67+
:isSymbolDeprecated="isSymbolDeprecated"
68+
:isSymbolBeta="isSymbolBeta"
69+
/>
70+
<Relationships v-if="relationshipsSections" :sections="relationshipsSections" />
71+
<!-- NOTE: see also may contain information about other apis, so we cannot
72+
pass deprecation and beta information -->
73+
<SeeAlso
74+
v-if="seeAlsoSections"
75+
:sections="seeAlsoSections"
76+
/>
77+
<BetaLegalText v-if="!isTargetIDE && hasBetaContent" />
78+
</main>
12279
</div>
12380
</template>
12481

@@ -128,12 +85,8 @@ import pageTitle from 'docc-render/mixins/pageTitle';
12885
import { getSetting } from 'docc-render/utils/theme-settings';
12986
13087
import Aside from 'docc-render/components/ContentNode/Aside.vue';
131-
import DocumentationNav from 'theme/components/DocumentationTopic/DocumentationNav.vue';
13288
import BetaLegalText from 'theme/components/DocumentationTopic/BetaLegalText.vue';
13389
import LanguageSwitcher from 'theme/components/DocumentationTopic/Summary/LanguageSwitcher.vue';
134-
import AdjustableSidebarWidth from 'docc-render/components/AdjustableSidebarWidth.vue';
135-
import Navigator from 'docc-render/components/Navigator.vue';
136-
import NavigatorDataProvider from 'theme/components/Navigator/NavigatorDataProvider.vue';
13790
import Abstract from './DocumentationTopic/Description/Abstract.vue';
13891
import ContentNode from './DocumentationTopic/ContentNode.vue';
13992
import CallToActionButton from './CallToActionButton.vue';
@@ -169,9 +122,6 @@ export default {
169122
},
170123
},
171124
components: {
172-
NavigatorDataProvider,
173-
Navigator,
174-
AdjustableSidebarWidth,
175125
Abstract,
176126
Aside,
177127
BetaLegalText,
@@ -181,7 +131,6 @@ export default {
181131
DownloadButton: CallToActionButton,
182132
TechnologyList,
183133
LanguageSwitcher,
184-
Nav: DocumentationNav,
185134
OnThisPageNav,
186135
PrimaryContent,
187136
Relationships,
@@ -284,6 +233,22 @@ export default {
284233
type: Array,
285234
required: true,
286235
},
236+
objcPath: {
237+
type: String,
238+
required: false,
239+
},
240+
swiftPath: {
241+
type: String,
242+
required: false,
243+
},
244+
isSymbolDeprecated: {
245+
type: Boolean,
246+
required: false,
247+
},
248+
isSymbolBeta: {
249+
type: Boolean,
250+
required: false,
251+
},
287252
},
288253
provide() {
289254
// NOTE: this is not reactive: if this.references change, the provided value
@@ -298,8 +263,6 @@ export default {
298263
data() {
299264
return {
300265
topicState: this.store.state,
301-
isSideNavOpen: false,
302-
showExtraNavigatorInfo: false,
303266
};
304267
},
305268
computed: {
@@ -320,38 +283,14 @@ export default {
320283
[trait.interfaceLanguage]: (_memo[trait.interfaceLanguage] || []).concat(variant.paths),
321284
})), memo)
322285
), {}),
323-
// The first path for any variant with an "occ" interface language trait (if any)
324-
objcPath: ({ languagePaths: { [Language.objectiveC.key.api]: [path] = [] } = {} }) => path,
325-
// The first path for any variant with a "swift" interface language trait (if any)
326-
swiftPath: ({ languagePaths: { [Language.swift.key.api]: [path] = [] } = {} }) => path,
327286
onThisPageSections() {
328287
return this.topicState.onThisPageSections;
329288
},
330-
isSymbolBeta:
331-
({ platforms }) => platforms
332-
&& platforms.length
333-
&& platforms.every(platform => platform.beta),
334289
hasBetaContent:
335290
({ platforms }) => platforms
336291
&& platforms.length
337292
&& platforms.some(platform => platform.beta),
338-
isSymbolDeprecated:
339-
({ platforms, deprecationSummary }) => (deprecationSummary && deprecationSummary.length > 0)
340-
|| (platforms
341-
&& platforms.length
342-
&& platforms.every(platform => platform.deprecatedAt)
343-
),
344293
pageTitle: ({ title }) => title,
345-
// The `hierarchy.paths` array will contain zero or more subarrays, each
346-
// representing a "path" of parent topic IDs that could be considered the
347-
// hierarchy/breadcrumb for a given topic. We choose to render only the
348-
// first one.
349-
parentTopicIdentifiers: ({ hierarchy: { paths: [ids = []] = [] } }) => ids,
350-
navigatorParentTopicIdentifiers: ({ hierarchy: { paths = [] } }) => paths.slice(-1)[0],
351-
technology: ({ references, parentTopicIdentifiers, identifier }) => {
352-
if (parentTopicIdentifiers.length) return references[parentTopicIdentifiers[0]];
353-
return references[identifier];
354-
},
355294
shouldShowLanguageSwitcher: ({ objcPath, swiftPath }) => objcPath && swiftPath,
356295
hideSummary: () => getSetting(['features', 'docs', 'summary', 'hide'], false),
357296
},
@@ -361,9 +300,6 @@ export default {
361300
// slash and sometimes they aren't
362301
return path.startsWith('/') ? path : `/${path}`;
363302
},
364-
handleWidthChange(width) {
365-
this.showExtraNavigatorInfo = width > 500;
366-
},
367303
},
368304
created() {
369305
// Switch to the Objective-C variant of a page if the query parameter is not
@@ -400,15 +336,6 @@ export default {
400336
height: 100%;
401337
}
402338
403-
.full-width-container {
404-
flex: 1 1 auto;
405-
width: 100%;
406-
407-
@include inTargetWeb {
408-
@include breakpoint-full-width-container()
409-
}
410-
}
411-
412339
#main {
413340
outline-style: none;
414341
border-left: 1px solid var(--color-grid);
@@ -467,14 +394,6 @@ export default {
467394
margin-top: 2em;
468395
}
469396
470-
.doc-topic-aside {
471-
height: 100%;
472-
box-sizing: border-box;
473-
@include breakpoint(small) {
474-
background: var(--color-fill);
475-
}
476-
}
477-
478397
/deep/ {
479398
@each $heading in (h3, h4, h5, h6) {
480399
#{$heading} {

src/components/DocumentationTopic/DocumentationNav.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
:isSymbolBeta="isSymbolBeta"
4747
:parentTopicIdentifiers="hierarchyItems"
4848
:currentTopicTags="currentTopicTags"
49+
:references="references"
4950
/>
5051
<slot name="tray-after" v-bind="{ breadcrumbCount }" />
5152
</template>
@@ -97,9 +98,8 @@ export default {
9798
type: Array,
9899
required: true,
99100
},
100-
},
101-
inject: {
102101
references: {
102+
type: Object,
103103
default: () => ({}),
104104
},
105105
},

src/components/DocumentationTopic/DocumentationNav/Hierarchy.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,10 @@ export default {
7070
HierarchyCollapsedItems,
7171
HierarchyItem,
7272
},
73-
inject: {
74-
references: {
75-
default: () => ({}),
76-
},
77-
},
7873
props: {
7974
isSymbolDeprecated: Boolean,
8075
isSymbolBeta: Boolean,
76+
references: Object,
8177
currentTopicTitle: {
8278
type: String,
8379
required: true,

src/components/Navigator.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ export default {
8484
type: Boolean,
8585
default: false,
8686
},
87+
references: {
88+
type: Object,
89+
default: () => {},
90+
},
8791
},
88-
inject: ['references'],
8992
data() {
9093
return {
9194
filter: '',

0 commit comments

Comments
 (0)