diff --git a/src/lib/components/lemmy/dropdowns/Location.svelte b/src/lib/components/lemmy/dropdowns/Location.svelte new file mode 100644 index 00000000..c74eaf88 --- /dev/null +++ b/src/lib/components/lemmy/dropdowns/Location.svelte @@ -0,0 +1,51 @@ + + + diff --git a/src/lib/components/lemmy/dropdowns/Sort.svelte b/src/lib/components/lemmy/dropdowns/Sort.svelte index 7151b537..740f2579 100644 --- a/src/lib/components/lemmy/dropdowns/Sort.svelte +++ b/src/lib/components/lemmy/dropdowns/Sort.svelte @@ -7,7 +7,8 @@ import type { SortType } from 'lemmy-js-client' import { Select } from 'mono-svelte' import { ChartBar, Clock, Icon } from 'svelte-hero-icons' - import { fly } from 'svelte/transition' + import { backOut } from 'svelte/easing' + import { fly, slide } from 'svelte/transition' export let selected: string export let navigate: boolean = true @@ -20,10 +21,38 @@ : undefined -
+
+ {#if selected?.startsWith('Top')} -
+
{/if} -
diff --git a/src/lib/components/lemmy/dropdowns/ViewSelect.svelte b/src/lib/components/lemmy/dropdowns/ViewSelect.svelte index 40b6da5b..2dde6655 100644 --- a/src/lib/components/lemmy/dropdowns/ViewSelect.svelte +++ b/src/lib/components/lemmy/dropdowns/ViewSelect.svelte @@ -6,7 +6,7 @@ export let showLabel = true - {#if showLabel} diff --git a/src/lib/components/lemmy/post/PostMeta.svelte b/src/lib/components/lemmy/post/PostMeta.svelte index ea6c60de..82a8afb5 100644 --- a/src/lib/components/lemmy/post/PostMeta.svelte +++ b/src/lib/components/lemmy/post/PostMeta.svelte @@ -108,7 +108,7 @@
{#if badges.nsfw} diff --git a/src/lib/components/ui/navbar/Navbar.svelte b/src/lib/components/ui/navbar/Navbar.svelte index 4d548860..6e86c6cf 100644 --- a/src/lib/components/ui/navbar/Navbar.svelte +++ b/src/lib/components/ui/navbar/Navbar.svelte @@ -22,10 +22,11 @@ } from 'svelte-hero-icons' import Profile from './Profile.svelte' import NavButton from './NavButton.svelte' - import { scale } from 'svelte/transition' + import { fly, scale } from 'svelte/transition' import { expoOut, backOut } from 'svelte/easing' import { flip } from 'svelte/animate' import SearchBar from '$lib/components/lemmy/util/SearchBar.svelte' + import { swipeGesture } from '$lib/input/swipe' let searching = false diff --git a/src/lib/input/swipe.ts b/src/lib/input/swipe.ts new file mode 100644 index 00000000..9144811d --- /dev/null +++ b/src/lib/input/swipe.ts @@ -0,0 +1,88 @@ +enum SwipeDirection { + Up = 'up', + Down = 'down', + Left = 'left', + Right = 'right', + None = 'none' +} + +export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => any) { + let touchstartX = 0 + let touchstartY = 0 + let touchendX = 0 + let touchendY = 0 + + node?.addEventListener( + 'touchstart', + function (event) { + // @ts-ignore + touchstartX = event?.screenX + // @ts-ignore + touchstartY = event?.screenY + }, + false + ) + + node?.addEventListener( + 'mousedown', + function (event) { + // @ts-ignore + touchstartX = event?.screenX + // @ts-ignore + touchstartY = event?.screenY + }, + false + ) + + node?.addEventListener( + 'mouseup', + function (event) { + // @ts-ignore + touchendX = event.screenX + // @ts-ignore + touchendY = event.screenY + return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY)) + }, + false + ) + + node?.addEventListener( + 'touchend', + function (event) { + // @ts-ignore + touchendX = event.screenX + // @ts-ignore + touchendY = event.screenY + return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY)) + }, + false + ) +} + +function swipeDir( + touchStartX: number, + touchStartY: number, + touchEndX: number, + touchEndY: number +): SwipeDirection { + const deltaX = touchEndX - touchStartX; + const deltaY = touchEndY - touchStartY; + + // Define a threshold for the minimum swipe distance + const minSwipeDistance = 10; // Adjust this value as needed + + // Check the absolute difference between deltaX and deltaY + if (Math.abs(deltaX) >= Math.abs(deltaY)) { + // Horizontal swipe + if (Math.abs(deltaX) >= minSwipeDistance) { + return deltaX > 0 ? SwipeDirection.Right : SwipeDirection.Left; + } + } else { + // Vertical swipe + if (Math.abs(deltaY) >= minSwipeDistance) { + return deltaY > 0 ? SwipeDirection.Down : SwipeDirection.Up; + } + } + + return SwipeDirection.None; +} \ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 949355f4..cade9c59 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -15,6 +15,7 @@ import { feature } from '$lib/version.js' import { userSettings } from '$lib/settings.js' import FormattedNumber from '$lib/components/util/FormattedNumber.svelte' + import Location from '$lib/components/lemmy/dropdowns/Location.svelte' export let data @@ -48,36 +49,11 @@ -
- -
- -
- -
+
+ + +
+
diff --git a/src/style/app.css b/src/style/app.css index faec52bb..4883da02 100644 --- a/src/style/app.css +++ b/src/style/app.css @@ -60,7 +60,7 @@ body { } #nprogress .bar { - @apply bg-black dark:bg-white !important; + @apply bg-primary-900 dark:bg-primary-100 !important; z-index: 999 !important; height: 1px !important; }