feat: add icons to settings page (#607)

This commit is contained in:
Xylight authored and GitHub committed 2025-07-11 01:15:51 +00:00
1 parent d48cdffcee
commit 10e96e86e9
3 files changed
+149 -23

No files matched your search

+55 -10
View File
@@ -28,21 +28,45 @@
ArrowDownTray, ArrowDownTray,
ArrowPath, ArrowPath,
ArrowRight, ArrowRight,
ArrowsPointingOut,
ArrowsRightLeft,
ArrowTopRightOnSquare, ArrowTopRightOnSquare,
ArrowTrendingDown, ArrowTrendingDown,
ArrowUpTray, ArrowUpTray,
Bars2,
Bars3,
BarsArrowDown,
BookOpen,
BugAnt,
Calendar,
ChartBar,
ChatBubbleOvalLeftEllipsis, ChatBubbleOvalLeftEllipsis,
ChevronDown, ChevronDown,
Clock, Clock,
CubeTransparent,
CursorArrowRays,
DocumentText,
ExclamationTriangle,
Eye,
EyeSlash,
Fire, Fire,
GlobeAmericas, GlobeAmericas,
Heart, Heart,
Icon, Icon,
Language, Language,
Photo,
Plus, Plus,
ServerStack,
Share,
Star, Star,
Swatch,
TableCells,
Tag,
Trash, Trash,
Trophy, Trophy,
User,
VideoCamera,
ViewColumns,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import Section from './Section.svelte' import Section from './Section.svelte'
import Setting from './Setting.svelte' import Setting from './Setting.svelte'
@@ -204,7 +228,7 @@
{/if} {/if}
<Section id="app" title={$t('settings.app.title')}> <Section id="app" title={$t('settings.app.title')}>
{#if env.PUBLIC_XYLIGHT_MODE} {#if env.PUBLIC_XYLIGHT_MODE}
<Setting class=""> <Setting icon={Heart}>
{#snippet title()} {#snippet title()}
<span class="dark:text-pink-400 text-pink-600 font-medium"> <span class="dark:text-pink-400 text-pink-600 font-medium">
{$t('nav.menu.donate')} {$t('nav.menu.donate')}
@@ -230,7 +254,7 @@
</Setting> </Setting>
{/if} {/if}
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<Setting> <Setting icon={Language}>
{#snippet title()} {#snippet title()}
<span class="inline-flex items-center gap-2"> <span class="inline-flex items-center gap-2">
{$t('settings.app.lang.title')} {$t('settings.app.lang.title')}
@@ -270,7 +294,7 @@
></ToggleSetting> ></ToggleSetting>
{/if} {/if}
</div> </div>
<Setting> <Setting icon={ViewColumns}>
{#snippet title()} {#snippet title()}
<span>{$t('settings.app.view.title')}</span> <span>{$t('settings.app.view.title')}</span>
{/snippet} {/snippet}
@@ -288,6 +312,7 @@
<Setting <Setting
optionClass="flex-2 max-w-full flex-wrap min-w-0 " optionClass="flex-2 max-w-full flex-wrap min-w-0 "
itemsClass="flex-col items-start! lg:items-center! lg:flex-row" itemsClass="flex-col items-start! lg:items-center! lg:flex-row"
icon={ChartBar}
> >
{#snippet title()} {#snippet title()}
<span>{$t('settings.app.sort.title')}</span> <span>{$t('settings.app.sort.title')}</span>
@@ -343,12 +368,12 @@
</div> </div>
</Setting> </Setting>
<ToggleSetting <ToggleSetting
beta icon={BarsArrowDown}
bind:checked={settings.infiniteScroll} bind:checked={settings.infiniteScroll}
title={$t('settings.app.infiniteScroll.title')} title={$t('settings.app.infiniteScroll.title')}
description={$t('settings.app.infiniteScroll.description')} description={$t('settings.app.infiniteScroll.description')}
/> />
<Setting> <Setting icon={Photo}>
{#snippet title()} {#snippet title()}
<span>{$t('settings.app.thumbnailSide.title')}</span> <span>{$t('settings.app.thumbnailSide.title')}</span>
{/snippet} {/snippet}
@@ -367,33 +392,38 @@
/> />
</Setting> </Setting>
<ToggleSetting <ToggleSetting
icon={ArrowsRightLeft}
bind:checked={settings.posts.reverseActions} bind:checked={settings.posts.reverseActions}
title={$t('settings.app.reverseActions.title')} title={$t('settings.app.reverseActions.title')}
description={$t('settings.app.reverseActions.description')} description={$t('settings.app.reverseActions.description')}
/> />
<ToggleSetting <ToggleSetting
icon={TableCells}
supportedPlatforms={{ desktop: true, tablet: false, mobile: false }} supportedPlatforms={{ desktop: true, tablet: false, mobile: false }}
bind:checked={settings.newWidth} bind:checked={settings.newWidth}
title={$t('settings.app.limitLayoutWidth.title')} title={$t('settings.app.limitLayoutWidth.title')}
description={$t('settings.app.limitLayoutWidth.description')} description={$t('settings.app.limitLayoutWidth.description')}
/> />
<ToggleSetting <ToggleSetting
icon={Calendar}
bind:checked={settings.absoluteDates} bind:checked={settings.absoluteDates}
title={$t('settings.app.absoluteDates.title')} title={$t('settings.app.absoluteDates.title')}
description={$t('settings.app.absoluteDates.description')} description={$t('settings.app.absoluteDates.description')}
/> />
<ToggleSetting <ToggleSetting
icon={CubeTransparent}
supportedPlatforms={{ desktop: false, tablet: false, mobile: true }} supportedPlatforms={{ desktop: false, tablet: false, mobile: true }}
bind:checked={settings.dock.autoHide} bind:checked={settings.dock.autoHide}
title={$t('settings.navigation.autoHide.title')} title={$t('settings.navigation.autoHide.title')}
description={$t('settings.navigation.autoHide.description')} description={$t('settings.navigation.autoHide.description')}
/> />
<ToggleSetting <ToggleSetting
icon={ArrowTopRightOnSquare}
bind:checked={settings.openLinksInNewTab} bind:checked={settings.openLinksInNewTab}
title={$t('settings.app.postsInNewTab.title')} title={$t('settings.app.postsInNewTab.title')}
description={$t('settings.app.postsInNewTab.description')} description={$t('settings.app.postsInNewTab.description')}
/> />
<Setting> <Setting icon={DocumentText}>
{#snippet title()} {#snippet title()}
<span>{$t('settings.app.font.title')}</span> <span>{$t('settings.app.font.title')}</span>
{/snippet} {/snippet}
@@ -407,26 +437,31 @@
</Select> </Select>
</Setting> </Setting>
<ToggleSetting <ToggleSetting
icon={ArrowPath}
bind:checked={settings.randomPlaceholders} bind:checked={settings.randomPlaceholders}
title={$t('settings.app.placeholders.title')} title={$t('settings.app.placeholders.title')}
description={$t('settings.app.placeholders.description')} description={$t('settings.app.placeholders.description')}
/> />
<ToggleSetting <ToggleSetting
icon={ArrowsPointingOut}
bind:checked={settings.expandImages} bind:checked={settings.expandImages}
title={$t('settings.app.expandImages.title')} title={$t('settings.app.expandImages.title')}
description={$t('settings.app.expandImages.description')} description={$t('settings.app.expandImages.description')}
/> />
<ToggleSetting <ToggleSetting
icon={Bars2}
bind:checked={settings.posts.deduplicateEmbed} bind:checked={settings.posts.deduplicateEmbed}
title={$t('settings.app.duplicateTitles.title')} title={$t('settings.app.duplicateTitles.title')}
description={$t('settings.app.duplicateTitles.description')} description={$t('settings.app.duplicateTitles.description')}
/> />
<ToggleSetting <ToggleSetting
icon={ArrowTopRightOnSquare}
bind:checked={settings.posts.titleOpensUrl} bind:checked={settings.posts.titleOpensUrl}
title={$t('settings.app.titleOpensUrl.title')} title={$t('settings.app.titleOpensUrl.title')}
description={$t('settings.app.titleOpensUrl.description')} description={$t('settings.app.titleOpensUrl.description')}
/> />
<ToggleSetting <ToggleSetting
icon={Tag}
title={$t('settings.app.titleTags.title')} title={$t('settings.app.titleTags.title')}
description={$t('settings.app.titleTags.description')} description={$t('settings.app.titleTags.description')}
bind:checked={settings.parseTags} bind:checked={settings.parseTags}
@@ -435,11 +470,12 @@
<Section id="embeds" title={$t('settings.embeds.title')}> <Section id="embeds" title={$t('settings.embeds.title')}>
<ToggleSetting <ToggleSetting
icon={CursorArrowRays}
title={$t('settings.embeds.clickToView.title')} title={$t('settings.embeds.clickToView.title')}
description={$t('settings.embeds.clickToView.description')} description={$t('settings.embeds.clickToView.description')}
bind:checked={settings.embeds.clickToView} bind:checked={settings.embeds.clickToView}
/> />
<Setting> <Setting icon={VideoCamera}>
{#snippet title()} {#snippet title()}
<span>YouTube</span> <span>YouTube</span>
{/snippet} {/snippet}
@@ -492,31 +528,36 @@
<Section id="lemmy" title={$t('settings.lemmy.title')}> <Section id="lemmy" title={$t('settings.lemmy.title')}>
<ToggleSetting <ToggleSetting
icon={Eye}
bind:checked={settings.posts.showHidden} bind:checked={settings.posts.showHidden}
title={$t('settings.lemmy.showHiddenPosts.title')} title={$t('settings.lemmy.showHiddenPosts.title')}
description={$t('settings.lemmy.showHiddenPosts.description')} description={$t('settings.lemmy.showHiddenPosts.description')}
/> />
<ToggleSetting <ToggleSetting
icon={Bars3}
bind:checked={settings.posts.compactFeatured} bind:checked={settings.posts.compactFeatured}
title={$t('settings.lemmy.compactFeatured.title')} title={$t('settings.lemmy.compactFeatured.title')}
description={$t('settings.lemmy.compactFeatured.description')} description={$t('settings.lemmy.compactFeatured.description')}
/> />
<ToggleSetting <ToggleSetting
icon={BookOpen}
bind:checked={settings.markPostsAsRead} bind:checked={settings.markPostsAsRead}
title={$t('settings.lemmy.markReadPosts.title')} title={$t('settings.lemmy.markReadPosts.title')}
description={$t('settings.lemmy.markReadPosts.description')} description={$t('settings.lemmy.markReadPosts.description')}
/> />
<ToggleSetting <ToggleSetting
icon={CubeTransparent}
bind:checked={settings.markReadPosts} bind:checked={settings.markReadPosts}
title={$t('settings.lemmy.fadeReadPosts.title')} title={$t('settings.lemmy.fadeReadPosts.title')}
description={$t('settings.lemmy.fadeReadPosts.description')} description={$t('settings.lemmy.fadeReadPosts.description')}
/> />
<ToggleSetting <ToggleSetting
icon={Share}
bind:checked={settings.crosspostOriginalLink} bind:checked={settings.crosspostOriginalLink}
title={$t('settings.lemmy.crosspostMarker.title')} title={$t('settings.lemmy.crosspostMarker.title')}
description={$t('settings.lemmy.crosspostMarker.description')} description={$t('settings.lemmy.crosspostMarker.description')}
/> />
<Setting> <Setting icon={EyeSlash}>
{#snippet title()} {#snippet title()}
<span>{$t('settings.lemmy.hideSubmissions.title')}</span> <span>{$t('settings.lemmy.hideSubmissions.title')}</span>
{/snippet} {/snippet}
@@ -535,11 +576,12 @@
</div> </div>
</Setting> </Setting>
<ToggleSetting <ToggleSetting
icon={ExclamationTriangle}
bind:checked={settings.nsfwBlur} bind:checked={settings.nsfwBlur}
title={$t('settings.lemmy.nsfwBlur.title')} title={$t('settings.lemmy.nsfwBlur.title')}
description={$t('settings.lemmy.nsfwBlur.description')} description={$t('settings.lemmy.nsfwBlur.description')}
/> />
<Setting> <Setting icon={ServerStack}>
{#snippet title()} {#snippet title()}
<span>{$t('settings.lemmy.instances.title')}</span> <span>{$t('settings.lemmy.instances.title')}</span>
{/snippet} {/snippet}
@@ -561,6 +603,7 @@
</div> </div>
</Setting> </Setting>
<ToggleSetting <ToggleSetting
icon={User}
bind:checked={settings.displayNames} bind:checked={settings.displayNames}
title={$t('settings.app.displayName.title')} title={$t('settings.app.displayName.title')}
description={$t('settings.app.displayName.description')} description={$t('settings.app.displayName.description')}
@@ -568,7 +611,7 @@
</Section> </Section>
<Section id="moderation" title={$t('settings.moderation.title')}> <Section id="moderation" title={$t('settings.moderation.title')}>
<Setting itemsClass="flex-col! items-start!"> <Setting icon={Trash} itemsClass="flex-col! items-start!">
{#snippet title()} {#snippet title()}
<span>{$t('settings.moderation.replyPresets.title')}</span> <span>{$t('settings.moderation.replyPresets.title')}</span>
{/snippet} {/snippet}
@@ -666,11 +709,13 @@
<Section id="other" title={$t('settings.other.title')}> <Section id="other" title={$t('settings.other.title')}>
<ToggleSetting <ToggleSetting
icon={BugAnt}
bind:checked={settings.debugInfo} bind:checked={settings.debugInfo}
title={$t('settings.other.debug.title')} title={$t('settings.other.debug.title')}
description={$t('settings.other.debug.description')} description={$t('settings.other.debug.description')}
/> />
<ToggleSetting <ToggleSetting
icon={Bars3}
bind:checked={settings.posts.noVirtualize} bind:checked={settings.posts.noVirtualize}
title={$t('settings.other.virtualizeFeeds.title')} title={$t('settings.other.virtualizeFeeds.title')}
description={$t('settings.other.virtualizeFeeds.description')} description={$t('settings.other.virtualizeFeeds.description')}
+68 -1
View File
@@ -6,6 +6,7 @@
DevicePhoneMobile, DevicePhoneMobile,
DeviceTablet, DeviceTablet,
Icon, Icon,
type IconSource,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
interface Props { interface Props {
@@ -21,6 +22,7 @@
title?: import('svelte').Snippet title?: import('svelte').Snippet
description?: import('svelte').Snippet description?: import('svelte').Snippet
children?: import('svelte').Snippet children?: import('svelte').Snippet
icon?: IconSource
} }
let { let {
@@ -36,11 +38,15 @@
title, title,
description, description,
children, children,
icon,
}: Props = $props() }: Props = $props()
</script> </script>
<div <div
class="flex flex-col w-full justify-between gap-2 max-w-full @container/setting {mainClass}" class={[
'flex flex-col w-full justify-between gap-2 max-w-full @container/setting setting',
mainClass,
]}
> >
{#if Object.values(supportedPlatforms).some(v => v == false)} {#if Object.values(supportedPlatforms).some(v => v == false)}
<div class="flex items-center gap-2 flex-wrap"> <div class="flex items-center gap-2 flex-wrap">
@@ -73,6 +79,13 @@
<div <div
class="flex flex-col @md/setting:flex-row items-center gap-2 {itemsClass}" class="flex flex-col @md/setting:flex-row items-center gap-2 {itemsClass}"
> >
{#if icon}
<Icon
src={icon}
size="32"
class="bg-red-200/20 dark:bg-red-800/20 p-1.5 self-start @md/setting:self-center rounded-lg color text-red-500 dark:text-red-200"
/>
{/if}
<div class="flex flex-col gap-0.5 flex-2 w-full shrink-0 min-w-48 {clazz}"> <div class="flex flex-col gap-0.5 flex-2 w-full shrink-0 min-w-48 {clazz}">
<h1 class="font-medium text-base"> <h1 class="font-medium text-base">
{@render title?.()} {@render title?.()}
@@ -93,3 +106,57 @@
{/if} {/if}
</div> </div>
</div> </div>
<style>
:global(.setting:nth-child(17n + 1) .color) {
filter: hue-rotate(10deg);
}
:global(.setting:nth-child(17n + 2) .color) {
filter: hue-rotate(30deg);
}
:global(.setting:nth-child(17n + 3) .color) {
filter: hue-rotate(50deg);
}
:global(.setting:nth-child(17n + 4) .color) {
filter: hue-rotate(70deg);
}
:global(.setting:nth-child(17n + 5) .color) {
filter: hue-rotate(90deg);
}
:global(.setting:nth-child(17n + 6) .color) {
filter: hue-rotate(110deg);
}
:global(.setting:nth-child(17n + 7) .color) {
filter: hue-rotate(130deg);
}
:global(.setting:nth-child(17n + 8) .color) {
filter: hue-rotate(150deg);
}
:global(.setting:nth-child(17n + 9) .color) {
filter: hue-rotate(170deg);
}
:global(.setting:nth-child(17n + 10) .color) {
filter: hue-rotate(190deg);
}
:global(.setting:nth-child(17n + 11) .color) {
filter: hue-rotate(210deg);
}
:global(.setting:nth-child(17n + 12) .color) {
filter: hue-rotate(230deg);
}
:global(.setting:nth-child(17n + 13) .color) {
filter: hue-rotate(250deg);
}
:global(.setting:nth-child(17n + 14) .color) {
filter: hue-rotate(270deg);
}
:global(.setting:nth-child(17n + 15) .color) {
filter: hue-rotate(290deg);
}
:global(.setting:nth-child(17n + 16) .color) {
filter: hue-rotate(310deg);
}
:global(.setting:nth-child(17n + 17) .color) {
filter: hue-rotate(330deg);
}
</style>
+26 -12
View File
@@ -6,6 +6,7 @@
DevicePhoneMobile, DevicePhoneMobile,
DeviceTablet, DeviceTablet,
Icon, Icon,
type IconSource,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
interface Props { interface Props {
@@ -18,6 +19,7 @@
tablet: boolean tablet: boolean
mobile: boolean mobile: boolean
} }
icon?: IconSource
} }
let { let {
@@ -30,10 +32,13 @@
tablet: true, tablet: true,
mobile: true, mobile: true,
}, },
icon,
}: Props = $props() }: Props = $props()
</script> </script>
<div class="flex flex-col w-full justify-between gap-2 max-w-full"> <div
class="flex flex-col w-full justify-between gap-2 max-w-full setting @container/setting"
>
{#if Object.values(supportedPlatforms).some(v => v == false) || beta} {#if Object.values(supportedPlatforms).some(v => v == false) || beta}
<div class="flex items-center gap-2 flex-wrap"> <div class="flex items-center gap-2 flex-wrap">
{#if beta} {#if beta}
@@ -67,16 +72,25 @@
{/if} {/if}
</div> </div>
{/if} {/if}
<Switch <div class="flex flex-col @md/setting:flex-row gap-2">
bind:checked {#if icon}
class="flex-row-reverse items-center w-full" <Icon
labelClass="flex-1 mr-auto" src={icon}
> size="32"
<h1 class="font-medium text-base">{title}</h1> class="bg-red-200/20 dark:bg-red-800/20 p-1.5 self-start @md/setting:self-center rounded-lg color text-red-500 dark:text-red-200"
{#if description} />
<p class="text-slate-600 dark:text-zinc-400 text-sm">
{description}
</p>
{/if} {/if}
</Switch> <Switch
bind:checked
class="flex-row-reverse items-center w-full"
labelClass="flex-1 mr-auto"
>
<h1 class="font-medium text-base">{title}</h1>
{#if description}
<p class="text-slate-600 dark:text-zinc-400 text-sm">
{description}
</p>
{/if}
</Switch>
</div>
</div> </div>