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 ButtonSize = keyof typeof buttonSize
|
||||
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 = {
|
||||
primary: `border border-slate-900 bg-slate-900 dark:bg-zinc-100
|
||||
@@ -51,6 +58,7 @@
|
||||
export let color: ButtonColor = 'secondary'
|
||||
export let size: ButtonSize = 'md'
|
||||
export let rounded: ButtonRoundness = 'md'
|
||||
export let alignment: ButtonAlignment = 'center'
|
||||
|
||||
// const dispatch = createEventDispatcher()
|
||||
export let href: string | undefined = undefined
|
||||
@@ -60,20 +68,24 @@
|
||||
<a
|
||||
{href}
|
||||
{...$$restProps}
|
||||
class="{`
|
||||
${buttonColor[color]}
|
||||
${buttonSize[size]}
|
||||
${buttonRoundness[rounded]}
|
||||
class="
|
||||
{buttonColor[color]}
|
||||
{buttonSize[size]}
|
||||
{buttonRoundness[rounded]}
|
||||
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
|
||||
${$$props.class}
|
||||
`} {loading
|
||||
{$$props.class}
|
||||
{loading
|
||||
? color == 'primary'
|
||||
? '!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}
|
||||
<Spinner
|
||||
width={size == 'lg' ? 20 : size == 'md' ? 18 : size == 'sm' ? 16 : 16}
|
||||
@@ -88,22 +100,24 @@
|
||||
<button
|
||||
{...$$restProps}
|
||||
on:click
|
||||
class="{`
|
||||
${buttonColor[color]}
|
||||
${buttonSize[size]}
|
||||
${buttonRoundness[rounded]}
|
||||
class="
|
||||
{buttonColor[color]}
|
||||
{buttonSize[size]}
|
||||
{buttonRoundness[rounded]}
|
||||
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:text-inherit
|
||||
${$$props.class}
|
||||
`} {loading
|
||||
{$$props.class}
|
||||
{loading
|
||||
? color == 'primary'
|
||||
? '!bg-transparent !text-inherit'
|
||||
: ''
|
||||
: ''}"
|
||||
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}
|
||||
<Spinner
|
||||
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 Moderation from '$lib/components/lemmy/moderation/Moderation.svelte'
|
||||
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({
|
||||
minimum: 0.4,
|
||||
@@ -30,13 +34,40 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Navbar />
|
||||
<ToastContainer />
|
||||
<Moderation />
|
||||
<main
|
||||
class="flex-1 p-4 w-full mx-auto"
|
||||
class:max-w-full={$userSettings.fullWidthLayout}
|
||||
class:max-w-5xl={!$userSettings.fullWidthLayout}
|
||||
>
|
||||
<slot />
|
||||
</main>
|
||||
<div class="flex flex-col">
|
||||
<Navbar />
|
||||
<ToastContainer />
|
||||
<Moderation />
|
||||
<div
|
||||
class="flex flex-row w-full max-w-full gap-4 divide-x dark:divide-zinc-800 divide-slate-200 flex-1"
|
||||
>
|
||||
<nav
|
||||
class="hidden lg:flex flex-col p-4 overflow-auto sticky top-16 bottom-0 flex-1 gap-1 max-h-[calc(100vh-4rem)]"
|
||||
>
|
||||
<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