From 9d7ebe3ee789e83d02e8fb6ca8a36188c13e4816 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 16 Dec 2024 15:26:12 -0600 Subject: [PATCH] Some skeleton UI --- src/components/TrendingTopics.tsx | 24 +++++++++++++++++++ .../shell/desktop/SidebarTrendingTopics.tsx | 15 +++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/components/TrendingTopics.tsx b/src/components/TrendingTopics.tsx index f20e1f5268..e765f03ea4 100644 --- a/src/components/TrendingTopics.tsx +++ b/src/components/TrendingTopics.tsx @@ -103,6 +103,30 @@ export function TrendingTopic({ ) } +export function TrendingTopicSkeleton({size}: {size: 'large' | 'small'}) { + const t = useTheme() + const isSmall = size === 'small' + return ( + + ) +} + export function TrendingTopicLink({ topic: raw, children, diff --git a/src/view/shell/desktop/SidebarTrendingTopics.tsx b/src/view/shell/desktop/SidebarTrendingTopics.tsx index c62d0c8898..28f47d9810 100644 --- a/src/view/shell/desktop/SidebarTrendingTopics.tsx +++ b/src/view/shell/desktop/SidebarTrendingTopics.tsx @@ -13,7 +13,11 @@ import {Divider} from '#/components/Divider' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending2' import * as Prompt from '#/components/Prompt' -import {TrendingTopic, TrendingTopicLink} from '#/components/TrendingTopics' +import { + TrendingTopic, + TrendingTopicLink, + TrendingTopicSkeleton, +} from '#/components/TrendingTopics' import {Text} from '#/components/Typography' export function SidebarTrendingTopics() { @@ -28,8 +32,9 @@ function Inner() { const {setTrendingSidebarHidden} = useTrendingSettingsApi() const {data: topics, error, isLoading} = useTrendingTopics() + const noTopics = !isLoading && !error && !topics - return ( + return error || noTopics ? null : ( <> @@ -55,7 +60,11 @@ function Inner() { - {isLoading ? null : error || !topics ? null : ( + {isLoading ? ( + Array(8) + .fill(0) + .map((_, i) => ) + ) : error || !topics ? null : ( <> {topics.map(topic => (