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

jackyr / react-fancy-carousel / 4497110656

pending completion
4497110656

push

github

jackyr
feat: unfinished

75 of 84 branches covered (89.29%)

Branch coverage included in aggregate %.

21 of 21 new or added lines in 2 files covered. (100.0%)

83 of 96 relevant lines covered (86.46%)

21.56 hits per line

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

80.43
/src/utils.ts
1
import { useRef, useCallback } from 'react';
2

3
export const classNames = (...args: Array<string | {[key: string]: boolean} | undefined>) => {
2✔
4
  return args.reduce<(string | undefined)[]>((p, c) => p.concat(
507✔
5
    typeof c === 'string' ? c : c && Object.keys(c).map(v => c[v] ? v : ''),
165✔
6
  ), []).filter(Boolean).join(' ');
7
};
8

9
export const reOrder = (targetIndex: number, length: number) => {
2✔
10
  const middle = Math.ceil(length / 2);
×
11
  return Array.from({ length }).map((_, i) => {
×
12
    const diff = middle - (targetIndex + 1);
×
13
    const order = (diff < 0 ? diff + length : diff) + i + 1;
×
14
    return order > length ? order - length : order;
×
15
  });
16
};
17

18
export const useUid = () => useRef(Math.random().toString(36).substring(2, 7)).current;
39✔
19

20
export const useAccessibility = () => {
2✔
21
  return useCallback((e: React.KeyboardEvent<HTMLElement>) => {
33✔
22
    e.preventDefault();
6✔
23
    e.stopPropagation();
6✔
24
    const parentNode = e.currentTarget.parentNode as HTMLElement;
6✔
25
    const childNodeArr = Array.from(parentNode.childNodes) as HTMLElement[];
6✔
26
    const currentFocusIndex = childNodeArr.findIndex(v => v === e.currentTarget);
8✔
27
    if (e.key === 'Enter' || e.key === ' ') e.currentTarget.click();
6✔
28
    if (e.key === 'ArrowRight') {
6✔
29
      if (currentFocusIndex === childNodeArr.length - 1) childNodeArr[0].focus();
2✔
30
      else childNodeArr[currentFocusIndex + 1].focus();
1✔
31
    }
32
    if (e.key === 'ArrowLeft') {
6✔
33
      if (currentFocusIndex === 0) childNodeArr[childNodeArr.length - 1].focus();
2✔
34
      else childNodeArr[currentFocusIndex - 1].focus();
1✔
35
    }
36
  }, []);
37
};
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

© 2026 Coveralls, Inc