-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import './styles.css'; | ||
|
||
import { nanoid } from 'nanoid'; | ||
import { ReactNode } from 'react'; | ||
|
||
interface IRow { | ||
row: Array<string | ReactNode>; | ||
} | ||
|
||
interface ITable { | ||
headers: string[]; | ||
rows: IRow[]; | ||
} | ||
|
||
export const Table = (props: ITable) => { | ||
const { headers, rows } = props; | ||
|
||
return ( | ||
<div className="table__container"> | ||
<table> | ||
<thead> | ||
<tr> | ||
{headers.map((header) => ( | ||
<th key={nanoid()}>{header}</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{rows.map((row) => ( | ||
<tr key={nanoid()}> | ||
{row.row.map((content) => ( | ||
<td key={nanoid()}>{content}</td> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
.table__container { | ||
display: flex; | ||
justify-content: center; | ||
/* margin: 20vh auto; */ | ||
width: full; | ||
/* background-color: #fff; */ | ||
/* border-radius: 10px; */ | ||
/* padding: 5px; */ | ||
} | ||
|
||
table { | ||
width: 100%; | ||
/* box-shadow: 15px 15px #ffffff0d; */ | ||
border-collapse: collapse; | ||
} | ||
|
||
tr:nth-of-type(odd) { | ||
background-color: #006cc6; | ||
color: #fff; | ||
} | ||
tr:nth-of-type(even) { | ||
background-color: #fff; | ||
color: #333; | ||
} | ||
|
||
th { | ||
background-color: #330835; | ||
color: #fff; | ||
font-weight: 800; | ||
font-size: 20px; | ||
} | ||
|
||
td, | ||
th { | ||
padding: 12px; | ||
/* border: 1px solid #ccc; */ | ||
vertical-align: baseline; | ||
} | ||
|
||
@media only screen and (max-width: 768px), | ||
(min-device-width: 768px) and (max-device-width: 992px) { | ||
.table-container { | ||
width: 95%; | ||
background: transparent; | ||
} | ||
|
||
table, | ||
thead, | ||
tbody, | ||
th, | ||
td, | ||
tr { | ||
display: block; | ||
} | ||
|
||
thead tr { | ||
position: absolute; | ||
top: -9999px; | ||
left: -9999px; | ||
} | ||
|
||
tr { | ||
border: 1px solid #ccc; | ||
margin-bottom: 10px; | ||
} | ||
|
||
td { | ||
border: none; | ||
border-bottom: 1px solid #eee; | ||
position: relative; | ||
padding-left: 50%; | ||
text-align: right; | ||
} | ||
|
||
td::before { | ||
position: absolute; | ||
top: 6px; | ||
left: 6px; | ||
width: 45%; | ||
padding-right: 10px; | ||
white-space: nowrap; | ||
font-size: 16px; | ||
font-weight: 600; | ||
text-align: left; | ||
} | ||
|
||
td:nth-of-type(1)::before { | ||
content: '#'; | ||
} | ||
|
||
td:nth-of-type(2)::before { | ||
content: 'Full Name'; | ||
} | ||
|
||
td:nth-of-type(3)::before { | ||
content: 'Age'; | ||
} | ||
|
||
td:nth-of-type(4)::before { | ||
content: 'Status'; | ||
} | ||
|
||
td:nth-of-type(5)::before { | ||
content: 'Job Title'; | ||
} | ||
|
||
td:nth-of-type(6)::before { | ||
content: 'Action'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters