Skip to content

Commit

Permalink
Add Dialog icon templating support Related - #4226
Browse files Browse the repository at this point in the history
  • Loading branch information
ulasturann committed Apr 11, 2023
1 parent a2c0d49 commit 6c7c30f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions components/lib/dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { CSSTransition } from '../csstransition/CSSTransition';
import { useEventListener, useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { Portal } from '../portal/Portal';
import { Ripple } from '../ripple/Ripple';
import { classNames, DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from '../utils/Utils';
import { classNames, DomHandler, IconUtils, ObjectUtils, UniqueComponentId, ZIndexUtils } from '../utils/Utils';
import { DialogBase } from './DialogBase';
import { TimesIcon } from '../icon/times';

export const Dialog = React.forwardRef((inProps, ref) => {
const props = DialogBase.getProps(inProps);
Expand Down Expand Up @@ -412,10 +413,13 @@ export const Dialog = React.forwardRef((inProps, ref) => {
const createCloseIcon = () => {
if (props.closable) {
const ariaLabel = props.ariaCloseIconLabel || localeOption('close');
const iconProps = { className: 'p-dialog-header-close-icon', 'aria-hidden': true };
const icon = props.closeIcon || <TimesIcon {...iconProps} />;
const headerCloseIcon = IconUtils.getJSXIcon(icon, { ...iconProps }, { props });

return (
<button ref={closeRef} type="button" className="p-dialog-header-icon p-dialog-header-close p-link" aria-label={ariaLabel} onClick={onClose}>
<span className="p-dialog-header-close-icon pi pi-times" aria-hidden="true"></span>
{headerCloseIcon}
<Ripple />
</button>
);
Expand Down
1 change: 1 addition & 0 deletions components/lib/dialog/DialogBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const DialogBase = {
breakpoints: null,
className: null,
closable: true,
closeIcon: null,
closeOnEscape: true,
contentClassName: null,
contentStyle: null,
Expand Down
5 changes: 5 additions & 0 deletions components/lib/dialog/dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
import * as React from 'react';
import { CSSTransitionProps } from '../csstransition';
import { IconType } from '../utils/utils';

/**
* Dialog break options
Expand Down Expand Up @@ -119,6 +120,10 @@ export interface DialogProps {
* Style class of the header section.
*/
headerClassName?: string | undefined;
/**
* Icon to display in the dialog close button.
*/
closeIcon?: IconType<DialogProps> | undefined;
/**
* Style of the header section.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dropdown/dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
*/
className?: string | undefined;
/**
* Icon class of the dropdown icon.
* Icon of the dropdown.
*/
clearIcon?: IconType<DropdownProps> | undefined;
/**
Expand Down

0 comments on commit 6c7c30f

Please sign in to comment.