Skip to content

Commit 1b77aaa

Browse files
author
Dobromir Hristov
committed
Merge branch 'main' into dhristov/add-sidenav
2 parents 9bf1d14 + 44edd61 commit 1b77aaa

39 files changed

+565
-154
lines changed

src/assets/img/[email protected]

6.01 KB
Loading

src/components/Article.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<script>
3434
import { PortalTarget } from 'portal-vue';
3535
36-
import NavigationBar from 'docc-render/components/Tutorial/NavigationBar.vue';
36+
import NavigationBar from 'theme/components/Tutorial/NavigationBar.vue';
3737
import pageTitle from 'docc-render/mixins/pageTitle';
3838
import Body from './Article/Body.vue';
3939
import CallToAction from './Article/CallToAction.vue';

src/components/BreakpointEmitter.vue

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,12 @@
99
-->
1010

1111
<script>
12-
import { BreakpointName } from 'docc-render/utils/breakpoints';
12+
import {
13+
BreakpointAttributes,
14+
BreakpointName,
15+
BreakpointScopes,
16+
} from 'docc-render/utils/breakpoints';
1317
14-
const BreakpointScopes = {
15-
default: 'default',
16-
nav: 'nav',
17-
};
18-
19-
const BreakpointAttributes = {
20-
[BreakpointScopes.default]: {
21-
[BreakpointName.large]: {
22-
minWidth: 1069,
23-
contentWidth: 980,
24-
},
25-
[BreakpointName.medium]: {
26-
minWidth: 736,
27-
maxWidth: 1068,
28-
contentWidth: 692,
29-
},
30-
[BreakpointName.small]: {
31-
minWidth: 320,
32-
maxWidth: 735,
33-
contentWidth: 280,
34-
},
35-
},
36-
[BreakpointScopes.nav]: {
37-
[BreakpointName.large]: {
38-
minWidth: 1024,
39-
},
40-
[BreakpointName.medium]: {
41-
minWidth: 768,
42-
maxWidth: 1023,
43-
},
44-
[BreakpointName.small]: {
45-
minWidth: 320,
46-
maxWidth: 767,
47-
},
48-
},
49-
};
5018
const maxQuery = maxWidth => (maxWidth ? `(max-width: ${maxWidth}px)` : '');
5119
const minQuery = minWidth => (minWidth ? `(min-width: ${minWidth}px)` : '');
5220

src/components/DocumentationTopic.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ export default {
225225
type: Array,
226226
required: false,
227227
},
228+
symbolKind: {
229+
type: String,
230+
required: false,
231+
},
228232
variants: {
229233
type: Array,
230234
default: () => ([]),
@@ -265,6 +269,7 @@ export default {
265269
identifier: this.identifier,
266270
languages: new Set(Object.keys(this.languagePaths)),
267271
interfaceLanguage: this.interfaceLanguage,
272+
symbolKind: this.symbolKind,
268273
};
269274
},
270275
data() {

src/components/DocumentationTopic/PrimaryContent/DeclarationGroup.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
</p>
2020
<Source
2121
:tokens="declaration.tokens"
22-
:simple-indent="isSwift && !isCocoaApi"
23-
:smart-indent="isCocoaApi"
22+
:simple-indent="shouldSimpleIndent"
23+
:smart-indent="shouldSmartIndent"
2424
:language="interfaceLanguage"
2525
/>
2626
</div>
@@ -30,6 +30,7 @@
3030
import DeclarationSource from 'docc-render/components/DocumentationTopic/PrimaryContent/DeclarationSource.vue';
3131
import Language from 'docc-render/constants/Language';
3232
import { APIChangesMultipleLines } from 'docc-render/mixins/apiChangesHelpers';
33+
import { isParentSymbolKind } from 'docc-render/utils/symbols';
3334
3435
/**
3536
* Renders a code source with an optional caption.
@@ -47,6 +48,9 @@ export default {
4748
interfaceLanguage: {
4849
default: () => Language.swift.key.api,
4950
},
51+
symbolKind: {
52+
default: () => undefined,
53+
},
5054
},
5155
props: {
5256
declaration: {
@@ -79,7 +83,9 @@ export default {
7983
return this.declaration.platforms.join(', ');
8084
},
8185
isSwift: ({ interfaceLanguage }) => interfaceLanguage === Language.swift.key.api,
82-
isCocoaApi: ({ languages }) => languages.has(Language.objectiveC.key.api),
86+
shouldSimpleIndent: ({ isSwift, shouldSmartIndent }) => isSwift && !shouldSmartIndent,
87+
shouldSmartIndent: ({ languages, symbolKind }) => languages.has(Language.objectiveC.key.api)
88+
&& !isParentSymbolKind(symbolKind),
8389
},
8490
};
8591
</script>

src/components/DocumentationTopic/PrimaryContent/PossibleValues.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dl class="datalist">
1515
<template v-for="value in values">
1616
<dt class="param-name" :key="`${value.name}:name`">
17-
<code>{{value.name}}</code>
17+
<WordBreak tag="code">{{value.name}}</WordBreak>
1818
</dt>
1919
<dd v-if="value.content" class="value-content" :key="`${value.name}:content`">
2020
<ContentNode :content="value.content" />
@@ -27,10 +27,11 @@
2727
<script>
2828
import OnThisPageSection from 'docc-render/components/DocumentationTopic/OnThisPageSection.vue';
2929
import ContentNode from 'docc-render/components/ContentNode.vue';
30+
import WordBreak from 'docc-render/components/WordBreak.vue';
3031
3132
export default {
3233
name: 'PossibleValues',
33-
components: { ContentNode, OnThisPageSection },
34+
components: { ContentNode, OnThisPageSection, WordBreak },
3435
props: {
3536
values: {
3637
type: Array,

src/components/DropdownCustom.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default {
117117
async closeAndFocusToggler() {
118118
this.closeDropdown();
119119
await this.$nextTick();
120-
this.$refs.dropdownToggle.focus();
120+
this.$refs.dropdownToggle.focus({ preventScroll: true });
121121
},
122122
closeDropdown() {
123123
this.isOpen = false;
@@ -151,7 +151,7 @@ export default {
151151
return;
152152
}
153153
// focus the new element
154-
nextElement.focus();
154+
nextElement.focus({ preventScroll: true });
155155
},
156156
/**
157157
* Focuses the currently active option
@@ -161,7 +161,7 @@ export default {
161161
const currentOption = this.$el.querySelector(`.${ActiveOptionClass}`);
162162
if (!currentOption) return;
163163
await this.$nextTick();
164-
currentOption.focus();
164+
currentOption.focus({ preventScroll: true });
165165
},
166166
},
167167
};
@@ -237,6 +237,7 @@ $focus-shadow: 0 0 0 2px var(--color-focus-color);
237237
// the wrapping in `dropdown-custom` is needed to properly apply the /deep/ selector
238238
.dropdown-custom {
239239
border-radius: $border-radius;
240+
240241
&.is-open {
241242
border-radius: $border-radius $border-radius 0 0;
242243
}

src/components/GenericModal.vue

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
>
2929
<CloseIcon />
3030
</button>
31-
<div class="modal-content">
31+
<div class="modal-content" ref="content">
3232
<slot />
3333
</div>
3434
</div>
@@ -137,7 +137,7 @@ export default {
137137
},
138138
mounted() {
139139
this.focusTrapInstance = new FocusTrap();
140-
document.addEventListener('keydown', this.onEscapeClick);
140+
document.addEventListener('keydown', this.onKeydown);
141141
// add listeners for dynamic themes
142142
if (this.isThemeDynamic) {
143143
const matchMedia = window.matchMedia('(prefers-color-scheme: dark)');
@@ -155,7 +155,7 @@ export default {
155155
if (this.isVisible) {
156156
scrollLock.unlockScroll(this.$refs.container);
157157
}
158-
document.removeEventListener('keydown', this.onEscapeClick);
158+
document.removeEventListener('keydown', this.onKeydown);
159159
this.focusTrapInstance.destroy();
160160
},
161161
methods: {
@@ -190,6 +190,14 @@ export default {
190190
closeModal() {
191191
this.isVisible = false;
192192
},
193+
/**
194+
* Select all modal's content
195+
*/
196+
selectContent() {
197+
window.getSelection().selectAllChildren(
198+
this.$refs.content,
199+
);
200+
},
193201
/**
194202
* Closes the modal when clicking on the backdrop
195203
*/
@@ -198,12 +206,23 @@ export default {
198206
},
199207
/**
200208
* Handle the keydown body event listener.
201-
* Used to close the modal on `Escape` click.
209+
* Used to:
210+
* - Overwrite cmd+a and ctrl+a behaviour to select modal content only
211+
* - Close the modal on `Escape` click.
202212
* @param {KeyboardEvent} params
203213
* @param {String} params.key
204214
*/
205-
onEscapeClick({ key }) {
206-
if (!this.isVisible || key !== 'Escape') return;
215+
onKeydown(event) {
216+
const {
217+
metaKey = false, ctrlKey = false, key,
218+
} = event;
219+
220+
if (!this.isVisible) return;
221+
if (key === 'a' && (metaKey || ctrlKey)) {
222+
event.preventDefault();
223+
this.selectContent();
224+
}
225+
if (key !== 'Escape') return;
207226
this.closeModal();
208227
},
209228
/**
@@ -269,12 +288,8 @@ $modal-close-color: light-color(figure-gray-tertiary) !default;
269288
&-standard {
270289
padding: 20px;
271290
272-
&.modal-with-close .container {
273-
padding-top: 80px;
274-
}
275-
276291
.container {
277-
padding: 50px;
292+
padding: 60px;
278293
border-radius: $big-border-radius;
279294
@include prefers-dark {
280295
background: rgb(29, 29, 31);

src/components/ImageAsset.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
-->
1010

1111
<template>
12-
<picture>
12+
<img
13+
v-if="fallbackImageSrcSet"
14+
class="fallback"
15+
:alt="`${alt} Image failed to load.`"
16+
:srcset="fallbackImageSrcSet"
17+
/>
18+
<picture v-else>
1319
<!--
1420
if "Auto" is selected, provide an alternate dark variant if available
1521
using the appropriate media query
@@ -24,6 +30,7 @@
2430
v-if="prefersDark && darkVariantAttributes"
2531
v-bind="darkVariantAttributes"
2632
:alt="alt"
33+
@error="handleImageLoadError"
2734
>
2835
<!--
2936
otherwise use the default variant (light preferred over dark if both available)
@@ -32,6 +39,7 @@
3239
v-else
3340
v-bind="defaultAttributes"
3441
:alt="alt"
42+
@error="handleImageLoadError"
3543
>
3644
</picture>
3745
</template>
@@ -41,6 +49,7 @@
4149
import imageAsset from 'docc-render/mixins/imageAsset';
4250
import AppStore from 'docc-render/stores/AppStore';
4351
import ColorScheme from 'docc-render/constants/ColorScheme';
52+
import noImage from 'theme/assets/img/[email protected]';
4453
import { normalizeAssetUrl } from 'docc-render/utils/assets';
4554
4655
function constructAttributes(sources) {
@@ -70,7 +79,10 @@ function constructAttributes(sources) {
7079
export default {
7180
name: 'ImageAsset',
7281
mixins: [imageAsset],
73-
data: () => ({ appState: AppStore.state }),
82+
data: () => ({
83+
appState: AppStore.state,
84+
fallbackImageSrcSet: null,
85+
}),
7486
computed: {
7587
defaultAttributes: ({
7688
lightVariantAttributes,
@@ -92,5 +104,12 @@ export default {
92104
required: true,
93105
},
94106
},
107+
methods: {
108+
handleImageLoadError() {
109+
// fall back to a default DocC-Render provided image if the specificed
110+
// image fails to load for any reason
111+
this.fallbackImageSrcSet = `${noImage} 2x`;
112+
},
113+
},
95114
};
96115
</script>

src/components/InitialLoadingPlaceholder.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ export default {
2121
};
2222
},
2323
created() {
24-
this.$router.onReady(() => {
25-
this.loaded = true;
26-
});
24+
const cb = () => { this.loaded = true; };
25+
this.$router.onReady(cb, cb);
2726
},
2827
};
2928
</script>

0 commit comments

Comments
 (0)