Skip to content

Commit f81e35c

Browse files
authored
Merge branch 'main' into r30234820/table-caption
2 parents 2d2864b + d90bfef commit f81e35c

30 files changed

+243
-105
lines changed

src/App.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@
2626
<slot :isTargetIDE="isTargetIDE">
2727
<router-view class="router-content" />
2828
<custom-footer v-if="hasCustomFooter" :data-color-scheme="preferredColorScheme" />
29-
<Footer v-else-if="!isTargetIDE" :enablei18n="enablei18n" />
29+
<Footer v-else-if="!isTargetIDE">
30+
<template #default="{ className }">
31+
<div v-if="enablei18n" :class="className">
32+
<LocaleSelector />
33+
</div>
34+
</template>
35+
</Footer>
3036
</slot>
3137
<slot name="footer" :isTargetIDE="isTargetIDE" />
3238
</div>
@@ -42,13 +48,15 @@ import { fetchThemeSettings, themeSettingsState, getSetting } from 'docc-render/
4248
import { objectToCustomProperties } from 'docc-render/utils/themes';
4349
import { AppTopID } from 'docc-render/constants/AppTopID';
4450
import SuggestLang from 'docc-render/components/SuggestLang.vue';
51+
import LocaleSelector from 'docc-render/components/LocaleSelector.vue';
4552
4653
export default {
4754
name: 'CoreApp',
4855
components: {
4956
Footer,
5057
InitialLoadingPlaceholder,
5158
SuggestLang,
59+
LocaleSelector,
5260
},
5361
provide() {
5462
return {
@@ -69,6 +77,7 @@ export default {
6977
computed: {
7078
currentColorScheme: ({ appState }) => appState.systemColorScheme,
7179
preferredColorScheme: ({ appState }) => appState.preferredColorScheme,
80+
availableLocales: ({ appState }) => appState.availableLocales,
7281
CSSCustomProperties: ({
7382
currentColorScheme,
7483
preferredColorScheme,
@@ -85,7 +94,9 @@ export default {
8594
),
8695
hasCustomHeader: () => !!window.customElements.get('custom-header'),
8796
hasCustomFooter: () => !!window.customElements.get('custom-footer'),
88-
enablei18n: () => getSetting(['features', 'docs', 'i18n', 'enable'], false),
97+
enablei18n: ({ availableLocales }) => (
98+
getSetting(['features', 'docs', 'i18n', 'enable'], false) && availableLocales.length > 1
99+
),
89100
},
90101
props: {
91102
enableThemeSettings: {

src/components/Article.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<script>
3535
import { PortalTarget } from 'portal-vue';
3636
37+
import AppStore from 'docc-render/stores/AppStore';
3738
import NavigationBar from 'theme/components/Tutorial/NavigationBar.vue';
3839
import metadata from 'theme/mixins/metadata.js';
3940
import Body from './Article/Body.vue';
@@ -166,9 +167,19 @@ export default {
166167
},
167168
},
168169
created() {
170+
AppStore.setAvailableLocales(this.metadata.availableLocales);
169171
this.store.reset();
170172
this.store.setReferences(this.references);
171173
},
174+
watch: {
175+
// update the references in the store, in case they update, but the component is not re-created
176+
references(references) {
177+
this.store.setReferences(references);
178+
},
179+
'metadata.availableLocales': function availableLocalesWatcher(availableLocales) {
180+
AppStore.setAvailableLocales(availableLocales);
181+
},
182+
},
172183
SectionKind,
173184
};
174185
</script>

src/components/CodeBlock.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ code {
3636
content: attr(data-after-code);
3737
}
3838
&::before, &::after {
39+
// ensure the pseudo elements dont fly off in space
40+
display: block;
3941
@include visuallyhidden()
4042
}
4143
}

src/components/ContentNode/LinkableHeading.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
v-if="shouldLink"
1818
:to="{ hash: `#${anchor}` }"
1919
class="header-anchor"
20-
aria-label="Scroll to section"
2120
@click="handleFocusAndScroll(anchor)"
2221
>
2322
<slot />
23+
<span class="visuallyhidden" >{{ $t('accessibility.in-page-link') }}</span>
2424
<LinkIcon class="icon" aria-hidden="true" />
2525
</router-link>
2626
<template v-else>
@@ -89,8 +89,10 @@ $icon-margin: 7px;
8989
margin-left: $icon-margin;
9090
}
9191
92-
&:hover .icon {
93-
display: inline;
92+
&:hover, &:focus {
93+
.icon {
94+
display: inline;
95+
}
9496
}
9597
}
9698
</style>

src/components/DocumentationTopic.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ import metadata from 'theme/mixins/metadata.js';
151151
import { buildUrl } from 'docc-render/utils/url-helper';
152152
import { normalizeRelativePath } from 'docc-render/utils/assets';
153153
154+
import AppStore from 'docc-render/stores/AppStore';
154155
import Aside from 'docc-render/components/ContentNode/Aside.vue';
155156
import BetaLegalText from 'theme/components/DocumentationTopic/BetaLegalText.vue';
156157
import LanguageSwitcher from 'theme/components/DocumentationTopic/Summary/LanguageSwitcher.vue';
@@ -365,6 +366,10 @@ export default {
365366
required: false,
366367
validator: v => Object.prototype.hasOwnProperty.call(StandardColors, v),
367368
},
369+
availableLocales: {
370+
type: Array,
371+
required: false,
372+
},
368373
},
369374
provide() {
370375
// NOTE: this is not reactive: if this.identifier change, the provided value
@@ -533,6 +538,7 @@ export default {
533538
conformance,
534539
hasNoExpandedDocumentation,
535540
modules,
541+
availableLocales,
536542
platforms,
537543
required: isRequirement = false,
538544
roleHeading,
@@ -574,6 +580,7 @@ export default {
574580
downloadNotAvailableSummary,
575581
diffAvailability,
576582
hasNoExpandedDocumentation,
583+
availableLocales,
577584
hierarchy,
578585
role,
579586
identifier,
@@ -621,7 +628,18 @@ export default {
621628
});
622629
}
623630
631+
AppStore.setAvailableLocales(this.availableLocales || []);
624632
this.store.reset();
633+
this.store.setReferences(this.references);
634+
},
635+
watch: {
636+
// update the references in the store, in case they update, but the component is not re-created
637+
references(references) {
638+
this.store.setReferences(references);
639+
},
640+
availableLocales(availableLocales) {
641+
AppStore.setAvailableLocales(availableLocales);
642+
},
625643
},
626644
};
627645
</script>

src/components/DocumentationTopic/DocumentationNav.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ $sidenav-icon-padding-size: 5px;
224224
@include font-styles(documentation-nav);
225225
226226
&-settings {
227+
// ensure settings can get smaller if needed
228+
min-width: 0;
229+
227230
@include font-styles(nav-toggles);
228231
229232
@include breakpoint-only-largenav() {
@@ -246,6 +249,7 @@ $sidenav-icon-padding-size: 5px;
246249
align-items: center;
247250
color: var(--color-nav-current-link);
248251
margin-left: 0;
252+
min-width: 0;
249253
250254
&:first-child:not(:only-child) {
251255
margin-right: $nav-space-between-elements;

src/components/DocumentationTopic/DocumentationNav/LanguageToggle.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ $nav-menu-toggle-label-margin: 6px;
234234
}
235235
236236
.language {
237+
&-container {
238+
// ensure the language picker is never crushed
239+
flex: 1 0 auto;
240+
}
241+
237242
&-dropdown {
238243
-webkit-text-size-adjust: none;
239244
appearance: none;

src/components/Footer.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,16 @@
1313
<div class="row">
1414
<ColorSchemeToggle />
1515
</div>
16-
<div v-if="enablei18n" class="row">
17-
<LocaleSelector/>
18-
</div>
16+
<slot className="row"/>
1917
</footer>
2018
</template>
2119

2220
<script>
2321
import ColorSchemeToggle from 'docc-render/components/ColorSchemeToggle.vue';
24-
import LocaleSelector from 'docc-render/components/LocaleSelector.vue';
2522
2623
export default {
2724
name: 'Footer',
28-
components: { ColorSchemeToggle, LocaleSelector },
29-
props: {
30-
enablei18n: {
31-
type: Boolean,
32-
default: false,
33-
},
34-
},
25+
components: { ColorSchemeToggle },
3526
};
3627
</script>
3728

src/components/LocaleSelector.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<script>
3232
import ChevronThickIcon from 'theme/components/Icons/ChevronThickIcon.vue';
33-
import locales from 'theme/lang/locales.json';
33+
import appLocales from 'theme/lang/locales.json';
3434
import { updateLocale, getLocaleParam } from 'docc-render/utils/i18n-utils';
3535
import AppStore from 'docc-render/stores/AppStore';
3636
@@ -39,18 +39,19 @@ export default {
3939
components: {
4040
ChevronThickIcon,
4141
},
42-
data() {
43-
return {
44-
locales,
45-
};
46-
},
4742
methods: {
4843
updateRouter({ target: { value: slug } }) {
4944
this.$router.push(getLocaleParam(slug));
5045
AppStore.setPreferredLocale(slug);
5146
updateLocale(slug, this);
5247
},
5348
},
49+
computed: {
50+
availableLocales: () => AppStore.state.availableLocales,
51+
locales: ({ availableLocales }) => (
52+
appLocales.filter(({ code }) => availableLocales.includes(code))
53+
),
54+
},
5455
};
5556
5657
</script>

src/components/Navigator/QuickNavigationPreview.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,6 @@ export default {
108108
};
109109
},
110110
},
111-
watch: {
112-
json: {
113-
immediate: true,
114-
async handler(json) {
115-
const { references = {} } = json || {};
116-
await this.$nextTick();
117-
PreviewStore.setReferences(references);
118-
},
119-
},
120-
},
121111
};
122112
</script>
123113

src/components/OnThisPageNav.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
class="base-link"
2121
@click.native="handleFocusAndScroll(item.anchor)"
2222
>
23-
<WordBreak v-if="item.i18n">{{ $t(item.title) }}</WordBreak>
24-
<WordBreak v-else>{{ item.title }}</WordBreak>
23+
<component :is="getWrapperComponent(item)">
24+
{{ getTextContent(item) }}
25+
</component>
2526
</router-link>
2627
</li>
2728
</ul>
@@ -122,6 +123,12 @@ export default {
122123
'child-item': item.level === 3,
123124
};
124125
},
126+
getTextContent(item) {
127+
return item.i18n ? this.$t(item.title) : item.title;
128+
},
129+
getWrapperComponent(item) {
130+
return item.isSymbol ? WordBreak : 'span';
131+
},
125132
},
126133
};
127134
</script>

