Skip to content

Commit 9955b04

Browse files
author
Kubit
committed
Add decorativeElement prop to navigationRow
1 parent d3e3b4c commit 9955b04

File tree

8 files changed

+52
-2
lines changed

8 files changed

+52
-2
lines changed

src/components/navigationCard/navigationCardStandAlone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const NavigationCardStandaloneComponent = (
3636
return (
3737
// Can not be spread -> styled component breaks
3838
<NavigationCardStyled
39-
ref={ref as any}
39+
ref={ref as React.ForwardedRef<HTMLButtonElement>}
4040
aria-disabled={props['aria-disabled']}
4141
as={props.url ? props.component : 'button'}
4242
className={props.className}

src/components/navigationRow/__tests__/navigationRow.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as React from 'react';
55

66
import { axe } from 'jest-axe';
77

8+
import { ElementOrIcon } from '@/components/elementOrIcon';
89
import { IconHighlightedSizeType, IconHighlightedType } from '@/components/iconHighlighted';
910
import { renderProvider } from '@/tests/renderProvider/renderProvider.utility';
1011

@@ -71,4 +72,18 @@ describe('NavigationRow component', () => {
7172
const iconHighlighted = screen.getByRole('img', { name: 'Alt Text', hidden: false });
7273
expect(iconHighlighted).toBeDefined();
7374
});
75+
it('Should show component with decorativeElement', () => {
76+
const decorativeElement = (
77+
<ElementOrIcon icon={'ICON_PLACEHOLDER'} altText="decorativeElement" />
78+
);
79+
renderProvider(
80+
<NavigationRow
81+
{...mockProps}
82+
decorativeElement={decorativeElement}
83+
description={{ content: 'Description' }}
84+
/>
85+
);
86+
const iconHighlighted = screen.getByRole('img', { name: 'decorativeElement' });
87+
expect(iconHighlighted).toBeDefined();
88+
});
7489
});

src/components/navigationRow/navigationRow.styled.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ export const TextSectionStyled = styled.span<INavigationRowStyled>`
2929
export const IconAndIconHighlightedContainerStyled = styled.span<INavigationRowStyled>`
3030
${({ styles }) => getStyles(styles?.iconTextContainer)}
3131
`;
32+
33+
export const DecorativeElementContainerStyled = styled.span<INavigationRowStyled>`
34+
${({ styles }) => getStyles(styles?.decorativeElementContainer)}
35+
`;

src/components/navigationRow/navigationRowStandAlone.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { TextComponentType } from '@/components/text/types/component';
77

88
import { IconHighlighted } from '../iconHighlighted';
99
import {
10+
DecorativeElementContainerStyled,
1011
IconAndIconHighlightedContainerStyled,
1112
NavigationRowStyled,
1213
TextSectionStyled,
@@ -53,6 +54,9 @@ const NavigationRowStandaloneComponent = (
5354
/>
5455
)}
5556
</IconAndIconHighlightedContainerStyled>
57+
<DecorativeElementContainerStyled styles={props.styles}>
58+
{props.decorativeElement}
59+
</DecorativeElementContainerStyled>
5660
<TextSectionStyled styles={props.styles}>
5761
{props.text && (
5862
<Text

src/components/navigationRow/stories/argtypes.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ export const argtypes = (variants: IThemeObjectVariants, themeSelected: string):
5454
category: CATEGORY_CONTROL.CONTENT,
5555
},
5656
},
57+
decorativeElement: {
58+
description: 'Decorative element',
59+
type: { name: 'object' },
60+
control: { type: 'object' },
61+
table: {
62+
type: {
63+
summary: 'React.ReactNode',
64+
},
65+
category: CATEGORY_CONTROL.CONTENT,
66+
},
67+
},
5768
iconHighlighted: {
5869
description: 'Highlighted icon',
5970
type: { name: 'object' },

src/components/navigationRow/stories/navigationRow.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { Meta, StoryObj } from '@storybook/react';
2+
import * as React from 'react';
23

34
import { ICONS } from '@/assets';
5+
import { ElementOrIcon } from '@/components/elementOrIcon';
46
import { STYLES_NAME } from '@/constants';
57
import { themesObject, variantsObject } from '@/designSystem/themesObject';
68

@@ -26,7 +28,7 @@ const commonArgs: INavigationRow = {
2628
text: { content: 'Text' },
2729
description: { content: 'Lorem ipsum dolor sit amet lorem' },
2830
arrowIcon: { icon: ICONS.ICON_PLACEHOLDER },
29-
decorativeIcon: { icon: ICONS.ICON_PLACEHOLDER },
31+
decorativeElement: <ElementOrIcon icon={ICONS.ICON_PLACEHOLDER} altText="decorativeElement" />,
3032
};
3133

3234
export const NavigationRow: Story = {

src/components/navigationRow/types/navigationRow.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@ export interface INavigationRowStandAlone {
2525
description?: NavigationRowTextAndDescriptionType;
2626
// icons
2727
arrowIcon: IElementOrIcon;
28+
/**
29+
* @deprecated this prop will be removed in the next major version. Use decorativeElement to send the IconHighlighted
30+
*/
2831
iconHighlighted?: NavigationRowIconHighlightedType;
32+
/**
33+
* @deprecated this prop will be removed in the next major version. Use decorativeElement to send the ElementOrIcon
34+
*/
2935
decorativeIcon?: IElementOrIcon;
36+
decorativeElement?: React.ReactNode;
3037
// lines
3138
topLine?: boolean;
3239
bottomLine?: boolean;

src/components/navigationRow/types/navigationRowTheme.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ export type NavigationRowStylesPropsType = {
1010
// description
1111
descriptionContainer?: CommonStyleType;
1212
description?: TypographyTypes;
13+
decorativeElementContainer?: CommonStyleType;
1314
// icons
1415
arrowIcon?: IconTypes;
16+
/**
17+
* @deprecated remove when deconrativeIcon props is removed in the next major version.
18+
*/
1519
decorativeIcon?: IconTypes;
20+
/**
21+
* @deprecated remove when deconrativeIcon props is removed in the next major version.
22+
*/
1623
iconHighlighted?: {
1724
variant: string;
1825
color: string;

0 commit comments

Comments
 (0)