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

glideapps / glide-data-grid / 7435539780

07 Jan 2024 02:33AM CUT coverage: 90.255% (+3.8%) from 86.42%
7435539780

Pull #810

github

web-flow
Merge c2dbff45d into 3068d54a9
Pull Request #810: 6.0.0

2629 of 3279 branches covered (0.0%)

16144 of 17887 relevant lines covered (90.26%)

2994.04 hits per line

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

60.0
/packages/core/src/cells/loading-cell.tsx
1
import { withAlpha } from "../internal/data-grid/color-parser.js";
1✔
2
import { roundedRect } from "../internal/data-grid/data-grid-lib.js";
1✔
3
import { GridCellKind, type LoadingCell } from "../internal/data-grid/data-grid-types.js";
1✔
4
import type { InternalCellRenderer } from "./cell-types.js";
1✔
5

1✔
6
// returns a "random" number between -1 and 1
1✔
7
function getRandomNumber(x: number, y: number): number {
×
8
    let seed = x * 49_632 + y * 325_176;
×
9

×
10
    // Inline Xorshift algorithm
×
11
    seed ^= seed << 13;
×
12
    seed ^= seed >> 17;
×
13
    seed ^= seed << 5;
×
14

×
15
    // eslint-disable-next-line unicorn/number-literal-case
×
16
    return (seed / 0xff_ff_ff_ff) * 2;
×
17
}
×
18

1✔
19
export const loadingCellRenderer: InternalCellRenderer<LoadingCell> = {
1✔
20
    getAccessibilityString: () => "",
1✔
21
    kind: GridCellKind.Loading,
1✔
22
    needsHover: false,
1✔
23
    useLabel: false,
1✔
24
    needsHoverPosition: false,
1✔
25
    measure: () => 120,
1✔
26
    draw: a => {
1✔
27
        const { cell, col, row, ctx, rect, theme } = a;
98✔
28
        if (cell.skeletonWidth === undefined || cell.skeletonWidth === 0) {
98!
29
            return;
98✔
30
        }
98!
31

×
32
        let width = cell.skeletonWidth;
×
33
        if (cell.skeletonWidthVariability !== undefined && cell.skeletonWidthVariability > 0) {
98!
34
            width += Math.round(getRandomNumber(col, row) * cell.skeletonWidthVariability);
×
35
        }
×
36

×
37
        const hpad = theme.cellHorizontalPadding;
×
38
        const rectHeight = cell.skeletonHeight ?? Math.min(18, rect.height - 2 * theme.cellVerticalPadding);
×
39

98✔
40
        roundedRect(ctx, rect.x + hpad, rect.y + (rect.height - rectHeight) / 2, width, rectHeight, 3);
98✔
41
        ctx.fillStyle = withAlpha(theme.textDark, 0.1);
98✔
42
        ctx.fill();
98✔
43
    },
98✔
44
    onPaste: () => undefined,
1✔
45
};
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