src/components/Tutorial.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<script>
3434
import { PortalTarget } from 'portal-vue';
3535
36+
import AppStore from 'docc-render/stores/AppStore';
3637
import CodeThemeStore from 'docc-render/stores/CodeThemeStore';
3738
import metadata from 'theme/mixins/metadata.js';
3839
import isClientMobile from 'docc-render/mixins/isClientMobile';
@@ -135,9 +136,19 @@ export default {
135136
},
136137
},
137138
created() {
139+
AppStore.setAvailableLocales(this.metadata.availableLocales);
138140
this.store.reset();
139141
this.store.setReferences(this.references);
140142
},
143+
watch: {
144+
// update the references in the store, in case they update, but the component is not re-created
145+
references(references) {
146+
this.store.setReferences(references);
147+
},
148+
'metadata.availableLocales': function availableLocalesWatcher(availableLocales) {
149+
AppStore.setAvailableLocales(availableLocales);
150+
},
151+
},
141152
mounted() {
142153
this.$bridge.on('codeColors', this.handleCodeColorsChange);
143154
this.$bridge.send({ type: 'requestCodeColors' });

src/components/TutorialsOverview.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
</template>
3636

3737
<script>
38+
import AppStore from 'docc-render/stores/AppStore';
3839
import TutorialsOverviewStore from 'docc-render/stores/TutorialsOverviewStore';
3940
import Nav from 'theme/components/TutorialsOverview/Nav.vue';
4041
import metadata from 'theme/mixins/metadata.js';
@@ -100,9 +101,19 @@ export default {
100101
};
101102
},
102103
created() {
104+
AppStore.setAvailableLocales(this.metadata.availableLocales);
103105
this.store.reset();
104106
this.store.setReferences(this.references);
105107
},
108+
watch: {
109+
// update the references in the store, in case they update, but the component is not re-created
110+
references(references) {
111+
this.store.setReferences(references);
112+
},
113+
'metadata.availableLocales': function availableLocalesWatcher(availableLocales) {
114+
AppStore.setAvailableLocales(availableLocales);
115+
},
116+
},
106117
};
107118
</script>
108119

