diff --git a/lemmy-translations b/lemmy-translations index b4c63029..62c84180 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit b4c63029e598c022a04fc21acb45855645bd6794 +Subproject commit 62c8418021bc39543c87b4ae3dcf2419d13f61e0 diff --git a/src/shared/components/common/loading-skeleton.tsx b/src/shared/components/common/loading-skeleton.tsx new file mode 100644 index 00000000..ab146b8a --- /dev/null +++ b/src/shared/components/common/loading-skeleton.tsx @@ -0,0 +1,118 @@ +import { Component } from "inferno"; + +interface LoadingSkeletonProps { + itemCount?: number; +} + +interface LoadingSkeletonLineProps { + size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; +} + +class LoadingSkeletonLine extends Component { + render() { + const className = "placeholder placeholder-lg col-" + this.props.size; + return ( +

+ +

+ ); + } +} + +export class PostsLoadingSkeleton extends Component { + render() { + return Array.from({ length: this.props.itemCount ?? 10 }, (_, index) => ( + + )); + } +} + +class PostThumbnailLoadingSkeleton extends Component { + render() { + return ( +
+ +
+ ); + } +} + +class PostsLoadingSkeletonItem extends Component { + render() { + return ( +
+
+
+
+ +
+
+ + + +
+
+
+
+ ); + } +} + +export class TrendingCommunitiesLoadingSkeleton extends Component< + LoadingSkeletonProps, + any +> { + render() { + return ( +
+ {Array.from({ length: this.props.itemCount ?? 10 }, (_, index) => ( + + ))} +
+ ); + } +} + +class TrendingCommunitiesLoadingSkeletonItem extends Component { + render() { + return ( +
+
+
+
+ +
+
+
+ +
+
+
+ ); + } +} + +export class CommentsLoadingSkeleton extends Component { + render() { + return Array.from({ length: this.props.itemCount ?? 10 }, (_, index) => ( + + )); + } +} + +class CommentsLoadingSkeletonItem extends Component { + render() { + return ( +
+
+
+ + + + +
+
+
+ ); + } +} diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index 195de1fe..8f9c8764 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -100,6 +100,10 @@ import { PostListings } from "../post/post-listings"; import { CommunityLink } from "./community-link"; import { PaginatorCursor } from "../common/paginator-cursor"; import { getHttpBaseInternal } from "../../utils/env"; +import { + CommentsLoadingSkeleton, + PostsLoadingSkeleton, +} from "../common/loading-skeleton"; import { Sidebar } from "./sidebar"; import { IRoutePropsWithFetch } from "../../routes"; @@ -435,11 +439,7 @@ export class Community extends Component { if (dataType === DataType.Post) { switch (this.state.postsRes.state) { case "loading": - return ( -
- -
- ); + return ; case "success": return ( { } else { switch (this.state.commentsRes.state) { case "loading": - return ( -
- -
- ); + return ; case "success": return ( { trendingCommunities() { switch (this.state.trendingCommunitiesRes?.state) { case "loading": - return ( -
- -
- ); + return ; case "success": { const trending = this.state.trendingCommunitiesRes.data.communities; return ( @@ -704,11 +705,7 @@ export class Home extends Component { case "empty": return
; case "loading": - return ( -
- -
- ); + return ; case "success": { const posts = this.state.postsRes.data.posts; return ( @@ -744,11 +741,7 @@ export class Home extends Component { } else { switch (this.state.commentsRes.state) { case "loading": - return ( -
- -
- ); + return ; case "success": { const comments = this.state.commentsRes.data.comments; return ( diff --git a/src/shared/components/person/inbox.tsx b/src/shared/components/person/inbox.tsx index 26b8a7e0..239e3340 100644 --- a/src/shared/components/person/inbox.tsx +++ b/src/shared/components/person/inbox.tsx @@ -80,6 +80,7 @@ import { Icon, Spinner } from "../common/icon"; import { Paginator } from "../common/paginator"; import { PrivateMessage } from "../private_message/private-message"; import { getHttpBaseInternal } from "../../utils/env"; +import { CommentsLoadingSkeleton } from "../common/loading-skeleton"; import { RouteComponentProps } from "inferno-router/dist/Route"; import { IRoutePropsWithFetch } from "../../routes"; @@ -583,11 +584,7 @@ export class Inbox extends Component { this.state.mentionsRes.state === "loading" || this.state.messagesRes.state === "loading" ) { - return ( -

- -

- ); + return ; } else { return (
{this.buildCombined().map(r => this.renderReplyType(r))}
@@ -598,11 +595,7 @@ export class Inbox extends Component { replies() { switch (this.state.repliesRes.state) { case "loading": - return ( -

- -

- ); + return ; case "success": { const replies = this.state.repliesRes.data.replies; return ( @@ -645,11 +638,7 @@ export class Inbox extends Component { mentions() { switch (this.state.mentionsRes.state) { case "loading": - return ( -

- -

- ); + return ; case "success": { const mentions = this.state.mentionsRes.data.mentions; return ( @@ -695,11 +684,7 @@ export class Inbox extends Component { messages() { switch (this.state.messagesRes.state) { case "loading": - return ( -

- -

- ); + return ; case "success": { const messages = this.state.messagesRes.data.private_messages; return (