Skip to content

Commit

Permalink
Merge branch 'main-upstream' into upstream-sync
Browse files Browse the repository at this point in the history
# Conflicts:
#	.vitepress/theme/styles/index.css
#	README.md
#	pnpm-lock.yaml
#	src/about/faq.md
#	src/api/application.md
#	src/api/built-in-components.md
#	src/api/built-in-directives.md
#	src/api/built-in-special-attributes.md
#	src/api/built-in-special-elements.md
#	src/api/component-instance.md
#	src/api/composition-api-dependency-injection.md
#	src/api/composition-api-lifecycle.md
#	src/api/general.md
#	src/api/options-composition.md
#	src/api/options-lifecycle.md
#	src/api/options-misc.md
#	src/api/options-rendering.md
#	src/api/options-state.md
#	src/api/reactivity-advanced.md
#	src/api/reactivity-core.md
#	src/api/render-function.md
#	src/api/sfc-script-setup.md
#	src/api/ssr.md
#	src/api/utility-types.md
#	src/examples/src/timer/App/template.html
#	src/guide/components/attrs.md
#	src/guide/components/props.md
#	src/guide/components/slots.md
#	src/guide/components/v-model.md
#	src/guide/essentials/class-and-style.md
#	src/guide/essentials/reactivity-fundamentals.md
#	src/guide/essentials/template-syntax.md
#	src/guide/extras/composition-api-faq.md
#	src/guide/extras/reactivity-in-depth.md
#	src/guide/extras/reactivity-transform.md
#	src/guide/extras/render-function.md
#	src/guide/extras/rendering-mechanism.md
#	src/guide/extras/ways-of-using-vue.md
#	src/guide/extras/web-components.md
#	src/guide/introduction.md
#	src/guide/quick-start.md
#	src/guide/reusability/composables.md
#	src/guide/scaling-up/ssr.md
#	src/guide/scaling-up/testing.md
#	src/guide/scaling-up/tooling.md
#	src/guide/typescript/composition-api.md
#	src/guide/typescript/overview.md
#	src/partners/partners.json
#	src/translations/index.md
#	src/tutorial/src/step-9/App/template.html
#	src/tutorial/src/step-9/_hint/App/composition.js
#	src/tutorial/src/step-9/_hint/App/options.js
#	src/tutorial/src/step-9/description.md
  • Loading branch information
matrunchyk committed Sep 18, 2023
2 parents 976dd37 + 7fe90c5 commit 9a0466e
Show file tree
Hide file tree
Showing 62 changed files with 1,956 additions and 716 deletions.
2 changes: 1 addition & 1 deletion .github/contributing/writing-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Writing documentation is an exercise in empathy. We're not describing an objecti

### Tips, Callouts, Alerts, and Line Highlights

We have some dedicated styles to denote something that's worth highlighting in a particular way. These are captured [on this page](https://vitepress.vuejs.org/guide/markdown.html#custom-containers). **They are to be used sparingly.**
We have some dedicated styles to denote something that's worth highlighting in a particular way. These are captured [on this page](https://vitepress.dev/guide/markdown#custom-containers). **They are to be used sparingly.**

There is a certain temptation to abuse these styles, as one can simply add a change inside a callout. However, this breaks up the flow of reading for the user and should only be used in special circumstances. Wherever possible, we should attempt to create a narrative and flow within the page to respect the reader's cognitive load.

Expand Down
16 changes: 14 additions & 2 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfigWithTheme } from 'vitepress'
import type { Config as ThemeConfig } from '@vue/theme'
import baseConfig from '@vue/theme/config'
import { headerPlugin } from './headerMdPlugin'
import { textAdPlugin } from './textAdMdPlugin'
// import { textAdPlugin } from './textAdMdPlugin'

