Skip to content

Commit

Permalink
merge: pull request #247 from grouting/master
Browse files Browse the repository at this point in the history
feat: server badges (addresses #36)
  • Loading branch information
insertish authored Dec 1, 2023
2 parents d86846a + dd797c2 commit 3c3ce3a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions components/ui/components/navigation/channels/ServerSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
BiRegularPhoneCall,
BiSolidChevronRight,
BiSolidCog,
BiSolidCheckCircle,
BiRegularCheckCircle
} from "solid-icons/bi";
import {
For,
Expand All @@ -17,12 +19,13 @@ import {
} from "solid-js";
import { styled } from "solid-styled-components";

import type { API, Channel, Server } from "revolt.js";
import type { API, Channel, Server, ServerFlags } from "revolt.js";

import { getController } from "@revolt/common";
import { KeybindAction } from "@revolt/keybinds/actions";
import { TextWithEmoji } from "@revolt/markdown";
import { Link, useNavigate } from "@revolt/routing";
import { Link } from "@revolt/routing";
import { useTranslation } from "@revolt/i18n";

import MdPersonAdd from "@material-design-icons/svg/filled/person_add.svg?component-solid";
import MdSettings from "@material-design-icons/svg/filled/settings.svg?component-solid";
Expand All @@ -36,6 +39,7 @@ import { MenuButton } from "../../design/atoms/inputs/MenuButton";
import { Column, OverflowingText, Row } from "../../design/layout";

import { SidebarBase } from "./common";
import { Tooltip } from "../../floating";

void scrollable;
void floating;
Expand Down Expand Up @@ -194,6 +198,7 @@ function ServerInfo(
) {
return (
<Row align grow>
<ServerBadge flags={props.server.flags} />
<ServerName onClick={props.openServerInfo}>
<OverflowingText>
<TextWithEmoji content={props.server.name} />
Expand Down Expand Up @@ -224,6 +229,21 @@ const SettingsLink = styled.a`
}
`;

/**
* Server badge
*/
function ServerBadge(props: { flags: ServerFlags }) {
const t = useTranslation();

return (
<Show when={props.flags}>
<Tooltip content={props.flags === 1 ? t("app.special.server-badges.official") : t("app.special.server-badges.verified")} placement="top">
{props.flags === 1 ? (<BiSolidCheckCircle size={12} />) : (<BiRegularCheckCircle size={12} />)}
</Tooltip>
</Show>
);
}

/**
* Single category entry
*/
Expand Down

0 comments on commit 3c3ce3a

Please sign in to comment.