• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cartesi / rollups-explorer / 10316192769

09 Aug 2024 08:31AM CUT coverage: 93.625% (-0.1%) from 93.722%
10316192769

Pull #223

github

nevendyulgerov
chore: Upgrade mantine packages
Pull Request #223: #220 Upgrade mantine packages

1137 of 1357 branches covered (83.79%)

Branch coverage included in aggregate %.

18 of 18 new or added lines in 4 files covered. (100.0%)

11 existing lines in 2 files now uncovered.

12403 of 13105 relevant lines covered (94.64%)

40.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.63
/apps/web/src/components/responsiveTable.tsx
1
import React, { Fragment, PropsWithChildren, ReactNode, useRef } from "react";
1✔
2
import {
1✔
3
    Loader,
1✔
4
    Paper,
1✔
5
    Table,
1✔
6
    Text,
1✔
7
    Transition,
1✔
8
    useMantineColorScheme,
1✔
9
    useMantineTheme,
1✔
10
} from "@mantine/core";
1✔
11
import TableResponsiveWrapper from "./tableResponsiveWrapper";
1✔
12
import { useElementVisibility } from "../hooks/useElementVisibility";
1✔
13

1✔
14
export interface Column<T> {
1✔
15
    key: string;
1✔
16
    label: ReactNode;
1✔
17
    sticky?: boolean;
1✔
18
    render: (item: T) => ReactNode;
1✔
19
}
1✔
20

1✔
21
interface ResponsiveTableProps<T> {
1✔
22
    columns: Column<T>[];
1✔
23
    items: T[];
1✔
24
    totalCount: number;
1✔
25
    fetching?: boolean;
1✔
26
    emptyLabel?: string;
1✔
27
}
1✔
28

1✔
29
const ResponsiveTable = <T extends { id: string | number }>(
1✔
30
    props: PropsWithChildren<ResponsiveTableProps<T>>,
9✔
31
) => {
9✔
32
    const {
9✔
33
        columns,
9✔
34
        items,
9✔
35
        totalCount,
9✔
36
        fetching = false,
9✔
37
        emptyLabel = "No entries found",
9✔
38
    } = props;
9✔
39
    const tableRowRef = useRef<HTMLDivElement>(null);
9✔
40
    const theme = useMantineTheme();
9✔
41
    const { colorScheme } = useMantineColorScheme();
9✔
42
    const bgColor = colorScheme === "dark" ? theme.colors.dark[7] : theme.white;
9!
43
    const { childrenRef, isVisible } = useElementVisibility({
9✔
44
        element: tableRowRef,
9✔
45
    });
9✔
46

9✔
47
    return (
9✔
48
        <TableResponsiveWrapper ref={tableRowRef}>
9✔
49
            <Table
9✔
50
                width={"100%"}
9✔
51
                style={{ borderCollapse: "collapse" }}
9✔
52
                data-testid="applications-table"
9✔
53
            >
9✔
54
                <Table.Thead>
9✔
55
                    <Table.Tr>
9✔
56
                        {columns.map((column) => (
9✔
57
                            <Fragment key={column.key}>
28✔
58
                                <Table.Th
28✔
59
                                    ref={column.sticky ? childrenRef : null}
28✔
60
                                >
28✔
61
                                    {column.label}
28✔
62
                                </Table.Th>
28✔
63
                                {column.sticky && (
28✔
64
                                    <Transition
5✔
65
                                        mounted={isVisible}
5✔
66
                                        transition="scale-x"
5✔
67
                                        duration={500}
5✔
68
                                        timingFunction="ease-out"
5✔
69
                                    >
5✔
70
                                        {(styles) => (
5✔
71
                                            <th
×
72
                                                style={{
×
73
                                                    ...styles,
×
74
                                                    position: "sticky",
×
75
                                                    top: 0,
×
76
                                                    right: 0,
×
77
                                                    backgroundColor: bgColor,
×
78
                                                    padding:
×
79
                                                        "var(--table-vertical-spacing) var(--table-horizontal-spacing, var(--mantine-spacing-lg))",
×
80
                                                }}
×
81
                                            >
×
82
                                                {column.label}
×
83
                                            </th>
×
84
                                        )}
5✔
85
                                    </Transition>
5✔
86
                                )}
28✔
87
                            </Fragment>
28✔
88
                        ))}
9✔
89
                    </Table.Tr>
9✔
90
                </Table.Thead>
9✔
91

9✔
92
                <Table.Tbody>
9✔
93
                    {fetching ? (
9✔
94
                        <Table.Tr>
1✔
95
                            <Table.Td align="center" colSpan={columns.length}>
1✔
96
                                <Loader data-testid="table-spinner" />
1✔
97
                            </Table.Td>
1✔
98
                        </Table.Tr>
1✔
99
                    ) : (
8✔
100
                        totalCount === 0 && (
8✔
101
                            <Table.Tr>
6✔
102
                                <Table.Td
6✔
103
                                    colSpan={columns.length}
6✔
104
                                    align="center"
6✔
105
                                >
6✔
106
                                    <Text fw={700}>{emptyLabel}</Text>
6✔
107
                                </Table.Td>
6✔
108
                            </Table.Tr>
6✔
109
                        )
9✔
110
                    )}
9✔
111

9✔
112
                    {items.map((item) => (
9✔
113
                        <Table.Tr key={item.id}>
8✔
114
                            {columns.map((column) => (
8✔
115
                                <Fragment key={`${item.id}-${column.key}`}>
16✔
116
                                    {column.sticky ? (
16!
117
                                        <Table.Td
×
118
                                            pos={
×
119
                                                isVisible ? "sticky" : "initial"
×
120
                                            }
×
121
                                            top={0}
×
122
                                            right={0}
×
123
                                            p={0}
×
124
                                        >
×
125
                                            <Paper
×
126
                                                shadow={
×
127
                                                    isVisible ? "xl" : undefined
×
128
                                                }
×
129
                                                radius={0}
×
130
                                                p="var(--table-vertical-spacing) var(--table-horizontal-spacing, var(--mantine-spacing-xs))"
×
131
                                            >
×
132
                                                {column.render(item)}
×
133
                                            </Paper>
×
134
                                        </Table.Td>
×
135
                                    ) : (
16✔
136
                                        <Table.Td>
16✔
137
                                            {column.render(item)}
16✔
138
                                        </Table.Td>
16✔
139
                                    )}
16✔
140
                                </Fragment>
16✔
141
                            ))}
8✔
142
                        </Table.Tr>
8✔
143
                    ))}
9✔
144
                </Table.Tbody>
9✔
145
            </Table>
9✔
146
        </TableResponsiveWrapper>
9✔
147
    );
9✔
148
};
9✔
149

1✔
150
export default ResponsiveTable;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc