-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
htmlTable.tsx
60 lines (53 loc) · 1.77 KB
/
htmlTable.tsx
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
/*
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the terms of the LICENSE file distributed with this project.
*/
import classNames from "classnames";
import * as React from "react";
import {
HTML_TABLE,
HTML_TABLE_BORDERED,
HTML_TABLE_CONDENSED,
HTML_TABLE_STRIPED,
INTERACTIVE,
SMALL,
} from "../../common/classes";
import { IElementRefProps } from "../html/html";
export interface IHTMLTableProps
extends React.TableHTMLAttributes<HTMLTableElement>,
IElementRefProps<HTMLTableElement> {
/** Enables borders between rows and cells. */
bordered?: boolean;
/** Use small, condensed appearance. */
condensed?: boolean;
/** Enables hover styles on row. */
interactive?: boolean;
/**
* Use small, condensed appearance for this element and all child elements.
* @deprecated
*/
small?: boolean;
/** Use an alternate background color on odd rows. */
striped?: boolean;
}
// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
export class HTMLTable extends React.PureComponent<IHTMLTableProps> {
public render() {
const { bordered, className, condensed, elementRef, interactive, small, striped, ...htmlProps } = this.props;
const classes = classNames(
HTML_TABLE,
{
[HTML_TABLE_BORDERED]: bordered,
[HTML_TABLE_CONDENSED]: condensed,
[HTML_TABLE_STRIPED]: striped,
[INTERACTIVE]: interactive,
[SMALL]: small,
},
className,
);
// tslint:disable-next-line:blueprint-html-components
return <table {...htmlProps} ref={elementRef} className={classes} />;
}
}