Skip to content

Commit 8e3004d

Browse files
leweohlsenchrvadala
authored andcommitted
Allow changing the active tool color via props. (#168)
* Allow changing the active tool color via props. * Document the changes. * Visualize the changes in the viewer storyboard.
1 parent 69b5b19 commit 8e3004d

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

docs/documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
| toolbarProps.position | `right` | one of `none`, `top`, `right`, `bottom`, `left` | Toolbar position |
4848
| toolbarProps.SVGAlignX | `left` | one of `left`, `center`, `right` | X Alignment used for "Fit to Viewer" action |
4949
| toolbarProps.SVGAlignY | `top` | one of `top`, `center`, `bottom` | Y Alignment used for "Fit to Viewer" action |
50+
| toolbarProps.activeToolColor | `#1CA6FC` | String | Color of active and hovered tool icons |
5051

5152
\* handler available only with the tool `none` or `auto`
5253

src/ui-toolbar/toolbar-button.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class ToolbarButton extends React.Component {
3535
width: "24px",
3636
height: "24px",
3737
margin: [POSITION_TOP, POSITION_BOTTOM].indexOf(this.props.toolbarPosition) >= 0 ? "2px 1px" : "1px 2px",
38-
color: this.props.active || this.state.hover ? '#1CA6FC' : '#FFF',
38+
color: this.props.active || this.state.hover ? this.props.activeColor : '#FFF',
3939
transition: "color 200ms ease",
4040
background: "none",
4141
padding: "0px",
@@ -72,6 +72,7 @@ ToolbarButton.propTypes = {
7272
title: PropTypes.string.isRequired,
7373
name: PropTypes.string.isRequired,
7474
toolbarPosition: PropTypes.string.isRequired,
75+
activeColor: PropTypes.string.isRequired,
7576
onClick: PropTypes.func.isRequired,
7677
active: PropTypes.bool.isRequired
7778
};

src/ui-toolbar/toolbar.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import IconZoomOut from './icon-zoom-out';
1414
import IconFit from './icon-fit';
1515
import ToolbarButton from './toolbar-button';
1616

17-
export default function Toolbar({tool, value, onChangeValue, onChangeTool, position, SVGAlignX, SVGAlignY}) {
17+
export default function Toolbar({tool, value, onChangeValue, onChangeTool, activeToolColor, position, SVGAlignX, SVGAlignY}) {
1818

1919
let handleChangeTool = (event, tool) => {
2020
onChangeTool(tool);
@@ -52,6 +52,7 @@ export default function Toolbar({tool, value, onChangeValue, onChangeTool, posit
5252
<ToolbarButton
5353
toolbarPosition={position}
5454
active={tool === TOOL_NONE}
55+
activeColor={activeToolColor}
5556
name="unselect-tools"
5657
title="Selection"
5758
onClick={ event => handleChangeTool(event, TOOL_NONE) }>
@@ -61,6 +62,7 @@ export default function Toolbar({tool, value, onChangeValue, onChangeTool, posit
6162
<ToolbarButton
6263
toolbarPosition={position}
6364
active={tool === TOOL_PAN}
65+
activeColor={activeToolColor}
6466
name="select-tool-pan"
6567
title="Pan"
6668
onClick={ event => handleChangeTool(event, TOOL_PAN) }>
@@ -70,6 +72,7 @@ export default function Toolbar({tool, value, onChangeValue, onChangeTool, posit
7072
<ToolbarButton
7173
toolbarPosition={position}
7274
active={tool === TOOL_ZOOM_IN}
75+
activeColor={activeToolColor}
7376
name="select-tool-zoom-in"
7477
title="Zoom in"
7578
onClick={ event => handleChangeTool(event, TOOL_ZOOM_IN) }>
@@ -79,6 +82,7 @@ export default function Toolbar({tool, value, onChangeValue, onChangeTool, posit
7982
<ToolbarButton
8083
toolbarPosition={position}
8184
active={tool === TOOL_ZOOM_OUT}
85+
activeColor={activeToolColor}
8286
name="select-tool-zoom-out"
8387
title="Zoom out"
8488
onClick={ event => handleChangeTool(event, TOOL_ZOOM_OUT) }>
@@ -88,6 +92,7 @@ export default function Toolbar({tool, value, onChangeValue, onChangeTool, posit
8892
<ToolbarButton
8993
toolbarPosition={position}
9094
active={false}
95+
activeColor={activeToolColor}
9196
name="fit-to-viewer"
9297
title="Fit to viewer"
9398
onClick={ event => handleFit(event) }>
@@ -107,10 +112,12 @@ Toolbar.propTypes = {
107112
position: PropTypes.oneOf([POSITION_TOP, POSITION_RIGHT, POSITION_BOTTOM, POSITION_LEFT]),
108113
SVGAlignX: PropTypes.oneOf([ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT]),
109114
SVGAlignY: PropTypes.oneOf([ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM]),
115+
activeToolColor: PropTypes.string
110116
};
111117

112118
Toolbar.defaultProps = {
113119
position: POSITION_RIGHT,
114120
SVGAlignX: ALIGN_LEFT,
115-
SVGAlignY: ALIGN_TOP
121+
SVGAlignY: ALIGN_TOP,
122+
activeToolColor: '#1CA6FC'
116123
};

src/viewer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ ReactSVGPanZoom.propTypes = {
597597
position: PropTypes.oneOf([POSITION_NONE, POSITION_TOP, POSITION_RIGHT, POSITION_BOTTOM, POSITION_LEFT]),
598598
SVGAlignX: PropTypes.oneOf([ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT]),
599599
SVGAlignY: PropTypes.oneOf([ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM]),
600+
activeToolColor: PropTypes.string,
600601
}),
601602

602603
/**************************************************************************/

storybook/stories/ViewerStory.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ export default class MainStory extends Component {
138138
[ALIGN_CENTER]: ALIGN_CENTER,
139139
[ALIGN_BOTTOM]: ALIGN_BOTTOM
140140
}, ALIGN_TOP),
141+
142+
activeToolColor: color('toolbarProps.activeToolColor', '#1CA6FC'),
141143
}}
142144

143145
miniatureProps={{

0 commit comments

Comments
 (0)