Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 19x 19x 19x 19x 5x 5x 10x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 19x 2x 2x 2x 2x 19x 2x 2x 2x 2x 19x 4x 4x 4x 4x 19x 3x 3x 3x 3x 3x 3x 19x 3x 3x 3x 3x 3x 3x | import * as classNames from 'classnames';
import * as React from 'react';
const NBSP = '\u00a0';
export interface ITableFixedProps {
fixRowHeaders: true;
rowHeaderWidth: number;
}
export interface ITableUnfixedProps {
fixRowHeaders?: false;
rowHeaderWidth?: undefined;
}
export interface ITableProps {
collapse?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
striped?: boolean;
bordered?: boolean;
hover?: boolean;
condensed?: boolean;
fill?: boolean;
}
export type TTable = React.SFC<
(ITableFixedProps | ITableUnfixedProps) & ITableProps & React.HTMLAttributes<HTMLTableElement>
>;
export const Table: TTable = (props) => {
const {
className,
children,
collapse = 'sm',
fixRowHeaders,
rowHeaderWidth,
striped,
bordered,
hover,
condensed,
fill,
...remainingProps
} = props;
const myClassNames = [
'table',
`${collapse}-collapse`,
fixRowHeaders ? 'fix-column-headers' : null,
striped ? 'striped' : null,
bordered ? 'bordered' : null,
hover ? 'hover' : null,
condensed ? 'condensed' : null,
fill ? 'fill' : null,
className
];
return (
<div className="table-wrapper">
<div style={{paddingLeft: fixRowHeaders ? rowHeaderWidth : null}}>
<div className="table-scroller">
<table
{...remainingProps}
className={classNames(myClassNames)}
>
{children}
</table>
</div>
</div>
</div>
);
}
export const TableHead: React.SFC<React.HTMLAttributes<HTMLTableSectionElement>> = (props) => {
const {
className,
children,
...remainingProps
} = props;
return (
<thead {...remainingProps} className={classNames('table-head', className)}>
{children}
</thead>
);
};
export const TableBody: React.SFC<React.HTMLAttributes<HTMLTableSectionElement>> = (props) => {
const {
className,
children,
...remainingProps
} = props;
return (
<tbody {...remainingProps} className={classNames('table-body', className)}>
{children}
</tbody>
);
};
export const TableRow: React.SFC<React.HTMLAttributes<HTMLTableRowElement>> = (props) => {
const {
className,
children,
...remainingProps
} = props;
return (
<tr {...remainingProps} className={classNames('table-row', className)}>
{children}
</tr>
);
};
export interface ITableCellProps {
width?: number | string;
}
export const TableHeader: React.SFC<ITableCellProps & React.HTMLAttributes<HTMLTableHeaderCellElement>> = (props) => {
const {
className,
children,
style,
width,
...remainingProps
} = props;
return (
<th
{...remainingProps}
className={classNames('table-header', className)}
style={{width, maxWidth: width, ...style}}
>
{children || NBSP}
</th>
);
};
export const TableCell: React.SFC<ITableCellProps & React.HTMLAttributes<HTMLTableCellElement>> = (props) => {
const {
className,
children,
style,
width,
...remainingProps
} = props;
return (
<td
{...remainingProps}
className={classNames('table-cell', className)}
style={{width, maxWidth: width, ...style}}
>
{children || NBSP}
</td>
);
};
|