-
+
-
+
-
+
-
+
-
+
);
};
-
-
const MainDrawer = (props: { onShowAttachmentClick(): void }) => {
- const params = useParams<{ serverId?: string; channelId?: string; }>();
+ const params = useParams<{ serverId?: string; channelId?: string }>();
const { channels } = useStore();
-
const channel = () => channels.get(params.channelId!);
const incrAttachments = (channelId: string) => {
const channel = channels.get(channelId);
- const count = (channel?._count?.attachments || 0);
+ const count = channel?._count?.attachments || 0;
channel?.update({ _count: { attachments: count + 1 } });
};
const decrAttachments = (channelId: string) => {
const channel = channels.get(channelId);
- const count = (channel?._count?.attachments || 1);
+ const count = channel?._count?.attachments || 1;
channel?.update({ _count: { attachments: count - 1 } });
};
@@ -241,61 +305,87 @@ const MainDrawer = (props: { onShowAttachmentClick(): void }) => {
};
socketClient.useSocketOn(ServerEvents.MESSAGE_CREATED, onMessage);
- const onDelete = (payload: { messageId: string, channelId: string }) => {
+ const onDelete = (payload: { messageId: string; channelId: string }) => {
decrAttachments(payload.channelId);
};
socketClient.useSocketOn(ServerEvents.MESSAGE_DELETED, onDelete);
+ const cachedNotice = () =>
+ params.channelId ? getCachedNotice(() => params.channelId!) : undefined;
- const cachedNotice = () => params.channelId ? getCachedNotice(() => params.channelId!) : undefined;
-
- return <>
-
-
-
-
-
-
-
-
-
-
- >;
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
};
-
const BannerItem = () => {
- const params = useParams<{ serverId?: string; channelId?: string; }>();
+ const params = useParams<{ serverId?: string; channelId?: string }>();
const { servers, channels } = useStore();
const server = () => servers.get(params.serverId!);
const channel = () => channels.get(params.channelId!)?.recipient();
- const bannerData = () => server() || channel() as { hexColor: string, banner?: string; };
+ const bannerData = () =>
+ server() || (channel() as { hexColor: string; banner?: string });
return (
-
+
);
};
-
const ServerDrawer = () => {
const params = useParams();
const { servers, serverMembers, serverRoles } = useStore();
@@ -305,68 +395,111 @@ const ServerDrawer = () => {
const members = () => serverMembers.array(params.serverId);
- const roleMembers = mapArray(roles, role => {
-
- const membersInThisRole = () => members().filter(member => {
- if (!member?.user()) return false;
- if (!member?.user().presence()?.status) return false;
- if (server()?.defaultRoleId === role!.id && !member?.unhiddenRole()) return true;
- if (member?.unhiddenRole()?.id === role!.id) return true;
- });
+ const roleMembers = mapArray(roles, (role) => {
+ const membersInThisRole = () =>
+ members().filter((member) => {
+ if (!member?.user()) return false;
+ if (!member?.user().presence()?.status) return false;
+ if (server()?.defaultRoleId === role!.id && !member?.unhiddenRole())
+ return true;
+ if (member?.unhiddenRole()?.id === role!.id) return true;
+ });
return { role, members: createMemo(() => membersInThisRole()) };
});
- const offlineMembers = createMemo(() => members().filter(member => !member?.user().presence()?.status));
- const defaultRole = () => serverRoles.get(server()?.id!, server()?.defaultRoleId!);
+ const offlineMembers = createMemo(() =>
+ members().filter((member) => !member?.user().presence()?.status)
+ );
+ const defaultRole = () =>
+ serverRoles.get(server()?.id!, server()?.defaultRoleId!);
return (
<>
{t("informationDrawer.members")}
-
{members().length.toLocaleString()}
+
+ {members().length.toLocaleString()}
+
{(item) => (
- a?.user().username.localeCompare(b?.user().username))} roleName={item.role?.name!} roleIcon={item.role?.icon!} />
+
+ a?.user().username.localeCompare(b?.user().username)
+ )}
+ roleName={item.role?.name!}
+ roleIcon={item.role?.icon!}
+ />
)}
{/* Offline */}
- a?.user().username.localeCompare(b?.user().username))} roleName="Offline" roleIcon={defaultRole()?.icon} />
+
+ a?.user().username.localeCompare(b?.user().username)
+ )}
+ roleName="Offline"
+ roleIcon={defaultRole()?.icon}
+ />
>
-
);
};
-function RoleItem(props: { roleName: string, members: ServerMember[], roleIcon?: string }) {
+function RoleItem(props: {
+ roleName: string;
+ members: ServerMember[];
+ roleIcon?: string;
+}) {
const [expanded, setExpanded] = createSignal(props.members.length <= 20);
const [hovered, setHovered] = createSignal(false);
return (
-
setHovered(true)} onMouseLeave={() => setHovered(false)}>
+
setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
setExpanded(!expanded())}>
-
{props.roleName}
-
{props.members.length.toLocaleString()}
-
+
+ {" "}
+
+
+ {" "}
+ {props.roleName}
+
+
+ {props.members.length.toLocaleString()}
+
+
- {member => }
+ {(member) => }
);
}
-
-
const ServerChannelNotice = () => {
const params = useParams<{ channelId: string }>();
@@ -376,15 +509,15 @@ const ServerChannelNotice = () => {
);
};
export default RightDrawer;
-
-
diff --git a/src/components/right-drawer/styles.module.scss b/src/components/right-drawer/styles.module.scss
index b6f88dae..56598246 100644
--- a/src/components/right-drawer/styles.module.scss
+++ b/src/components/right-drawer/styles.module.scss
@@ -47,6 +47,7 @@
gap: 4px;
}
.roleExpandButton {
+ margin: 0;
margin-left: 8px;
}
.roleCount {
diff --git a/src/components/ui/Button.module.scss b/src/components/ui/Button.module.scss
new file mode 100644
index 00000000..b8775b48
--- /dev/null
+++ b/src/components/ui/Button.module.scss
@@ -0,0 +1,32 @@
+.container {
+ all: unset;
+ display: flex;
+ align-items: center;
+ flex-shrink: 0;
+ justify-content: center;
+ padding: 5px;
+
+ margin: 5px;
+ border: solid 1px rgba(255, 255, 255, 0.1);
+ border-radius: 6px;
+ color: white;
+ background-color: rgba(255, 255, 255, 0.08);
+ cursor: pointer;
+ user-select: none;
+ transition: 0.2s background-color, 0.2s opacity;
+ text-align: center;
+ &:focus {
+ background-color: rgba(255, 255, 255, 0.15);
+ }
+ &:hover {
+ background-color: rgba(255, 255, 255, 0.15);
+ }
+ &.primary {
+ &:hover {
+ opacity: 0.6;
+ }
+ }
+ :nth-child(2) {
+ margin-left: 5px;
+ }
+}
diff --git a/src/components/ui/Button.tsx b/src/components/ui/Button.tsx
index 80854704..5a9c5100 100644
--- a/src/components/ui/Button.tsx
+++ b/src/components/ui/Button.tsx
@@ -1,131 +1,108 @@
import Icon from "@/components/ui/icon/Icon";
-import { JSX, JSXElement } from "solid-js";
-import { styled } from "solid-styled-components";
+import { JSX, JSXElement, splitProps } from "solid-js";
import Text from "./Text";
+import { cn } from "@/common/classNames";
+import style from "./Button.module.scss";
+import { Dynamic } from "solid-js/web";
+import { A } from "solid-navigator";
-export interface ButtonProps {
- onMouseLeave?: (event: MouseEvent) => void;
- onMouseEnter?: (event: MouseEvent) => void;
- onPointerEnter?: (event: PointerEvent) => void;
- onPointerLeave?: (event: PointerEvent) => void;
- onPointerMove?: (event: PointerEvent) => void;
- onTouchMove?: (event: TouchEvent) => void;
- onTouchStart?: (event: TouchEvent) => void;
- color?: string;
- class?: string;
+export type ButtonProps = Omit<
+ JSX.ButtonHTMLAttributes
,
+ "color"
+> & {
+ color?: string | null;
label?: string;
margin?: number | number[];
padding?: number | number[];
iconSize?: number;
textSize?: number;
iconName?: string;
- onClick?: (event: MouseEvent) => void;
- onPointerDown?: (event: PointerEvent) => void;
- onPointerUp?: (event: PointerEvent) => void;
- onContextMenu?: (event: MouseEvent) => void;
primary?: boolean;
customChildren?: JSXElement;
customChildrenLeft?: JSXElement;
+ href?: string;
styles?: JSX.CSSProperties;
tabIndex?: string;
hoverText?: string;
iconClass?: string;
alert?: boolean;
-}
-
-const ButtonContainer = styled("button")<{
- padding?: number | number[];
- margin?: number | number[];
- primary?: boolean;
-}>`
- all: unset;
- display: flex;
- text-align: center;
- align-items: center;
- justify-content: center;
- border-radius: 6px;
- flex-shrink: 0;
- padding: ${(props) =>
- props.padding !== undefined
- ? typeof props.padding === "object"
- ? props.padding.join("px ")
- : props.padding
- : 5}px;
- margin: ${(props) =>
- props.margin !== undefined
- ? typeof props.margin === "object"
- ? props.margin.join("px ")
- : props.margin
- : 5}px;
- color: white;
- cursor: pointer;
- user-select: none;
- transition: 0.2s background-color, 0.2s opacity;
- background-color: rgba(255, 255, 255, 0.08);
- border: solid 1px rgba(255, 255, 255, 0.1);
-
- &:hover {
- background-color: rgba(255, 255, 255, 0.15);
- ${(props) => props.primary ? "opacity: 0.6" : undefined};
- }
- &:focus {
- background-color: rgba(255, 255, 255, 0.15);
- }
-
- :nth-child(2) {
- margin-left: 5px;
- }
-`;
+};
export default function Button(props: ButtonProps) {
+ const [customProps, ogProps] = splitProps(props, [
+ "color",
+ "label",
+ "margin",
+ "padding",
+ "iconSize",
+ "textSize",
+ "iconName",
+ "primary",
+ "customChildren",
+ "href",
+ "customChildrenLeft",
+ "styles",
+ "tabIndex",
+ "hoverText",
+ "iconClass",
+ "alert",
+ ]);
const color = () =>
- props.alert ? "var(--alert-color)" : props.color || "var(--primary-color)";
+ customProps.alert
+ ? "var(--alert-color)"
+ : customProps.color || "var(--primary-color)";
- const style = () => ({
- ...(props.primary ? { "background-color": color() } : undefined),
- ...props.styles,
+ const btnStyle = () => ({
+ ...(customProps.primary ? { "background-color": color() } : {}),
+ margin:
+ props.margin !== undefined
+ ? typeof props.margin === "object"
+ ? props.margin.join("px ") + "px"
+ : props.margin + "px"
+ : undefined,
+ padding:
+ props.padding !== undefined
+ ? typeof props.padding === "object"
+ ? props.padding.join("px ") + "px"
+ : props.padding + "px"
+ : undefined,
+ ...customProps.styles,
});
return (
-
- {props.customChildrenLeft && props.customChildrenLeft}
- {props.iconName && (
+ {customProps.customChildrenLeft && customProps.customChildrenLeft}
+ {customProps.iconName && (
)}
- {props.label && (
+ {customProps.label && (
- {props.label}
+ {customProps.label}
)}
- {props.customChildren && props.customChildren}
-
+ {customProps.customChildren && customProps.customChildren}
+
);
}