From 6550051fa0ce6e5d28665ef3aa20e10b0be6d9ea Mon Sep 17 00:00:00 2001 From: Poltergeist Date: Thu, 21 Jun 2018 16:44:14 +0200 Subject: [PATCH] feat(table): add column component This introduces the Column component to the library. The Column will take 3 properties: - cellRenderer The cellRenderer will expect a function which returns a JSX.Element which will be used to render the Datum cell. - width The width will expect a function to calculate the width it should return a number. As a parameter the total count of columns, total width, remaining width and current column index are provided in a single object. - label The label expects a JSX Element or a string which will be used to render the header. closes DCOS-38064 --- packages/index.ts | 1 + packages/table/README.md | 3 +++ packages/table/components/Column.tsx | 16 ++++++++++++++++ packages/table/index.ts | 1 + 4 files changed, 21 insertions(+) create mode 100644 packages/table/README.md create mode 100644 packages/table/components/Column.tsx create mode 100644 packages/table/index.ts diff --git a/packages/index.ts b/packages/index.ts index c487ebb17..65d236e44 100644 --- a/packages/index.ts +++ b/packages/index.ts @@ -1,2 +1,3 @@ export { Badge } from "./badge"; export { BadgeButton } from "./badge"; +export { Column } from "./table"; diff --git a/packages/table/README.md b/packages/table/README.md new file mode 100644 index 000000000..eb6ceb36f --- /dev/null +++ b/packages/table/README.md @@ -0,0 +1,3 @@ +# Table Name + +Table documentation diff --git a/packages/table/components/Column.tsx b/packages/table/components/Column.tsx new file mode 100644 index 000000000..401d6f52c --- /dev/null +++ b/packages/table/components/Column.tsx @@ -0,0 +1,16 @@ +import * as React from "react"; +interface IWidthArgs { + width: number; + totalColumns: number; + remainingWidth: number; + currentIndex: number; +} +export interface IColumnProps { + header: string | React.ReactNode; + cellRenderer: (data: any) => React.ReactNode; + width: (args: IWidthArgs) => number; +} + +export class Column extends React.PureComponent {} + +export default Column; diff --git a/packages/table/index.ts b/packages/table/index.ts new file mode 100644 index 000000000..9078798c3 --- /dev/null +++ b/packages/table/index.ts @@ -0,0 +1 @@ +export { default as Column } from "./components/Column";