Skip to content

Commit 26ff8fa

Browse files
committed
Add the Table component.
1 parent 0f4cb7a commit 26ff8fa

File tree

8 files changed

+128
-2
lines changed

8 files changed

+128
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The components in this library will be described below.
3333
- [Pagination](https://github.com/macroing/simple-react-components/tree/master/documentation/pagination) provides a component that defines a pagination.
3434
- [Select](https://github.com/macroing/simple-react-components/tree/master/documentation/select) provides a component that defines a select.
3535
- [TabPane](https://github.com/macroing/simple-react-components/tree/master/documentation/tab-pane) provides a component that defines a tab pane.
36+
- [Table](https://github.com/macroing/simple-react-components/tree/master/documentation/table) provides a component that defines a table.
3637
- [TextArea](https://github.com/macroing/simple-react-components/tree/master/documentation/text-area) provides a component that defines a text area.
3738

3839
## Font Awesome

dist/index/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index/src/Table.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import e from"./Table.module.css.js";import{jsx as l}from"react/jsx-runtime";function t(t){let{children:r,styles:s,...a}=t;return null==s&&(s=e),l("table",{className:s.table,...a,children:r})}export{t as default};

dist/index/src/Table.module.css.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/table/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# `Table`

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import OptionList from "./src/OptionList";
1313
import Pagination from "./src/Pagination";
1414
import Select from "./src/Select";
1515
import TabPane from "./src/TabPane";
16+
import Table from "./src/Table";
1617
import TextArea from "./src/TextArea";
1718

18-
export { Button, DesktopMenuBar, Dialog, Footer, Form, ImageViewer, Input, Jumbotron, LinkButton, MenuBar, MobileMenuBar, OptionList, Pagination, Select, TabPane, TextArea };
19+
export { Button, DesktopMenuBar, Dialog, Footer, Form, ImageViewer, Input, Jumbotron, LinkButton, MenuBar, MobileMenuBar, OptionList, Pagination, Select, TabPane, Table, TextArea };

src/Table.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import importedStyles from "./Table.module.css";
2+
3+
export default function Table(props) {
4+
let { children, styles, ...rest } = props;
5+
6+
//If no styles property has been assigned, the imported CSS module will be used for styling.
7+
if (styles === null || styles === undefined) {
8+
styles = importedStyles;
9+
}
10+
11+
return (
12+
<table className={styles.table} {...rest}>
13+
{children}
14+
</table>
15+
);
16+
}

src/Table.module.css

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.table {
2+
--src-table-background-color: #f6f6f6;
3+
--src-table-background-color-even: #f6f6f6;
4+
--src-table-background-color-odd: #ffffff;
5+
--src-table-border-color: #dddddd;
6+
--src-table-color: #333333;
7+
8+
border: 1px solid var(--src-table-border-color);
9+
border-collapse: collapse;
10+
border-spacing: 0px;
11+
box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.12);
12+
table-layout: fixed;
13+
width: 100%;
14+
}
15+
16+
.table > tbody {
17+
border: 1px solid var(--src-table-border-color);
18+
}
19+
20+
.table > tbody > tr {
21+
background: linear-gradient(rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 50%, transparent 50%, rgba(255, 255, 255, 0.1) 100%);
22+
border-bottom: 1px solid var(--src-table-border-color);
23+
border-top: 1px solid var(--src-table-border-color);
24+
}
25+
26+
.table > tbody > tr:first-child {
27+
border-top: none;
28+
}
29+
30+
.table > tbody > tr:last-child {
31+
border-bottom: none;
32+
}
33+
34+
.table > tbody > tr:nth-child(even) {
35+
background-color: var(--src-table-background-color-even);
36+
}
37+
38+
.table > tbody > tr:nth-child(odd) {
39+
background-color: var(--src-table-background-color-odd);
40+
}
41+
42+
.table > tbody > tr > td {
43+
border-left: 1px solid var(--src-table-border-color);
44+
border-right: 1px solid var(--src-table-border-color);
45+
color: var(--src-table-color);
46+
overflow: hidden;
47+
padding: 5px 10px 5px 10px;
48+
text-align: left;
49+
text-overflow: ellipsis;
50+
white-space: nowrap;
51+
}
52+
53+
.table > tbody > tr > td:first-child {
54+
border-left: none;
55+
}
56+
57+
.table > tbody > tr > td:last-child {
58+
border-right: none;
59+
}
60+
61+
.table > tbody > tr > th {
62+
border-left: 1px solid var(--src-table-border-color);
63+
border-right: 1px solid var(--src-table-border-color);
64+
overflow: hidden;
65+
padding: 5px 10px 5px 10px;
66+
text-align: left;
67+
text-overflow: ellipsis;
68+
white-space: nowrap;
69+
}
70+
71+
.table > tbody > tr > th:first-child {
72+
border-left: none;
73+
}
74+
75+
.table > tbody > tr > th:last-child {
76+
border-right: none;
77+
}
78+
79+
.table > thead {
80+
background-color: var(--src-table-background-color);
81+
border: 1px solid var(--src-table-border-color);
82+
}
83+
84+
.table > thead > tr {
85+
background: linear-gradient(rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 50%, transparent 50%, rgba(255, 255, 255, 0.1) 100%);
86+
}
87+
88+
.table > thead > tr > th {
89+
border-left: 1px solid var(--src-table-border-color);
90+
border-right: 1px solid var(--src-table-border-color);
91+
color: var(--src-table-color);
92+
overflow: hidden;
93+
padding: 5px 10px 5px 10px;
94+
text-align: left;
95+
text-overflow: ellipsis;
96+
white-space: nowrap;
97+
}
98+
99+
.table > thead > tr > th:first-child {
100+
border-left: none;
101+
}
102+
103+
.table > thead > tr > th:last-child {
104+
border-right: none;
105+
}

0 commit comments

Comments
 (0)