mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-02 10:39:56 +00:00
c77086a9d5
* feat: Use Bootstrap 5; remove Bootstrap 4 * feat: Add link decoration override global var * fix: Change sr-only to visually-hidden * fix: Fix missing toggle button classes * fix: Use darker green to pass 3:1 contrast and allow foreground color generation * fix: Replace all mr- and ml- classes with me- (end) and ms- (start) classes * fix: Replace all pr- and pl- classes with pe- (end) and ps- (start) classes * fix: Replace custom-select with form-select d-inline-block * fix: Change max-width to Bootstrap 4's max-width * fix: Fix badge colors * fix: Replace deprecated btn-block class with d-block * fix: Temporary fix for missing btn-block styles * fix: Fix margin-left auto and margin-right auto * fix: Fix default border color * fix: Fix some button widths * fix: Fix form row margins * fix: Remove theme color maps; no longer necessary in Bootstrap 5 * fix: Remove unused gray * test commit * fix: Fix deprecated input-group-append usage * fix: Add missing col-form-label classes * fix: Fix some column widths * fix: Fix language dropdown style regression * fix: Fix toast background color * fix: Fix missing colors in red themes * fix: Fix default radio button appearance for toggles * fix: Fix missing margin in search form * fix: Fix search form widths * fix: Fix rate limit form columns * fix: Fix search filters layout * fix: Fix weird table background issue; re-compile from main updates * fix: Fix modlog filter layout * fix: Fix some horizontal margins * fix: Fix incorrect usage of input-group * chore: Empty commit to re-trigger Woodpecker job * fix: Fix incorrect Bootstrap 5 padding class * fix: Tighten up the home filter bars for the hell of it * fix: Fix home filter bar gap --------- Co-authored-by: SleeplessOne1917 <abias1122@gmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
128 lines
4.2 KiB
TypeScript
128 lines
4.2 KiB
TypeScript
import { Link } from "inferno-router";
|
|
import {
|
|
CommunityAggregates,
|
|
CommunityId,
|
|
SiteAggregates,
|
|
} from "lemmy-js-client";
|
|
import { i18n } from "../../i18next";
|
|
import { numToSI } from "../../utils";
|
|
|
|
interface BadgesProps {
|
|
counts: CommunityAggregates | SiteAggregates;
|
|
communityId?: CommunityId;
|
|
}
|
|
|
|
const isCommunityAggregates = (
|
|
counts: CommunityAggregates | SiteAggregates
|
|
): counts is CommunityAggregates => {
|
|
return "subscribers" in counts;
|
|
};
|
|
|
|
const isSiteAggregates = (
|
|
counts: CommunityAggregates | SiteAggregates
|
|
): counts is SiteAggregates => {
|
|
return "communities" in counts;
|
|
};
|
|
|
|
export const Badges = ({ counts, communityId }: BadgesProps) => {
|
|
return (
|
|
<ul className="my-1 list-inline">
|
|
<li
|
|
className="list-inline-item badge text-bg-secondary pointer"
|
|
data-tippy-content={i18n.t("active_users_in_the_last_day", {
|
|
count: Number(counts.users_active_day),
|
|
formattedCount: numToSI(counts.users_active_day),
|
|
})}
|
|
>
|
|
{i18n.t("number_of_users", {
|
|
count: Number(counts.users_active_day),
|
|
formattedCount: numToSI(counts.users_active_day),
|
|
})}{" "}
|
|
/ {i18n.t("day")}
|
|
</li>
|
|
<li
|
|
className="list-inline-item badge text-bg-secondary pointer"
|
|
data-tippy-content={i18n.t("active_users_in_the_last_week", {
|
|
count: Number(counts.users_active_week),
|
|
formattedCount: numToSI(counts.users_active_week),
|
|
})}
|
|
>
|
|
{i18n.t("number_of_users", {
|
|
count: Number(counts.users_active_week),
|
|
formattedCount: numToSI(counts.users_active_week),
|
|
})}{" "}
|
|
/ {i18n.t("week")}
|
|
</li>
|
|
<li
|
|
className="list-inline-item badge text-bg-secondary pointer"
|
|
data-tippy-content={i18n.t("active_users_in_the_last_month", {
|
|
count: Number(counts.users_active_month),
|
|
formattedCount: numToSI(counts.users_active_month),
|
|
})}
|
|
>
|
|
{i18n.t("number_of_users", {
|
|
count: Number(counts.users_active_month),
|
|
formattedCount: numToSI(counts.users_active_month),
|
|
})}{" "}
|
|
/ {i18n.t("month")}
|
|
</li>
|
|
<li
|
|
className="list-inline-item badge text-bg-secondary pointer"
|
|
data-tippy-content={i18n.t("active_users_in_the_last_six_months", {
|
|
count: Number(counts.users_active_half_year),
|
|
formattedCount: numToSI(counts.users_active_half_year),
|
|
})}
|
|
>
|
|
{i18n.t("number_of_users", {
|
|
count: Number(counts.users_active_half_year),
|
|
formattedCount: numToSI(counts.users_active_half_year),
|
|
})}{" "}
|
|
/ {i18n.t("number_of_months", { count: 6, formattedCount: 6 })}
|
|
</li>
|
|
{isSiteAggregates(counts) && (
|
|
<>
|
|
<li className="list-inline-item badge text-bg-secondary">
|
|
{i18n.t("number_of_users", {
|
|
count: Number(counts.users),
|
|
formattedCount: numToSI(counts.users),
|
|
})}
|
|
</li>
|
|
<li className="list-inline-item badge text-bg-secondary">
|
|
{i18n.t("number_of_communities", {
|
|
count: Number(counts.communities),
|
|
formattedCount: numToSI(counts.communities),
|
|
})}
|
|
</li>
|
|
</>
|
|
)}
|
|
{isCommunityAggregates(counts) && (
|
|
<li className="list-inline-item badge text-bg-secondary">
|
|
{i18n.t("number_of_subscribers", {
|
|
count: Number(counts.subscribers),
|
|
formattedCount: numToSI(counts.subscribers),
|
|
})}
|
|
</li>
|
|
)}
|
|
<li className="list-inline-item badge text-bg-secondary">
|
|
{i18n.t("number_of_posts", {
|
|
count: Number(counts.posts),
|
|
formattedCount: numToSI(counts.posts),
|
|
})}
|
|
</li>
|
|
<li className="list-inline-item badge text-bg-secondary">
|
|
{i18n.t("number_of_comments", {
|
|
count: Number(counts.comments),
|
|
formattedCount: numToSI(counts.comments),
|
|
})}
|
|
</li>
|
|
<li className="list-inline-item">
|
|
<Link
|
|
className="badge text-bg-primary"
|
|
to={`/modlog${communityId ? `/${communityId}` : ""}`}
|
|
>
|
|
{i18n.t("modlog")}
|
|
</Link>
|
|
</li>
|
|
</ul>
|
|
);
|
|
};
|