Add keyword and URL filtering for posts (#711)
* feat: Add keyword and URL filtering for posts * impr: add minimizing filters, improve UI, fix some reactivity problems
This commit is contained in:
1 parent
21a0baacf9
commit
5630ac3bf8
8 files changed
+232
-42
No files matched your search
@@ -7,7 +7,7 @@
|
||||
import Link from '$lib/ui/form/Link.svelte'
|
||||
import Switch from '$lib/ui/form/Switch.svelte'
|
||||
import { CommonList } from '$lib/ui/layout'
|
||||
import { Button, Option, Select } from 'mono-svelte'
|
||||
import { Button, Option, Select, TextArea } from 'mono-svelte'
|
||||
import {
|
||||
ArrowsPointingOut,
|
||||
ArrowsRightLeft,
|
||||
@@ -22,12 +22,14 @@
|
||||
Clock,
|
||||
CubeTransparent,
|
||||
DocumentText,
|
||||
EyeSlash,
|
||||
Fire,
|
||||
GlobeAmericas,
|
||||
Heart,
|
||||
Icon,
|
||||
Language,
|
||||
Photo,
|
||||
Plus,
|
||||
Star,
|
||||
TableCells,
|
||||
Tag,
|
||||
@@ -36,6 +38,7 @@
|
||||
} from 'svelte-hero-icons/dist'
|
||||
import Setting from '../Setting.svelte'
|
||||
import ToggleSetting from '../ToggleSetting.svelte'
|
||||
import Filter from './Filter.svelte'
|
||||
|
||||
let localeMap: Map<
|
||||
string,
|
||||
@@ -191,6 +194,32 @@
|
||||
title={$t('settings.app.infiniteScroll.title')}
|
||||
description={$t('settings.app.infiniteScroll.description')}
|
||||
/>
|
||||
<Setting icon={EyeSlash} adaptive={false} mainClass="rounded-b-none!">
|
||||
{#snippet title()}
|
||||
<span>{$t('settings.lemmy.contentFilter.title')}</span>
|
||||
{/snippet}
|
||||
{#snippet description()}
|
||||
<span>{$t('settings.lemmy.contentFilter.description')}</span>
|
||||
{/snippet}
|
||||
</Setting>
|
||||
{#each settings.filters as filter, index}
|
||||
<Filter onremove={() => settings.filters.splice(index, 1)} bind:filter />
|
||||
{/each}
|
||||
<li class="rounded-t-none! -mt-1! border-t-0!">
|
||||
<Button
|
||||
color="none"
|
||||
class="w-full p-2"
|
||||
icon={Plus}
|
||||
onclick={() =>
|
||||
settings.filters.push({
|
||||
match: 'New filter.',
|
||||
action: 'none',
|
||||
type: 'keyword',
|
||||
})}
|
||||
>
|
||||
{$t('common.add')}
|
||||
</Button>
|
||||
</li>
|
||||
<Setting icon={Photo}>
|
||||
{#snippet title()}
|
||||
<span>{$t('settings.app.thumbnailSide.title')}</span>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<script lang="ts">
|
||||
import { t } from '$lib/app/i18n'
|
||||
import type { Filter } from '$lib/feature/post/filters'
|
||||
import Switch from '$lib/ui/form/Switch.svelte'
|
||||
import { Button, TextInput } from 'mono-svelte'
|
||||
import { Trash } from 'svelte-hero-icons/dist'
|
||||
|
||||
interface Props {
|
||||
filter: Filter
|
||||
onremove?: () => void
|
||||
}
|
||||
|
||||
let { filter = $bindable(), onremove }: Props = $props()
|
||||
</script>
|
||||
|
||||
<li
|
||||
class="adaptive px-3 py-1 flex flex-col md:flex-row md:items-center xs gap-4"
|
||||
>
|
||||
<TextInput bind:value={filter.match} label="" class="flex-1"></TextInput>
|
||||
<Switch
|
||||
options={['hide', 'minimize', 'none']}
|
||||
optionNames={[
|
||||
$t('settings.lemmy.contentFilter.hide'),
|
||||
$t('settings.lemmy.contentFilter.minimize'),
|
||||
$t('settings.lemmy.contentFilter.disabled'),
|
||||
]}
|
||||
bind:selected={filter.action}
|
||||
/>
|
||||
<Button
|
||||
icon={Trash}
|
||||
size="square-md"
|
||||
onclick={onremove}
|
||||
aria-label={$t('common.remove')}
|
||||
/>
|
||||
</li>
|
||||
|
||||
<style>
|
||||
li {
|
||||
border-top-left-radius: 0 !important;
|
||||
border-top-right-radius: 0 !important;
|
||||
border-bottom-left-radius: 0 !important;
|
||||
border-bottom-right-radius: 0 !important;
|
||||
margin-top: calc(var(--spacing) * -1);
|
||||
border-top: none !important;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user