refactor: use icon prop instead of snippet prefix
This commit is contained in:
56 files changed
+409
-595
No files matched your search
@@ -139,7 +139,6 @@
|
||||
loading.subscribing = false
|
||||
}
|
||||
|
||||
|
||||
let setFlair = $state(false)
|
||||
|
||||
interface Props {
|
||||
@@ -155,7 +154,6 @@
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
|
||||
{#await community_view}
|
||||
<div
|
||||
class="w-full h-full grid place-items-center"
|
||||
@@ -165,9 +163,12 @@
|
||||
<Spinner width={24} />
|
||||
</div>
|
||||
{:then community_view}
|
||||
<Modal title={$t('cards.community.flair')} bind:open={setFlair}>
|
||||
<CommunityFlair community={community_view.community.id} onsubmit={() => setFlair = !setFlair} />
|
||||
</Modal>
|
||||
<Modal title={$t('cards.community.flair')} bind:open={setFlair}>
|
||||
<CommunityFlair
|
||||
community={community_view.community.id}
|
||||
onsubmit={() => (setFlair = !setFlair)}
|
||||
/>
|
||||
</Modal>
|
||||
<aside
|
||||
class={[
|
||||
'min-w-full pt-0 text-slate-600 dark:text-zinc-400 flex flex-col gap-1',
|
||||
@@ -198,7 +199,7 @@
|
||||
</EndPlaceholder>
|
||||
{#if profile.current?.jwt}
|
||||
{@const subscribed = profile.current.user?.follows.some(
|
||||
i => i.community.id == community_view.community.id,
|
||||
(i) => i.community.id == community_view.community.id,
|
||||
)}
|
||||
<Button
|
||||
disabled={loading.subscribing}
|
||||
@@ -209,25 +210,19 @@
|
||||
onclick={() => subscribe(community_view)}
|
||||
class="px-4 relative z-[inherit]"
|
||||
alignment="left"
|
||||
icon={community_view.subscribed == 'Subscribed' ? Check : Plus}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon
|
||||
src={community_view.subscribed == 'Subscribed' ? Check : Plus}
|
||||
mini
|
||||
size="16"
|
||||
/>
|
||||
{/snippet}
|
||||
{subscribed
|
||||
? $t('cards.community.subscribed')
|
||||
: $t('cards.community.subscribe')}
|
||||
</Button>
|
||||
{#if client().setFlair}
|
||||
<SidebarButton
|
||||
onclick={() => setFlair = !setFlair}
|
||||
rounding="xl"
|
||||
icon={Tag}
|
||||
label={$t('cards.community.flair')}
|
||||
/>
|
||||
{#if client().setFlair}
|
||||
<SidebarButton
|
||||
onclick={() => (setFlair = !setFlair)}
|
||||
rounding="xl"
|
||||
icon={Tag}
|
||||
label={$t('cards.community.flair')}
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if profile.current?.user && amMod(profile.current.user, community_view.community)}
|
||||
@@ -269,10 +264,8 @@
|
||||
size="lg"
|
||||
onclick={() =>
|
||||
block(community_view.community.id, !community_view.blocked)}
|
||||
icon={NoSymbol}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={NoSymbol} size="16" mini />
|
||||
{/snippet}
|
||||
{community_view.blocked
|
||||
? $t('cards.community.unblock')
|
||||
: $t('cards.community.block')}
|
||||
@@ -282,10 +275,8 @@
|
||||
color="danger-subtle"
|
||||
size="lg"
|
||||
onclick={() => blockInstance(community_view.community.instance_id)}
|
||||
icon={BuildingOffice2}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={BuildingOffice2} size="16" mini />
|
||||
{/snippet}
|
||||
{$t('cards.community.blockInstance')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
@@ -312,10 +303,8 @@
|
||||
dismissable: true,
|
||||
type: 'error',
|
||||
})}
|
||||
icon={Fire}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Fire} size="16" mini />
|
||||
{/snippet}
|
||||
{$t('admin.purge')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
@@ -364,7 +353,7 @@
|
||||
</span>
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={moderators.map(i => ({
|
||||
items={moderators.map((i) => ({
|
||||
id: i.moderator.id,
|
||||
name: i.moderator.display_name || i.moderator.name,
|
||||
url: userLink(i.moderator),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
Option,
|
||||
Select,
|
||||
Material,
|
||||
Menu
|
||||
Menu,
|
||||
} from 'mono-svelte'
|
||||
import { GlobeAlt, Icon, MapPin, Plus } from 'svelte-hero-icons'
|
||||
import { Header } from '$lib/components/ui/layout'
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
if (profile.current.user) {
|
||||
const c = profile.current.user.moderates
|
||||
.map(m => m.community.id)
|
||||
.map((m) => m.community.id)
|
||||
.indexOf(res.community_view.community.id)
|
||||
if (c != -1) {
|
||||
profile.current.user.moderates[c] = {
|
||||
@@ -139,7 +139,7 @@
|
||||
</script>
|
||||
|
||||
<form
|
||||
onsubmit={e => {
|
||||
onsubmit={(e) => {
|
||||
e.preventDefault()
|
||||
submit()
|
||||
}}
|
||||
@@ -201,7 +201,7 @@
|
||||
</Badge>
|
||||
</button>
|
||||
{/snippet}
|
||||
{#each site.data.all_languages.filter(l => !formData.languages?.includes(l.id)) as language (language.id)}
|
||||
{#each site.data.all_languages.filter((l) => !formData.languages?.includes(l.id)) as language (language.id)}
|
||||
<MenuButton
|
||||
class="min-h-[16px] py-0"
|
||||
onclick={() => {
|
||||
@@ -217,7 +217,7 @@
|
||||
</Menu>
|
||||
{#each formData.languages ?? [] as languageId, index (languageId)}
|
||||
{@const language = site.data.all_languages.find(
|
||||
l => l.id == languageId,
|
||||
(l) => l.id == languageId,
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -14,7 +14,15 @@
|
||||
CommunityModeratorView,
|
||||
SubscribedType,
|
||||
} from '$lib/client/types'
|
||||
import { action, Button, Menu, MenuButton, Modal, modal, toast } from 'mono-svelte'
|
||||
import {
|
||||
action,
|
||||
Button,
|
||||
Menu,
|
||||
MenuButton,
|
||||
Modal,
|
||||
modal,
|
||||
toast,
|
||||
} from 'mono-svelte'
|
||||
import {
|
||||
BuildingOffice2,
|
||||
Check,
|
||||
@@ -61,9 +69,11 @@
|
||||
let setFlair = $state(false)
|
||||
</script>
|
||||
|
||||
|
||||
<Modal title={$t('cards.community.flair')} bind:open={setFlair}>
|
||||
<CommunityFlair community={community.id} onsubmit={() => setFlair = !setFlair} />
|
||||
<CommunityFlair
|
||||
community={community.id}
|
||||
onsubmit={() => (setFlair = !setFlair)}
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
<EntityHeader
|
||||
@@ -119,7 +129,7 @@
|
||||
<hr class="flex-1 border-slate-200 dark:border-zinc-800 mx-3" />
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={moderators.map(m => ({
|
||||
items={moderators.map((m) => ({
|
||||
id: m.moderator.id,
|
||||
name: m.moderator.name,
|
||||
url: userLink(m.moderator),
|
||||
@@ -129,7 +139,12 @@
|
||||
/>
|
||||
</Expandable>
|
||||
{/if}
|
||||
<div class={["flex items-center gap-2 h-max w-max", compact == 'lg' && 'lg:hidden']}>
|
||||
<div
|
||||
class={[
|
||||
'flex items-center gap-2 h-max w-max',
|
||||
compact == 'lg' && 'lg:hidden',
|
||||
]}
|
||||
>
|
||||
{#if profile.current?.jwt}
|
||||
<Subscribe
|
||||
community={{
|
||||
@@ -152,14 +167,8 @@
|
||||
}}
|
||||
class="relative z-[inherit]"
|
||||
rounding="pill"
|
||||
icon={subscribed != 'NotSubscribed' ? Check : Plus}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon
|
||||
src={subscribed != 'NotSubscribed' ? Check : Plus}
|
||||
micro
|
||||
size="16"
|
||||
/>
|
||||
{/snippet}
|
||||
{subscribed == 'Subscribed' || subscribed == 'Pending'
|
||||
? $t('cards.community.subscribed')
|
||||
: $t('cards.community.subscribe')}
|
||||
@@ -167,13 +176,19 @@
|
||||
{/snippet}
|
||||
</Subscribe>
|
||||
|
||||
<Button size="custom" class="h-9 aspect-square" rounding="pill" onclick={() => setFlair = !setFlair} aria-label={$t('cards.community.flair')}>
|
||||
<Button
|
||||
size="custom"
|
||||
class="h-9 aspect-square"
|
||||
rounding="pill"
|
||||
onclick={() => (setFlair = !setFlair)}
|
||||
aria-label={$t('cards.community.flair')}
|
||||
>
|
||||
<Icon src={Tag} size="16" micro />
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
{#if profile.current?.user && profile.current.user.moderates
|
||||
.map(c => c.community.id)
|
||||
.map((c) => c.community.id)
|
||||
.includes(community.id)}
|
||||
<Button
|
||||
color="secondary"
|
||||
@@ -190,11 +205,13 @@
|
||||
{/if}
|
||||
<Menu placement="top-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button {@attach attachment} size="custom" rounding="pill" class="h-8.5 aspect-square">
|
||||
{#snippet prefix()}
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<Button
|
||||
{@attach attachment}
|
||||
size="custom"
|
||||
rounding="pill"
|
||||
class="h-8.5 aspect-square"
|
||||
icon={EllipsisHorizontal}
|
||||
></Button>
|
||||
{/snippet}
|
||||
<MenuButton href="/modlog?community={community.id}">
|
||||
<Icon src={Newspaper} size="16" mini />
|
||||
@@ -214,10 +231,8 @@
|
||||
color="danger-subtle"
|
||||
size="lg"
|
||||
onclick={() => block(community.id, !blocked)}
|
||||
icon={NoSymbol}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={NoSymbol} size="16" mini />
|
||||
{/snippet}
|
||||
{blocked
|
||||
? $t('cards.community.unblock')
|
||||
: $t('cards.community.block')}
|
||||
@@ -227,10 +242,8 @@
|
||||
color="danger-subtle"
|
||||
size="lg"
|
||||
onclick={() => blockInstance(community.instance_id)}
|
||||
icon={BuildingOffice2}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={BuildingOffice2} size="16" mini />
|
||||
{/snippet}
|
||||
{$t('cards.community.blockInstance')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
@@ -257,10 +270,8 @@
|
||||
dismissable: true,
|
||||
type: 'error',
|
||||
})}
|
||||
icon={Fire}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Fire} size="16" mini />
|
||||
{/snippet}
|
||||
{$t('admin.purge')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
|
||||
@@ -201,10 +201,8 @@
|
||||
? 'aspect-square @md:px-2 @md:min-w-30 @md:aspect-auto'
|
||||
: 'px-3',
|
||||
]}
|
||||
icon={subscribed ? Check : Plus}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={subscribed ? Check : Plus} size="16" micro />
|
||||
{/snippet}
|
||||
<span class={[view == 'compact' && 'hidden', '@md:block']}>
|
||||
{#if subscribed}
|
||||
{$t('cards.community.subscribed')}
|
||||
|
||||
Reference in new issue
Block a user