@conduction/components 2.2.54 → 2.2.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +1,80 @@
1
- import * as React from "react";
2
- import * as styles from "./HorizontalOverflowWrapper.module.css";
3
- import clsx from "clsx";
4
- import { Button } from "@utrecht/component-library-react/dist/css-module";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import { faChevronLeft, faChevronRight } from "@fortawesome/free-solid-svg-icons";
7
-
8
- interface HorizontalOverflowWrapperProps {
9
- children: React.ReactNode;
10
- ariaLabels: {
11
- scrollRightButton: string;
12
- scrollLeftButton: string;
13
- };
14
- }
15
-
16
- export const HorizontalOverflowWrapper: React.FC<HorizontalOverflowWrapperProps> = ({ children, ariaLabels }) => {
17
- const [canScrollRight, setCanScrollRight] = React.useState<boolean>(false);
18
- const [canScrollLeft, setCanScrollLeft] = React.useState<boolean>(false);
19
-
20
- const wrapperRef = React.useRef<HTMLDivElement | null>(null);
21
-
22
- const scrollRight = (): void => {
23
- wrapperRef.current?.scrollTo({
24
- left: wrapperRef.current.scrollLeft + wrapperRef.current.clientWidth * 0.9,
25
- behavior: "smooth",
26
- });
27
- };
28
-
29
- const scrollLeft = (): void => {
30
- wrapperRef.current?.scrollTo({
31
- left: wrapperRef.current.scrollLeft - wrapperRef.current.clientWidth * 0.9,
32
- behavior: "smooth",
33
- });
34
- };
35
-
36
- React.useEffect(() => {
37
- checkScrollDirections(); // initiate available scroll directions
38
-
39
- window.addEventListener("resize", checkScrollDirections);
40
-
41
- return () => window.removeEventListener("resize", checkScrollDirections);
42
- }, []);
43
-
44
- const checkScrollDirections = (): void => {
45
- if (!wrapperRef.current) return;
46
-
47
- setCanScrollRight(wrapperRef.current.scrollLeft + wrapperRef.current.clientWidth < wrapperRef.current.scrollWidth);
48
- setCanScrollLeft(wrapperRef.current.scrollLeft > 0);
49
- };
50
-
51
- return (
52
- <div className={styles.container}>
53
- {canScrollLeft && (
54
- <Button
55
- className={clsx(styles.scrollButton)}
56
- onClick={scrollLeft}
57
- appearance="secondary-action-button"
58
- aria-label={ariaLabels.scrollLeftButton}
59
- >
60
- <FontAwesomeIcon icon={faChevronLeft} />
61
- </Button>
62
- )}
63
-
64
- {canScrollRight && (
65
- <Button
66
- className={clsx(styles.scrollButton, styles.right)}
67
- onClick={scrollRight}
68
- appearance="secondary-action-button"
69
- aria-label={ariaLabels.scrollRightButton}
70
- >
71
- <FontAwesomeIcon icon={faChevronRight} />
72
- </Button>
73
- )}
74
-
75
- <div ref={wrapperRef} className={styles.wrapper} onScroll={checkScrollDirections}>
76
- {children}
77
- </div>
78
- </div>
79
- );
80
- };
1
+ import * as React from "react";
2
+ import * as styles from "./HorizontalOverflowWrapper.module.css";
3
+ import clsx from "clsx";
4
+ import { Button } from "@utrecht/component-library-react/dist/css-module";
5
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
+ import { faChevronLeft, faChevronRight } from "@fortawesome/free-solid-svg-icons";
7
+
8
+ interface HorizontalOverflowWrapperProps {
9
+ children: React.ReactNode;
10
+ ariaLabels: {
11
+ scrollRightButton: string;
12
+ scrollLeftButton: string;
13
+ };
14
+ }
15
+
16
+ export const HorizontalOverflowWrapper: React.FC<HorizontalOverflowWrapperProps> = ({ children, ariaLabels }) => {
17
+ const [canScrollRight, setCanScrollRight] = React.useState<boolean>(false);
18
+ const [canScrollLeft, setCanScrollLeft] = React.useState<boolean>(false);
19
+
20
+ const wrapperRef = React.useRef<HTMLDivElement | null>(null);
21
+
22
+ const scrollRight = (): void => {
23
+ wrapperRef.current?.scrollTo({
24
+ left: wrapperRef.current.scrollLeft + wrapperRef.current.clientWidth * 0.9,
25
+ behavior: "smooth",
26
+ });
27
+ };
28
+
29
+ const scrollLeft = (): void => {
30
+ wrapperRef.current?.scrollTo({
31
+ left: wrapperRef.current.scrollLeft - wrapperRef.current.clientWidth * 0.9,
32
+ behavior: "smooth",
33
+ });
34
+ };
35
+
36
+ React.useEffect(() => {
37
+ checkScrollDirections(); // initiate available scroll directions
38
+
39
+ window.addEventListener("resize", checkScrollDirections);
40
+
41
+ return () => window.removeEventListener("resize", checkScrollDirections);
42
+ }, []);
43
+
44
+ const checkScrollDirections = (): void => {
45
+ if (!wrapperRef.current) return;
46
+
47
+ setCanScrollRight(wrapperRef.current.scrollLeft + wrapperRef.current.clientWidth < wrapperRef.current.scrollWidth);
48
+ setCanScrollLeft(wrapperRef.current.scrollLeft > 0);
49
+ };
50
+
51
+ return (
52
+ <div className={styles.container}>
53
+ {canScrollLeft && (
54
+ <Button
55
+ className={clsx(styles.scrollButton)}
56
+ onClick={scrollLeft}
57
+ appearance="secondary-action-button"
58
+ aria-label={ariaLabels.scrollLeftButton}
59
+ >
60
+ <FontAwesomeIcon icon={faChevronLeft} />
61
+ </Button>
62
+ )}
63
+
64
+ {canScrollRight && (
65
+ <Button
66
+ className={clsx(styles.scrollButton, styles.right)}
67
+ onClick={scrollRight}
68
+ appearance="secondary-action-button"
69
+ aria-label={ariaLabels.scrollRightButton}
70
+ >
71
+ <FontAwesomeIcon icon={faChevronRight} />
72
+ </Button>
73
+ )}
74
+
75
+ <div ref={wrapperRef} className={styles.wrapper} onScroll={checkScrollDirections}>
76
+ {children}
77
+ </div>
78
+ </div>
79
+ );
80
+ };
@@ -1,21 +1,24 @@
1
- import * as React from "react";
2
- import * as styles from "./Logo.module.css";
3
- import clsx from "clsx";
4
-
5
- interface LogoProps {
6
- variant?: "header" | "footer" | "navbar";
7
- onClick?: () => any;
8
- layoutClassName?: string;
9
- }
10
-
11
- export const Logo: React.FC<LogoProps> = ({ onClick, layoutClassName, variant = "header" }) => {
12
- return (
13
- <div
14
- className={clsx(styles.container, styles[variant], [
15
- onClick && styles.clickable,
16
- layoutClassName && layoutClassName,
17
- ])}
18
- {...{ onClick }}
19
- />
20
- );
21
- };
1
+ import * as React from "react";
2
+ import * as styles from "./Logo.module.css";
3
+ import clsx from "clsx";
4
+
5
+ interface LogoProps {
6
+ variant?: "header" | "footer" | "navbar";
7
+ onClick?: () => any;
8
+ layoutClassName?: string;
9
+ ariaLabel?: string;
10
+ }
11
+
12
+ export const Logo: React.FC<LogoProps> = ({ onClick, layoutClassName, variant = "header", ariaLabel = "logo" }) => {
13
+ return (
14
+ <div
15
+ className={clsx(styles.container, styles[variant], [
16
+ onClick && styles.clickable,
17
+ layoutClassName && layoutClassName,
18
+ ])}
19
+ role="img"
20
+ aria-label={ariaLabel}
21
+ {...{ onClick }}
22
+ />
23
+ );
24
+ };