your personal website on atproto - mirror
blento.app
1import type { Component } from 'svelte';
2import type { Item, UserCache } from '$lib/types';
3import type { Did } from '@atcute/lexicons';
4
5export type CreationModalComponentProps = {
6 item: Item;
7 oncreate: () => void;
8 oncancel: () => void;
9};
10
11export type SettingsComponentProps = {
12 item: Item;
13 onclose: () => void;
14};
15
16export type SidebarComponentProps = {
17 onclick: () => void;
18};
19
20export type ContentComponentProps = {
21 item: Item;
22 isEditing?: boolean;
23};
24
25export type CardDefinition = {
26 type: string; // should be unique
27 contentComponent: Component<ContentComponentProps>; // content of card
28 editingContentComponent?: Component<ContentComponentProps>; // optional content of card in editing mode
29
30 createNew?: (item: Item) => void; // set some custom cardData stuff here (or custom default sizes)
31
32 creationModalComponent?: Component<CreationModalComponentProps>;
33
34 upload?: (item: Item) => Promise<Item>; // optionally upload some other data needed for this card
35
36 // one of those two has to be set for a card to appear in the sidebar
37 sidebarComponent?: Component<SidebarComponentProps>;
38 sidebarButtonText?: string;
39
40 // if this component exists, a settings button with a popover will be shown containing this component
41 settingsComponent?: Component<SettingsComponentProps>;
42
43 // optionally load some extra data
44 loadData?: (
45 // all cards of that type
46 items: Item[],
47 { did, handle, cache }: { did: Did; handle: string; cache?: UserCache }
48 ) => Promise<unknown>;
49
50 // show color selection popup
51 allowSetColor?: boolean;
52
53 // default card background color one of 'base', 'accent', 'transparent', or one of the tailwind colors
54 // (actual colors only, without 'gray', 'neutral', 'stone', etc)
55 defaultColor?: string;
56
57 // for resizing:
58 minW?: number;
59 maxW?: number;
60
61 minH?: number;
62 maxH?: number;
63
64 canResize?: boolean;
65
66 onUrlHandler?: (url: string, item: Item) => Item | null;
67 urlHandlerPriority?: number;
68
69 canChange?: (item: Item) => boolean;
70 change?: (item: Item) => Item;
71
72 name?: string;
73
74 canHaveLabel?: boolean;
75
76 migrate?: (item: Item) => void;
77};