feat: add svelte workspace feature panels
This commit is contained in:
41
apps/web/src/features/inbox/SuggestionList.svelte
Normal file
41
apps/web/src/features/inbox/SuggestionList.svelte
Normal file
@@ -0,0 +1,41 @@
|
||||
<script lang="ts">
|
||||
export type Suggestion = {
|
||||
kind: 'task' | 'note' | 'source';
|
||||
title: string;
|
||||
body: string;
|
||||
};
|
||||
|
||||
export let suggestions: Suggestion[] = [];
|
||||
export let onConfirm: (selected: Suggestion[]) => void;
|
||||
|
||||
let selectedIndexes: number[] = [];
|
||||
|
||||
function toggle(index: number) {
|
||||
selectedIndexes = selectedIndexes.includes(index)
|
||||
? selectedIndexes.filter((item) => item !== index)
|
||||
: [...selectedIndexes, index];
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
onConfirm(selectedIndexes.map((index) => suggestions[index]));
|
||||
}
|
||||
</script>
|
||||
|
||||
<section aria-label="AI 整理建议" class="suggestions">
|
||||
{#each suggestions as suggestion, index}
|
||||
<label class="suggestion">
|
||||
<input
|
||||
aria-label={`选择 ${suggestion.title}`}
|
||||
type="checkbox"
|
||||
checked={selectedIndexes.includes(index)}
|
||||
on:change={() => toggle(index)}
|
||||
/>
|
||||
<span class="suggestion-body">
|
||||
<strong>{suggestion.title}</strong>
|
||||
<small>{suggestion.kind}</small>
|
||||
<span>{suggestion.body}</span>
|
||||
</span>
|
||||
</label>
|
||||
{/each}
|
||||
<button type="button" on:click={confirm}>创建选中项</button>
|
||||
</section>
|
||||
Reference in New Issue
Block a user