Commit 59b5f887 by ryan

rename handleXXX to onXX events

parent aa7e3486
...@@ -39,7 +39,7 @@ class ColorInput extends React.PureComponent<ColorInputProps, ColorInputState> { ...@@ -39,7 +39,7 @@ class ColorInput extends React.PureComponent<ColorInputProps, ColorInputState> {
this.props.onChange(color); this.props.onChange(color);
}; };
handleChange = (event: React.SyntheticEvent<HTMLInputElement>) => { onChange = (event: React.SyntheticEvent<HTMLInputElement>) => {
const newColor = tinycolor(event.currentTarget.value); const newColor = tinycolor(event.currentTarget.value);
this.setState({ this.setState({
...@@ -51,7 +51,7 @@ class ColorInput extends React.PureComponent<ColorInputProps, ColorInputState> { ...@@ -51,7 +51,7 @@ class ColorInput extends React.PureComponent<ColorInputProps, ColorInputState> {
} }
}; };
handleBlur = () => { onBlur = () => {
const newColor = tinycolor(this.state.value); const newColor = tinycolor(this.state.value);
if (!newColor.isValid()) { if (!newColor.isValid()) {
...@@ -84,7 +84,7 @@ class ColorInput extends React.PureComponent<ColorInputProps, ColorInputState> { ...@@ -84,7 +84,7 @@ class ColorInput extends React.PureComponent<ColorInputProps, ColorInputState> {
flexGrow: 1, flexGrow: 1,
}} }}
> >
<input className="gf-form-input" value={value} onChange={this.handleChange} onBlur={this.handleBlur} /> <input className="gf-form-input" value={value} onChange={this.onChange} onBlur={this.onBlur} />
</div> </div>
</div> </div>
); );
......
...@@ -15,7 +15,7 @@ export const colorPickerFactory = <T extends ColorPickerProps>( ...@@ -15,7 +15,7 @@ export const colorPickerFactory = <T extends ColorPickerProps>(
static displayName = displayName; static displayName = displayName;
pickerTriggerRef = createRef<HTMLDivElement>(); pickerTriggerRef = createRef<HTMLDivElement>();
handleColorChange = (color: string) => { onColorChange = (color: string) => {
const { onColorChange, onChange } = this.props; const { onColorChange, onChange } = this.props;
const changeHandler = (onColorChange || onChange) as ColorPickerChangeHandler; const changeHandler = (onColorChange || onChange) as ColorPickerChangeHandler;
...@@ -25,7 +25,7 @@ export const colorPickerFactory = <T extends ColorPickerProps>( ...@@ -25,7 +25,7 @@ export const colorPickerFactory = <T extends ColorPickerProps>(
render() { render() {
const popoverElement = React.createElement(popover, { const popoverElement = React.createElement(popover, {
...this.props, ...this.props,
onChange: this.handleColorChange, onChange: this.onColorChange,
}); });
const { theme, children } = this.props; const { theme, children } = this.props;
......
...@@ -60,7 +60,7 @@ export class ColorPickerPopover<T extends CustomPickersDescriptor> extends React ...@@ -60,7 +60,7 @@ export class ColorPickerPopover<T extends CustomPickersDescriptor> extends React
changeHandler(getColorFromHexRgbOrName(color, theme.type)); changeHandler(getColorFromHexRgbOrName(color, theme.type));
}; };
handleTabChange = (tab: PickerType | keyof T) => { onTabChange = (tab: PickerType | keyof T) => {
return () => this.setState({ activePicker: tab }); return () => this.setState({ activePicker: tab });
}; };
...@@ -104,7 +104,7 @@ export class ColorPickerPopover<T extends CustomPickersDescriptor> extends React ...@@ -104,7 +104,7 @@ export class ColorPickerPopover<T extends CustomPickersDescriptor> extends React
<> <>
{Object.keys(customPickers).map(key => { {Object.keys(customPickers).map(key => {
return ( return (
<div className={this.getTabClassName(key)} onClick={this.handleTabChange(key)} key={key}> <div className={this.getTabClassName(key)} onClick={this.onTabChange(key)} key={key}>
{customPickers[key].name} {customPickers[key].name}
</div> </div>
); );
...@@ -119,10 +119,10 @@ export class ColorPickerPopover<T extends CustomPickersDescriptor> extends React ...@@ -119,10 +119,10 @@ export class ColorPickerPopover<T extends CustomPickersDescriptor> extends React
return ( return (
<div className={`ColorPickerPopover ColorPickerPopover--${colorPickerTheme}`}> <div className={`ColorPickerPopover ColorPickerPopover--${colorPickerTheme}`}>
<div className="ColorPickerPopover__tabs"> <div className="ColorPickerPopover__tabs">
<div className={this.getTabClassName('palette')} onClick={this.handleTabChange('palette')}> <div className={this.getTabClassName('palette')} onClick={this.onTabChange('palette')}>
Colors Colors
</div> </div>
<div className={this.getTabClassName('spectrum')} onClick={this.handleTabChange('spectrum')}> <div className={this.getTabClassName('spectrum')} onClick={this.onTabChange('spectrum')}>
Custom Custom
</div> </div>
{this.renderCustomPickerTabs()} {this.renderCustomPickerTabs()}
......
...@@ -37,7 +37,7 @@ export const ToggleButton: FC<ToggleButtonProps> = ({ ...@@ -37,7 +37,7 @@ export const ToggleButton: FC<ToggleButtonProps> = ({
tooltip, tooltip,
onChange, onChange,
}) => { }) => {
const handleChange = event => { const onClick = event => {
event.stopPropagation(); event.stopPropagation();
if (onChange) { if (onChange) {
onChange(value); onChange(value);
...@@ -46,7 +46,7 @@ export const ToggleButton: FC<ToggleButtonProps> = ({ ...@@ -46,7 +46,7 @@ export const ToggleButton: FC<ToggleButtonProps> = ({
const btnClassName = `btn ${className} ${selected ? 'active' : ''}`; const btnClassName = `btn ${className} ${selected ? 'active' : ''}`;
const button = ( const button = (
<button className={btnClassName} onClick={handleChange}> <button className={btnClassName} onClick={onClick}>
<span>{children}</span> <span>{children}</span>
</button> </button>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment