Skip to content

Commit c3b3ffb

Browse files
authored
Merge branch 'development' into fix/th-125-fix-header
2 parents 638e443 + 9314c32 commit c3b3ffb

File tree

6 files changed

+105
-8
lines changed

6 files changed

+105
-8
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Works on Firefox */
2+
html {
3+
scrollbar-color: $scroll-bar-thumb rgba(238 239 242 / 50%);
4+
scrollbar-width: thin;
5+
}
6+
7+
/* Works on Chrome, Edge, and Safari */
8+
body::-webkit-scrollbar {
9+
width: 3px;
10+
background: $scroll-bar;
11+
border-radius: 5px;
12+
opacity: 0.5;
13+
}
14+
15+
body::-webkit-scrollbar-thumb {
16+
background: $scroll-bar-thumb;
17+
border-radius: 5px;
18+
}

frontend/src/assets/css/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
@import "./scaffolding.scss";
44
@import "./typography.scss";
55
@import "./animations.scss";
6+
@import "./scroll-bar.scss";

frontend/src/assets/css/vars.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ $green: #00ca99;
1717
$background-color-grey: #f6f7f9;
1818
$body-background: #f6f7f9;
1919
$header-background: #000955;
20+
$scroll-bar: #e6e8eb;
21+
$scroll-bar-thumb: #3563ad;
2022
$shadow-light: 0 4px 8px -2px rgb(0 85 255 / 16%);
2123
$shadow: 0 2px 4px -2px rgb(0 44 132 / 6%);
2224
$font-family: "Plus Jakarta Sans", sans-serif;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const DEFAULT_COLUMN = {
2+
minSize: 50,
3+
maxSize: 300,
4+
};
5+
6+
export { DEFAULT_COLUMN };

frontend/src/libs/components/table/styles.module.scss

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,77 @@
1616

1717
.thead {
1818
color: white;
19-
background-color: #000b6a;
19+
background-color: $header-background;
2020
}
2121

2222
.th,
2323
.td {
2424
padding: 10px 15px;
25+
border: 1px solid white;
26+
}
27+
28+
.th {
29+
position: relative;
30+
}
31+
32+
.resizer {
33+
position: absolute;
34+
top: 0;
35+
right: 0;
36+
width: 5px;
37+
height: 100%;
38+
background: $grey;
39+
cursor: col-resize;
40+
opacity: 0.5;
41+
user-select: none;
42+
touch-action: none;
43+
}
44+
45+
.resizer.isResizing {
46+
background: $red;
47+
opacity: 1;
2548
}
2649

2750
.th:first-child {
51+
border: none;
2852
border-top-left-radius: 8px;
2953
}
3054

3155
.th:last-child {
56+
border: none;
3257
border-top-right-radius: 8px;
58+
59+
.resizer {
60+
border-top-right-radius: 8px;
61+
}
3362
}
3463

35-
.tr {
36-
border-bottom: 1px solid white;
64+
.td {
65+
text-align: center;
3766
}
3867

3968
.tr:nth-child(even) {
4069
background-color: #b9d1f1fa;
4170
}
4271

4372
.tr:last-child {
44-
border: none;
45-
4673
.td:first-child {
74+
border: none;
4775
border-bottom-left-radius: 8px;
4876
}
4977

5078
.td:last-child {
79+
border: none;
5180
border-bottom-right-radius: 8px;
5281
}
5382
}
83+
84+
@media (hover: hover) {
85+
.resizer {
86+
opacity: 0;
87+
}
88+
89+
*:hover > .resizer {
90+
opacity: 1;
91+
}
92+
}

frontend/src/libs/components/table/table.tsx

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getValidClassNames } from '~/libs/helpers/helpers.js';
12
import {
23
flexRender,
34
getCoreRowModel,
@@ -8,6 +9,7 @@ import {
89
import { type ColumnDef } from '~/libs/types/types.js';
910

1011
import { Pagination } from '../pagination/pagination.jsx';
12+
import { DEFAULT_COLUMN } from './libs/constant.js';
1113
import styles from './styles.module.scss';
1214

1315
type Properties<T> = {
@@ -33,6 +35,8 @@ const Table = <T,>({
3335
const table = useReactTable({
3436
data,
3537
columns,
38+
columnResizeMode: 'onChange',
39+
defaultColumn: DEFAULT_COLUMN,
3640
getCoreRowModel: getCoreRowModel(),
3741
getPaginationRowModel: getPaginationRowModel(),
3842
initialState: {
@@ -56,13 +60,29 @@ const Table = <T,>({
5660
{table.getHeaderGroups().map((headerGroup) => (
5761
<tr key={headerGroup.id} className={styles.tr}>
5862
{headerGroup.headers.map((header) => (
59-
<th key={header.id} className={styles.th}>
63+
<th
64+
key={header.id}
65+
className={styles.th}
66+
style={{
67+
width: header.getSize(),
68+
}}
69+
>
6070
{header.isPlaceholder
6171
? null
6272
: flexRender(
6373
header.column.columnDef.header,
6474
header.getContext(),
6575
)}
76+
<div
77+
{...{
78+
onMouseDown: header.getResizeHandler(),
79+
onTouchStart: header.getResizeHandler(),
80+
className: getValidClassNames(
81+
styles.resizer,
82+
header.column.getIsResizing() && styles.isResizing,
83+
),
84+
}}
85+
/>
6686
</th>
6787
))}
6888
</tr>
@@ -75,7 +95,13 @@ const Table = <T,>({
7595
{table.getRowModel().rows.map((row) => (
7696
<tr key={row.id} className={styles.tr}>
7797
{row.getVisibleCells().map((cell) => (
78-
<td key={cell.id} className={styles.td}>
98+
<td
99+
key={cell.id}
100+
className={styles.td}
101+
style={{
102+
width: cell.column.getSize(),
103+
}}
104+
>
79105
{flexRender(cell.column.columnDef.cell, cell.getContext())}
80106
</td>
81107
))}
@@ -86,7 +112,12 @@ const Table = <T,>({
86112

87113
return (
88114
<div className={styles.container}>
89-
<table className={styles.table}>
115+
<table
116+
className={styles.table}
117+
style={{
118+
width: table.getCenterTotalSize(),
119+
}}
120+
>
90121
{createThead()}
91122
{createTbody()}
92123
</table>

0 commit comments

Comments
 (0)