diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index 4ad15383..079edec7 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 text-black", + shrink: false, + })} + + {isMod_ && + getRoleLabelPill({ + label: I18NextService.i18n.t("mod"), + tooltip: I18NextService.i18n.t("mod"), + classes: "text-bg-primary text-black", + })} + + {isAdmin_ && + getRoleLabelPill({ + label: I18NextService.i18n.t("admin"), + tooltip: I18NextService.i18n.t("admin"), + classes: "text-bg-danger text-white", + })} + + {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/person/profile.tsx b/src/shared/components/person/profile.tsx index afd88184..4a8de027 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 text-white", + shrink: false, + })}
  • )} {pv.person.deleted && ( -
  • - {I18NextService.i18n.t("deleted")} +
  • + {getRoleLabelPill({ + label: I18NextService.i18n.t("deleted"), + tooltip: I18NextService.i18n.t("deleted"), + classes: "text-bg-danger text-white", + 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 bd9e8853..98c38470 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 { @@ -404,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 text-black", + })} + {this.creatorIsAdmin_ && + getRoleLabelPill({ + label: I18NextService.i18n.t("admin"), + tooltip: I18NextService.i18n.t("admin"), + classes: "text-bg-danger text-white", + })} + {post_view.creator.bot_account && + getRoleLabelPill({ + label: I18NextService.i18n.t("bot_account").toLowerCase(), + tooltip: I18NextService.i18n.t("bot_account"), + })} {this.props.showCommunity && ( <> {" "} @@ -442,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 00000000..0cb0a414 --- /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 f98357d7..12cf1ea2 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,