|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
import ReactDOM from 'react-dom';
|
|
import ReactDOM from 'react-dom';
|
|
|
import $ from 'jquery';
|
|
import $ from 'jquery';
|
|
|
import Drop from 'tether-drop';
|
|
import Drop from 'tether-drop';
|
|
|
-import coreModule from 'app/core/core_module';
|
|
|
|
|
import { ColorPickerPopover } from './ColorPickerPopover';
|
|
import { ColorPickerPopover } from './ColorPickerPopover';
|
|
|
|
|
+import { react2AngularDirective } from 'app/core/utils/react2angular';
|
|
|
|
|
|
|
|
export interface IProps {
|
|
export interface IProps {
|
|
|
color: string;
|
|
color: string;
|
|
@@ -27,9 +27,7 @@ export class ColorPicker extends React.Component<IProps, any> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
openColorPicker() {
|
|
openColorPicker() {
|
|
|
- const dropContent = (
|
|
|
|
|
- <ColorPickerPopover color={this.props.color} onColorSelect={this.onColorSelect} />
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ const dropContent = <ColorPickerPopover color={this.props.color} onColorSelect={this.onColorSelect} />;
|
|
|
|
|
|
|
|
let dropContentElem = document.createElement('div');
|
|
let dropContentElem = document.createElement('div');
|
|
|
ReactDOM.render(dropContent, dropContentElem);
|
|
ReactDOM.render(dropContent, dropContentElem);
|
|
@@ -38,12 +36,12 @@ export class ColorPicker extends React.Component<IProps, any> {
|
|
|
target: this.pickerElem[0],
|
|
target: this.pickerElem[0],
|
|
|
content: dropContentElem,
|
|
content: dropContentElem,
|
|
|
position: 'top center',
|
|
position: 'top center',
|
|
|
- classes: 'drop-popover drop-popover--form',
|
|
|
|
|
- openOn: 'hover',
|
|
|
|
|
|
|
+ classes: 'drop-popover',
|
|
|
|
|
+ openOn: 'click',
|
|
|
hoverCloseDelay: 200,
|
|
hoverCloseDelay: 200,
|
|
|
tetherOptions: {
|
|
tetherOptions: {
|
|
|
- constraints: [{ to: 'scrollParent', attachment: "none both" }]
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ constraints: [{ to: 'scrollParent', attachment: 'none both' }],
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
drop.on('close', this.closeColorPicker);
|
|
drop.on('close', this.closeColorPicker);
|
|
@@ -68,17 +66,14 @@ export class ColorPicker extends React.Component<IProps, any> {
|
|
|
return (
|
|
return (
|
|
|
<div className="sp-replacer sp-light" onClick={this.openColorPicker} ref={this.setPickerElem}>
|
|
<div className="sp-replacer sp-light" onClick={this.openColorPicker} ref={this.setPickerElem}>
|
|
|
<div className="sp-preview">
|
|
<div className="sp-preview">
|
|
|
- <div className="sp-preview-inner" style={{backgroundColor: this.props.color}}>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div className="sp-preview-inner" style={{ backgroundColor: this.props.color }} />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-coreModule.directive('colorPicker', function (reactDirective) {
|
|
|
|
|
- return reactDirective(ColorPicker, [
|
|
|
|
|
- 'color',
|
|
|
|
|
- ['onChange', { watchDepth: 'reference', wrapApply: true }]
|
|
|
|
|
- ]);
|
|
|
|
|
-});
|
|
|
|
|
|
|
+react2AngularDirective('colorPicker', ColorPicker, [
|
|
|
|
|
+ 'color',
|
|
|
|
|
+ ['onChange', { watchDepth: 'reference', wrapApply: true }],
|
|
|
|
|
+]);
|