Skip to content

Commit 543d2a2

Browse files
author
Kubit
committed
Add new prop to genericComponent link
1 parent 58b06f8 commit 543d2a2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/provider/genericComponents/defaultGenericComponents.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Link = React.forwardRef(function Link(props: IGenericLink, ref: unknown) {
66
return (
77
<a
88
ref={ref as React.LegacyRef<HTMLAnchorElement> | undefined}
9+
aria-current={props['aria-current']}
910
aria-describedby={props['aria-describedby']}
1011
aria-disabled={props['aria-disabled']}
1112
aria-label={props['aria-label']}

src/provider/genericComponents/genericComponents.type.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import React from 'react';
22

33
import { ROLES } from '@/types/role';
44

5+
type GenericLinkAriaAttributes = Pick<
6+
React.AriaAttributes,
7+
'aria-label' | 'aria-describedby' | 'aria-disabled' | 'aria-current'
8+
>;
9+
510
/**
611
* Defines the properties for a generic link component.
712
* @property {string} url - The URL the link points to.
@@ -10,6 +15,8 @@ import { ROLES } from '@/types/role';
1015
* @property {string} [target] - Specifies where to open the linked document.
1116
* @property {boolean} [aria-disabled] - Indicates that the element is perceivable but disabled.
1217
* @property {string} [aria-label] - Defines a string value that labels the current element.
18+
* @property {string} [aria-describedby] - Defines a string value that labels the current element.
19+
* @property {string} [aria-current] - Defines value for the current element.
1320
* @property {() => void} [onClick] - Function to call when the link is clicked.
1421
* @property {() => void} [onFocus] - Function to call when the link is focused.
1522
* @property {() => void} [onMouseEnter] - Function to call when the mouse enters the link area.
@@ -23,16 +30,14 @@ export type IGenericLink = {
2330
children: string | JSX.Element;
2431
className?: string;
2532
target?: string;
26-
['aria-disabled']?: boolean;
27-
['aria-label']?: string;
2833
onClick?: () => void;
2934
onFocus?: () => void;
3035
onMouseEnter?: () => void;
3136
onMouseLeave?: () => void;
3237
role?: ROLES;
3338
dataTestId?: string;
3439
draggable?: boolean;
35-
};
40+
} & GenericLinkAriaAttributes;
3641

3742
/**
3843
* Defines the type for a generic link component, which can be either a functional component or a forward ref component.

0 commit comments

Comments
 (0)