Skip to content

Commit ada1313

Browse files
committed
Merge branch 'dhristov/add-sidenav-hero' into hqhuang/remove-right-side-bar
2 parents c3664b8 + cd3cca0 commit ada1313

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1492
-346
lines changed
12.3 KB
Loading

app/public/developer-og.jpg

12.6 KB
Loading

app/public/theme-settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"meta": {},
33
"theme": {
4+
"code": {
5+
"indentationWidth": 4
6+
},
47
"colors": {
58
"text": "",
69
"text-background": "",
@@ -53,6 +56,9 @@
5356
"docs": {
5457
"summary": {
5558
"hide": false
59+
},
60+
"navigator": {
61+
"enable": false
5662
}
5763
}
5864
}

src/components/AdjustableSidebarWidth.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const STORAGE_KEY = 'sidebar';
5555
5656
// the maximum width, after which the full-width content does not grow
5757
export const MAX_WIDTH = 1800;
58+
export const ULTRA_WIDE_DEFAULT = 500;
5859
5960
export const eventsMap = {
6061
touch: {
@@ -99,19 +100,25 @@ export default {
99100
},
100101
},
101102
data() {
103+
const windowWidth = window.innerWidth;
104+
const breakpoint = BreakpointName.large;
102105
// get the min width, in case we dont have a previously saved value
103-
const fallback = calcWidthPercent(minWidthResponsivePercents[BreakpointName.large]);
104-
// computed is not ready yet in `data`.
106+
const minWidth = calcWidthPercent(minWidthResponsivePercents[breakpoint]);
107+
// calc the maximum width
108+
const maxWidth = calcWidthPercent(maxWidthResponsivePercents[breakpoint]);
109+
// have a default width for very large screens, or use half of the min and max
110+
const defaultWidth = windowWidth >= MAX_WIDTH
111+
? ULTRA_WIDE_DEFAULT
112+
: Math.round((minWidth + maxWidth) / 2);
113+
// get the already stored data, fallback to a default one.
114+
const storedWidth = storage.get(STORAGE_KEY, defaultWidth);
105115
return {
106116
isDragging: false,
107-
width: Math.min(
108-
storage.get(STORAGE_KEY, fallback),
109-
// calc the maximum width
110-
calcWidthPercent(maxWidthResponsivePercents[BreakpointName.large]),
111-
),
117+
// limit the width to a range
118+
width: Math.min(Math.max(storedWidth, minWidth), maxWidth),
112119
isTouch: false,
113-
windowWidth: window.innerWidth,
114-
breakpoint: BreakpointName.large,
120+
windowWidth,
121+
breakpoint,
115122
noTransition: false,
116123
focusTrapInstance: null,
117124
};

src/components/Article.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import { PortalTarget } from 'portal-vue';
3535
3636
import NavigationBar from 'theme/components/Tutorial/NavigationBar.vue';
37-
import pageTitle from 'docc-render/mixins/pageTitle';
37+
import metadata from 'docc-render/mixins/metadata';
3838
import Body from './Article/Body.vue';
3939
import CallToAction from './Article/CallToAction.vue';
4040
import Hero from './Article/Hero.vue';
@@ -50,7 +50,7 @@ const SectionKind = {
5050
export default {
5151
name: 'Article',
5252
components: { NavigationBar, PortalTarget },
53-
mixins: [pageTitle],
53+
mixins: [metadata],
5454
inject: {
5555
isTargetIDE: {
5656
default: false,
@@ -98,6 +98,9 @@ export default {
9898
undefined
9999
);
100100
},
101+
pageDescription: ({ heroSection, extractFirstParagraphText }) => (
102+
heroSection ? extractFirstParagraphText(heroSection.content) : null
103+
),
101104
},
102105
methods: {
103106
componentFor(section) {

src/components/ContentNode.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,43 @@ export default {
478478
479479
return $forEach(this.content);
480480
},
481+
// Recursively walk a given content tree, applying the callback function for
482+
// each node encountered (depth first) and returning an accumulated result.
483+
//
484+
// @param fn {Function} A callback function which will called for each node
485+
// in the tree along with the most recently accumulated result. The last
486+
// result is the first argument passed to this function and the node is
487+
// the second argument.
488+
// @param initialValue {Any} Some initial value to start accumulating.
489+
//
490+
// @return {Any} The final accumulated value based on the initial value and
491+
// the result of applying the function to every node.
492+
reduce(fn, initialValue) {
493+
let result = initialValue;
494+
this.forEach((node) => {
495+
result = fn(result, node);
496+
});
497+
return result;
498+
},
499+
},
500+
computed: {
501+
// Computed property that returns a single plaintext string equivalent
502+
// of the content tree.
503+
//
504+
// Paragraphs will be transformed into newlines and text will be presented
505+
// without any inline formatting—other block kinds like asides will be
506+
// ignored in the resulting plaintext representation.
507+
plaintext() {
508+
return this.reduce((text, node) => {
509+
if (node.type === BlockType.paragraph) {
510+
return `${text}\n`;
511+
}
512+
if (node.type === InlineType.text) {
513+
return `${text}${node.text}`;
514+
}
515+
return text;
516+
}, '').trim();
517+
},
481518
},
482519
BlockType,
483520
InlineType,

src/components/DocumentationTopic.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
<script>
8383
import Language from 'docc-render/constants/Language';
84-
import pageTitle from 'docc-render/mixins/pageTitle';
84+
import metadata from 'docc-render/mixins/metadata';
8585
import { getSetting } from 'docc-render/utils/theme-settings';
8686
8787
import Aside from 'docc-render/components/ContentNode/Aside.vue';
@@ -105,7 +105,7 @@ import Topics from './DocumentationTopic/Topics.vue';
105105
106106
export default {
107107
name: 'DocumentationTopic',
108-
mixins: [pageTitle],
108+
mixins: [metadata],
109109
inject: {
110110
isTargetIDE: {
111111
default() {
@@ -301,6 +301,9 @@ export default {
301301
&& platforms.length
302302
&& platforms.some(platform => platform.beta),
303303
pageTitle: ({ title }) => title,
304+
pageDescription: ({ abstract, extractFirstParagraphText }) => (
305+
abstract ? extractFirstParagraphText(abstract) : null
306+
),
304307
shouldShowLanguageSwitcher: ({ objcPath, swiftPath }) => objcPath && swiftPath,
305308
hideSummary: () => getSetting(['features', 'docs', 'summary', 'hide'], false),
306309
},
@@ -347,10 +350,13 @@ export default {
347350
348351
#main {
349352
outline-style: none;
350-
border-left: 1px solid var(--color-grid);
351-
border-right: 1px solid var(--color-grid);
352353
height: 100%;
353354
355+
@include with-adjustable-sidebar {
356+
border-left: 1px solid var(--color-grid);
357+
border-right: 1px solid var(--color-grid);
358+
}
359+
354360
@include inTargetIde {
355361
min-height: 100vh;
356362
display: flex;
@@ -364,9 +370,9 @@ export default {
364370
}
365371
366372
.container {
367-
@include breakpoint-dynamic-sidebar-content;
368-
outline-style: none;
369373
margin-top: $section-spacing-single-side / 2;
374+
outline-style: none;
375+
@include dynamic-content-container;
370376
}
371377
372378
.button-cta {

src/components/DocumentationTopic/ContentTable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default {
5050
}
5151
5252
.container {
53-
@include breakpoint-dynamic-sidebar-content;
53+
@include dynamic-content-container;
5454
padding-bottom: $section-spacing-single-side;
5555
}
5656

src/components/DocumentationTopic/DocumentationHero.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ $doc-hero-icon-color: dark-color(fill-secondary) !default;
120120
&__content {
121121
position: relative;
122122
z-index: 1;
123-
@include breakpoint-dynamic-sidebar-content;
123+
@include dynamic-content-container;
124124
}
125125
}
126126
</style>

src/components/DocumentationTopic/DocumentationNav.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111
<template>
1212
<NavBase
13+
:breakpoint="isWideFormat ? BreakpointName.small: BreakpointName.medium"
1314
:hasOverlay="false"
1415
hasSolidBackground
1516
:hasNoBorder="hasNoBorder"
1617
:isDark="isDark"
17-
isWideFormat
18+
:isWideFormat="isWideFormat"
1819
hasFullWidthBorder
1920
class="documentation-nav"
2021
aria-label="API Reference"
2122
>
22-
<template slot="pre-title">
23+
<template slot="pre-title" v-if="isWideFormat">
2324
<button class="sidenav-toggle" @click.prevent="$emit('toggle-sidenav')">
2425
<SidenavIcon class="icon-inline sidenav-icon" />
2526
</button>
@@ -102,6 +103,10 @@ export default {
102103
type: Object,
103104
default: () => ({}),
104105
},
106+
isWideFormat: {
107+
type: Boolean,
108+
default: true,
109+
},
105110
},
106111
computed: {
107112
BreakpointName: () => BreakpointName,
@@ -178,4 +183,12 @@ $sidenav-icon-size: 19px;
178183
width: $sidenav-icon-size;
179184
height: $sidenav-icon-size;
180185
}
186+
187+
// make sure toggle is not visible, from medium up, in default scope.
188+
// Sidenav is only toggle-able at small, in default scope.
189+
.sidenav-toggle {
190+
@include breakpoints-from(medium) {
191+
display: none;
192+
}
193+
}
181194
</style>

0 commit comments

Comments
 (0)