diff --git a/apps/docs/src/lib/components/Sidebar.svelte b/apps/docs/src/lib/components/Sidebar.svelte index bc20dbb5..343a7b2f 100644 --- a/apps/docs/src/lib/components/Sidebar.svelte +++ b/apps/docs/src/lib/components/Sidebar.svelte @@ -22,6 +22,20 @@ } from 'radix-icons-svelte'; import { base } from '$app/paths'; + export let pathname: string; + + let accordionEl: HTMLElement; + $: { + // Sets the active link in the Sidebar when the page changes + accordionEl?.querySelectorAll('a').forEach((a) => { + if (a.getAttribute('href') === pathname) { + a.classList.add('active'); + } else { + a.classList.remove('active'); + } + }); + } + const useStyles = createStyles(() => ({ '.svelteui-AccordionItem-panel': { padding: '0 !important', @@ -76,7 +90,13 @@
- +
Changelog
    diff --git a/apps/docs/src/lib/theme/components/Layout.svelte b/apps/docs/src/lib/theme/components/Layout.svelte deleted file mode 100644 index 43625de7..00000000 --- a/apps/docs/src/lib/theme/components/Layout.svelte +++ /dev/null @@ -1,69 +0,0 @@ - - - - {title} - - - - -
    -
    - -
    -
    - - - {#if !nosidebar} - {#if !mobile || (mobile && show_sidebar)} - - {/if} - {/if} - -
    - {#if mobile && !nosidebar} - (show_sidebar = !show_sidebar)} - /> - {/if} - -
    -
    -
    diff --git a/apps/docs/src/lib/theme/utils/index.js b/apps/docs/src/lib/theme/utils/index.js index 1a02f57e..94e3f759 100644 --- a/apps/docs/src/lib/theme/utils/index.js +++ b/apps/docs/src/lib/theme/utils/index.js @@ -1 +1 @@ -export { outside_click, set_active_link } from './link-actions'; +export { outside_click } from './link-actions'; diff --git a/apps/docs/src/lib/theme/utils/link-actions.js b/apps/docs/src/lib/theme/utils/link-actions.js index 834ad735..3ee9ec47 100644 --- a/apps/docs/src/lib/theme/utils/link-actions.js +++ b/apps/docs/src/lib/theme/utils/link-actions.js @@ -1,20 +1,8 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-nocheck -// import { current_page } from '@svelte-docs/get/routes'; - -export function set_active_link(node, options) { - node.querySelectorAll('a').forEach((a) => { - if (a.getAttribute('href') === options.page.url.pathname) { - a.classList.add('active'); - } else { - a.classList.remove('active'); - } - }); -} export function outside_click(node, options) { const { handler } = options; - console.log(node); const HTMLCollection = node.children[1].children; let runner; diff --git a/apps/docs/src/routes/+layout.svelte b/apps/docs/src/routes/+layout.svelte index c2a4eac6..815bd655 100644 --- a/apps/docs/src/routes/+layout.svelte +++ b/apps/docs/src/routes/+layout.svelte @@ -3,7 +3,6 @@ import { colorScheme, Burger, SvelteUIProvider } from '@svelteuidev/core'; import { page } from '$app/stores'; import { Device, Logo, PageTransition, TopBar, Sidebar } from '$lib/components'; - import { set_active_link } from '$lib/theme/utils'; import '$lib/theme/style.css'; import type { PageData } from './$types'; import { onMount } from 'svelte'; @@ -36,11 +35,7 @@ class="sidebar" class:active-sidebar={show_sidebar} > - {#key $page} -
    - -
    - {/key} + {/if}