mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: compact compare headers
This commit is contained in:
1 parent
4ff8d77460
commit
5adbec25c4
3 files changed
+19
-15
No files matched your search
@@ -14,7 +14,7 @@ import { StickyRowHeaderCell } from "../StickyRowHeaderCell";
|
|||||||
|
|
||||||
type CompareRowProps = {
|
type CompareRowProps = {
|
||||||
display?: (
|
display?: (
|
||||||
member: Awaited<TankCharacteristics>
|
member: Awaited<TankCharacteristics>,
|
||||||
) => number | string | undefined;
|
) => number | string | undefined;
|
||||||
deltaType?: CompareCellDirection;
|
deltaType?: CompareCellDirection;
|
||||||
decimals?: number;
|
decimals?: number;
|
||||||
@@ -46,7 +46,7 @@ export function CompareRow({
|
|||||||
const values = stats.map((stat) =>
|
const values = stats.map((stat) =>
|
||||||
typeof props.value === "function"
|
typeof props.value === "function"
|
||||||
? props.value(stat)!
|
? props.value(stat)!
|
||||||
: (stat[props.value] as number)
|
: (stat[props.value] as number),
|
||||||
);
|
);
|
||||||
const id = useRef(Math.random());
|
const id = useRef(Math.random());
|
||||||
const name =
|
const name =
|
||||||
@@ -56,10 +56,10 @@ export function CompareRow({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<StickyRowHeaderCell>
|
<StickyRowHeaderCell left="-1.25rem">
|
||||||
<Flex
|
<Flex
|
||||||
align="center"
|
align="center"
|
||||||
style={{ whiteSpace: "nowrap" }}
|
maxWidth={{ initial: "6rem", sm: "unset" }}
|
||||||
gap={indent ? { initial: "4", sm: "6" } : { initial: "1", sm: "2" }}
|
gap={indent ? { initial: "4", sm: "6" } : { initial: "1", sm: "2" }}
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -111,8 +111,8 @@ export function CompareRow({
|
|||||||
const resolvedDisplayValue = display
|
const resolvedDisplayValue = display
|
||||||
? display(stats[index])
|
? display(stats[index])
|
||||||
: decimals === undefined
|
: decimals === undefined
|
||||||
? value
|
? value
|
||||||
: value?.toFixed(decimals);
|
: value?.toFixed(decimals);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CompareCell
|
<CompareCell
|
||||||
@@ -145,8 +145,8 @@ export function CompareRow({
|
|||||||
deltaNominalDisplay
|
deltaNominalDisplay
|
||||||
? deltaNominalDisplay(delta)
|
? deltaNominalDisplay(delta)
|
||||||
: decimals === undefined
|
: decimals === undefined
|
||||||
? delta
|
? delta
|
||||||
: delta.toFixed(decimals)
|
: delta.toFixed(decimals)
|
||||||
}`}
|
}`}
|
||||||
)
|
)
|
||||||
</Text>
|
</Text>
|
||||||
@@ -156,7 +156,7 @@ export function CompareRow({
|
|||||||
<Text color="gray">
|
<Text color="gray">
|
||||||
(
|
(
|
||||||
{`${deltaPercentage > 0 ? "+" : ""}${Math.round(
|
{`${deltaPercentage > 0 ? "+" : ""}${Math.round(
|
||||||
deltaPercentage * 100
|
deltaPercentage * 100,
|
||||||
)}%`}
|
)}%`}
|
||||||
)
|
)
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Heading, Table } from '@radix-ui/themes';
|
import { Heading, Table } from "@radix-ui/themes";
|
||||||
import { times } from 'lodash-es';
|
import { times } from "lodash-es";
|
||||||
import { CompareEphemeral } from '../../stores/compareEphemeral';
|
import { CompareEphemeral } from "../../stores/compareEphemeral";
|
||||||
import { StickyColumnHeaderCell } from '../StickyColumnHeaderCell';
|
import { StickyColumnHeaderCell } from "../StickyColumnHeaderCell";
|
||||||
|
|
||||||
export function CompareSectionTitle({ children }: { children: string }) {
|
export function CompareSectionTitle({ children }: { children: string }) {
|
||||||
const memberCount = CompareEphemeral.use((state) => state.members.length);
|
const memberCount = CompareEphemeral.use((state) => state.members.length);
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import { Table } from "@radix-ui/themes";
|
import { Table } from "@radix-ui/themes";
|
||||||
import type { RowHeaderCellProps } from "@radix-ui/themes/src/components/table.js";
|
import type { RowHeaderCellProps } from "@radix-ui/themes/src/components/table.js";
|
||||||
|
|
||||||
export function StickyRowHeaderCell({ style, ...props }: RowHeaderCellProps) {
|
interface Props extends RowHeaderCellProps {
|
||||||
|
left?: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function StickyRowHeaderCell({ style, left = 0, ...props }: Props) {
|
||||||
return (
|
return (
|
||||||
<Table.RowHeaderCell
|
<Table.RowHeaderCell
|
||||||
style={{
|
style={{
|
||||||
position: "sticky",
|
position: "sticky",
|
||||||
left: 0,
|
left,
|
||||||
backgroundColor: "var(--color-panel)",
|
backgroundColor: "var(--color-panel)",
|
||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in new issue
Block a user