Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make percent cell declarative #479

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/components/model/ModelSchemaTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Column } from "react-table";
import {
FloatCell,
IntCell,
NumericCellFactory,
PercentCell,
Table,
} from "@phoenix/components/table";

Expand Down Expand Up @@ -100,7 +100,7 @@ export function ModelSchemaTable(props: ModelSchemaTableProps) {
{
Header: "% empty",
accessor: "percentEmpty",
Cell: NumericCellFactory({ suffix: "%" }),
Cell: PercentCell,
},
{
Header: "min",
Expand Down
25 changes: 0 additions & 25 deletions app/src/components/table/NumericCellFactory.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/components/table/PercentCell.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react";
import { format } from "d3-format";

const formatter = format(".2%");
const formatter = format(".2f");
/**
* A table cell that nicely formats the value of a percent.
*/
export function PercentCell({ value }: { value: number | null }) {
return (
<span title={value != null ? String(value) : ""}>
{value != null ? formatter(value) : "--"}
{value != null ? `${formatter(value)}%` : "--"}
</span>
);
}
1 change: 0 additions & 1 deletion app/src/components/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export * from "./Table";
export * from "./FloatCell";
export * from "./IntCell";
export * from "./PercentCell";
export * from "./NumericCellFactory";