feat: add community sidebar
This commit is contained in:
1 parent
c4e12b5b30
commit
86dd44adb7
2 files changed
+69
-24
No files matched your search
@@ -4,6 +4,13 @@
|
|||||||
type ButtonColor = keyof typeof buttonColor
|
type ButtonColor = keyof typeof buttonColor
|
||||||
type ButtonSize = keyof typeof buttonSize
|
type ButtonSize = keyof typeof buttonSize
|
||||||
type ButtonRoundness = keyof typeof buttonRoundness
|
type ButtonRoundness = keyof typeof buttonRoundness
|
||||||
|
type ButtonAlignment = keyof typeof buttonAlignment
|
||||||
|
|
||||||
|
const buttonAlignment = {
|
||||||
|
left: 'justify-start text-left',
|
||||||
|
center: 'justify-center text-center',
|
||||||
|
right: 'justify-end text-right',
|
||||||
|
}
|
||||||
|
|
||||||
const buttonColor = {
|
const buttonColor = {
|
||||||
primary: `border border-slate-900 bg-slate-900 dark:bg-zinc-100
|
primary: `border border-slate-900 bg-slate-900 dark:bg-zinc-100
|
||||||
@@ -51,6 +58,7 @@
|
|||||||
export let color: ButtonColor = 'secondary'
|
export let color: ButtonColor = 'secondary'
|
||||||
export let size: ButtonSize = 'md'
|
export let size: ButtonSize = 'md'
|
||||||
export let rounded: ButtonRoundness = 'md'
|
export let rounded: ButtonRoundness = 'md'
|
||||||
|
export let alignment: ButtonAlignment = 'center'
|
||||||
|
|
||||||
// const dispatch = createEventDispatcher()
|
// const dispatch = createEventDispatcher()
|
||||||
export let href: string | undefined = undefined
|
export let href: string | undefined = undefined
|
||||||
@@ -60,20 +68,24 @@
|
|||||||
<a
|
<a
|
||||||
{href}
|
{href}
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
class="{`
|
class="
|
||||||
${buttonColor[color]}
|
{buttonColor[color]}
|
||||||
${buttonSize[size]}
|
{buttonSize[size]}
|
||||||
${buttonRoundness[rounded]}
|
{buttonRoundness[rounded]}
|
||||||
text-sm transition-colors disabled:!opacity-70 disabled:!pointer-events-none
|
text-sm transition-colors disabled:!opacity-70 disabled:!pointer-events-none
|
||||||
disabled:!border disabled:!border-slate-300 disabled:!bg-slate-200 disabled:dark:!border-zinc-700 disabled:dark:!bg-zinc-800
|
disabled:!border disabled:!border-slate-300 disabled:!bg-slate-200 disabled:dark:!border-zinc-700 disabled:dark:!bg-zinc-800
|
||||||
${$$props.class}
|
{$$props.class}
|
||||||
`} {loading
|
{loading
|
||||||
? color == 'primary'
|
? color == 'primary'
|
||||||
? '!bg-transparent !text-inherit'
|
? '!bg-transparent !text-inherit'
|
||||||
: ''
|
: ''
|
||||||
: ''}"
|
: ''}"
|
||||||
>
|
>
|
||||||
<div class="flex flex-row items-center justify-center gap-1.5 h-full">
|
<div
|
||||||
|
class="flex flex-row items-center gap-1.5 h-full {buttonAlignment[
|
||||||
|
alignment
|
||||||
|
]}"
|
||||||
|
>
|
||||||
{#if loading}
|
{#if loading}
|
||||||
<Spinner
|
<Spinner
|
||||||
width={size == 'lg' ? 20 : size == 'md' ? 18 : size == 'sm' ? 16 : 16}
|
width={size == 'lg' ? 20 : size == 'md' ? 18 : size == 'sm' ? 16 : 16}
|
||||||
@@ -88,22 +100,24 @@
|
|||||||
<button
|
<button
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
class="{`
|
class="
|
||||||
${buttonColor[color]}
|
{buttonColor[color]}
|
||||||
${buttonSize[size]}
|
{buttonSize[size]}
|
||||||
${buttonRoundness[rounded]}
|
{buttonRoundness[rounded]}
|
||||||
text-sm transition-colors disabled:!opacity-70 disabled:!pointer-events-none
|
text-sm transition-colors disabled:!opacity-70 disabled:!pointer-events-none
|
||||||
disabled:!border disabled:!border-slate-300 disabled:!bg-slate-200
|
disabled:!border disabled:!border-slate-300 disabled:!bg-slate-200
|
||||||
disabled:dark:!border-zinc-700 disabled:dark:!bg-zinc-800 disabled:text-inherit
|
disabled:dark:!border-zinc-700 disabled:dark:!bg-zinc-800 disabled:text-inherit
|
||||||
${$$props.class}
|
{$$props.class}
|
||||||
`} {loading
|
{loading
|
||||||
? color == 'primary'
|
? color == 'primary'
|
||||||
? '!bg-transparent !text-inherit'
|
? '!bg-transparent !text-inherit'
|
||||||
: ''
|
: ''
|
||||||
: ''}"
|
: ''}"
|
||||||
type={submit ? 'submit' : 'button'}
|
type={submit ? 'submit' : 'button'}
|
||||||
>
|
>
|
||||||
<div class="flex flex-row items-center justify-center gap-1.5">
|
<div
|
||||||
|
class="flex flex-row items-center gap-1.5 {buttonAlignment[alignment]}"
|
||||||
|
>
|
||||||
{#if loading}
|
{#if loading}
|
||||||
<Spinner
|
<Spinner
|
||||||
width={size == 'lg' ? 20 : size == 'md' ? 18 : size == 'sm' ? 16 : 16}
|
width={size == 'lg' ? 20 : size == 'md' ? 18 : size == 'sm' ? 16 : 16}
|
||||||
|
|||||||
+41
-10
@@ -7,6 +7,10 @@
|
|||||||
import ToastContainer from '$lib/components/ui/toasts/ToastContainer.svelte'
|
import ToastContainer from '$lib/components/ui/toasts/ToastContainer.svelte'
|
||||||
import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte'
|
import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte'
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
|
import { user } from '$lib/lemmy.js'
|
||||||
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import { Home, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
nProgress.configure({
|
nProgress.configure({
|
||||||
minimum: 0.4,
|
minimum: 0.4,
|
||||||
@@ -30,13 +34,40 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Navbar />
|
<div class="flex flex-col">
|
||||||
<ToastContainer />
|
<Navbar />
|
||||||
<Moderation />
|
<ToastContainer />
|
||||||
<main
|
<Moderation />
|
||||||
class="flex-1 p-4 w-full mx-auto"
|
<div
|
||||||
class:max-w-full={$userSettings.fullWidthLayout}
|
class="flex flex-row w-full max-w-full gap-4 divide-x dark:divide-zinc-800 divide-slate-200 flex-1"
|
||||||
class:max-w-5xl={!$userSettings.fullWidthLayout}
|
>
|
||||||
>
|
<nav
|
||||||
<slot />
|
class="hidden lg:flex flex-col p-4 overflow-auto sticky top-16 bottom-0 flex-1 gap-1 max-h-[calc(100vh-4rem)]"
|
||||||
</main>
|
>
|
||||||
|
<Button href="/" color="tertiary" alignment="left">
|
||||||
|
<Icon src={Home} solid size="20" />
|
||||||
|
Frontpage
|
||||||
|
</Button>
|
||||||
|
{#if $user}
|
||||||
|
{#each $user.follows.map((f) => f.community) as follow}
|
||||||
|
<Button
|
||||||
|
color="tertiary"
|
||||||
|
alignment="left"
|
||||||
|
href="/c/{follow.name}@{new URL(follow.actor_id).hostname}"
|
||||||
|
>
|
||||||
|
<Avatar
|
||||||
|
url={follow.icon}
|
||||||
|
alt={follow.name}
|
||||||
|
width={20}
|
||||||
|
slot="icon"
|
||||||
|
/>
|
||||||
|
{follow.title}
|
||||||
|
</Button>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</nav>
|
||||||
|
<main class="p-4 mx-auto flex-[4]">
|
||||||
|
<slot />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in new issue
Block a user