From aa527d00948cd24d744fd038c1065afc0173f2b7 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 17 Jul 2025 14:53:49 +0200 Subject: [PATCH] chore: set up viteconf banner (#3266) --- .../inlined-scripts/restorePreference.js | 4 +- .vitepress/theme/components/Banner.vue | 183 ++++++++++++++++-- .vitepress/theme/index.ts | 4 +- 3 files changed, 166 insertions(+), 25 deletions(-) diff --git a/.vitepress/inlined-scripts/restorePreference.js b/.vitepress/inlined-scripts/restorePreference.js index 5e18b50ff..9338835ac 100644 --- a/.vitepress/inlined-scripts/restorePreference.js +++ b/.vitepress/inlined-scripts/restorePreference.js @@ -8,6 +8,6 @@ restore('vue-docs-prefer-composition', 'prefer-composition', true) restore('vue-docs-prefer-sfc', 'prefer-sfc', true) - // window.__VUE_BANNER_ID__ = '' - // restore(`vue-docs-banner-${__VUE_BANNER_ID__}`, 'banner-dismissed') + window.__VUE_BANNER_ID__ = 'viteconf2025' + restore(`vue-docs-banner-${__VUE_BANNER_ID__}`, 'banner-dismissed') })() diff --git a/.vitepress/theme/components/Banner.vue b/.vitepress/theme/components/Banner.vue index 6730fcd48..47242691c 100644 --- a/.vitepress/theme/components/Banner.vue +++ b/.vitepress/theme/components/Banner.vue @@ -20,12 +20,48 @@ function dismiss() { } + @@ -46,31 +82,80 @@ html:not(.banner-dismissed) { height: var(--vt-banner-height); line-height: var(--vt-banner-height); text-align: center; - font-size: 13px; - font-weight: 600; - color: #fff; - background-color: var(--vt-c-green); - background: linear-gradient( - 90deg, - rgba(66, 184, 131, 1) 0%, - rgba(39, 179, 137, 1) 19%, - rgba(100, 126, 255, 1) 100% - ); + font-size: 12px; + color: white; + background: #262626; + display: flex; + justify-content: center; + align-items: center; + overflow: hidden; } -.banner-dismissed .banner { - display: none; +.glow.glow--purple { + position: absolute; + bottom: -15%; + left: -75%; + width: 80%; + aspect-ratio: 1.5; + pointer-events: none; + border-radius: 100%; + background: linear-gradient(270deg, #7a23a1, #715ebde6 60% 80%, #bd34fe00); + filter: blur(15vw); + transform: none; + opacity: .6 +} + +.glow.glow--blue { + position: absolute; + bottom: -15%; + right: -40%; + width: 80%; + aspect-ratio: 1.5; + pointer-events: none; + border-radius: 100%; + background: linear-gradient(180deg, #61d9ff, #0000); + filter: blur(15vw); + transform: none; + opacity: .3 +} + +@media (min-width: 768px) { + .glow.glow--blue { + top: -15%; + right: -40%; + width: 80%; + } + + .glow.glow--purple { + bottom: -15%; + left: -40%; + width: 80%; + } } -a:hover { - text-decoration: underline; +@media (min-width: 1025px) { + .glow.glow--blue { + top: -15%; + right: -40%; + width: 80%; + } + + .glow.glow--purple { + bottom: -15%; + left: -40%; + width: 80%; + } +} + +.banner-dismissed .banner { + display: none; } button { position: absolute; right: 0; top: 0; - padding: 5px; + padding: 5px 5px; } .close { @@ -79,10 +164,66 @@ button { fill: #fff; transform: rotate(45deg); } -/* -@media (max-width: 720px) { - a > span { + +.vt-banner-text { + color: #fff; + font-size: 12px; +} + +.vt-main { + color: transparent; + background-image: linear-gradient(120deg, #b047ff 16%, #9499ff, #9499ff); + background-clip: text; +} + +.vt-primary-action { + background: radial-gradient(141.42% 141.42% at 100% 0%, #ffffff80, #fff0), radial-gradient(140.35% 140.35% at 100% 94.74%, #bd34fe, #bd34fe00), radial-gradient(89.94% 89.94% at 18.42% 15.79%, #41d1ff, #41d1ff00); + color: #fff; + padding: 4px 8px; + border-radius: 5px; + font-size: 10px; + text-decoration: none; + margin: 0 10px; + transition: all .2s ease-in-out; + + &:hover { + box-shadow: 0 1px #fffc inset; + } +} + + +@media (max-width: 1280px) { + .banner .vt-banner-text { + font-size: 14px; + } + + .vt-tagline { display: none; } -} */ - +} + +@media (max-width: 780px) { + .vt-tagline { + display: none; + } + + .vt-coupon { + display: none; + } + + .vt-primary-action { + margin: 0 10px; + padding: 4px 8px; + } + + .vt-time-now { + display: none; + } +} + +@media (max-width: 560px) { + .vt-place { + display: none; + } +} + \ No newline at end of file diff --git a/.vitepress/theme/index.ts b/.vitepress/theme/index.ts index 7782fa6f6..4aa8af648 100644 --- a/.vitepress/theme/index.ts +++ b/.vitepress/theme/index.ts @@ -11,7 +11,7 @@ import { import SponsorsAside from './components/SponsorsAside.vue' import VueSchoolLink from './components/VueSchoolLink.vue' import ScrimbaLink from './components/ScrimbaLink.vue' -// import Banner from './components/Banner.vue' +import Banner from './components/Banner.vue' // import TextAd from './components/TextAd.vue' import 'vitepress/dist/client/theme-default/styles/components/vp-code-group.css' @@ -21,7 +21,7 @@ export default Object.assign({}, VPTheme, { Layout: () => { // @ts-ignore return h(VPTheme.Layout, null, { - // banner: () => h(Banner), + banner: () => h(Banner), 'sidebar-top': () => h(PreferenceSwitch), 'sidebar-bottom': () => h(SecurityUpdateBtn), 'aside-mid': () => h(SponsorsAside)