impr: use custom progress bar
This commit is contained in:
6 files changed
+58
-17
No files matched your search
@@ -14,7 +14,6 @@
|
|||||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||||
"@tailwindcss/container-queries": "^0.1.1",
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tailwindcss/postcss": "^4.1.8",
|
"@tailwindcss/postcss": "^4.1.8",
|
||||||
"@types/nprogress": "^0.2.0",
|
|
||||||
"@types/ua-parser-js": "^0.7.39",
|
"@types/ua-parser-js": "^0.7.39",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.28.0",
|
||||||
"eslint-plugin-svelte": "^3.9.1",
|
"eslint-plugin-svelte": "^3.9.1",
|
||||||
@@ -23,7 +22,6 @@
|
|||||||
"linkify-it": "^5.0.0",
|
"linkify-it": "^5.0.0",
|
||||||
"marked": "7.0.5",
|
"marked": "7.0.5",
|
||||||
"marked-linkify-it": "^3.1.10",
|
"marked-linkify-it": "^3.1.10",
|
||||||
"nprogress": "^0.2.0",
|
|
||||||
"postcss": "^8.4.30",
|
"postcss": "^8.4.30",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"prettier-plugin-svelte": "^3.2.7",
|
"prettier-plugin-svelte": "^3.2.7",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<svelte:element
|
<svelte:element
|
||||||
this={settings.expandImages ? 'button' : 'a'}
|
this={settings.expandImages ? 'button' : 'a'}
|
||||||
href={postLink(post)}
|
href={postLink(post)}
|
||||||
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
|
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900 cursor-pointer"
|
||||||
data-sveltekit-preload-data="off"
|
data-sveltekit-preload-data="off"
|
||||||
aria-label={post.name}
|
aria-label={post.name}
|
||||||
onclick={() => showImage(bestImageURL(post, false, -1, null))}
|
onclick={() => showImage(bestImageURL(post, false, -1, null))}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
size="16"
|
size="16"
|
||||||
micro
|
micro
|
||||||
class={[
|
class={[
|
||||||
open && 'rotate-90',
|
open && 'rotate-180',
|
||||||
'transition-transform duration-300 ease-out',
|
'transition-transform duration-300 ease-out',
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let progress = $state(0)
|
||||||
|
|
||||||
|
let increaseInterval: number = -1
|
||||||
|
let startTimeout: number = -1
|
||||||
|
let stopTimeout: number = -1
|
||||||
|
|
||||||
|
export function start() {
|
||||||
|
clearTimeout(stopTimeout)
|
||||||
|
progress = 0
|
||||||
|
startTimeout = setTimeout(() => {
|
||||||
|
progress = 1
|
||||||
|
// schedule a setInterval and run the code immediately
|
||||||
|
;(function i() {
|
||||||
|
if (progress < 100 && progress > 0)
|
||||||
|
// slowly get closer and closer to 90% -- 100% doesnt look very good to be stuck on
|
||||||
|
progress += (100 - (progress - 10)) / 4
|
||||||
|
increaseInterval = setInterval(i, 400) as unknown as number
|
||||||
|
})()
|
||||||
|
}, 100) as unknown as number
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stop() {
|
||||||
|
if (progress != 0) progress = 100
|
||||||
|
// reset progress to 0 after bar disappears
|
||||||
|
setTimeout(() => (progress = 0), 500)
|
||||||
|
clearInterval(increaseInterval)
|
||||||
|
clearTimeout(startTimeout)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class={[
|
||||||
|
'fixed top-0 left-0 h-px z-[400] bg-primary-900 dark:bg-primary-100',
|
||||||
|
progress == 100 && 'opacity-0',
|
||||||
|
progress > 0 && 'use-transition',
|
||||||
|
]}
|
||||||
|
style="width: {progress}%;"
|
||||||
|
id="progress-bar"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#progress-bar.use-transition {
|
||||||
|
transition:
|
||||||
|
width 0.7s cubic-bezier(0, 0, 0.22, 0.76),
|
||||||
|
opacity 0.5s linear;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -13,25 +13,17 @@
|
|||||||
import { inDarkColorScheme, rgbToHex, theme } from '$lib/ui/colors.svelte.js'
|
import { inDarkColorScheme, rgbToHex, theme } from '$lib/ui/colors.svelte.js'
|
||||||
import { getDefaultColors } from '$lib/ui/presets'
|
import { getDefaultColors } from '$lib/ui/presets'
|
||||||
import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte'
|
import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte'
|
||||||
import nProgress from 'nprogress'
|
|
||||||
import 'nprogress/nprogress.css'
|
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { Forward, Icon } from 'svelte-hero-icons'
|
import { Forward, Icon } from 'svelte-hero-icons'
|
||||||
import '../style/app.css'
|
import '../style/app.css'
|
||||||
|
import NavigationProgress from '$lib/components/ui/layout/NavigationProgress.svelte'
|
||||||
interface Props {
|
interface Props {
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let { children }: Props = $props()
|
let { children }: Props = $props()
|
||||||
|
|
||||||
nProgress.configure({
|
let progressBar = $state<{ start: () => void; stop: () => void }>()
|
||||||
minimum: 0.4,
|
|
||||||
trickleSpeed: 200,
|
|
||||||
easing: 'ease-out',
|
|
||||||
speed: 300,
|
|
||||||
showSpinner: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
if (window.location.hash == 'main') {
|
if (window.location.hash == 'main') {
|
||||||
@@ -71,12 +63,12 @@
|
|||||||
document.documentElement.dir =
|
document.documentElement.dir =
|
||||||
($locale == 'he' || $locale == 'ar') && settings.useRtl ? 'rtl' : 'ltr'
|
($locale == 'he' || $locale == 'ar') && settings.useRtl ? 'rtl' : 'ltr'
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (navigating.to) nProgress.start()
|
if (navigating.to) progressBar?.start()
|
||||||
else nProgress.done()
|
else progressBar?.stop()
|
||||||
})
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -104,6 +96,7 @@
|
|||||||
<Button
|
<Button
|
||||||
class="fixed -top-16 focus:top-0 left-0 m-4 z-300 transition-all"
|
class="fixed -top-16 focus:top-0 left-0 m-4 z-300 transition-all"
|
||||||
href="#main"
|
href="#main"
|
||||||
|
onclick={() => document.getElementById('main')?.focus()}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={Forward} mini size="16" />
|
<Icon src={Forward} mini size="16" />
|
||||||
@@ -111,6 +104,8 @@
|
|||||||
Skip Navigation
|
Skip Navigation
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<NavigationProgress bind:this={progressBar} />
|
||||||
|
|
||||||
<Shell>
|
<Shell>
|
||||||
<Moderation />
|
<Moderation />
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
|
|||||||
Reference in new issue
Block a user