feat: use native select menu for sorts

This commit is contained in:
Xyphyn committed 2023-09-03 17:59:01 -07:00
1 parent 7358486ee0
commit d3ba6d969c
5 files changed
+63 -34

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@
"@dicebear/initials": "^6.0.4", "@dicebear/initials": "^6.0.4",
"lemmy-js-client": "^0.18.0-rc.2", "lemmy-js-client": "^0.18.0-rc.2",
"markdown-it": "^13.0.1", "markdown-it": "^13.0.1",
"mono-svelte": "^0.1.4" "mono-svelte": "^0.1.5"
}, },
"type": "module" "type": "module"
} }
+2 -2
View File
@@ -51,13 +51,13 @@
</span> </span>
</div> </div>
</div> </div>
<div class="flex flex-row gap-4 max-w-full w-full items-end">
<Sort selected={data.sort} />
<div class="xl:hidden"> <div class="xl:hidden">
<Button color="secondary" on:click={() => (sidebar = !sidebar)}> <Button color="secondary" on:click={() => (sidebar = !sidebar)}>
About About
</Button> </Button>
</div> </div>
<div class="flex flex-col sm:flex-row gap-4 max-w-full w-full">
<Sort selected={data.sort} />
</div> </div>
<PostFeed posts={data.posts.posts} /> <PostFeed posts={data.posts.posts} />
<Pageination <Pageination
+26 -13
View File
@@ -6,10 +6,15 @@
import { toast } from '$lib/components/ui/toasts/toasts.js' import { toast } from '$lib/components/ui/toasts/toasts.js'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte' import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import Link from '$lib/components/input/Link.svelte' import Link from '$lib/components/input/Link.svelte'
import { ArrowPath, Icon } from 'svelte-hero-icons' import {
ArrowPath,
ChatBubbleOvalLeftEllipsis,
GlobeAmericas,
Icon,
} from 'svelte-hero-icons'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js' import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
import { Button, Checkbox } from 'mono-svelte' import { Button, Checkbox, Select } from 'mono-svelte'
let data = { let data = {
loading: false, loading: false,
@@ -42,22 +47,30 @@
<span slot="description">The default sort to use for feeds.</span> <span slot="description">The default sort to use for feeds.</span>
<div class="flex flex-wrap flex-row gap-4 w-full"> <div class="flex flex-wrap flex-row gap-4 w-full">
<div class="max-w-full"> <div class="max-w-full">
<span class="block my-1 font-bold">Feed</span> <Select bind:value={$userSettings.defaultSort.feed} class="w-28">
<MultiSelect <span slot="label" class="flex items-center gap-1">
options={['Subscribed', 'Local', 'All']} <Icon src={GlobeAmericas} size="16" mini />
bind:selected={$userSettings.defaultSort.feed} Location
/> </span>
<option value="All">All</option>
<option value="Local">Local</option>
<option value="Subscribed">Subscribed</option>
</Select>
</div> </div>
<div class="max-w-full"> <div class="max-w-full">
<span class="block my-1 font-bold">Sort</span>
<Sort bind:selected={$userSettings.defaultSort.sort} navigate={false} /> <Sort bind:selected={$userSettings.defaultSort.sort} navigate={false} />
</div> </div>
<div class="max-w-full"> <div class="max-w-full">
<span class="block my-1 font-bold">Comments</span> <Select bind:value={$userSettings.defaultSort.comments}>
<MultiSelect <span slot="label" class="flex items-center gap-1">
options={['Hot', 'Top', 'New']} <Icon src={ChatBubbleOvalLeftEllipsis} size="14" mini />
bind:selected={$userSettings.defaultSort.comments} Comments
/> </span>
<option value="Hot">Hot</option>
<option value="Top">Top</option>
<option value="New">New</option>
</Select>
</div> </div>
</div> </div>
</Setting> </Setting>
+30 -14
View File
@@ -6,7 +6,9 @@
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte' import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte' import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { import {
Bars3BottomRight,
Calendar, Calendar,
ChartBar,
ChatBubbleOvalLeftEllipsis, ChatBubbleOvalLeftEllipsis,
Envelope, Envelope,
Icon, Icon,
@@ -33,7 +35,7 @@
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte' import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { Button, Modal } from 'mono-svelte' import { Button, Modal, Select } from 'mono-svelte'
export let data export let data
@@ -141,19 +143,33 @@
<div class="flex flex-col-reverse xl:flex-row gap-4 max-w-full w-full"> <div class="flex flex-col-reverse xl:flex-row gap-4 max-w-full w-full">
<div class="flex flex-col gap-4 max-w-full w-full min-w-0"> <div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<div class="flex flex-row gap-4 flex-wrap"> <div class="flex flex-row gap-4 flex-wrap justify-between">
<MultiSelect <Select
options={['New', 'TopAll', 'Old']} bind:value={data.sort}
optionNames={['New', 'Top', 'Old']} on:change={() => searchParam($page.url, 'sort', data.sort, 'page')}
selected={data.sort} class="w-48"
on:select={(e) => searchParam($page.url, 'sort', e.detail, 'page')} >
/> <span slot="label" class="flex items-center gap-1">
<MultiSelect <Icon src={ChartBar} size="14" mini />
options={['all', 'posts', 'comments']} Sort
optionNames={['All', 'Posts', 'Comments']} </span>
selected={data.type} <option value="New">New</option>
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')} <option value="TopAll">Top</option>
/> <option value="Old">Old</option>
</Select>
<Select
bind:value={data.type}
on:change={() => searchParam($page.url, 'type', data.type, 'page')}
class="w-48"
>
<span slot="label" class="flex items-center gap-1">
<Icon src={Bars3BottomRight} size="15" mini />
Type
</span>
<option value="all">All</option>
<option value="posts">Posts</option>
<option value="comments">Comments</option>
</Select>
</div> </div>
{#if data.items.length == 0} {#if data.items.length == 0}
<Placeholder <Placeholder
+4 -4
View File
@@ -2977,10 +2977,10 @@ mlly@^1.2.0, mlly@^1.4.0:
pkg-types "^1.0.3" pkg-types "^1.0.3"
ufo "^1.1.2" ufo "^1.1.2"
mono-svelte@^0.1.4: mono-svelte@^0.1.5:
version "0.1.4" version "0.1.5"
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.1.4.tgz#bdb124a4869ed049acdea628ce51fdf7503a1a3f" resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.1.5.tgz#0306598c171d32b8acebc2350a363ab15e3b7613"
integrity sha512-rm9sKw/QFH0pUhBNYPAa8i2F2rQwxsss9Fz9IdCcXfoCIVZVk3Yki9857OtyY8wq8VV3iD8KBBQQsRnqQU8dSA== integrity sha512-4Hz9wEPOrlfvJ157YE7agKgJiyh2XHVRmObLD1r27IcRBUmTB/ANdrUBwtyZS9CsSX4RNY1Zpxm2z/g2gsJMgw==
mri@^1.1.0: mri@^1.1.0:
version "1.2.0" version "1.2.0"