const nav: ThemeConfig['nav'] = [
{
Expand All @@ -16,6 +16,7 @@ const nav: ThemeConfig['nav'] = [
{ text: 'Приклади', link: '/examples/' },
{ text: 'Швидкий старт', link: '/guide/quick-start' },
// { text: 'Style Guide', link: '/style-guide/' },
{ text: 'Glossary', link: '/glossary/' },
{
text: 'Документація по Vue 2',
link: 'https://v2.vuejs.org.ua'
Expand Down Expand Up @@ -652,6 +653,16 @@ export default defineConfigWithTheme<ThemeConfig>({
text: 'Français',
repo: 'https://github.com/vuejs-translations/docs-fr'
},
{
link: 'https://ko.vuejs.org',
text: '한국어',
repo: 'https://github.com/vuejs-translations/docs-ko'
},
{
link: 'https://pt.vuejs.org',
text: 'Português',
repo: 'https://github.com/vuejs-translations/docs-pt'
},
{
link: '/translations/',
text: 'Допоможіть нам перекласти!',
Expand Down Expand Up @@ -719,7 +730,8 @@ export default defineConfigWithTheme<ThemeConfig>({

markdown: {
config(md) {
md.use(headerPlugin).use(textAdPlugin)
md.use(headerPlugin)
// .use(textAdPlugin)
}
},

Expand Down
6 changes: 3 additions & 3 deletions .vitepress/inlined-scripts/restorePreference.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
document.documentElement.classList.add(cls)
}
}
restore('vue-docs-prefer-composition', 'prefer-composition')
restore('vue-docs-prefer-composition', 'prefer-composition', true)
restore('vue-docs-prefer-sfc', 'prefer-sfc', true)

window.__VUE_BANNER_ID__ = 'mid-2023-conf-promo'
restore(`vue-docs-banner-${__VUE_BANNER_ID__}`, 'banner-dismissed')
// window.__VUE_BANNER_ID__ = ''
// restore(`vue-docs-banner-${__VUE_BANNER_ID__}`, 'banner-dismissed')
})()
8 changes: 3 additions & 5 deletions .vitepress/theme/components/Banner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ function dismiss() {
<!-- -webkit-linear-gradient(315deg, #42d392 25%, #647eff) -->
<template>
<div class="banner" v-if="open">
<a href="http://vueconf.us/" target="_blank"
><span>Upcoming: </span>VueConf US - New Orleans - May 24-26</a
>
<a target="_blank"></a>
<button @click="dismiss">
<VTIconPlus class="close" />
</button>
Expand Down Expand Up @@ -98,10 +96,10 @@ button {
fill: #fff;
transform: rotate(45deg);
}

/*
@media (max-width: 720px) {
a > span {
display: none;
}
}
} */
</style>
2 changes: 2 additions & 0 deletions .vitepress/theme/components/PreferenceSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
preferSFCKey,
preferSFC
} from './preferences'
import PreferenceTooltip from './PreferenceTooltip.vue'
const route = useRoute()
const show = computed(() =>
Expand Down Expand Up @@ -94,6 +95,7 @@ function useToggleFn(
@click="closeSideBar"
>?</a
>
<PreferenceTooltip />
</div>
<div class="switch-container" v-if="showSFC">
<label class="no-sfc-label" @click="toggleSFC(false)">HTML</label>
Expand Down
227 changes: 227 additions & 0 deletions .vitepress/theme/components/PreferenceTooltip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
import {
inBrowser,
preferComposition,
preferCompositionKey
} from './preferences'
import { useData, type Header } from 'vitepress'
const show = ref(false)
const { page } = useData()
type Source = 'url-query' | 'url-header' | 'default'
let source: Source | false =
inBrowser && localStorage.getItem(preferCompositionKey) === null
? 'default'
: false
if (inBrowser) {
// 1. check if URL contains explicit preference
const match = location.search.match(/[\?&]api=(\w+)/)
const preference = match && match[1]
if (preference === 'composition') {
setPreference(true, 'url-query')
} else if (preference === 'options') {
setPreference(false, 'url-query')
} else {
// 2. check if target header only exists for a certain API
if (location.hash) {
const h = findHeader(page.value.headers, location.hash)
if (h && h.optionsOnly) {
setPreference(false, 'url-header')
} else if (h && h.compositionOnly) {
setPreference(true, 'url-header')
}
}
}
}
function findHeader(
headers: Header[],
link: string
):
| (Header & {
optionsOnly?: boolean
compositionOnly?: boolean
})
| undefined {
for (const h of headers) {
if (h.link === link) {
return h
}
if (h.children) {
const c = findHeader(h.children, link)
if (c) return c
}
}
}
function setPreference(capi: boolean, s: Source) {
if (capi && !preferComposition.value) {
source = s
preferComposition.value = true
document.documentElement.classList.add('prefer-composition')
} else if (!capi && preferComposition.value) {
source = s
preferComposition.value = false
document.documentElement.classList.remove('prefer-composition')
}
}
onMounted(() => {
if (
!page.value.relativePath.startsWith('tutorial/') &&
source !== false
) {
show.value = true
// dismiss if user switches with the tooltip open
const stop = watch(preferComposition, () => {
show.value = false
stop()
})
}
})
function dismiss() {
show.value = false
// save if default
if (source === 'default') {
localStorage.setItem(
preferCompositionKey,
String(preferComposition.value)
)
}
}
</script>

<template>
<Transition name="fly-in">
<div class="preference-tooltip" v-if="show">
<template v-if="source === 'default'">
<p>API style now defaults to Composition API.</p>
<p>
Some pages contain different content based on the API style
chosen. Use this switch to toggle between APIs styles.
</p>
</template>
<template v-if="source && source.startsWith('url')">
<p>
Showing content for
{{ preferComposition ? 'Composition' : 'Options' }} API because
{{
source === 'url-query'
? 'it is specified by the URL query.'
: 'the target section is only available for that API.'
}}
</p>
<p>
This is different from your saved preference and will only affect
the current browsing session.
</p>
</template>
<p class="actions">
<a href="/guide/introduction#api-styles">Learn more</a>
<button @click="dismiss">Got it</button>
</p>
<div class="arrow-top"></div>
<div class="arrow-top inner"></div>
</div>
</Transition>
</template>

<style scoped>
.preference-tooltip {
font-weight: 500;
line-height: 1.6;
position: absolute;
padding: 12px 20px 12px 36px;
width: 100%;
background-color: var(--vt-c-bg-soft);
top: 7.5em;
border: 1px solid var(--vt-c-green);
border-radius: 8px;
box-shadow: var(--vt-shadow-3);
z-index: 10;
}
.preference-tooltip:before {
content: '';
position: absolute;
font-weight: 600;
font-size: 14px;
top: 9px;
left: 13px;
}
.dark .preference-tooltip {
box-shadow: var(--vt-shadow-1);
}
p {
margin-bottom: 8px;
}
.arrow-top {
width: 0;
height: 0;
border: 6px solid transparent;
border-bottom: 9px solid var(--vt-c-green);
position: absolute;
top: -16px;
left: 18px;
}
.prefer-composition .arrow-top {
left: 130px;
}
@media (max-width: 1439px) {
.arrow-top {
left: 16px;
}
.prefer-composition .arrow-top {
left: 136px;
}
}
.arrow-top.inner {
border-bottom-color: var(--vt-c-bg-soft);
top: -14px;
}
.actions {
text-align: right;
margin-top: 14px;
margin-bottom: 0;
}
a {
color: var(--vt-c-green);
text-decoration: underline;
margin-right: 1.5em;
}
button {
color: var(--vt-c-bg-soft);
font-weight: 500;
box-shadow: var(--vt-shadow-2);
padding: 2px 8px;
border-radius: 6px;
background-color: var(--vt-c-green);
}
.fly-in-enter-active {
transition: all 0.2s ease-out;
}
.fly-in-leave-active {
transition: all 0.15s ease-in;
}
.fly-in-enter-from,
.fly-in-leave-to {
opacity: 0;
transform: translateY(16px);
}
</style>
2 changes: 1 addition & 1 deletion .vitepress/theme/components/SponsorsGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function track(interest?: boolean) {
href="/sponsor/"
class="sponsor-item action"
@click="track(true)"
>Your logo</a
>Become a Sponsor</a
>
</div>
</template>
Expand Down
6 changes: 3 additions & 3 deletions .vitepress/theme/components/preferences.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ref } from 'vue'
import { AugmentedHeader } from '../../headerMdPlugin'

const hasStorage = typeof localStorage !== 'undefined'
export const inBrowser = typeof window !== 'undefined'
const get = (key: string, defaultValue = false): boolean =>
hasStorage
inBrowser
? JSON.parse(localStorage.getItem(key) || String(defaultValue))
: defaultValue

export const preferCompositionKey = 'vue-docs-prefer-composition'
export const preferComposition = ref(get(preferCompositionKey))
export const preferComposition = ref(get(preferCompositionKey, true))

export const preferSFCKey = 'vue-docs-prefer-sfc'
export const preferSFC = ref(get(preferSFCKey, true))
Expand Down
8 changes: 4 additions & 4 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
} from './components/preferences'
import SponsorsAside from './components/SponsorsAside.vue'
import VueSchoolLink from './components/VueSchoolLink.vue'
import Banner from './components/Banner.vue'
import TextAd from './components/TextAd.vue'
// import Banner from './components/Banner.vue'
// import TextAd from './components/TextAd.vue'

export default Object.assign({}, VPTheme, {
Layout: () => {
// @ts-ignore
return h(VPTheme.Layout, null, {
banner: () => h(Banner),
// banner: () => h(Banner),
'sidebar-top': () => h(PreferenceSwitch),
'aside-mid': () => h(SponsorsAside)
})
Expand All @@ -26,6 +26,6 @@ export default Object.assign({}, VPTheme, {
app.provide('prefer-sfc', preferSFC)
app.provide('filter-headers', filterHeadersByPreference)
app.component('VueSchoolLink', VueSchoolLink)
app.component('TextAd', TextAd)
// app.component('TextAd', TextAd)
}
})
6 changes: 6 additions & 0 deletions .vitepress/theme/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
:root {
--vp-sidebar-width-small: 289px !important;
}

/* bugfix: https://github.com/vuejs/theme/pull/95 */

.vt-flyout-menu {
max-height: calc(100vh - var(--vt-nav-height) - var(--vt-banner-height, 0px)) !important;
}
Loading

0 comments on commit 9a0466e

Please sign in to comment.