From cb9006abb230561839c92322ba997e3697e84f2b Mon Sep 17 00:00:00 2001 From: reya Date: Thu, 9 Nov 2023 09:12:42 +0700 Subject: [PATCH] add topic widget --- src/app/auth/onboarding/hashtag.tsx | 4 +- src/app/space/components/toggle.tsx | 4 +- src/app/space/components/widgetList.tsx | 81 +++---- src/app/space/index.tsx | 36 +-- src/shared/notes/actions.tsx | 4 +- src/shared/notes/mentions/hashtag.tsx | 4 +- src/shared/notes/mentions/note.tsx | 4 +- src/shared/notes/mentions/user.tsx | 6 +- src/shared/notes/notify.tsx | 4 +- src/shared/notes/text.tsx | 4 +- src/shared/widgets/index.ts | 1 + src/shared/widgets/tmp/feeds.tsx | 4 +- src/shared/widgets/tmp/hashtag.tsx | 4 +- src/shared/widgets/topic.tsx | 128 ++++++++++ src/stores/constants.ts | 296 ++++++++++++++++++++++-- src/utils/types.d.ts | 1 + 16 files changed, 489 insertions(+), 96 deletions(-) create mode 100644 src/shared/widgets/topic.tsx diff --git a/src/app/auth/onboarding/hashtag.tsx b/src/app/auth/onboarding/hashtag.tsx index 8965c983..92b4fd57 100644 --- a/src/app/auth/onboarding/hashtag.tsx +++ b/src/app/auth/onboarding/hashtag.tsx @@ -6,7 +6,7 @@ import { useStorage } from '@libs/storage/provider'; import { ArrowLeftIcon, CheckCircleIcon, LoaderIcon } from '@shared/icons'; -import { HASHTAGS, WidgetKinds } from '@stores/constants'; +import { HASHTAGS, WIDGET_KIND } from '@stores/constants'; import { useOnboarding } from '@stores/onboarding'; export function OnboardHashtagScreen() { @@ -35,7 +35,7 @@ export function OnboardHashtagScreen() { setLoading(true); for (const tag of tags) { - await db.createWidget(WidgetKinds.global.hashtag, tag, tag.replace('#', '')); + await db.createWidget(WIDGET_KIND.global.hashtag, tag, tag.replace('#', '')); } setHashtag(); diff --git a/src/app/space/components/toggle.tsx b/src/app/space/components/toggle.tsx index 9fe73b43..b7657939 100644 --- a/src/app/space/components/toggle.tsx +++ b/src/app/space/components/toggle.tsx @@ -1,7 +1,7 @@ import { PlusIcon } from '@shared/icons'; import { WidgetWrapper } from '@shared/widgets'; -import { WidgetKinds } from '@stores/constants'; +import { WIDGET_KIND } from '@stores/constants'; import { useWidget } from '@utils/hooks/useWidget'; @@ -14,7 +14,7 @@ export function ToggleWidgetList() { + ) : null} + + + + ); +} diff --git a/src/stores/constants.ts b/src/stores/constants.ts index 8b844365..d574a7fa 100644 --- a/src/stores/constants.ts +++ b/src/stores/constants.ts @@ -41,7 +41,7 @@ export const HASHTAGS = [ { hashtag: '#primal' }, ]; -export const WidgetKinds = { +export const WIDGET_KIND = { local: { network: 100, feeds: 101, @@ -57,6 +57,7 @@ export const WidgetKinds = { files: 1001, articles: 1002, hashtag: 1003, + topic: 108, }, nostrBand: { trendingAccounts: 1, @@ -72,24 +73,293 @@ export const WidgetKinds = { }, }; -export const DefaultWidgets: Array = [ +export const TOPICS = [ + { + title: 'Gaming', + description: '', + kind: WIDGET_KIND.global.topic, + content: [ + '#gamestr', + '#gaming', + '#gamer', + '#ps', + '#playstation', + '#videogames', + '#game', + '#xbox', + '#games', + '#twitch', + '#fortnite', + '#pc', + '#memes', + '#pcgaming', + '#gamers', + '#gamingcommunity', + '#youtube', + '#switch', + '#gamergirl', + '#nintendo', + '#gta', + '#callofduty', + '#streamer', + '#follow', + '#pubg', + '#videogame', + '#esports', + '#bhfyp', + '#meme', + '#twitchstreamer', + '#art', + '#genshinimpact', + '#honkaiimpact', + '#warthunder', + '#hovoverse', + '#arknights', + '#soul', + '#eldenring', + '#steam', + '#pubg', + '#cs2', + '#apexlegends', + '#baldurgate3', + '#starfield', + '#gta6', + '#gameoftheyear', + ], + }, + { + title: 'Music', + description: '', + kind: WIDGET_KIND.global.topic, + content: [ + '#audiostr', + '#musicstr', + '#music', + '#love', + '#hiphop', + '#rap', + '#art', + '#musician', + '#artist', + '#musica', + '#instagood', + '#singer', + '#dj', + '#follow', + '#rock', + '#like', + '#dance', + '#guitar', + '#s', + '#photography', + '#song', + '#bhfyp', + '#newmusic', + '#producer', + '#life', + '#rapper', + '#party', + '#fashion', + '#explorepage', + '#viral', + '#beats', + ], + }, + { + title: 'Photography', + description: '', + kind: WIDGET_KIND.global.topic, + content: [ + '#photography', + '#photooftheday', + '#love', + '#photo', + '#nature', + '#picoftheday', + '#like', + '#photographer', + '#beautiful', + '#follow', + '#art', + '#fashion', + '#travel', + '#bhfyp', + '#photoshoot', + '#likeforlikes', + '#instadaily', + '#naturephotography', + '#model', + '#me', + '#smile', + '#style', + '#instalike', + '#happy', + '#likes', + '#myself', + '#followme', + '#followforfollowback', + ], + }, + { + title: 'Art', + description: '', + kind: WIDGET_KIND.global.topic, + content: [ + '#artstr', + '#art', + '#artist', + '#love', + '#drawing', + '#photography', + '#artwork', + '#instagood', + '#photooftheday', + '#painting', + '#fashion', + '#like', + '#artistsoninstagram', + '#beautiful', + '#illustration', + '#digitalart', + '#follow', + '#design', + '#nature', + '#picoftheday', + '#photo', + '#bhfyp', + '#sketch', + '#style', + '#arte', + '#happy', + '#cute', + '#draw', + '#artoftheday', + ], + }, + { + title: 'Movie', + description: '', + kind: WIDGET_KIND.global.topic, + content: [ + '#filmstr', + '#moviestr', + '#movies', + '#movie', + '#film', + '#cinema', + '#films', + '#hollywood', + '#actor', + '#love', + '#s', + '#art', + '#cinematography', + '#actress', + '#netflix', + '#moviescenes', + '#music', + '#filmmaking', + '#horror', + '#instagood', + '#bollywood', + '#movienight', + '#photography', + '#comedy', + '#cinephile', + '#cine', + '#tv', + '#director', + '#horrormovies', + '#drama', + '#filmmaker', + ], + }, + { + title: 'Technology', + description: '', + kind: WIDGET_KIND.global.topic, + content: [ + '#apple', + '#xiaomi', + '#huawei', + '#ai', + '#oppo', + '#nostr', + '#technology', + '#tech', + '#innovation', + '#engineering', + '#business', + '#iphone', + '#technews', + '#science', + '#design', + '#gadgets', + '#electronics', + '#android', + '#software', + '#programming', + '#smartphone', + '#bhfyp', + '#samsung', + '#instagood', + '#coding', + '#computer', + '#pro', + '#education', + '#security', + '#gadget', + '#mobile', + '#technologynews', + ], + }, + { + title: 'Anime', + description: '', + kind: WIDGET_KIND.global.topic, + content: [ + '#animestr', + '#anime', + '#manga', + '#ntr', + '#otaku', + '#animeart', + '#animegirl', + '#cosplay', + '#kawaii', + '#weeb', + '#onepiece', + '#demonslayer', + '#animeworld', + '#aot', + '#hentai', + '#fanart', + ], + }, +]; + +export const DEFAULT_WIDGETS: Array = [ + { + title: 'Topics', + data: TOPICS, + }, { title: 'Local', data: [ { - kind: WidgetKinds.tmp.xfeed, + kind: WIDGET_KIND.tmp.xfeed, title: 'Group feeds', description: 'All posts from specific people you want to keep up with', }, { - kind: WidgetKinds.local.files, + kind: WIDGET_KIND.local.files, title: 'Files', - description: 'All files shared by people in your circle', + description: 'All files shared by people you follow', }, { - kind: WidgetKinds.local.articles, + kind: WIDGET_KIND.local.articles, title: 'Articles', - description: 'All articles shared by people in your circle', + description: 'All articles shared by people you follow', }, ], }, @@ -97,17 +367,17 @@ export const DefaultWidgets: Array = [ title: 'Global', data: [ { - kind: WidgetKinds.tmp.xhashtag, + kind: WIDGET_KIND.tmp.xhashtag, title: 'Hashtag', description: 'All posts have a specific hashtag', }, { - kind: WidgetKinds.global.files, + kind: WIDGET_KIND.global.files, title: 'Files', description: 'All files shared by people in your current relay set', }, { - kind: WidgetKinds.global.articles, + kind: WIDGET_KIND.global.articles, title: 'Articles', description: 'All articles shared by people in your current relay set', }, @@ -117,12 +387,12 @@ export const DefaultWidgets: Array = [ title: 'nostr.band', data: [ { - kind: WidgetKinds.nostrBand.trendingAccounts, + kind: WIDGET_KIND.nostrBand.trendingAccounts, title: 'Accounts', description: 'Trending accounts from the last 24 hours', }, { - kind: WidgetKinds.nostrBand.trendingNotes, + kind: WIDGET_KIND.nostrBand.trendingNotes, title: 'Notes', description: 'Trending notes from the last 24 hours', }, @@ -132,7 +402,7 @@ export const DefaultWidgets: Array = [ title: 'Other', data: [ { - kind: WidgetKinds.local.notification, + kind: WIDGET_KIND.local.notification, title: 'Notification', description: 'Everything happens around you', }, diff --git a/src/utils/types.d.ts b/src/utils/types.d.ts index 0c427925..f6315707 100644 --- a/src/utils/types.d.ts +++ b/src/utils/types.d.ts @@ -43,6 +43,7 @@ export interface WidgetGroup { export interface WidgetGroupItem { title: string; description: string; + content: string; kind: number; icon?: string; }