Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add version banner #1487

Merged
merged 22 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docs/.vitepress/components/Banner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script setup lang="ts">
import { useElementSize } from '@vueuse/core';
import { inBrowser } from 'vitepress';
import { ref, watchEffect } from 'vue';

const el = ref<HTMLElement>();
const { height } = useElementSize(el);

watchEffect(() => {
if (inBrowser) {
document.documentElement.style.setProperty(
'--vp-layout-top-height',
`${height.value + 16}px`
);
}
});
</script>

<template>
<div ref="el" class="banner">
These docs are of the next (unreleased) version. For docs of the current
version visit: <a href="https://fakerjs.dev/">fakerjs.dev</a>
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</template>

<style>
html {
--vp-layout-top-height: 40px;
}
</style>

<style scoped>
.banner {
position: fixed;
z-index: var(--vp-z-index-layout-top);
top: 0;
left: 0;
right: 0;

text-align: center;
padding: 8px;

background: #383636;
color: #fff;
}

a {
text-decoration: underline;
}
</style>
5 changes: 5 additions & 0 deletions docs/.vitepress/components/shims.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import type { DefineComponent } from 'vue';
const component: DefineComponent;
export default component;
}
11 changes: 10 additions & 1 deletion docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import DefaultTheme from 'vitepress/theme';
import { h } from 'vue';
import Banner from '../components/Banner.vue';
import './index.css';

export default DefaultTheme;
export default {
...DefaultTheme,
Layout() {
return h(DefaultTheme.Layout, null, {
'layout-top': () => h(Banner),
});
},
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"@typescript-eslint/parser": "~5.40.1",
"@vitest/coverage-c8": "~0.24.3",
"@vitest/ui": "~0.24.3",
"@vueuse/core": "~9.4.0",
"c8": "~7.12.0",
"conventional-changelog-cli": "~2.2.2",
"cypress": "~10.10.0",
Expand Down Expand Up @@ -137,8 +138,9 @@
"typescript": "~4.8.4",
"validator": "~13.7.0",
"vite": "~3.1.8",
"vitepress": "1.0.0-alpha.22",
"vitest": "~0.24.3"
"vitepress": "1.0.0-alpha.25",
"vitest": "~0.24.3",
"vue": "~3.2.41"
},
"packageManager": "pnpm@7.14.0",
"engines": {
Expand Down
Loading