mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-05 01:05:02 -05:00
* Chat initial component * Connect to websocket * Chat render actual messages * Chat keep scrolled to bottom * Pending messages * Pass rooms as arg * Chat with tabs * Message max length * Looking tabs initial * Fixes * Chat on looking page w/ unread messages count * Add reconnecting websocket * Patron custom color * Change ChatMessage data model * Fix mobile layout * Add clean up to useEffect * Chat codes * FF + clear messages on group morph * Hide messages when user leaves etc. * Fix match page layout when chat missing * New tabs * Tabs for mobile * Add TODOs * Switch to own group tab when roster changes * Chat styling * Redesign group cards * Bring back manager buttons * Remove flipped * Remove unused code * Align better * Link to user profile * Better room pass + highlighted * Fix view when group expired * Fix MemberAdder (missing input + overflow) * Chat stay connected in looking * Remove filters for now * Fix chat number align * Fix chat unseen messages * Hide chat when alone * Remove rest todos
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { useTranslation } from "~/hooks/useTranslation";
|
|
import { Label } from "./Label";
|
|
import * as React from "react";
|
|
import { Button } from "./Button";
|
|
|
|
const CUSTOM_COLORS = [
|
|
"bg",
|
|
"bg-darker",
|
|
"bg-lighter",
|
|
"text",
|
|
"text-lighter",
|
|
"theme",
|
|
"chat",
|
|
] as const;
|
|
|
|
type CustomColorsRecord = Partial<
|
|
Record<(typeof CUSTOM_COLORS)[number], string>
|
|
>;
|
|
|
|
export function CustomizedColorsInput({
|
|
initialColors,
|
|
}: {
|
|
initialColors?: Record<string, string> | null;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const [colors, setColors] = React.useState<CustomColorsRecord>(
|
|
initialColors ?? {},
|
|
);
|
|
|
|
return (
|
|
<div className="w-full">
|
|
<Label>{t("custom.colors.title")}</Label>
|
|
<input type="hidden" name="css" value={JSON.stringify(colors)} />
|
|
<div className="colors__grid">
|
|
{CUSTOM_COLORS.map((cssVar) => {
|
|
return (
|
|
<React.Fragment key={cssVar}>
|
|
<div>{t(`custom.colors.${cssVar}`)}</div>
|
|
<input
|
|
type="color"
|
|
className="plain"
|
|
value={colors[cssVar]}
|
|
onChange={(e) => {
|
|
const extras: Record<string, string> = {};
|
|
if (cssVar === "bg-lighter") {
|
|
extras["bg-lightest"] = `${e.target.value}80`;
|
|
}
|
|
setColors({ ...colors, ...extras, [cssVar]: e.target.value });
|
|
}}
|
|
data-testid={`color-input-${cssVar}`}
|
|
/>
|
|
<Button
|
|
size="tiny"
|
|
variant="minimal-destructive"
|
|
onClick={() => {
|
|
const newColors: Record<string, string> = { ...colors };
|
|
if (cssVar === "bg-lighter") {
|
|
delete newColors["bg-lightest"];
|
|
}
|
|
setColors({ ...newColors, [cssVar]: undefined });
|
|
}}
|
|
>
|
|
{t("actions.reset")}
|
|
</Button>
|
|
</React.Fragment>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|