diff --git a/src/app/space/components/userProfile.tsx b/src/shared/widgets/nostrBandUserProfile.tsx
similarity index 98%
rename from src/app/space/components/userProfile.tsx
rename to src/shared/widgets/nostrBandUserProfile.tsx
index 739403dd..2c36a4f5 100644
--- a/src/app/space/components/userProfile.tsx
+++ b/src/shared/widgets/nostrBandUserProfile.tsx
@@ -15,7 +15,7 @@ export interface Profile {
profile: { content: string };
}
-export function UserProfile({ data }: { data: Profile }) {
+export function NostrBandUserProfile({ data }: { data: Profile }) {
const { db } = useStorage();
const { addContact, removeContact } = useNostr();
const { status, data: userStats } = useQuery(
diff --git a/src/app/space/components/forms/feed.tsx b/src/shared/widgets/tmp/feeds.tsx
similarity index 97%
rename from src/app/space/components/forms/feed.tsx
rename to src/shared/widgets/tmp/feeds.tsx
index d89d473b..c3b756a0 100644
--- a/src/app/space/components/forms/feed.tsx
+++ b/src/shared/widgets/tmp/feeds.tsx
@@ -10,7 +10,7 @@ import { WidgetKinds, useWidgets } from '@stores/widgets';
import { Widget } from '@utils/types';
-export function FeedWidgetForm({ params }: { params: Widget }) {
+export function XfeedsWidget({ params }: { params: Widget }) {
const { db } = useStorage();
const [setWidget, removeWidget] = useWidgets((state) => [
@@ -34,7 +34,7 @@ export function FeedWidgetForm({ params }: { params: Widget }) {
const submit = async () => {
setWidget(db, {
- kind: WidgetKinds.feed,
+ kind: WidgetKinds.local.feeds,
title: title || 'Group',
content: JSON.stringify(groups),
});
diff --git a/src/app/space/components/forms/hashtag.tsx b/src/shared/widgets/tmp/hashtag.tsx
similarity index 96%
rename from src/app/space/components/forms/hashtag.tsx
rename to src/shared/widgets/tmp/hashtag.tsx
index 1c4cd271..76393c4c 100644
--- a/src/app/space/components/forms/hashtag.tsx
+++ b/src/shared/widgets/tmp/hashtag.tsx
@@ -26,7 +26,7 @@ const resolver: Resolver = async (values) => {
};
};
-export function HashTagWidgetForm({ params }: { params: Widget }) {
+export function XhashtagWidget({ params }: { params: Widget }) {
const [setWidget, removeWidget] = useWidgets((state) => [
state.setWidget,
state.removeWidget,
@@ -47,7 +47,7 @@ export function HashTagWidgetForm({ params }: { params: Widget }) {
const onSubmit = async (data: FormValues) => {
try {
setWidget(db, {
- kind: WidgetKinds.hashtag,
+ kind: WidgetKinds.global.hashtag,
title: data.hashtag + ' in 24 hours ago',
content: data.hashtag.replace('#', ''),
});
diff --git a/src/stores/widgets.ts b/src/stores/widgets.ts
index 74b29b38..214e245c 100644
--- a/src/stores/widgets.ts
+++ b/src/stores/widgets.ts
@@ -13,19 +13,81 @@ interface WidgetState {
}
export const WidgetKinds = {
- feed: 1, // NIP-01
- thread: 2, // NIP-01
- hashtag: 3, // NIP-01
- article: 4, // NIP-23
- user: 5, // NIP-01
- trendingProfiles: 6,
- trendingNotes: 7,
- file: 8, // NIP-94
- network: 9999,
- xfeed: 10000, // x is temporary state for new feed widget form
- xhashtag: 10001, // x is temporary state for new hashtag widget form
+ local: {
+ network: 100,
+ feeds: 101,
+ files: 102,
+ articles: 103,
+ user: 104,
+ thread: 105,
+ },
+ global: {
+ feeds: 1000,
+ files: 1001,
+ articles: 1002,
+ hashtag: 1003,
+ },
+ nostrBand: {
+ trendingAccounts: 1,
+ trendingNotes: 2,
+ },
+ tmp: {
+ list: 10000,
+ xfeed: 10001,
+ xhashtag: 10002,
+ },
};
+export const DefaultWidgets = [
+ {
+ title: 'Network / Follows',
+ data: [
+ {
+ kind: WidgetKinds.tmp.xfeed,
+ title: 'Group feeds',
+ },
+ {
+ kind: WidgetKinds.local.files,
+ title: 'Files',
+ },
+ {
+ kind: WidgetKinds.local.articles,
+ title: 'Articles',
+ },
+ ],
+ },
+ {
+ title: 'Global',
+ data: [
+ {
+ kind: WidgetKinds.tmp.xhashtag,
+ title: 'Hashtag',
+ },
+ {
+ kind: WidgetKinds.global.files,
+ title: 'Files',
+ },
+ {
+ kind: WidgetKinds.global.articles,
+ title: 'Articles',
+ },
+ ],
+ },
+ {
+ title: 'Trending (nostr.band)',
+ data: [
+ {
+ kind: WidgetKinds.nostrBand.trendingAccounts,
+ title: 'Accounts',
+ },
+ {
+ kind: WidgetKinds.nostrBand.trendingNotes,
+ title: 'Notes',
+ },
+ ],
+ },
+];
+
export const useWidgets = create()(
persist(
(set) => ({
@@ -39,7 +101,7 @@ export const useWidgets = create()(
id: '9999',
title: 'Network',
content: '',
- kind: WidgetKinds.network,
+ kind: WidgetKinds.local.network,
});
set({ widgets: dbWidgets });
diff --git a/src/utils/types.d.ts b/src/utils/types.d.ts
index 91d9f7ff..b9e1b66b 100644
--- a/src/utils/types.d.ts
+++ b/src/utils/types.d.ts
@@ -36,6 +36,16 @@ export interface Profile extends NDKUserProfile {
pubkey?: string;
}
+export interface WidgetGroup {
+ title: string;
+ data: WidgetGroupItem[];
+}
+
+export interface WidgetGroupItem {
+ title: string;
+ kind: number;
+}
+
export interface Widget {
id?: string;
account_id?: number;