From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Wed, 28 Jun 2023 04:12:10 +0000 (-0400) Subject: Merge branch 'main' into feat/pureblack-theme X-Git-Url: http://these/git/?a=commitdiff_plain;h=0ef2e8969c59af3cf416b37d78b500a8ac44730b;hp=93e015393cfb1371559c045cbaf67af53390c3dc;p=lemmy-ui.git Merge branch 'main' into feat/pureblack-theme --- diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index 4ad1538..8f689aa 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -1,6 +1,7 @@ import { colorList, getCommentParentId, + getRoleLabelPill, myAuth, myAuthRequired, showScores, @@ -308,32 +309,43 @@ export class CommentNode extends Component { classes="icon-inline" /> + + {cv.comment.distinguished && ( )} - {this.isPostCreator && ( -
- {I18NextService.i18n.t("creator")} -
- )} - {isMod_ && ( -
- {I18NextService.i18n.t("mod")} -
- )} - {isAdmin_ && ( -
- {I18NextService.i18n.t("admin")} -
- )} - {cv.creator.bot_account && ( -
- {I18NextService.i18n.t("bot_account").toLowerCase()} -
- )} + + {this.isPostCreator && + getRoleLabelPill({ + label: I18NextService.i18n.t("op").toUpperCase(), + tooltip: I18NextService.i18n.t("creator"), + classes: "text-bg-info", + shrink: false, + })} + + {isMod_ && + getRoleLabelPill({ + label: I18NextService.i18n.t("mod"), + tooltip: I18NextService.i18n.t("mod"), + classes: "text-bg-primary", + })} + + {isAdmin_ && + getRoleLabelPill({ + label: I18NextService.i18n.t("admin"), + tooltip: I18NextService.i18n.t("admin"), + classes: "text-bg-danger", + })} + + {cv.creator.bot_account && + getRoleLabelPill({ + label: I18NextService.i18n.t("bot_account").toLowerCase(), + tooltip: I18NextService.i18n.t("bot_account"), + })} + {this.props.showCommunity && ( <> {I18NextService.i18n.t("to")} @@ -344,7 +356,9 @@ export class CommentNode extends Component { )} - {this.linkBtn(true)} + + {this.getLinkButton(true)} + {cv.comment.language_id !== 0 && ( { @@ -410,7 +424,7 @@ export class CommentNode extends Component { /> )}
- {this.props.showContext && this.linkBtn()} + {this.props.showContext && this.getLinkButton()} {this.props.markable && ( diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index 733c19a..d5cf2cb 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -260,20 +260,18 @@ export class Sidebar extends Component { subscribe() { const community_view = this.props.community_view; return ( - <> - {community_view.subscribed == "NotSubscribed" && ( - - )} - + community_view.subscribed === "NotSubscribed" && ( + + ) ); } @@ -281,18 +279,16 @@ export class Sidebar extends Component { const { subscribed, blocked } = this.props.community_view; return ( - <> - {subscribed == "NotSubscribed" && ( - - )} - + subscribed === "NotSubscribed" && ( + + ) ); } diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index afd8818..ad7c5fe 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -5,6 +5,7 @@ import { enableDownvotes, enableNsfw, getCommentParentId, + getRoleLabelPill, myAuth, myAuthRequired, setIsoData, @@ -484,23 +485,43 @@ export class Profile extends Component< /> {isBanned(pv.person) && ( -
  • - {I18NextService.i18n.t("banned")} +
  • + {getRoleLabelPill({ + label: I18NextService.i18n.t("banned"), + tooltip: I18NextService.i18n.t("banned"), + classes: "text-bg-danger", + shrink: false, + })}
  • )} {pv.person.deleted && ( -
  • - {I18NextService.i18n.t("deleted")} +
  • + {getRoleLabelPill({ + label: I18NextService.i18n.t("deleted"), + tooltip: I18NextService.i18n.t("deleted"), + classes: "text-bg-danger", + shrink: false, + })}
  • )} {pv.person.admin && ( -
  • - {I18NextService.i18n.t("admin")} +
  • + {getRoleLabelPill({ + label: I18NextService.i18n.t("admin"), + tooltip: I18NextService.i18n.t("admin"), + shrink: false, + })}
  • )} {pv.person.bot_account && ( -
  • - {I18NextService.i18n.t("bot_account").toLowerCase()} +
  • + {getRoleLabelPill({ + label: I18NextService.i18n + .t("bot_account") + .toLowerCase(), + tooltip: I18NextService.i18n.t("bot_account"), + shrink: false, + })}
  • )} diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index b9a1913..eb3d0f6 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -1,4 +1,4 @@ -import { myAuthRequired } from "@utils/app"; +import { getRoleLabelPill, myAuthRequired } from "@utils/app"; import { canShare, share } from "@utils/browser"; import { getExternalHost, getHttpBase } from "@utils/env"; import { @@ -331,16 +331,19 @@ export class PostListing extends Component { if (!this.props.hideImage && url && isImage(url) && this.imageSrc) { return ( - {this.imgThumb(this.imageSrc)} - - + + ); } else if (!this.props.hideImage && url && thumbnail && this.imageSrc) { return ( @@ -351,7 +354,10 @@ export class PostListing extends Component { title={url} > {this.imgThumb(this.imageSrc)} - + ); } else if (url) { @@ -398,23 +404,27 @@ export class PostListing extends Component { createdLine() { const post_view = this.postView; return ( - - - {this.creatorIsMod_ && ( - - {I18NextService.i18n.t("mod")} - - )} - {this.creatorIsAdmin_ && ( - - {I18NextService.i18n.t("admin")} - - )} - {post_view.creator.bot_account && ( - - {I18NextService.i18n.t("bot_account").toLowerCase()} - - )} +
    + + + + {this.creatorIsMod_ && + getRoleLabelPill({ + label: I18NextService.i18n.t("mod"), + tooltip: I18NextService.i18n.t("mod"), + classes: "text-bg-primary", + })} + {this.creatorIsAdmin_ && + getRoleLabelPill({ + label: I18NextService.i18n.t("admin"), + tooltip: I18NextService.i18n.t("admin"), + classes: "text-bg-danger", + })} + {post_view.creator.bot_account && + getRoleLabelPill({ + label: I18NextService.i18n.t("bot_account").toLowerCase(), + tooltip: I18NextService.i18n.t("bot_account"), + })} {this.props.showCommunity && ( <> {" "} @@ -436,7 +446,7 @@ export class PostListing extends Component { published={post_view.post.published} updated={post_view.post.updated} /> - +
    ); } diff --git a/src/shared/utils/app/get-role-label-pill.tsx b/src/shared/utils/app/get-role-label-pill.tsx new file mode 100644 index 0000000..0cb0a41 --- /dev/null +++ b/src/shared/utils/app/get-role-label-pill.tsx @@ -0,0 +1,21 @@ +export default function getRoleLabelPill({ + label, + tooltip, + classes, + shrink = true, +}: { + label: string; + tooltip: string; + classes?: string; + shrink?: boolean; +}) { + return ( + + {shrink ? label[0].toUpperCase() : label} + + ); +} diff --git a/src/shared/utils/app/index.ts b/src/shared/utils/app/index.ts index f98357d..12cf1ea 100644 --- a/src/shared/utils/app/index.ts +++ b/src/shared/utils/app/index.ts @@ -29,6 +29,7 @@ import getDataTypeString from "./get-data-type-string"; import getDepthFromComment from "./get-depth-from-comment"; import getIdFromProps from "./get-id-from-props"; import getRecipientIdFromProps from "./get-recipient-id-from-props"; +import getRoleLabelPill from "./get-role-label-pill"; import getUpdatedSearchId from "./get-updated-search-id"; import initializeSite from "./initialize-site"; import insertCommentIntoTree from "./insert-comment-into-tree"; @@ -87,6 +88,7 @@ export { getDepthFromComment, getIdFromProps, getRecipientIdFromProps, + getRoleLabelPill, getUpdatedSearchId, getUserInterfaceLangId, initializeSite,