mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-03 12:10:34 +00:00
Start table
This commit is contained in:
@@ -11,6 +11,7 @@ import { DocumentContextProps } from './DocumentView';
|
||||
import { Images } from './Images';
|
||||
import { Tabs } from './Tabs';
|
||||
import { Expandable } from './Expandable';
|
||||
import { Table } from './Table';
|
||||
|
||||
export interface BlockProps<T> extends DocumentContextProps {
|
||||
block: T;
|
||||
@@ -43,6 +44,8 @@ export function Block<T>(props: BlockProps<T>) {
|
||||
return <Tabs {...props} {...contextProps} />;
|
||||
case 'expandable':
|
||||
return <Expandable {...props} {...contextProps} />;
|
||||
case 'table':
|
||||
return <Table {...props} {...contextProps} />
|
||||
default:
|
||||
return <div className={tcls(style)}>Unsupported block {block.type}</div>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { BlockProps } from "../Block";
|
||||
import { ViewCards } from "./ViewCards";
|
||||
|
||||
export interface TableViewProps<View> extends BlockProps<any> {
|
||||
view: View;
|
||||
record: any[];
|
||||
}
|
||||
|
||||
export function Table(props: BlockProps<any>) {
|
||||
const { block } = props;
|
||||
|
||||
switch (block.data.view.type) {
|
||||
case 'cards':
|
||||
return <ViewCards view={block.data.view} {...props} />;
|
||||
default:
|
||||
return <div>Unsupported view {block.data.view.type}</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { TableViewProps } from "./Table";
|
||||
|
||||
|
||||
export function ViewCards(props: TableViewProps<any>) {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>Cards!</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from './Table';
|
||||
Reference in New Issue
Block a user