refactor again

This commit is contained in:
Alec Armbruster 2023-06-27 15:00:35 -04:00
parent 4944f19143
commit 4e161f5f91
No known key found for this signature in database
GPG key ID: 52BC7C84E960FD1B

View file

@ -321,22 +321,22 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
this.getRoleLabelPill({ this.getRoleLabelPill({
label: I18NextService.i18n.t("op").toUpperCase(), label: I18NextService.i18n.t("op").toUpperCase(),
tooltip: I18NextService.i18n.t("creator"), tooltip: I18NextService.i18n.t("creator"),
parentClasses: "text-info", classes: "text-bg-info text-black",
shrinkToSingleLetter: false, shrink: false,
})} })}
{isMod_ && {isMod_ &&
this.getRoleLabelPill({ this.getRoleLabelPill({
label: I18NextService.i18n.t("mod"), label: I18NextService.i18n.t("mod"),
tooltip: I18NextService.i18n.t("mod"), tooltip: I18NextService.i18n.t("mod"),
shrunkenLabelClasses: "text-primary", classes: "text-bg-primary text-black",
})} })}
{isAdmin_ && {isAdmin_ &&
this.getRoleLabelPill({ this.getRoleLabelPill({
label: I18NextService.i18n.t("admin"), label: I18NextService.i18n.t("admin"),
tooltip: I18NextService.i18n.t("admin"), tooltip: I18NextService.i18n.t("admin"),
shrunkenLabelClasses: "text-danger", classes: "text-bg-danger text-black",
})} })}
{cv.creator.bot_account && {cv.creator.bot_account &&
@ -1202,43 +1202,21 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
getRoleLabelPill({ getRoleLabelPill({
label, label,
tooltip, tooltip,
parentClasses, classes,
shrunkenLabelClasses, shrink = true,
hideOnMobile = false,
shrinkToSingleLetter = true,
}: { }: {
label: string; label: string;
tooltip: string; tooltip: string;
parentClasses?: string; classes?: string;
shrunkenLabelClasses?: string; shrink?: boolean;
hideOnMobile?: boolean;
shrinkToSingleLetter?: boolean;
}) { }) {
const parentClassNames = classNames(
`badge me-1 text-bg-light ${parentClasses}`,
{
"d-none d-md-inline": hideOnMobile,
}
);
let fullLabelClassNames = "d-none d-md-inline";
let shrunkenLabelClassNames = `d-inline d-md-none ${shrunkenLabelClasses}`;
if (!shrinkToSingleLetter) {
fullLabelClassNames = "";
shrunkenLabelClassNames = "d-none";
}
return ( return (
<span <span
className={parentClassNames} className={`badge me-1 ${classes ?? "text-bg-light"}`}
aria-label={tooltip} aria-label={tooltip}
data-tippy-content={tooltip} data-tippy-content={tooltip}
> >
<span className={fullLabelClassNames}>{label}</span> {shrink ? label[0].toUpperCase() : label}
<span className={shrunkenLabelClassNames}>
{label[0].toUpperCase()}
</span>
</span> </span>
); );
} }