Skip to content

Commit

Permalink
Refactor #1917 - For ColorPicker
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent 77c5238 commit 88d526e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/colorpicker/ColorPicker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface ColorPickerProps {
inputId?: string;
tooltip?: string;
tooltipOptions?: TooltipOptions;
transitionOptions?: object;
onChange?(e: ChangeParams): void;
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/colorpicker/ColorPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class ColorPicker extends Component {
inputId: null,
tooltip: null,
tooltipOptions: null,
transitionOptions: null,
onChange: null
}

Expand All @@ -44,6 +45,7 @@ export class ColorPicker extends Component {
inputId: PropTypes.string,
tooltip: PropTypes.string,
tooltipOptions: PropTypes.object,
transitionOptions: PropTypes.object,
onChange: PropTypes.func
}

Expand Down Expand Up @@ -697,7 +699,8 @@ export class ColorPicker extends Component {
<div ref={(el) => this.container = el} id={this.props.id} style={this.props.style} className={containerClassName}>
{input}
<ColorPickerPanel ref={this.overlayRef} appendTo={this.props.appendTo} inline={this.props.inline} disabled={this.props.disabled} onClick={this.onPanelClick}
in={this.props.inline || this.state.overlayVisible} onEnter={this.onOverlayEnter} onEntered={this.onOverlayEntered} onExit={this.onOverlayExit} onExited={this.onOverlayExited}>
in={this.props.inline || this.state.overlayVisible} onEnter={this.onOverlayEnter} onEntered={this.onOverlayEntered} onExit={this.onOverlayExit} onExited={this.onOverlayExited}
transitionOptions={this.props.transitionOptions}>
{content}
</ColorPickerPanel>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/colorpicker/ColorPickerPanel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { classNames } from '../utils/ClassNames';
import { CSSTransition } from 'react-transition-group';
import { CSSTransition } from '../transition/CSSTransition';
import { Portal } from '../portal/Portal';

class ColorPickerPanelComponent extends Component {
Expand All @@ -27,7 +27,7 @@ class ColorPickerPanelComponent extends Component {
});

return (
<CSSTransition nodeRef={this.props.forwardRef} classNames="p-connected-overlay" in={this.props.in} timeout={{ enter: 120, exit: 100 }}
<CSSTransition nodeRef={this.props.forwardRef} classNames="p-connected-overlay" in={this.props.in} timeout={{ enter: 120, exit: 100 }} options={this.props.transitionOptions}
unmountOnExit onEnter={this.props.onEnter} onEntered={this.props.onEntered} onExit={this.props.onExit} onExited={this.props.onExited}>
<div ref={this.props.forwardRef} className={className} onClick={this.props.onClick}>
{this.props.children}
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/colorpicker/ColorPickerDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ import {ColorPicker} from 'primereact/colorpicker';
<td>null</td>
<td>Configuration of the tooltip, refer to the tooltip documentation for more information.</td>
</tr>
<tr>
<td>transitionOptions</td>
<td>object</td>
<td>null</td>
<td>The properties of <a href="https://reactcommunity.org/react-transition-group/css-transition" rel="noopener noreferrer" target="_blank">CSSTransition</a> can be customized, except for "nodeRef" and "in" properties.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 88d526e

Please sign in to comment.