feat: switch from card to material

This commit is contained in:
Xyphyn committed 2023-09-04 11:27:19 -07:00
1 parent 43b0e87ebf
commit c53ec52d86
16 files changed
+61 -126

No files matched your search

@@ -1,15 +1,14 @@
<script lang="ts">
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import Card from '$lib/components/ui/Card.svelte'
import { getInstance } from '$lib/lemmy.js'
import type { CommentView } from 'lemmy-js-client'
import { Button } from 'mono-svelte'
import { Button, Material } from 'mono-svelte'
export let comment: CommentView
</script>
<Card class="flex flex-col bg-white rounded-md p-5 flex-1 gap-1">
<Material class="flex flex-col flex-1 gap-1" color="distinct" padding="lg">
<div class="flex flex-row justify-between items-center">
<PostMeta
community={comment.community}
@@ -42,4 +41,4 @@
replying={false}
/>
</div>
</Card>
</Material>
@@ -3,7 +3,6 @@
import { amMod } from '$lib/components/lemmy/moderation/moderation.js'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import Card from '$lib/components/ui/Card.svelte'
import StickyCard from '$lib/components/ui/StickyCard.svelte'
import { toast } from 'mono-svelte'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
+6 -13
View File
@@ -1,13 +1,12 @@
<script lang="ts">
import type { PostView } from 'lemmy-js-client'
import { isImage } from '$lib/ui/image.js'
import Card from '$lib/components/ui/Card.svelte'
import { getInstance } from '$lib/lemmy.js'
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
import { userSettings } from '$lib/settings.js'
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import { toast } from 'mono-svelte'
import { Material, toast } from 'mono-svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
export let post: PostView
@@ -18,7 +17,9 @@
let loaded = false
</script>
<Card
<Material
color="distinct"
padding="none"
class="flex flex-col max-w-full min-w-0 w-full gap-2.5 {compact
? '!bg-transparent !border-0 py-5'
: 'p-5'}"
@@ -42,7 +43,7 @@
/>
<a
href="/post/{getInstance()}/{post.post.id}"
class="font-medium max-w-full w-full break-words"
class="font-medium max-w-full w-full break-words text-base"
style="word-break: break-word;"
class:text-slate-500={post.read && $userSettings.markReadPosts}
class:dark:text-zinc-400={post.read && $userSettings.markReadPosts}
@@ -51,14 +52,6 @@
</a>
</div>
{#if !$userSettings.showCompactPosts}
{#if post.post.url && !post.post.thumbnail_url}
<a
href={post.post.url}
class="max-w-full overflow-hidden overflow-ellipsis whitespace-nowrap text-sky-400 hover:underline text-xs"
>
{post.post.url}
</a>
{/if}
{#if isImage(post.post.url)}
<!--disabled preloads here since most people will hover over every image while scrolling-->
<a
@@ -153,4 +146,4 @@
/>
</div>
{/if}
</Card>
</Material>
-24
View File
@@ -1,24 +0,0 @@
<script lang="ts">
export let label: string = ''
const badgeColor = {
red: 'bg-red-200 dark:bg-red-900 text-red-800 dark:text-red-300',
green: 'bg-green-200 dark:bg-green-900 text-green-800 dark:text-green-300',
yellow:
'bg-yellow-200 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-300',
gray: 'bg-slate-200 dark:bg-zinc-800 text-gray-800 dark:text-gray-200',
}
type BadgeColor = keyof typeof badgeColor
export let color: BadgeColor = 'gray'
</script>
<span
class="px-2 py-0.5 rounded-full text-xs ml-auto font-bold flex items-center gap-1 {badgeColor[
color
]} {$$props.class}"
title={label}
>
<slot />
</span>
-28
View File
@@ -1,28 +0,0 @@
<script lang="ts">
type CardColor = 'default' | 'warning' | 'error'
export let cardColor: CardColor = 'default'
export let elevation: 0 | 1 = 1
const getColor = (color: CardColor) => {
switch (color) {
case 'default':
return elevation == 0
? 'border border-slate-200 dark:border-zinc-900 bg-slate-100 dark:bg-zinc-950'
: 'border border-slate-200 dark:border-zinc-800 bg-white dark:bg-zinc-900'
case 'warning':
return 'border border-yellow-300 dark:bg-yellow-950/30 dark:border-yellow-900 bg-yellow-50'
}
}
let clazz = ''
export { clazz as class }
</script>
<div
class="break-words
{getColor(cardColor)} rounded-lg {clazz}"
{...$$restProps}
>
<slot />
</div>