feat: auto expand right sidebar items, close #388

This commit is contained in:
Xylight committed 2024-08-02 16:40:04 -07:00
1 parent d8975e31a4
commit c7570840dd
3 files changed
+27 -29

No files matched your search

+4 -3
View File
@@ -19,6 +19,7 @@
import { userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations'
import Entity from '../ui/Entity.svelte'
import { userSettings } from '$lib/settings'
export let site: SiteView
export let taglines: Tagline[] | undefined = undefined
@@ -74,7 +75,7 @@
/>
{/if}
<Expandable>
<Expandable bind:open={$userSettings.expand.about}>
<svelte:fragment slot="title">
<Icon src={InformationCircle} size="15" mini />
{$t('cards.site.about')}
@@ -84,7 +85,7 @@
<Markdown source={site.site.sidebar} />
</Expandable>
<Expandable>
<Expandable bind:open={$userSettings.expand.stats}>
<svelte:fragment slot="title">
<Icon src={ChartBar} size="15" mini />
{$t('cards.site.stats')}
@@ -109,7 +110,7 @@
</Expandable>
{#if admins}
<Expandable>
<Expandable bind:open={$userSettings.expand.team}>
<svelte:fragment slot="title">
<Icon src={UserGroup} size="15" mini />
{$t('cards.site.admins')}
@@ -7,18 +7,9 @@
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import StickyCard from '$lib/components/ui/StickyCard.svelte'
import {
Menu,
MenuButton,
Modal,
Popover,
removeToast,
toast,
} from 'mono-svelte'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { Menu, MenuButton, Modal, removeToast, toast } from 'mono-svelte'
import { client, getClient } from '$lib/lemmy.js'
import { addSubscription, hasFavorite } from '$lib/lemmy/user.js'
import { addSubscription } from '$lib/lemmy/user.js'
import { fullCommunityName } from '$lib/util.js'
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
import { Button } from 'mono-svelte'
@@ -26,7 +17,6 @@
BuildingOffice2,
Calendar,
ChartBar,
ChatBubbleOvalLeftEllipsis,
Check,
Cog6Tooth,
EllipsisHorizontal,
@@ -35,20 +25,17 @@
InformationCircle,
Newspaper,
NoSymbol,
PencilSquare,
Plus,
Star,
UserGroup,
} from 'svelte-hero-icons'
import { publishedToDate } from '$lib/components/util/date.js'
import CommunityLink from './CommunityLink.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import LabelStat from '$lib/components/ui/LabelStat.svelte'
import ShieldIcon from '../moderation/ShieldIcon.svelte'
import ItemList from '../generic/ItemList.svelte'
import { communityLink, userLink } from '$lib/lemmy/generic'
import { userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations'
import Entity from '$lib/components/ui/Entity.svelte'
import { userSettings } from '$lib/settings'
export let community_view: CommunityView
export let moderators: CommunityModeratorView[] = []
@@ -197,7 +184,7 @@
name={community_view.community.title}
label="!{fullCommunityName(
community_view.community.name,
community_view.community.actor_id,
community_view.community.actor_id
)}"
>
<Avatar
@@ -212,7 +199,7 @@
<div
class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800 [&>*]:py-3"
>
<Expandable class="!pt-0">
<Expandable bind:open={$userSettings.expand.about} class="!pt-0">
<svelte:fragment slot="title">
<Icon src={InformationCircle} size="15" mini />
{$t('cards.site.about')}
@@ -220,7 +207,7 @@
<Markdown source={community_view.community.description} />
</Expandable>
<Expandable>
<Expandable bind:open={$userSettings.expand.stats}>
<svelte:fragment slot="title">
<Icon src={ChartBar} size="15" mini />
{$t('cards.site.stats')}
@@ -240,7 +227,7 @@
</Expandable>
{#if moderators && moderators.length > 0}
<Expandable>
<Expandable bind:open={$userSettings.expand.team}>
<svelte:fragment slot="title">
<ShieldIcon width={15} filled />
{$t('cards.community.moderators')}
@@ -287,7 +274,7 @@
<Button
href="/c/{fullCommunityName(
community_view.community.name,
community_view.community.actor_id,
community_view.community.actor_id
)}/settings"
size="square-md"
>
+14 -4
View File
@@ -26,6 +26,7 @@ interface Preset {
}
interface Settings {
settingsVer: number
expandableImages: boolean
// should have been named "fade" read posts
markReadPosts: boolean
@@ -51,6 +52,9 @@ interface Settings {
communities: boolean
moderates: boolean
favorites: boolean
about: boolean
stats: boolean
team: boolean
}
displayNames: boolean
nsfwBlur: boolean
@@ -95,11 +99,11 @@ interface Settings {
parseTags: boolean
tagRules: {
[key: string]: 'hide' | 'blur'
},
downloadMbfc: boolean
}
}
export const defaultSettings: Settings = {
settingsVer: 1,
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
showInstances: {
@@ -121,6 +125,9 @@ export const defaultSettings: Settings = {
communities: toBool(env.PUBLIC_EXPAND_COMMUNITIES) ?? true,
favorites: toBool(env.PUBLIC_EXPAND_FAVORITES) ?? true,
moderates: toBool(env.PUBLIC_EXPAND_MODERATES) ?? true,
about: false,
stats: false,
team: false,
},
displayNames: toBool(env.PUBLIC_DISPLAY_NAMES) ?? true,
nsfwBlur: toBool(env.PUBLIC_NSFW_BLUR) ?? true,
@@ -172,7 +179,6 @@ export const defaultSettings: Settings = {
nsfl: 'blur',
nsfw: 'blur',
},
downloadMbfc: false
}
export const userSettings = writable(defaultSettings)
@@ -198,7 +204,11 @@ if (typeof window != 'undefined') {
oldUserSettings = migrate(oldUserSettings)
userSettings.set({ ...defaultSettings, ...oldUserSettings })
userSettings.set({
...defaultSettings,
...oldUserSettings,
settingsVer: defaultSettings.settingsVer,
})
}
userSettings.subscribe((settings) => {