Sidebar.svelte 842 B

123456789101112131415161718192021222324252627282930
  1. <script lang="ts">
  2. import { quadInOut, quintIn } from 'svelte/easing';
  3. import { fade, slide } from 'svelte/transition';
  4. export let show = false;
  5. export let side = 'right';
  6. export let width = '200px';
  7. export let className = '';
  8. </script>
  9. {#if show}
  10. <!-- svelte-ignore a11y-no-static-element-interactions -->
  11. <div
  12. class="absolute z-20 top-0 right-0 left-0 bottom-0 bg-white/20 dark:bg-black/20 w-full min-h-full h-full flex justify-center overflow-hidden overscroll-contain"
  13. on:mousedown={() => {
  14. show = false;
  15. }}
  16. transition:fade
  17. />
  18. <div
  19. class="absolute z-30 shadow-xl {side === 'right' ? 'right-0' : 'left-0'} top-0 bottom-0"
  20. transition:slide={{ easing: quadInOut, axis: side === 'right' ? 'x' : 'y' }}
  21. >
  22. <div class="{className} h-full" style="width: {show ? width : '0px'}">
  23. <slot />
  24. </div>
  25. </div>
  26. {/if}