Skip to content

Commit

Permalink
Connect UnitInfo color button to show the ColorPickerDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jul 19, 2017
1 parent ede7d5c commit 8ad59aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/common/components/ColorPicker/colorPickerActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {
openModal
} from "features/modals/modalActions";

export function showColorPicker(initialColor) {
return openModal("ColorPickerDialog", {color : initialColor});
}
11 changes: 10 additions & 1 deletion src/features/unitInfo/UnitInfo/UnitInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {

import {selectUnitInfo} from "../unitInfoSelectors";
import {updateUnitInfo} from "../unitInfoActions";
import {showColorPicker} from "common/components/ColorPicker/colorPickerActions";
import {getValueFromEvent} from "common/utils/clientUtils";

import FormEditWrapper from "common/components/FormEditWrapper";
Expand All @@ -30,6 +31,7 @@ const mapState = (state) => ({

const actions = {
updateUnitInfo,
showColorPicker,
};

class UnitInfo extends Component {
Expand All @@ -46,6 +48,10 @@ class UnitInfo extends Component {
this.props.updateUnitInfo(newValues);
}

onColorClicked = () => {
this.props.showColorPicker(this.props.unitInfo.color);
}


render() {
const {unitInfo, updateUnitInfo} = this.props;
Expand Down Expand Up @@ -80,7 +86,10 @@ class UnitInfo extends Component {
</Form.Field>
<Form.Field name="color">
<label>Color</label>
<ColorPickerButton value={color} />
<ColorPickerButton
value={color}
onClick={this.onColorClicked}
/>
</Form.Field>
</Form>
</Segment>
Expand Down

0 comments on commit 8ad59aa

Please sign in to comment.