feat(fe/layout): add columns layout
This commit is contained in:
parent
7c1bc34c48
commit
e013acadfe
1 changed files with 43 additions and 0 deletions
43
src/client/web/src/components/layout/columns.tsx
Normal file
43
src/client/web/src/components/layout/columns.tsx
Normal file
|
@ -0,0 +1,43 @@
|
|||
import * as React from "react";
|
||||
import { List } from "immutable";
|
||||
|
||||
export interface Props {
|
||||
rows: List<List<React.ReactNode>>;
|
||||
widths: List<string>;
|
||||
childrenClassNames?: List<string>;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const Columns = (props: Props) => {
|
||||
const children = props.rows.map(
|
||||
(row: List<React.ReactNode>, i: number): React.ReactNode => {
|
||||
const cells = row.map((cell: React.ReactNode, j: number) => {
|
||||
const width = props.widths.get(j, Math.trunc(100 / row.size));
|
||||
const className = props.childrenClassNames.get(j, "");
|
||||
return (
|
||||
<div
|
||||
key={`td-${i}-${j}`}
|
||||
className={`float-l ${className}`}
|
||||
style={{ width }}
|
||||
>
|
||||
{cell}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<div key={`tr-${i}`}>
|
||||
{cells}
|
||||
<div className="fix"></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<div style={props.style} className={props.className}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue