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