Skip to content

Commit

Permalink
Merge pull request systeminit#4258 from systeminit/adamhjk/lightbox-docs
Browse files Browse the repository at this point in the history
docs: add zoom to images on the docs site
  • Loading branch information
adamhjk authored Jul 31, 2024
2 parents cf45fbd + 1c6f5f9 commit 2a8ff87
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"@si/tsconfig": "workspace:*",
"@types/node": "^18.15.11",
"eslint": "^8.36.0",
"medium-zoom": "^1.1.0",
"typescript": "^4.9.5",
"vitepress": "~1.0.2"
"vitepress": "~1.0.2",
"vitepress-plugin-lightbox": "^1.0.2"
},
"volta": {
"extends": "../../package.json"
Expand Down
4 changes: 4 additions & 0 deletions app/docs/src/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "vitepress";
import dotenv from "dotenv";
import path from "path";
import lightbox from "vitepress-plugin-lightbox";

dotenv.config();

Expand All @@ -12,6 +13,9 @@ export default defineConfig({
light: "github-light",
dark: "github-dark",
},
config: (md) => {
md.use(lightbox, {});
}
},
head: [
['script', {}, `
Expand Down
37 changes: 37 additions & 0 deletions app/docs/src/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script setup lang="ts">
import DefaultTheme from "vitepress/theme";
import { onMounted } from "vue";
import { useRouter } from "vitepress";
import mediumZoom from "medium-zoom";
const { Layout } = DefaultTheme;
const router = useRouter();
// Setup medium zoom with the desired options
const setupMediumZoom = () => {
mediumZoom("[data-zoomable]", {
background: "transparent",
});
};
// Apply medium zoom on load
onMounted(setupMediumZoom);
// Subscribe to route changes to re-apply medium zoom effect
router.onAfterRouteChanged = setupMediumZoom;
</script>

<template>
<Layout />
</template>

<style>
.medium-zoom-overlay {
backdrop-filter: blur(5rem);
}
.medium-zoom-overlay,
.medium-zoom-image--opened {
z-index: 999;
}
</style>
7 changes: 7 additions & 0 deletions app/docs/src/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import DefaultTheme from "vitepress/theme";
import Layout from "./Layout.vue";

export default {
extends: DefaultTheme,
Layout,
}
22 changes: 22 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 2a8ff87

Please sign in to comment.