src/lang/locales/en-US.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
"read-only": "Read-only",
165165
"error": {
166166
"unknown": "An unknown error occurred.",
167-
"image": "Image failed to load"
167+
"image": "Image failed to load",
168+
"not-found": "The page you're looking for can't be found."
168169
},
169170
"color-scheme": {
170171
"select": "Select a color scheme preference",
@@ -181,7 +182,8 @@
181182
"start": "start of code block",
182183
"end": "end of code block"
183184
},
184-
"skip-navigation": "Skip Navigation"
185+
"skip-navigation": "Skip Navigation",
186+
"in-page-link": "in page link"
185187
},
186188
"select-language": "Select the language for this page",
187189
"icons": {

src/mixins/onThisPageRegistrator.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
import ContentNode from 'docc-render/components/DocumentationTopic/ContentNode.vue';
1919
import { AppTopID } from 'docc-render/constants/AppTopID';
2020

21+
const SYMBOL_KIND = 'symbol';
22+
2123
/**
2224
* Crawls the `topicData` of a page, and extracts onThisPage sections.
2325
*/
@@ -44,11 +46,13 @@ export default {
4446
defaultImplementationsSections,
4547
relationshipsSections,
4648
seeAlsoSections,
49+
kind,
4750
} = topicData;
4851
this.store.addOnThisPageSection({
4952
title,
5053
anchor: AppTopID,
5154
level: 1,
55+
isSymbol: kind === SYMBOL_KIND,
5256
}, { i18n: false });
5357
if (primaryContentSections) {
5458
primaryContentSections.forEach((section) => {

0 commit comments

Comments
 (0)