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

feat(docs): add site banner for survey #4555

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"devDependencies": {
"@playwright/test": "^1.44.0",
"@types/node": "^20.12.10",
"@vueuse/core": "^10.9.0",
"sass": "^1.77.0",
"vitepress": "^1.1.4"
"vitepress": "^1.1.4",
"vue": "^3.4.27"
},
"scripts": {
"website:dev": "vitepress dev --host localhost --port 8080 runatlantis.io",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 96 additions & 0 deletions runatlantis.io/.vitepress/components/Banner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<script setup lang="ts">
import { useElementSize } from '@vueuse/core';
import { ref, watchEffect } from 'vue';
const el = ref<HTMLElement>();
const { height } = useElementSize(el);
watchEffect(() => {
if (height.value) {
document.documentElement.style.setProperty(
'--vp-layout-top-height',
`${height.value + 16}px`
);
}
});
const dismiss = () => {
localStorage.setItem(
'survey-banner',
(Date.now() + 8.64e7 * 1).toString() // current time + 1 day
);
document.documentElement.classList.add('banner-dismissed');
};
</script>

<template>
<div ref="el" class="banner">
<div class="text">
<p>
In April 2024, the Core Atlantis Team launched an anonymous survey to better understand our community's needs and help prioritize our roadmap.
</p>
<p>
If you're an Atlantis user, please take 5 minutes to fill it out:
<a href="https://docs.google.com/forms/d/1fOGWkdinDV2_46CZvzQRdz8401ypZR8Z-iwkNNt3EX0">Survey Link</a>
</p>
</div>

<button type="button" @click="dismiss">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
/>
</svg>
</button>
</div>
</template>

<style>
.banner-dismissed {
--vp-layout-top-height: 0px !important;
}
html {
--vp-layout-top-height: 88px;
}
@media (min-width: 375px) {
html {
--vp-layout-top-height: 64px;
}
}
@media (min-width: 768px) {
html {
--vp-layout-top-height: 40px;
}
}
</style>

<style scoped>
.banner-dismissed .banner {
display: none;
}
.banner {
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: var(--vp-z-index-layout-top);
padding: 8px;
text-align: center;
background: #383636;
color: #fff;
display: flex;
justify-content: space-between;
}
.text {
flex: 1;
}
a {
text-decoration: underline;
}
svg {
width: 20px;
height: 20px;
margin-left: 8px;
}
</style>
5 changes: 5 additions & 0 deletions runatlantis.io/.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;
}
14 changes: 14 additions & 0 deletions runatlantis.io/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ export default defineConfig({
gtag('js', new Date());

gtag('config', 'UA-6850151-3');`
],
[
'script',
{ id: 'restore-banner-preference' },
`
(() => {
const restore = (key, cls, def = false) => {
const saved = localStorage.getItem(key);
if (saved ? saved !== 'false' && new Date() < saved : def) {
document.documentElement.classList.add(cls);
}
};
restore('survey-banner', 'banner-dismissed');
})();`,
]
],
sitemap: {
Expand Down
10 changes: 9 additions & 1 deletion runatlantis.io/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import DefaultTheme from "vitepress/theme";
import { defineAsyncComponent, h } from 'vue';
import "./index.scss";
import "./palette.scss";

export default DefaultTheme;
export default {
...DefaultTheme,
Layout() {
return h(DefaultTheme.Layout, null, {
'layout-top': () => h(defineAsyncComponent(() => import('../components/Banner.vue')))
});
}
};
Loading