mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-10 01:03:36 -05:00
Style categories.
This commit is contained in:
parent
8e24d1490c
commit
f2c59ae451
2 changed files with 38 additions and 14 deletions
|
@ -1,7 +1,9 @@
|
||||||
import AutoSizer from "react-virtualized-auto-sizer";
|
import AutoSizer from "react-virtualized-auto-sizer";
|
||||||
import { FixedSizeList as List } from "react-window";
|
import { FixedSizeList as List } from "react-window";
|
||||||
import { User } from "revolt.js/dist/maps/Users";
|
import { User } from "revolt.js/dist/maps/Users";
|
||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
import { Text } from "preact-i18n";
|
||||||
import { forwardRef } from "preact/compat";
|
import { forwardRef } from "preact/compat";
|
||||||
|
|
||||||
import { UserButton } from "../items/ButtonItem";
|
import { UserButton } from "../items/ButtonItem";
|
||||||
|
@ -13,6 +15,17 @@ interface ItemData {
|
||||||
|
|
||||||
const PADDING_SIZE = 6;
|
const PADDING_SIZE = 6;
|
||||||
|
|
||||||
|
const ListCategory = styled.div`
|
||||||
|
display: flex;
|
||||||
|
padding: 14px;
|
||||||
|
font-size: 0.8em;
|
||||||
|
font-weight: 600;
|
||||||
|
user-select: none;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-end;
|
||||||
|
color: var(--secondary-foreground);
|
||||||
|
`;
|
||||||
|
|
||||||
const Row = ({
|
const Row = ({
|
||||||
data,
|
data,
|
||||||
style,
|
style,
|
||||||
|
@ -23,16 +36,27 @@ const Row = ({
|
||||||
style: JSX.CSSProperties;
|
style: JSX.CSSProperties;
|
||||||
}) => {
|
}) => {
|
||||||
const item = data.entries[index];
|
const item = data.entries[index];
|
||||||
|
style.top = `${parseFloat(style.top as string) + PADDING_SIZE}px`;
|
||||||
|
|
||||||
|
if (typeof item === "string") {
|
||||||
|
const [cat, count] = item.split(":");
|
||||||
return (
|
return (
|
||||||
<div
|
<div style={style}>
|
||||||
style={{
|
<ListCategory>
|
||||||
...style,
|
{cat === "online" ? (
|
||||||
top: `${parseFloat(style.top as string) + PADDING_SIZE}px`,
|
<Text id="app.status.online" />
|
||||||
}}>
|
|
||||||
{typeof item === "string" ? (
|
|
||||||
`cat ${item}`
|
|
||||||
) : (
|
) : (
|
||||||
|
<Text id="app.status.offline" />
|
||||||
|
)}
|
||||||
|
{" - "}
|
||||||
|
{count}
|
||||||
|
</ListCategory>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
// eslint-disable-next-line
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div style={style}>
|
||||||
<UserButton
|
<UserButton
|
||||||
key={item._id}
|
key={item._id}
|
||||||
user={item}
|
user={item}
|
||||||
|
@ -45,9 +69,9 @@ const Row = ({
|
||||||
})
|
})
|
||||||
} */
|
} */
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Copied directly from example code.
|
// @ts-expect-error Copied directly from example code.
|
||||||
|
|
|
@ -203,9 +203,9 @@ export const ServerMemberSidebar = observer(
|
||||||
const entries = [];
|
const entries = [];
|
||||||
|
|
||||||
entries.push(
|
entries.push(
|
||||||
"online",
|
`online:${categories.online.length}`,
|
||||||
...categories.online.map((x) => x[0]),
|
...categories.online.map((x) => x[0]),
|
||||||
"offline",
|
`offline:${categories.offline.length}`,
|
||||||
...categories.offline.map((x) => x[0]),
|
...categories.offline.map((x) => x[0]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue