Skip to content

Commit 8adc18e

Browse files
authored
Localnav & Navigator UI changes and refactors (#772)
[rdar://116401230] Localnav & Navigator UI changes and refactors
1 parent 78f9ae6 commit 8adc18e

34 files changed

+633
-732
lines changed

src/components/DocumentationTopic.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
<slot name="above-hero-content" />
3131
</template>
3232
<slot name="above-title" />
33+
<Hierarchy
34+
v-if="hierarchyItems.length && !enableMinimized"
35+
:currentTopicTitle="title"
36+
:isSymbolDeprecated="isSymbolDeprecated"
37+
:isSymbolBeta="isSymbolBeta"
38+
:parentTopicIdentifiers="hierarchyItems"
39+
:currentTopicTags="tags"
40+
/>
3341
<LanguageSwitcher
3442
v-if="shouldShowLanguageSwitcher"
3543
:interfaceLanguage="interfaceLanguage"
@@ -172,7 +180,7 @@ import Aside from 'docc-render/components/ContentNode/Aside.vue';
172180
import BetaLegalText from 'theme/components/DocumentationTopic/BetaLegalText.vue';
173181
import LanguageSwitcher from 'theme/components/DocumentationTopic/Summary/LanguageSwitcher.vue';
174182
import ViewMore from 'theme/components/DocumentationTopic/ViewMore.vue';
175-
import DocumentationHero from 'docc-render/components/DocumentationTopic/DocumentationHero.vue';
183+
import DocumentationHero from 'docc-render/components/DocumentationTopic/Hero/DocumentationHero.vue';
176184
import WordBreak from 'docc-render/components/WordBreak.vue';
177185
import { TopicSectionsStyle } from 'docc-render/constants/TopicSectionsStyle';
178186
import OnThisPageNav from 'theme/components/OnThisPageNav.vue';
@@ -189,9 +197,10 @@ import Relationships from './DocumentationTopic/Relationships.vue';
189197
import RequirementMetadata from './DocumentationTopic/Description/RequirementMetadata.vue';
190198
import Availability from './DocumentationTopic/Summary/Availability.vue';
191199
import SeeAlso from './DocumentationTopic/SeeAlso.vue';
192-
import Title from './DocumentationTopic/Title.vue';
200+
import Title from './DocumentationTopic/Hero/Title.vue';
193201
import Topics from './DocumentationTopic/Topics.vue';
194202
import OnThisPageStickyContainer from './DocumentationTopic/OnThisPageStickyContainer.vue';
203+
import Hierarchy from './DocumentationTopic/Hero/Hierarchy.vue';
195204
196205
// size above which, the OnThisPage container is visible
197206
const ON_THIS_PAGE_CONTAINER_BREAKPOINT = 1050;
@@ -236,6 +245,7 @@ export default {
236245
Topics,
237246
ViewMore,
238247
WordBreak,
248+
Hierarchy,
239249
InlinePlusCircleIcon,
240250
},
241251
props: {
@@ -388,6 +398,10 @@ export default {
388398
type: Array,
389399
required: false,
390400
},
401+
hierarchyItems: {
402+
type: Array,
403+
default: () => ([]),
404+
},
391405
},
392406
provide() {
393407
// NOTE: this is not reactive: if this.identifier change, the provided value

src/components/DocumentationTopic/DocumentationNav.vue

Lines changed: 21 additions & 133 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-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,7 +12,6 @@
1212
<NavBase
1313
:breakpoint="BreakpointName.medium"
1414
:hasOverlay="false"
15-
hasSolidBackground
1615
:hasNoBorder="hasNoBorder"
1716
:isDark="isDark"
1817
isWideFormat
@@ -22,54 +21,27 @@
2221
>
2322
<template #pre-title="{ closeNav, isOpen, currentBreakpoint, className }" v-if="displaySidenav">
2423
<div :class="className">
25-
<transition name="sidenav-toggle">
26-
<div
27-
v-show="sidenavHiddenOnLarge"
28-
class="sidenav-toggle-wrapper"
24+
<div class="sidenav-toggle-wrapper">
25+
<button
26+
:aria-label="$t('navigator.open-navigator')"
27+
:id="baseNavOpenSidenavButtonId"
28+
class="sidenav-toggle"
29+
:tabindex="isOpen ? -1 : null"
30+
@click.prevent="handleSidenavToggle(closeNav, currentBreakpoint)"
2931
>
30-
<button
31-
:aria-label="$t('navigator.open-navigator')"
32-
:id="baseNavOpenSidenavButtonId"
33-
class="sidenav-toggle"
34-
:tabindex="isOpen ? -1 : null"
35-
@click.prevent="handleSidenavToggle(closeNav, currentBreakpoint)"
36-
>
37-
<span class="sidenav-icon-wrapper">
38-
<SidenavIcon class="icon-inline sidenav-icon" />
39-
</span>
40-
</button>
41-
<span class="sidenav-toggle__separator" />
42-
</div>
43-
</transition>
32+
<span class="sidenav-icon-wrapper">
33+
<SidenavIcon class="icon-inline sidenav-icon" />
34+
</span>
35+
</button>
36+
</div>
4437
</div>
4538
</template>
4639
<template #default>
47-
<slot
48-
name="title"
49-
v-bind="{ rootLink, linkClass: 'nav-title-link', inactiveClass: 'inactive' }"
50-
>
51-
<router-link
52-
v-if="rootLink"
53-
:to="rootLink"
54-
class="nav-title-link"
55-
>
56-
{{ $t('documentation.title') }}
57-
</router-link>
58-
<span v-else class="nav-title-link inactive">{{ $t('documentation.title') }}</span>
59-
</slot>
40+
<slot name="title" />
6041
</template>
6142
<template #tray="{ closeNav }">
62-
<Hierarchy
63-
:currentTopicTitle="title"
64-
:isSymbolDeprecated="isSymbolDeprecated"
65-
:isSymbolBeta="isSymbolBeta"
66-
:parentTopicIdentifiers="hierarchyItems"
67-
:currentTopicTags="currentTopicTags"
68-
:references="references"
69-
/>
7043
<NavMenuItems
7144
class="nav-menu-settings"
72-
:previousSiblingChildren="breadcrumbCount"
7345
>
7446
<LanguageToggle
7547
v-if="interfaceLanguage && (swiftPath || objcPath)"
@@ -80,7 +52,7 @@
8052
/>
8153
<slot name="menu-items" />
8254
</NavMenuItems>
83-
<slot name="tray-after" v-bind="{ breadcrumbCount }" />
55+
<slot name="tray-after" />
8456
</template>
8557
<template #after-content>
8658
<slot name="after-content" />
@@ -95,7 +67,6 @@ import { BreakpointName } from 'docc-render/utils/breakpoints';
9567
import SidenavIcon from 'theme/components/Icons/SidenavIcon.vue';
9668
import { SIDEBAR_HIDE_BUTTON_ID } from 'docc-render/constants/sidebar';
9769
import { baseNavOpenSidenavButtonId } from 'docc-render/constants/nav';
98-
import Hierarchy from './DocumentationNav/Hierarchy.vue';
9970
import LanguageToggle from './DocumentationNav/LanguageToggle.vue';
10071
10172
export default {
@@ -104,26 +75,9 @@ export default {
10475
SidenavIcon,
10576
NavBase,
10677
NavMenuItems,
107-
Hierarchy,
10878
LanguageToggle,
10979
},
11080
props: {
111-
title: {
112-
type: String,
113-
required: false,
114-
},
115-
parentTopicIdentifiers: {
116-
type: Array,
117-
required: false,
118-
},
119-
isSymbolBeta: {
120-
type: Boolean,
121-
required: false,
122-
},
123-
isSymbolDeprecated: {
124-
type: Boolean,
125-
required: false,
126-
},
12781
isDark: {
12882
type: Boolean,
12983
default: false,
@@ -132,14 +86,6 @@ export default {
13286
type: Boolean,
13387
default: false,
13488
},
135-
currentTopicTags: {
136-
type: Array,
137-
required: true,
138-
},
139-
references: {
140-
type: Object,
141-
default: () => ({}),
142-
},
14389
interfaceLanguage: {
14490
type: String,
14591
required: false,
@@ -152,10 +98,6 @@ export default {
15298
type: String,
15399
required: false,
154100
},
155-
sidenavHiddenOnLarge: {
156-
type: Boolean,
157-
default: false,
158-
},
159101
displaySidenav: {
160102
type: Boolean,
161103
default: false,
@@ -164,38 +106,6 @@ export default {
164106
computed: {
165107
baseNavOpenSidenavButtonId: () => baseNavOpenSidenavButtonId,
166108
BreakpointName: () => BreakpointName,
167-
breadcrumbCount: ({ hierarchyItems }) => hierarchyItems.length + 1,
168-
/**
169-
* Returns the first(root) hierarchy item reference
170-
* @return {Object}
171-
*/
172-
rootHierarchyReference: ({ parentTopicIdentifiers, references }) => (
173-
references[parentTopicIdentifiers[0]] || {}
174-
),
175-
/**
176-
* Returns whether the root link is a technology page.
177-
* @return {boolean}
178-
*/
179-
isRootTechnologyLink: ({ rootHierarchyReference: { kind } }) => kind === 'technologies',
180-
/**
181-
* Returns the root url reference object, if is a `technologies` link.
182-
* Otherwise returns a manual route query object.
183-
* @return {Object}
184-
*/
185-
rootLink: ({
186-
isRootTechnologyLink, rootHierarchyReference, $route,
187-
}) => (isRootTechnologyLink
188-
? {
189-
path: rootHierarchyReference.url,
190-
query: $route.query,
191-
} : null),
192-
/**
193-
* Strips out the first link, if is the root Technologies link.
194-
* @return {string[]}
195-
*/
196-
hierarchyItems: ({ parentTopicIdentifiers, isRootTechnologyLink }) => (
197-
isRootTechnologyLink ? parentTopicIdentifiers.slice(1) : parentTopicIdentifiers
198-
),
199109
},
200110
methods: {
201111
async handleSidenavToggle(closeNav, currentBreakpoint) {
@@ -233,24 +143,17 @@ $sidenav-icon-padding-size: 5px;
233143
margin-left: $nav-space-between-elements;
234144
}
235145
236-
@include nav-in-breakpoint {
237-
// do not apply border if no item are above setting links
238-
&:not([data-previous-menu-children-count="0"]) {
239-
.nav-menu-setting:first-child {
240-
border-top: 1px solid dark-color(figure-gray-tertiary);
241-
display: flex;
242-
align-items: center;
243-
}
244-
}
245-
}
246-
247146
.nav-menu-setting {
248147
display: flex;
249148
align-items: center;
250149
color: var(--color-nav-current-link);
251150
margin-left: 0;
252151
min-width: 0;
253152
153+
.nav-menu-link, .current-language, span {
154+
font-weight: $font-weight-semibold;
155+
}
156+
254157
&:first-child:not(:only-child) {
255158
margin-right: $nav-space-between-elements;
256159
@@ -274,17 +177,8 @@ $sidenav-icon-padding-size: 5px;
274177
275178
.documentation-nav {
276179
:deep() {
277-
// normalize the Title font with menu items
278180
.nav-title {
279-
@include font-styles(documentation-nav);
280-
281-
.nav-title-link.inactive {
282-
height: auto;
283-
color: var(--color-figure-gray-secondary-alt);
284-
@include nav-dark($nested: true) {
285-
color: dark-color(figure-gray-secondary-alt);
286-
}
287-
}
181+
@include font-styles(nav-title-large);
288182
}
289183
}
290184
}
@@ -317,6 +211,7 @@ $sidenav-icon-padding-size: 5px;
317211
color: var(--color-nav-link-color);
318212
position: relative;
319213
margin: 0 (-$sidenav-icon-padding-size);
214+
border-radius: $nano-border-radius;
320215
321216
@include nav-dark {
322217
color: var(--color-nav-dark-link-color);
@@ -339,13 +234,6 @@ $sidenav-icon-padding-size: 5px;
339234
}
340235
341236
@include nav-in-breakpoint() {
342-
$space: 14px;
343-
margin-left: -$space;
344-
margin-right: -$space;
345-
padding-left: $space;
346-
padding-right: $space;
347-
align-self: stretch;
348-
349237
&__separator {
350238
display: none;
351239
}

src/components/DocumentationTopic/DocumentationHero.vue renamed to src/components/DocumentationTopic/Hero/DocumentationHero.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ $doc-hero-icon-dimension: 250px;
206206
207207
&__content:not(.minimized-hero) {
208208
padding-top: rem(40px);
209-
padding-bottom: 40px;
209+
padding-bottom: rem(40px);
210210
position: relative;
211211
z-index: 1;
212212
@include dynamic-content-container;
@@ -247,5 +247,4 @@ $doc-hero-icon-dimension: 250px;
247247
// apply extra bottom padding when shouldShowLanguageSwitcher
248248
padding-bottom: rem(65px);
249249
}
250-
251250
</style>

0 commit comments

Comments
 (0)