Skip to content

Commit 8b558d7

Browse files
authored
chore: allow to use ReactNode in label/title (#340)
1 parent af7de88 commit 8b558d7

File tree

21 files changed

+37
-35
lines changed

21 files changed

+37
-35
lines changed

src/components/Alert/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919

2020
export interface DialAlertProps extends HTMLAttributes<HTMLDivElement> {
2121
variant?: AlertVariant;
22-
message: string | ReactNode;
22+
message: ReactNode;
2323
closable?: boolean;
2424
iconSize?: number;
2525
iconStroke?: number;

src/components/Button/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface DialButtonProps
1717
> {
1818
variant?: ButtonVariant;
1919
textClassName?: string;
20-
label?: string;
20+
label?: ReactNode;
2121
iconBefore?: ReactNode;
2222
iconAfter?: ReactNode;
2323
hideTitleOnMobile?: boolean;
@@ -74,7 +74,7 @@ export const DialButton: FC<DialButtonProps> = ({
7474
{...props}
7575
type={type}
7676
className={btnClassName}
77-
aria-label={label || props['aria-label']}
77+
aria-label={(typeof label === 'string' && label) || props['aria-label']}
7878
>
7979
<DialIcon icon={iconBefore} />
8080
{label && <span className={btnTextClassName}>{label}</span>}

src/components/Checkbox/Checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DialEllipsisTooltip } from '@/components/EllipsisTooltip/EllipsisToolti
1414
export interface DialCheckboxProps
1515
extends Omit<LabelHTMLAttributes<HTMLLabelElement>, 'onChange'> {
1616
id: string;
17-
label?: string | ReactNode;
17+
label?: ReactNode;
1818
checked: boolean;
1919
disabled?: boolean;
2020
indeterminate?: boolean;

src/components/CollapsibleSidebar/CollapsibleSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { mergeClasses } from '@/utils/merge-classes';
1515
export interface DialCollapsibleSidebarProps {
1616
children: ReactNode;
1717
width?: number;
18-
title: string;
18+
title: ReactNode;
1919
titleClassName?: string;
2020
containerClassName?: string;
2121
iconSize?: number;

src/components/ConfirmationPopup/ConfirmationPopup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ButtonVariant } from '@/types/button';
1616
import { PopupSize } from '@/types/popup';
1717

1818
export interface DialConfirmationPopupProps extends DialPopupProps {
19-
description?: string | ReactNode;
19+
description?: ReactNode;
2020
descriptionClassName?: string;
2121
confirmLabel?: string;
2222
cancelLabel?: string;

src/components/Dropdown/Dropdown.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable react-hooks/rules-of-hooks */
22
import type { Meta, StoryObj } from '@storybook/react-vite';
3-
import { useRef, useState } from 'react';
3+
import { useRef, useState, type ReactNode } from 'react';
44
import type { Placement } from '@floating-ui/react';
55
import {
66
IconUser,
@@ -59,7 +59,7 @@ const specItems: DropdownItem[] = [
5959
{ key: 'del', label: 'Delete', icon: <IconTrash size={16} />, danger: true },
6060
];
6161

62-
const TriggerBtn = ({ label = 'Open' }: { label?: string }) => (
62+
const TriggerBtn = ({ label = 'Open' }: { label?: ReactNode }) => (
6363
<DialButton
6464
variant={ButtonVariant.Primary}
6565
iconAfter={<IconChevronDown size={16} />}

src/components/EllipsisTooltip/EllipsisTooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { tooltipContentBaseClassName } from './constants';
99
import { mergeClasses } from '@/utils/merge-classes';
1010

1111
export interface DialEllipsisTooltipProps extends DialTooltipContainerOptions {
12-
text: string | ReactNode;
12+
text: ReactNode;
1313
className?: string;
1414
contentClassName?: string;
1515
hideTooltip?: boolean;

src/components/Field/Field.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type NativeLabelProps = Omit<
1010
>;
1111

1212
export interface DialFieldLabelProps extends NativeLabelProps {
13-
fieldTitle?: string | ReactNode;
13+
fieldTitle?: ReactNode;
1414
optional?: boolean;
1515
optionalText?: string;
1616
description?: string;

src/components/FileIcon/FileIcon.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface DialFileIconProps {
1212
stroke?: number;
1313
className?: string;
1414
decorative?: boolean;
15-
label?: string;
15+
label?: ReactNode;
1616
indicator?: ReactNode;
1717
}
1818

@@ -58,7 +58,9 @@ export const DialFileIcon: FC<DialFileIconProps> = ({
5858
});
5959

6060
const computedLabel =
61-
label ?? `${normalized.slice(1).toUpperCase()} file icon`;
61+
typeof label === 'string'
62+
? label
63+
: `${normalized.slice(1).toUpperCase()} file icon`;
6264

6365
return (
6466
<span

src/components/FileManager/FileManager.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export interface FileMetadataPopupOptions {
133133
fileMetadata?: DialFile;
134134
loading?: boolean;
135135
clearMetadata?: () => void;
136-
title?: string;
136+
title?: ReactNode;
137137
nameLabel?: string;
138138
pathLabel?: string;
139139
modifiedDateLabel?: string;
@@ -144,7 +144,7 @@ export interface FileMetadataPopupOptions {
144144
export interface FileTreeOptions
145145
extends Omit<DialFoldersTreeProps, 'items' | 'selectedPath' | 'onItemClick'> {
146146
width?: number;
147-
title?: string;
147+
title?: ReactNode;
148148
containerClassName?: string;
149149
additionalButtons?: ReactNode;
150150
collapsed?: boolean;
@@ -165,7 +165,7 @@ export interface FileTreeOptions
165165

166166
export interface DeleteConfirmationOptions {
167167
cancelLabel?: string;
168-
titleRenderer?: (fileNames: string[]) => ReactNode | string;
168+
titleRenderer?: (fileNames: string[]) => ReactNode;
169169
confirmLabel?: string;
170170
contentRenderer?: (fileNames: string[]) => ReactNode;
171171
}

0 commit comments

Comments
 (0)