Fork of atp.tools as a universal profile for people on the ATmosphere
at main 41 lines 1.4 kB view raw
1import { JSX } from "preact/jsx-runtime"; 2import AppBskyFeedPostView from "./appBsky/feedPost"; 3import { 4 ComAtprotoRepoDescribeRepo, 5 ComAtprotoRepoGetRecord, 6} from "@atcute/client/lexicons"; 7import { AppBskyFeedRepostView } from "./appBsky/feedRepost"; 8import { AppBskyFeedLikeView } from "./appBsky/feedLike"; 9import { AppBskyActorProfileView } from "./appBsky/actorProfile"; 10import CommunityLexiconCalendarEventView from "./CommunityLexicon/calendarEvent"; 11import EventsSmokesignalCalendarEventView from "./eventsSmokesignal/calendarEvent"; 12 13export type CollectionViewComponent<T = {}> = ( 14 props: React.HTMLAttributes<HTMLDivElement> & T, 15) => JSX.Element; 16 17export interface CollectionViewProps 18 extends React.HTMLAttributes<HTMLDivElement> { 19 data: ComAtprotoRepoGetRecord.Output; 20 repoData?: ComAtprotoRepoDescribeRepo.Output; 21} 22 23const viewMap: Record< 24 string, 25 CollectionViewComponent<CollectionViewProps> | undefined 26> = { 27 "app.bsky.feed.post": AppBskyFeedPostView, 28 "app.bsky.feed.repost": AppBskyFeedRepostView, 29 "app.bsky.feed.like": AppBskyFeedLikeView, 30 "app.bsky.actor.profile": AppBskyActorProfileView, 31 "community.lexicon.calendar.event": CommunityLexiconCalendarEventView, 32 "events.smokesignal.calendar.event": EventsSmokesignalCalendarEventView, 33}; 34 35const getView = ( 36 type: string, 37): CollectionViewComponent<CollectionViewProps> | null => { 38 return viewMap[type] || null; 39}; 40 41export default getView;