Table empty placeholder (#18)

* Add empty placeholder when table does not contain value
This commit is contained in:
Arnaud 2024-09-16 18:23:28 +02:00 committed by GitHub
parent 50af3fe96b
commit 97a1ecbf0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 1 deletions

View File

@ -3,6 +3,19 @@
width: 100%;
}
.table-placeholder {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
margin-top: 2rem;
}
.table-placeholderText {
margin-top: 0.5rem;
margin-bottom: 0;
}
.table-container {
border: 1px solid var(--codex-border-color);
background-color: var(--codex-background-secondary);

View File

@ -1,5 +1,8 @@
import "./Table.css";
import { ReactNode } from "react";
import { EmptyPlaceholderIcon as EPI } from "../EmptyPlaceholder/EmptyPlaceholderIcon";
import { EmptyPlaceholder } from "../EmptyPlaceholder/EmptyPlaceholder";
import { Search } from "lucide-react";
type Props = {
/**
@ -46,6 +49,13 @@ export function Table({ headers, cells, className }: Props) {
))}
</tbody>
</table>
{!cells.length && (
<div className="table-placeholder">
<Search />
<p className="table-placeholderText">No search results.</p>
</div>
)}
</div>
);
}

View File

@ -151,7 +151,7 @@ export function UploadFile({
);
},
onError: (error) => {
worker.current?.terminate();
// worker.current?.terminate();
dispatch({ type: "error", error: error.message });
},
onSuccess: (cid: string) => {

View File

@ -87,3 +87,10 @@ export const State: Story = {
headers: ["id", "title", "state", "actions"],
},
};
export const Empty: Story = {
args: {
cells: [],
headers: ["id", "title", "state", "actions"],
},
};