-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resize listview, add metadata component
- Loading branch information
1 parent
197eb48
commit 2e47438
Showing
12 changed files
with
242 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script lang="ts"> | ||
import { cn } from "@kksh/ui/utils" | ||
import type { Snippet } from "svelte" | ||
import type { HTMLAttributes } from "svelte/elements" | ||
import { open } from "tauri-plugin-shellx-api" | ||
const { | ||
href, | ||
class: className = "", | ||
children | ||
}: { | ||
href: string | ||
class?: HTMLAttributes<HTMLAnchorElement>["class"] | ||
children: Snippet | ||
} = $props() | ||
function handleClick() { | ||
open(href) | ||
} | ||
</script> | ||
|
||
<button | ||
class={cn( | ||
"font-medium text-blue-600 hover:cursor-pointer hover:underline dark:text-blue-500", | ||
className | ||
)} | ||
onclick={handleClick} | ||
> | ||
{@render children?.()} | ||
</button> |
7 changes: 7 additions & 0 deletions
7
packages/ui/src/components/extension/templates/Markdown.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script lang="ts"> | ||
import SvelteMarkdown from "svelte-markdown" | ||
const { markdown }: { markdown: string } = $props() | ||
</script> | ||
|
||
<SvelteMarkdown source={markdown} /> |
40 changes: 14 additions & 26 deletions
40
packages/ui/src/components/extension/templates/list-detail.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
<!-- <script setup lang="ts"> | ||
import { | ||
List, | ||
ListSchema, | ||
MarkdownSchema, | ||
NodeNameEnum, | ||
WorkerExtension | ||
} from "@kksh/api/ui/worker" | ||
import Markdown from "./Markdown.vue" | ||
import Metadata from "./Metadata.vue" | ||
<script lang="ts"> | ||
import { ListSchema, MarkdownSchema, NodeNameEnum } from "@kksh/api/ui/worker" | ||
import Markdown from "./Markdown.svelte" | ||
import Metadata from './metadata/Metadata.svelte' | ||
const props = defineProps<{ | ||
detail: ListSchema.ItemDetail | ||
}>() | ||
const { detail }: { detail: ListSchema.ItemDetail } = $props() | ||
</script> | ||
<template> | ||
<div v-for="child in detail.children" class="max-h-full overflow-y-auto"> | ||
<Markdown | ||
v-if="child.nodeName === NodeNameEnum.Markdown" | ||
:markdown="(child as MarkdownSchema).content" | ||
/> | ||
<Metadata | ||
v-if="child.nodeName === NodeNameEnum.ListItemDetailMetadata" | ||
:items="(child as ListSchema.ItemDetailMetadata).items" | ||
/> | ||
</div> | ||
</template> --> | ||
{#each detail.children as child} | ||
{#if child.nodeName === NodeNameEnum.Markdown} | ||
<Markdown markdown={(child as MarkdownSchema).content} /> | ||
{:else if child.nodeName === NodeNameEnum.ListItemDetailMetadata} | ||
<Metadata items={(child as ListSchema.ItemDetailMetadata).items} /> | ||
{:else} | ||
<div>Unhandled Component</div> | ||
{/if} | ||
{/each} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/ui/src/components/extension/templates/metadata/Metadata.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script lang="ts"> | ||
import { | ||
List, | ||
ListSchema, | ||
MarkdownSchema, | ||
NodeNameEnum, | ||
WorkerExtension | ||
} from "@kksh/api/ui/worker" | ||
import { Separator } from "@kksh/svelte5" | ||
import Label from "./label.svelte" | ||
import Link from "./link.svelte" | ||
import Tags from "./tags.svelte" | ||
const { items }: { items: ListSchema.ItemDetailMetadataItem[] } = $props() | ||
</script> | ||
|
||
<div class="px-3"> | ||
{#each items as item} | ||
{#if item.nodeName === NodeNameEnum.ListItemDetailMetadataLabel} | ||
<Label | ||
title={(item as ListSchema.ItemDetailMetadataLabel).title} | ||
text={(item as ListSchema.ItemDetailMetadataLabel).text} | ||
icon={(item as ListSchema.ItemDetailMetadataLabel).icon} | ||
/> | ||
{/if} | ||
{#if item.nodeName === NodeNameEnum.ListItemDetailMetadataSeparator} | ||
<Separator /> | ||
{/if} | ||
{#if item.nodeName === NodeNameEnum.ListItemDetailMetadataLink} | ||
<Link | ||
title={(item as ListSchema.ItemDetailMetadataLink).title} | ||
text={(item as ListSchema.ItemDetailMetadataLink).text} | ||
url={(item as ListSchema.ItemDetailMetadataLink).url} | ||
/> | ||
{/if} | ||
{#if item.nodeName === NodeNameEnum.ListItemDetailMetadataTagList} | ||
<Tags | ||
tags={(item as ListSchema.ItemDetailMetadataTagList).tags} | ||
title={(item as ListSchema.ItemDetailMetadataTagList).title} | ||
/> | ||
{/if} | ||
{/each} | ||
</div> |
32 changes: 32 additions & 0 deletions
32
packages/ui/src/components/extension/templates/metadata/label.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script lang="ts"> | ||
import type { IconType, List, ListSchema } from "@kksh/api/ui/worker" | ||
import { IconMultiplexer } from "../../../common" | ||
const { | ||
title, | ||
text, | ||
icon | ||
}: { | ||
title: string | ||
text?: | ||
| string | ||
| { | ||
text: string | ||
color: string | ||
} | ||
icon?: { | ||
type: IconType | ||
value: string | ||
} | ||
} = $props() | ||
</script> | ||
|
||
<div class="flex justify-between gap-1 py-1"> | ||
<span class="text-muted-foreground text-sm font-semibold">{title}</span> | ||
<span class="flex items-center gap-2"> | ||
{#if icon} | ||
<IconMultiplexer {icon} class="h-4 w-4" /> | ||
{/if} | ||
<span class="text-sm">{text}</span> | ||
</span> | ||
</div> |
22 changes: 22 additions & 0 deletions
22
packages/ui/src/components/extension/templates/metadata/link.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script lang="ts"> | ||
import Icon from "@iconify/svelte" | ||
import TauriLink from "../../../common/TauriLink.svelte" | ||
const { | ||
text, | ||
title, | ||
url | ||
}: { | ||
text: string | ||
title: string | ||
url: string | ||
} = $props() | ||
</script> | ||
|
||
<div class="flex justify-between gap-1 py-1"> | ||
<span class="text-muted-foreground text-sm font-semibold">{title}</span> | ||
<TauriLink href={url} class="flex items-center justify-center gap-1"> | ||
<span class="text-sm">{text}</span> | ||
<Icon icon="gridicons:external" /> | ||
</TauriLink> | ||
</div> |
19 changes: 19 additions & 0 deletions
19
packages/ui/src/components/extension/templates/metadata/tag.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script lang="ts"> | ||
import type { Color, ListSchema } from "@kksh/api/ui/worker" | ||
import { Badge } from "@kksh/svelte5" | ||
const { | ||
text, | ||
color | ||
}: { | ||
text?: string | ||
color?: Color | ||
// icon?: Icon | ||
} = $props() | ||
</script> | ||
|
||
<Badge | ||
style={`style: ${color ? color : "var(--muted-foreground)"}; background-color: ${color ? `${color}30` : "var(--muted)"};`} | ||
> | ||
{text} | ||
</Badge> |
21 changes: 21 additions & 0 deletions
21
packages/ui/src/components/extension/templates/metadata/tags.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script lang="ts"> | ||
import type { Color, ListSchema } from "@kksh/api/ui/worker" | ||
import Tag from "./tag.svelte" | ||
const { | ||
tags, | ||
title | ||
}: { | ||
tags: Array<{ text?: string; color?: Color }> | ||
title: string | ||
} = $props() | ||
</script> | ||
|
||
<div class="flex justify-between gap-1 py-1"> | ||
<span class="text-muted-foreground text-sm font-semibold">{title}</span> | ||
<span class="flex gap-1"> | ||
{#each tags as tag} | ||
<Tag text={tag.text} color={tag.color} /> | ||
{/each} | ||
</span> | ||
</div> |
Oops, something went wrong.