Upload 325 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .babelrc +9 -9
- .tx/config +8 -8
- src/components/arrow-mode/arrow-mode.jsx +21 -21
- src/components/arrow-mode/arrow.svg +7 -7
- src/components/arrow-mode/test.html +3 -3
- src/components/bit-brush-mode/bit-brush-mode.jsx +23 -23
- src/components/bit-brush-mode/brush.svg +9 -9
- src/components/bit-eraser-mode/bit-eraser-mode.jsx +23 -23
- src/components/bit-eraser-mode/eraser.svg +9 -9
- src/components/bit-fill-mode/bit-fill-mode.jsx +23 -23
- src/components/bit-fill-mode/fill.svg +9 -9
- src/components/bit-line-mode/bit-line-mode.jsx +22 -22
- src/components/bit-line-mode/line.svg +9 -9
- src/components/bit-oval-mode/bit-oval-mode.jsx +22 -22
- src/components/bit-oval-mode/oval-outlined.svg +18 -18
- src/components/bit-oval-mode/oval.svg +9 -9
- src/components/bit-rect-mode/bit-rect-mode.jsx +23 -23
- src/components/bit-rect-mode/rectangle-outlined.svg +9 -9
- src/components/bit-rect-mode/rectangle.svg +9 -9
- src/components/bit-select-mode/bit-select-mode.jsx +22 -22
- src/components/bit-select-mode/marquee.svg +9 -9
- src/components/bit-text-mode/bit-text-mode.jsx +23 -23
- src/components/bit-text-mode/text.svg +9 -9
- src/components/box/box.jsx +141 -141
- src/components/brush-mode/brush-mode.jsx +22 -22
- src/components/brush-mode/brush.svg +11 -11
- src/components/button-group/button-group.jsx +18 -18
- src/components/button/button.jsx +55 -55
- src/components/color-button/color-button.jsx +69 -69
- src/components/color-button/mixed-fill.svg +16 -16
- src/components/color-button/no-fill.svg +11 -11
- src/components/color-indicator.jsx +63 -63
- src/components/color-picker/color-picker.css +2 -2
- src/components/color-picker/color-picker.jsx +397 -397
- src/components/color-picker/icons/eye-dropper.svg +11 -11
- src/components/color-picker/icons/fill-horz-gradient-enabled.svg +15 -15
- src/components/color-picker/icons/fill-radial-enabled.svg +14 -14
- src/components/color-picker/icons/fill-solid-enabled.svg +9 -9
- src/components/color-picker/icons/fill-vert-gradient-enabled.svg +14 -14
- src/components/color-picker/icons/swap.svg +13 -13
- src/components/coming-soon/coming-soon.jsx +147 -147
- src/components/dragon-mode/dragon-mode.jsx +21 -21
- src/components/dropdown/dropdown-caret.svg +11 -11
- src/components/dropdown/dropdown.jsx +79 -79
- src/components/eraser-mode/eraser-mode.jsx +22 -22
- src/components/eraser-mode/eraser.svg +11 -11
- src/components/fill-mode/fill-mode.jsx +22 -22
- src/components/fill-mode/fill.svg +11 -11
- src/components/fixed-tools/fixed-tools.jsx +325 -325
- src/components/fixed-tools/icons/group.svg +24 -24
.babelrc
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
{
|
2 |
-
"plugins": [
|
3 |
-
"transform-object-rest-spread",
|
4 |
-
["react-intl", {
|
5 |
-
"messagesDir": "./translations/messages/"
|
6 |
-
}]
|
7 |
-
],
|
8 |
-
"presets": [["env", {"targets": {"browsers": ["last 3 versions", "Safari >= 8", "iOS >= 8"]}}], "react"]
|
9 |
-
}
|
|
|
1 |
+
{
|
2 |
+
"plugins": [
|
3 |
+
"transform-object-rest-spread",
|
4 |
+
["react-intl", {
|
5 |
+
"messagesDir": "./translations/messages/"
|
6 |
+
}]
|
7 |
+
],
|
8 |
+
"presets": [["env", {"targets": {"browsers": ["last 3 versions", "Safari >= 8", "iOS >= 8"]}}], "react"]
|
9 |
+
}
|
.tx/config
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
[main]
|
2 |
-
host = https://www.transifex.com
|
3 |
-
|
4 |
-
[scratch-editor.paint-editor]
|
5 |
-
file_filter = translations/<lang>.json
|
6 |
-
source_file = translations/en.json
|
7 |
-
source_lang = en
|
8 |
-
type = CHROME
|
|
|
1 |
+
[main]
|
2 |
+
host = https://www.transifex.com
|
3 |
+
|
4 |
+
[scratch-editor.paint-editor]
|
5 |
+
file_filter = translations/<lang>.json
|
6 |
+
source_file = translations/en.json
|
7 |
+
source_lang = en
|
8 |
+
type = CHROME
|
src/components/arrow-mode/arrow-mode.jsx
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import arrowIcon from './arrow.svg';
|
6 |
-
|
7 |
-
const ArrowModeComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.arrow}
|
10 |
-
imgSrc={arrowIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
/>
|
14 |
-
);
|
15 |
-
|
16 |
-
ArrowModeComponent.propTypes = {
|
17 |
-
isSelected: PropTypes.bool.isRequired,
|
18 |
-
onMouseDown: PropTypes.func.isRequired
|
19 |
-
};
|
20 |
-
|
21 |
-
export default ArrowModeComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import arrowIcon from './arrow.svg';
|
6 |
+
|
7 |
+
const ArrowModeComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.arrow}
|
10 |
+
imgSrc={arrowIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
/>
|
14 |
+
);
|
15 |
+
|
16 |
+
ArrowModeComponent.propTypes = {
|
17 |
+
isSelected: PropTypes.bool.isRequired,
|
18 |
+
onMouseDown: PropTypes.func.isRequired
|
19 |
+
};
|
20 |
+
|
21 |
+
export default ArrowModeComponent;
|
src/components/arrow-mode/arrow.svg
CHANGED
|
|
src/components/arrow-mode/test.html
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14.5"
|
2 |
height="14.5" viewBox="0,0,14.5,14.5">
|
3 |
<g transform="translate(-232.75,-172.75)">
|
4 |
<g data-paper-data="{"isPaintingLayer":true}" fill-rule="evenodd" stroke="none" stroke-width="1"
|
@@ -33,10 +33,10 @@
|
|
33 |
fill="#575e75" opacity="0.5" />
|
34 |
<path
|
35 |
d="M242.20833,175.54167c0,-1.24264 1.00736,-2.25 2.25,-2.25c1.24264,0 2.25,1.00736 2.25,2.25c0,1.24264 -1.00736,2.25 -2.25,2.25c-1.24264,0 -2.25,-1.00736 -2.25,-2.25z"
|
36 |
-
fill="#
|
37 |
<path
|
38 |
d="M233.20834,184.45833c0,-1.28866 1.04467,-2.33333 2.33333,-2.33333c1.28866,0 2.33333,1.04467 2.33333,2.33333c0,1.28866 -1.04467,2.33333 -2.33333,2.33333c-1.28866,0 -2.33333,-1.04467 -2.33333,-2.33333z"
|
39 |
-
fill="#
|
40 |
</g>
|
41 |
</g>
|
42 |
</svg><!--rotationCenter:7.25:7.25-->
|
|
|
1 |
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14.5"
|
2 |
height="14.5" viewBox="0,0,14.5,14.5">
|
3 |
<g transform="translate(-232.75,-172.75)">
|
4 |
<g data-paper-data="{"isPaintingLayer":true}" fill-rule="evenodd" stroke="none" stroke-width="1"
|
|
|
33 |
fill="#575e75" opacity="0.5" />
|
34 |
<path
|
35 |
d="M242.20833,175.54167c0,-1.24264 1.00736,-2.25 2.25,-2.25c1.24264,0 2.25,1.00736 2.25,2.25c0,1.24264 -1.00736,2.25 -2.25,2.25c-1.24264,0 -2.25,-1.00736 -2.25,-2.25z"
|
36 |
+
fill="#625edb" />
|
37 |
<path
|
38 |
d="M233.20834,184.45833c0,-1.28866 1.04467,-2.33333 2.33333,-2.33333c1.28866,0 2.33333,1.04467 2.33333,2.33333c0,1.28866 -1.04467,2.33333 -2.33333,2.33333c-1.28866,0 -2.33333,-1.04467 -2.33333,-2.33333z"
|
39 |
+
fill="#625edb" />
|
40 |
</g>
|
41 |
</g>
|
42 |
</svg><!--rotationCenter:7.25:7.25-->
|
src/components/bit-brush-mode/bit-brush-mode.jsx
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
|
6 |
-
import brushIcon from './brush.svg';
|
7 |
-
|
8 |
-
const BitBrushModeComponent = props => (
|
9 |
-
<ToolSelectComponent
|
10 |
-
imgDescriptor={messages.brush}
|
11 |
-
imgSrc={brushIcon}
|
12 |
-
isSelected={props.isSelected}
|
13 |
-
onMouseDown={props.onMouseDown}
|
14 |
-
keybinding="B"
|
15 |
-
/>
|
16 |
-
);
|
17 |
-
|
18 |
-
BitBrushModeComponent.propTypes = {
|
19 |
-
isSelected: PropTypes.bool.isRequired,
|
20 |
-
onMouseDown: PropTypes.func.isRequired
|
21 |
-
};
|
22 |
-
|
23 |
-
export default BitBrushModeComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
|
6 |
+
import brushIcon from './brush.svg';
|
7 |
+
|
8 |
+
const BitBrushModeComponent = props => (
|
9 |
+
<ToolSelectComponent
|
10 |
+
imgDescriptor={messages.brush}
|
11 |
+
imgSrc={brushIcon}
|
12 |
+
isSelected={props.isSelected}
|
13 |
+
onMouseDown={props.onMouseDown}
|
14 |
+
keybinding="B"
|
15 |
+
/>
|
16 |
+
);
|
17 |
+
|
18 |
+
BitBrushModeComponent.propTypes = {
|
19 |
+
isSelected: PropTypes.bool.isRequired,
|
20 |
+
onMouseDown: PropTypes.func.isRequired
|
21 |
+
};
|
22 |
+
|
23 |
+
export default BitBrushModeComponent;
|
src/components/bit-brush-mode/brush.svg
CHANGED
|
|
src/components/bit-eraser-mode/bit-eraser-mode.jsx
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import messages from '../../lib/messages.js';
|
4 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
-
|
6 |
-
import eraserIcon from './eraser.svg';
|
7 |
-
|
8 |
-
const BitEraserComponent = props => (
|
9 |
-
<ToolSelectComponent
|
10 |
-
imgDescriptor={messages.eraser}
|
11 |
-
imgSrc={eraserIcon}
|
12 |
-
isSelected={props.isSelected}
|
13 |
-
onMouseDown={props.onMouseDown}
|
14 |
-
keybinding="E"
|
15 |
-
/>
|
16 |
-
);
|
17 |
-
|
18 |
-
BitEraserComponent.propTypes = {
|
19 |
-
isSelected: PropTypes.bool.isRequired,
|
20 |
-
onMouseDown: PropTypes.func.isRequired
|
21 |
-
};
|
22 |
-
|
23 |
-
export default BitEraserComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import messages from '../../lib/messages.js';
|
4 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
+
|
6 |
+
import eraserIcon from './eraser.svg';
|
7 |
+
|
8 |
+
const BitEraserComponent = props => (
|
9 |
+
<ToolSelectComponent
|
10 |
+
imgDescriptor={messages.eraser}
|
11 |
+
imgSrc={eraserIcon}
|
12 |
+
isSelected={props.isSelected}
|
13 |
+
onMouseDown={props.onMouseDown}
|
14 |
+
keybinding="E"
|
15 |
+
/>
|
16 |
+
);
|
17 |
+
|
18 |
+
BitEraserComponent.propTypes = {
|
19 |
+
isSelected: PropTypes.bool.isRequired,
|
20 |
+
onMouseDown: PropTypes.func.isRequired
|
21 |
+
};
|
22 |
+
|
23 |
+
export default BitEraserComponent;
|
src/components/bit-eraser-mode/eraser.svg
CHANGED
|
|
src/components/bit-fill-mode/bit-fill-mode.jsx
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
|
4 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
-
import messages from '../../lib/messages.js';
|
6 |
-
import fillIcon from './fill.svg';
|
7 |
-
|
8 |
-
const BitFillComponent = props => (
|
9 |
-
<ToolSelectComponent
|
10 |
-
imgDescriptor={messages.fill}
|
11 |
-
imgSrc={fillIcon}
|
12 |
-
isSelected={props.isSelected}
|
13 |
-
onMouseDown={props.onMouseDown}
|
14 |
-
keybinding="F"
|
15 |
-
/>
|
16 |
-
);
|
17 |
-
|
18 |
-
BitFillComponent.propTypes = {
|
19 |
-
isSelected: PropTypes.bool.isRequired,
|
20 |
-
onMouseDown: PropTypes.func.isRequired
|
21 |
-
};
|
22 |
-
|
23 |
-
export default BitFillComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
|
4 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
+
import messages from '../../lib/messages.js';
|
6 |
+
import fillIcon from './fill.svg';
|
7 |
+
|
8 |
+
const BitFillComponent = props => (
|
9 |
+
<ToolSelectComponent
|
10 |
+
imgDescriptor={messages.fill}
|
11 |
+
imgSrc={fillIcon}
|
12 |
+
isSelected={props.isSelected}
|
13 |
+
onMouseDown={props.onMouseDown}
|
14 |
+
keybinding="F"
|
15 |
+
/>
|
16 |
+
);
|
17 |
+
|
18 |
+
BitFillComponent.propTypes = {
|
19 |
+
isSelected: PropTypes.bool.isRequired,
|
20 |
+
onMouseDown: PropTypes.func.isRequired
|
21 |
+
};
|
22 |
+
|
23 |
+
export default BitFillComponent;
|
src/components/bit-fill-mode/fill.svg
CHANGED
|
|
src/components/bit-line-mode/bit-line-mode.jsx
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import lineIcon from './line.svg';
|
6 |
-
|
7 |
-
const BitLineComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.line}
|
10 |
-
imgSrc={lineIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
keybinding="L"
|
14 |
-
/>
|
15 |
-
);
|
16 |
-
|
17 |
-
BitLineComponent.propTypes = {
|
18 |
-
isSelected: PropTypes.bool.isRequired,
|
19 |
-
onMouseDown: PropTypes.func.isRequired
|
20 |
-
};
|
21 |
-
|
22 |
-
export default BitLineComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import lineIcon from './line.svg';
|
6 |
+
|
7 |
+
const BitLineComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.line}
|
10 |
+
imgSrc={lineIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
keybinding="L"
|
14 |
+
/>
|
15 |
+
);
|
16 |
+
|
17 |
+
BitLineComponent.propTypes = {
|
18 |
+
isSelected: PropTypes.bool.isRequired,
|
19 |
+
onMouseDown: PropTypes.func.isRequired
|
20 |
+
};
|
21 |
+
|
22 |
+
export default BitLineComponent;
|
src/components/bit-line-mode/line.svg
CHANGED
|
|
src/components/bit-oval-mode/bit-oval-mode.jsx
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import ovalIcon from './oval.svg';
|
6 |
-
|
7 |
-
const BitOvalComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.oval}
|
10 |
-
imgSrc={ovalIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
keybinding="C"
|
14 |
-
/>
|
15 |
-
);
|
16 |
-
|
17 |
-
BitOvalComponent.propTypes = {
|
18 |
-
isSelected: PropTypes.bool.isRequired,
|
19 |
-
onMouseDown: PropTypes.func.isRequired
|
20 |
-
};
|
21 |
-
|
22 |
-
export default BitOvalComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import ovalIcon from './oval.svg';
|
6 |
+
|
7 |
+
const BitOvalComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.oval}
|
10 |
+
imgSrc={ovalIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
keybinding="C"
|
14 |
+
/>
|
15 |
+
);
|
16 |
+
|
17 |
+
BitOvalComponent.propTypes = {
|
18 |
+
isSelected: PropTypes.bool.isRequired,
|
19 |
+
onMouseDown: PropTypes.func.isRequired
|
20 |
+
};
|
21 |
+
|
22 |
+
export default BitOvalComponent;
|
src/components/bit-oval-mode/oval-outlined.svg
CHANGED
|
|
src/components/bit-oval-mode/oval.svg
CHANGED
|
|
src/components/bit-rect-mode/bit-rect-mode.jsx
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
|
4 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
-
import messages from '../../lib/messages.js';
|
6 |
-
import rectIcon from './rectangle.svg';
|
7 |
-
|
8 |
-
const BitRectComponent = props => (
|
9 |
-
<ToolSelectComponent
|
10 |
-
imgDescriptor={messages.rect}
|
11 |
-
imgSrc={rectIcon}
|
12 |
-
isSelected={props.isSelected}
|
13 |
-
onMouseDown={props.onMouseDown}
|
14 |
-
keybinding="R"
|
15 |
-
/>
|
16 |
-
);
|
17 |
-
|
18 |
-
BitRectComponent.propTypes = {
|
19 |
-
isSelected: PropTypes.bool.isRequired,
|
20 |
-
onMouseDown: PropTypes.func.isRequired
|
21 |
-
};
|
22 |
-
|
23 |
-
export default BitRectComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
|
4 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
+
import messages from '../../lib/messages.js';
|
6 |
+
import rectIcon from './rectangle.svg';
|
7 |
+
|
8 |
+
const BitRectComponent = props => (
|
9 |
+
<ToolSelectComponent
|
10 |
+
imgDescriptor={messages.rect}
|
11 |
+
imgSrc={rectIcon}
|
12 |
+
isSelected={props.isSelected}
|
13 |
+
onMouseDown={props.onMouseDown}
|
14 |
+
keybinding="R"
|
15 |
+
/>
|
16 |
+
);
|
17 |
+
|
18 |
+
BitRectComponent.propTypes = {
|
19 |
+
isSelected: PropTypes.bool.isRequired,
|
20 |
+
onMouseDown: PropTypes.func.isRequired
|
21 |
+
};
|
22 |
+
|
23 |
+
export default BitRectComponent;
|
src/components/bit-rect-mode/rectangle-outlined.svg
CHANGED
|
|
src/components/bit-rect-mode/rectangle.svg
CHANGED
|
|
src/components/bit-select-mode/bit-select-mode.jsx
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import selectIcon from './marquee.svg';
|
6 |
-
|
7 |
-
const BitSelectComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.select}
|
10 |
-
imgSrc={selectIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
keybinding="S"
|
14 |
-
/>
|
15 |
-
);
|
16 |
-
|
17 |
-
BitSelectComponent.propTypes = {
|
18 |
-
isSelected: PropTypes.bool.isRequired,
|
19 |
-
onMouseDown: PropTypes.func.isRequired
|
20 |
-
};
|
21 |
-
|
22 |
-
export default BitSelectComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import selectIcon from './marquee.svg';
|
6 |
+
|
7 |
+
const BitSelectComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.select}
|
10 |
+
imgSrc={selectIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
keybinding="S"
|
14 |
+
/>
|
15 |
+
);
|
16 |
+
|
17 |
+
BitSelectComponent.propTypes = {
|
18 |
+
isSelected: PropTypes.bool.isRequired,
|
19 |
+
onMouseDown: PropTypes.func.isRequired
|
20 |
+
};
|
21 |
+
|
22 |
+
export default BitSelectComponent;
|
src/components/bit-select-mode/marquee.svg
CHANGED
|
|
src/components/bit-text-mode/bit-text-mode.jsx
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
|
4 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
-
import messages from '../../lib/messages.js';
|
6 |
-
import textIcon from './text.svg';
|
7 |
-
|
8 |
-
const BitTextComponent = props => (
|
9 |
-
<ToolSelectComponent
|
10 |
-
imgDescriptor={messages.text}
|
11 |
-
imgSrc={textIcon}
|
12 |
-
isSelected={props.isSelected}
|
13 |
-
onMouseDown={props.onMouseDown}
|
14 |
-
keybinding="T"
|
15 |
-
/>
|
16 |
-
);
|
17 |
-
|
18 |
-
BitTextComponent.propTypes = {
|
19 |
-
isSelected: PropTypes.bool.isRequired,
|
20 |
-
onMouseDown: PropTypes.func.isRequired
|
21 |
-
};
|
22 |
-
|
23 |
-
export default BitTextComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
|
4 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
5 |
+
import messages from '../../lib/messages.js';
|
6 |
+
import textIcon from './text.svg';
|
7 |
+
|
8 |
+
const BitTextComponent = props => (
|
9 |
+
<ToolSelectComponent
|
10 |
+
imgDescriptor={messages.text}
|
11 |
+
imgSrc={textIcon}
|
12 |
+
isSelected={props.isSelected}
|
13 |
+
onMouseDown={props.onMouseDown}
|
14 |
+
keybinding="T"
|
15 |
+
/>
|
16 |
+
);
|
17 |
+
|
18 |
+
BitTextComponent.propTypes = {
|
19 |
+
isSelected: PropTypes.bool.isRequired,
|
20 |
+
onMouseDown: PropTypes.func.isRequired
|
21 |
+
};
|
22 |
+
|
23 |
+
export default BitTextComponent;
|
src/components/bit-text-mode/text.svg
CHANGED
|
|
src/components/box/box.jsx
CHANGED
@@ -1,141 +1,141 @@
|
|
1 |
-
/* DO NOT EDIT
|
2 |
-
@todo This file is copied from GUI and should be pulled out into a shared library.
|
3 |
-
See https://github.com/LLK/scratch-paint/issues/13 */
|
4 |
-
|
5 |
-
import PropTypes from 'prop-types';
|
6 |
-
import React from 'react';
|
7 |
-
import stylePropType from 'react-style-proptype';
|
8 |
-
|
9 |
-
const getRandomColor = (function () {
|
10 |
-
// In "DEBUG" mode this is used to output a random background color for each
|
11 |
-
// box. The function gives the same "random" set for each seed, allowing re-
|
12 |
-
// renders of the same content to give the same random display.
|
13 |
-
const random = (function (seed) {
|
14 |
-
let mW = seed;
|
15 |
-
let mZ = 987654321;
|
16 |
-
const mask = 0xffffffff;
|
17 |
-
return function () {
|
18 |
-
mZ = ((36969 * (mZ & 65535)) + (mZ >> 16)) & mask;
|
19 |
-
mW = ((18000 * (mW & 65535)) + (mW >> 16)) & mask;
|
20 |
-
let result = ((mZ << 16) + mW) & mask;
|
21 |
-
result /= 4294967296;
|
22 |
-
return result + 1;
|
23 |
-
};
|
24 |
-
}(601));
|
25 |
-
return function () {
|
26 |
-
const r = Math.max(parseInt(random() * 100, 10) % 256, 1);
|
27 |
-
const g = Math.max(parseInt(random() * 100, 10) % 256, 1);
|
28 |
-
const b = Math.max(parseInt(random() * 100, 10) % 256, 1);
|
29 |
-
return `rgb(${r},${g},${b})`;
|
30 |
-
};
|
31 |
-
}());
|
32 |
-
|
33 |
-
const Box = props => {
|
34 |
-
const {
|
35 |
-
alignContent,
|
36 |
-
alignItems,
|
37 |
-
alignSelf,
|
38 |
-
basis,
|
39 |
-
children,
|
40 |
-
className,
|
41 |
-
componentRef,
|
42 |
-
direction,
|
43 |
-
element,
|
44 |
-
grow,
|
45 |
-
height,
|
46 |
-
justifyContent,
|
47 |
-
width,
|
48 |
-
wrap,
|
49 |
-
shrink,
|
50 |
-
style,
|
51 |
-
...componentProps
|
52 |
-
} = props;
|
53 |
-
return React.createElement(element, {
|
54 |
-
className: className,
|
55 |
-
ref: componentRef,
|
56 |
-
style: Object.assign(
|
57 |
-
{
|
58 |
-
alignContent: alignContent,
|
59 |
-
alignItems: alignItems,
|
60 |
-
alignSelf: alignSelf,
|
61 |
-
flexBasis: basis,
|
62 |
-
flexDirection: direction,
|
63 |
-
flexGrow: grow,
|
64 |
-
flexShrink: shrink,
|
65 |
-
flexWrap: wrap,
|
66 |
-
justifyContent: justifyContent,
|
67 |
-
width: width,
|
68 |
-
height: height
|
69 |
-
},
|
70 |
-
process.env.DEBUG ? { // eslint-disable-line no-undef
|
71 |
-
backgroundColor: getRandomColor(),
|
72 |
-
outline: `1px solid black`
|
73 |
-
} : {},
|
74 |
-
style
|
75 |
-
),
|
76 |
-
...componentProps
|
77 |
-
}, children);
|
78 |
-
};
|
79 |
-
Box.propTypes = {
|
80 |
-
/** Defines how the browser distributes space between and around content items vertically within this box. */
|
81 |
-
alignContent: PropTypes.oneOf([
|
82 |
-
'flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch'
|
83 |
-
]),
|
84 |
-
/** Defines how the browser distributes space between and around flex items horizontally within this box. */
|
85 |
-
alignItems: PropTypes.oneOf([
|
86 |
-
'flex-start', 'flex-end', 'center', 'baseline', 'stretch'
|
87 |
-
]),
|
88 |
-
/** Specifies how this box should be aligned inside of its container (requires the container to be flexable). */
|
89 |
-
alignSelf: PropTypes.oneOf([
|
90 |
-
'auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch'
|
91 |
-
]),
|
92 |
-
/** Specifies the initial length of this box */
|
93 |
-
basis: PropTypes.oneOfType([
|
94 |
-
PropTypes.number,
|
95 |
-
PropTypes.oneOf(['auto'])
|
96 |
-
]),
|
97 |
-
/** Specifies the the HTML nodes which will be child elements of this box. */
|
98 |
-
children: PropTypes.node,
|
99 |
-
/** Specifies the class name that will be set on this box */
|
100 |
-
className: PropTypes.string,
|
101 |
-
/**
|
102 |
-
* A callback function whose first parameter is the underlying dom elements.
|
103 |
-
* This call back will be executed immediately after the component is mounted or unmounted
|
104 |
-
*/
|
105 |
-
componentRef: PropTypes.func,
|
106 |
-
/** https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction */
|
107 |
-
direction: PropTypes.oneOf([
|
108 |
-
'row', 'row-reverse', 'column', 'column-reverse'
|
109 |
-
]),
|
110 |
-
/** Specifies the type of HTML element of this box. Defaults to div. */
|
111 |
-
element: PropTypes.string,
|
112 |
-
/** Specifies the flex grow factor of a flex item. */
|
113 |
-
grow: PropTypes.number,
|
114 |
-
/** The height in pixels (if specified as a number) or a string if different units are required. */
|
115 |
-
height: PropTypes.oneOfType([
|
116 |
-
PropTypes.number,
|
117 |
-
PropTypes.string
|
118 |
-
]),
|
119 |
-
/** https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content */
|
120 |
-
justifyContent: PropTypes.oneOf([
|
121 |
-
'flex-start', 'flex-end', 'center', 'space-between', 'space-around'
|
122 |
-
]),
|
123 |
-
/** Specifies the flex shrink factor of a flex item. */
|
124 |
-
shrink: PropTypes.number,
|
125 |
-
/** An object whose keys are css property names and whose values correspond the the css property. */
|
126 |
-
style: stylePropType,
|
127 |
-
/** The width in pixels (if specified as a number) or a string if different units are required. */
|
128 |
-
width: PropTypes.oneOfType([
|
129 |
-
PropTypes.number,
|
130 |
-
PropTypes.string
|
131 |
-
]),
|
132 |
-
/** How whitespace should wrap within this block. */
|
133 |
-
wrap: PropTypes.oneOf([
|
134 |
-
'nowrap', 'wrap', 'wrap-reverse'
|
135 |
-
])
|
136 |
-
};
|
137 |
-
Box.defaultProps = {
|
138 |
-
element: 'div',
|
139 |
-
style: {}
|
140 |
-
};
|
141 |
-
export default Box;
|
|
|
1 |
+
/* DO NOT EDIT
|
2 |
+
@todo This file is copied from GUI and should be pulled out into a shared library.
|
3 |
+
See https://github.com/LLK/scratch-paint/issues/13 */
|
4 |
+
|
5 |
+
import PropTypes from 'prop-types';
|
6 |
+
import React from 'react';
|
7 |
+
import stylePropType from 'react-style-proptype';
|
8 |
+
|
9 |
+
const getRandomColor = (function () {
|
10 |
+
// In "DEBUG" mode this is used to output a random background color for each
|
11 |
+
// box. The function gives the same "random" set for each seed, allowing re-
|
12 |
+
// renders of the same content to give the same random display.
|
13 |
+
const random = (function (seed) {
|
14 |
+
let mW = seed;
|
15 |
+
let mZ = 987654321;
|
16 |
+
const mask = 0xffffffff;
|
17 |
+
return function () {
|
18 |
+
mZ = ((36969 * (mZ & 65535)) + (mZ >> 16)) & mask;
|
19 |
+
mW = ((18000 * (mW & 65535)) + (mW >> 16)) & mask;
|
20 |
+
let result = ((mZ << 16) + mW) & mask;
|
21 |
+
result /= 4294967296;
|
22 |
+
return result + 1;
|
23 |
+
};
|
24 |
+
}(601));
|
25 |
+
return function () {
|
26 |
+
const r = Math.max(parseInt(random() * 100, 10) % 256, 1);
|
27 |
+
const g = Math.max(parseInt(random() * 100, 10) % 256, 1);
|
28 |
+
const b = Math.max(parseInt(random() * 100, 10) % 256, 1);
|
29 |
+
return `rgb(${r},${g},${b})`;
|
30 |
+
};
|
31 |
+
}());
|
32 |
+
|
33 |
+
const Box = props => {
|
34 |
+
const {
|
35 |
+
alignContent,
|
36 |
+
alignItems,
|
37 |
+
alignSelf,
|
38 |
+
basis,
|
39 |
+
children,
|
40 |
+
className,
|
41 |
+
componentRef,
|
42 |
+
direction,
|
43 |
+
element,
|
44 |
+
grow,
|
45 |
+
height,
|
46 |
+
justifyContent,
|
47 |
+
width,
|
48 |
+
wrap,
|
49 |
+
shrink,
|
50 |
+
style,
|
51 |
+
...componentProps
|
52 |
+
} = props;
|
53 |
+
return React.createElement(element, {
|
54 |
+
className: className,
|
55 |
+
ref: componentRef,
|
56 |
+
style: Object.assign(
|
57 |
+
{
|
58 |
+
alignContent: alignContent,
|
59 |
+
alignItems: alignItems,
|
60 |
+
alignSelf: alignSelf,
|
61 |
+
flexBasis: basis,
|
62 |
+
flexDirection: direction,
|
63 |
+
flexGrow: grow,
|
64 |
+
flexShrink: shrink,
|
65 |
+
flexWrap: wrap,
|
66 |
+
justifyContent: justifyContent,
|
67 |
+
width: width,
|
68 |
+
height: height
|
69 |
+
},
|
70 |
+
process.env.DEBUG ? { // eslint-disable-line no-undef
|
71 |
+
backgroundColor: getRandomColor(),
|
72 |
+
outline: `1px solid black`
|
73 |
+
} : {},
|
74 |
+
style
|
75 |
+
),
|
76 |
+
...componentProps
|
77 |
+
}, children);
|
78 |
+
};
|
79 |
+
Box.propTypes = {
|
80 |
+
/** Defines how the browser distributes space between and around content items vertically within this box. */
|
81 |
+
alignContent: PropTypes.oneOf([
|
82 |
+
'flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch'
|
83 |
+
]),
|
84 |
+
/** Defines how the browser distributes space between and around flex items horizontally within this box. */
|
85 |
+
alignItems: PropTypes.oneOf([
|
86 |
+
'flex-start', 'flex-end', 'center', 'baseline', 'stretch'
|
87 |
+
]),
|
88 |
+
/** Specifies how this box should be aligned inside of its container (requires the container to be flexable). */
|
89 |
+
alignSelf: PropTypes.oneOf([
|
90 |
+
'auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch'
|
91 |
+
]),
|
92 |
+
/** Specifies the initial length of this box */
|
93 |
+
basis: PropTypes.oneOfType([
|
94 |
+
PropTypes.number,
|
95 |
+
PropTypes.oneOf(['auto'])
|
96 |
+
]),
|
97 |
+
/** Specifies the the HTML nodes which will be child elements of this box. */
|
98 |
+
children: PropTypes.node,
|
99 |
+
/** Specifies the class name that will be set on this box */
|
100 |
+
className: PropTypes.string,
|
101 |
+
/**
|
102 |
+
* A callback function whose first parameter is the underlying dom elements.
|
103 |
+
* This call back will be executed immediately after the component is mounted or unmounted
|
104 |
+
*/
|
105 |
+
componentRef: PropTypes.func,
|
106 |
+
/** https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction */
|
107 |
+
direction: PropTypes.oneOf([
|
108 |
+
'row', 'row-reverse', 'column', 'column-reverse'
|
109 |
+
]),
|
110 |
+
/** Specifies the type of HTML element of this box. Defaults to div. */
|
111 |
+
element: PropTypes.string,
|
112 |
+
/** Specifies the flex grow factor of a flex item. */
|
113 |
+
grow: PropTypes.number,
|
114 |
+
/** The height in pixels (if specified as a number) or a string if different units are required. */
|
115 |
+
height: PropTypes.oneOfType([
|
116 |
+
PropTypes.number,
|
117 |
+
PropTypes.string
|
118 |
+
]),
|
119 |
+
/** https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content */
|
120 |
+
justifyContent: PropTypes.oneOf([
|
121 |
+
'flex-start', 'flex-end', 'center', 'space-between', 'space-around'
|
122 |
+
]),
|
123 |
+
/** Specifies the flex shrink factor of a flex item. */
|
124 |
+
shrink: PropTypes.number,
|
125 |
+
/** An object whose keys are css property names and whose values correspond the the css property. */
|
126 |
+
style: stylePropType,
|
127 |
+
/** The width in pixels (if specified as a number) or a string if different units are required. */
|
128 |
+
width: PropTypes.oneOfType([
|
129 |
+
PropTypes.number,
|
130 |
+
PropTypes.string
|
131 |
+
]),
|
132 |
+
/** How whitespace should wrap within this block. */
|
133 |
+
wrap: PropTypes.oneOf([
|
134 |
+
'nowrap', 'wrap', 'wrap-reverse'
|
135 |
+
])
|
136 |
+
};
|
137 |
+
Box.defaultProps = {
|
138 |
+
element: 'div',
|
139 |
+
style: {}
|
140 |
+
};
|
141 |
+
export default Box;
|
src/components/brush-mode/brush-mode.jsx
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import brushIcon from './brush.svg';
|
6 |
-
|
7 |
-
const BrushModeComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.brush}
|
10 |
-
imgSrc={brushIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
keybinding="B"
|
14 |
-
/>
|
15 |
-
);
|
16 |
-
|
17 |
-
BrushModeComponent.propTypes = {
|
18 |
-
isSelected: PropTypes.bool.isRequired,
|
19 |
-
onMouseDown: PropTypes.func.isRequired
|
20 |
-
};
|
21 |
-
|
22 |
-
export default BrushModeComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import brushIcon from './brush.svg';
|
6 |
+
|
7 |
+
const BrushModeComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.brush}
|
10 |
+
imgSrc={brushIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
keybinding="B"
|
14 |
+
/>
|
15 |
+
);
|
16 |
+
|
17 |
+
BrushModeComponent.propTypes = {
|
18 |
+
isSelected: PropTypes.bool.isRequired,
|
19 |
+
onMouseDown: PropTypes.func.isRequired
|
20 |
+
};
|
21 |
+
|
22 |
+
export default BrushModeComponent;
|
src/components/brush-mode/brush.svg
CHANGED
|
|
src/components/button-group/button-group.jsx
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
import classNames from 'classnames';
|
2 |
-
import React from 'react';
|
3 |
-
import PropTypes from 'prop-types';
|
4 |
-
|
5 |
-
import styles from './button-group.css';
|
6 |
-
|
7 |
-
const ButtonGroup = props => (
|
8 |
-
<div className={classNames(props.className, styles.buttonGroup)}>
|
9 |
-
{props.children}
|
10 |
-
</div>
|
11 |
-
);
|
12 |
-
|
13 |
-
ButtonGroup.propTypes = {
|
14 |
-
children: PropTypes.node.isRequired,
|
15 |
-
className: PropTypes.string
|
16 |
-
};
|
17 |
-
|
18 |
-
export default ButtonGroup;
|
|
|
1 |
+
import classNames from 'classnames';
|
2 |
+
import React from 'react';
|
3 |
+
import PropTypes from 'prop-types';
|
4 |
+
|
5 |
+
import styles from './button-group.css';
|
6 |
+
|
7 |
+
const ButtonGroup = props => (
|
8 |
+
<div className={classNames(props.className, styles.buttonGroup)}>
|
9 |
+
{props.children}
|
10 |
+
</div>
|
11 |
+
);
|
12 |
+
|
13 |
+
ButtonGroup.propTypes = {
|
14 |
+
children: PropTypes.node.isRequired,
|
15 |
+
className: PropTypes.string
|
16 |
+
};
|
17 |
+
|
18 |
+
export default ButtonGroup;
|
src/components/button/button.jsx
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
/* DO NOT EDIT
|
2 |
-
@todo This file is copied from GUI and should be pulled out into a shared library.
|
3 |
-
See #13 */
|
4 |
-
|
5 |
-
/* ACTUALLY, THIS IS EDITED ;)
|
6 |
-
THIS WAS CHANGED ON 10/25/2017 BY @mewtaylor TO ADD HANDLING FOR DISABLED STATES.*/
|
7 |
-
|
8 |
-
import classNames from 'classnames';
|
9 |
-
import PropTypes from 'prop-types';
|
10 |
-
import React from 'react';
|
11 |
-
|
12 |
-
import styles from './button.css';
|
13 |
-
|
14 |
-
const ButtonComponent = ({
|
15 |
-
className,
|
16 |
-
highlighted,
|
17 |
-
onClick,
|
18 |
-
children,
|
19 |
-
...props
|
20 |
-
}) => {
|
21 |
-
const disabled = props.disabled || false;
|
22 |
-
if (disabled === false) {
|
23 |
-
// if not disabled, add `onClick()` to be applied
|
24 |
-
// in props. If disabled, don't add `onClick()`
|
25 |
-
props.onClick = onClick;
|
26 |
-
}
|
27 |
-
return (
|
28 |
-
<span
|
29 |
-
className={classNames(
|
30 |
-
styles.button,
|
31 |
-
className,
|
32 |
-
{
|
33 |
-
[styles.modDisabled]: disabled,
|
34 |
-
[styles.highlighted]: highlighted
|
35 |
-
}
|
36 |
-
)}
|
37 |
-
role="button"
|
38 |
-
{...props}
|
39 |
-
>
|
40 |
-
{children}
|
41 |
-
</span>
|
42 |
-
);
|
43 |
-
};
|
44 |
-
|
45 |
-
ButtonComponent.propTypes = {
|
46 |
-
children: PropTypes.node,
|
47 |
-
className: PropTypes.string,
|
48 |
-
disabled: PropTypes.oneOfType([
|
49 |
-
PropTypes.string,
|
50 |
-
PropTypes.bool
|
51 |
-
]),
|
52 |
-
highlighted: PropTypes.bool,
|
53 |
-
onClick: PropTypes.func.isRequired
|
54 |
-
};
|
55 |
-
export default ButtonComponent;
|
|
|
1 |
+
/* DO NOT EDIT
|
2 |
+
@todo This file is copied from GUI and should be pulled out into a shared library.
|
3 |
+
See #13 */
|
4 |
+
|
5 |
+
/* ACTUALLY, THIS IS EDITED ;)
|
6 |
+
THIS WAS CHANGED ON 10/25/2017 BY @mewtaylor TO ADD HANDLING FOR DISABLED STATES.*/
|
7 |
+
|
8 |
+
import classNames from 'classnames';
|
9 |
+
import PropTypes from 'prop-types';
|
10 |
+
import React from 'react';
|
11 |
+
|
12 |
+
import styles from './button.css';
|
13 |
+
|
14 |
+
const ButtonComponent = ({
|
15 |
+
className,
|
16 |
+
highlighted,
|
17 |
+
onClick,
|
18 |
+
children,
|
19 |
+
...props
|
20 |
+
}) => {
|
21 |
+
const disabled = props.disabled || false;
|
22 |
+
if (disabled === false) {
|
23 |
+
// if not disabled, add `onClick()` to be applied
|
24 |
+
// in props. If disabled, don't add `onClick()`
|
25 |
+
props.onClick = onClick;
|
26 |
+
}
|
27 |
+
return (
|
28 |
+
<span
|
29 |
+
className={classNames(
|
30 |
+
styles.button,
|
31 |
+
className,
|
32 |
+
{
|
33 |
+
[styles.modDisabled]: disabled,
|
34 |
+
[styles.highlighted]: highlighted
|
35 |
+
}
|
36 |
+
)}
|
37 |
+
role="button"
|
38 |
+
{...props}
|
39 |
+
>
|
40 |
+
{children}
|
41 |
+
</span>
|
42 |
+
);
|
43 |
+
};
|
44 |
+
|
45 |
+
ButtonComponent.propTypes = {
|
46 |
+
children: PropTypes.node,
|
47 |
+
className: PropTypes.string,
|
48 |
+
disabled: PropTypes.oneOfType([
|
49 |
+
PropTypes.string,
|
50 |
+
PropTypes.bool
|
51 |
+
]),
|
52 |
+
highlighted: PropTypes.bool,
|
53 |
+
onClick: PropTypes.func.isRequired
|
54 |
+
};
|
55 |
+
export default ButtonComponent;
|
src/components/color-button/color-button.jsx
CHANGED
@@ -1,69 +1,69 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import classNames from 'classnames';
|
4 |
-
|
5 |
-
import {MIXED} from '../../helper/style-path';
|
6 |
-
|
7 |
-
import noFillIcon from './no-fill.svg';
|
8 |
-
import mixedFillIcon from './mixed-fill.svg';
|
9 |
-
import styles from './color-button.css';
|
10 |
-
import GradientTypes from '../../lib/gradient-types';
|
11 |
-
import log from '../../log/log';
|
12 |
-
|
13 |
-
const colorToBackground = (color, color2, gradientType) => {
|
14 |
-
if (color === MIXED || (gradientType !== GradientTypes.SOLID && color2 === MIXED)) return 'white';
|
15 |
-
if (color === null) color = 'white';
|
16 |
-
if (color2 === null) color2 = 'white';
|
17 |
-
switch (gradientType) {
|
18 |
-
case GradientTypes.SOLID: return color;
|
19 |
-
case GradientTypes.HORIZONTAL: return `linear-gradient(to right, ${color}, ${color2})`;
|
20 |
-
case GradientTypes.VERTICAL: return `linear-gradient(${color}, ${color2})`;
|
21 |
-
case GradientTypes.RADIAL: return `radial-gradient(${color}, ${color2})`;
|
22 |
-
default: log.error(`Unrecognized gradient type: ${gradientType}`);
|
23 |
-
}
|
24 |
-
};
|
25 |
-
|
26 |
-
const ColorButtonComponent = props => (
|
27 |
-
<div
|
28 |
-
className={styles.colorButton}
|
29 |
-
onClick={props.onClick}
|
30 |
-
>
|
31 |
-
<div
|
32 |
-
className={classNames(styles.colorButtonSwatch, {
|
33 |
-
[styles.outlineSwatch]: props.outline && !(props.color === MIXED)
|
34 |
-
})}
|
35 |
-
style={{
|
36 |
-
background: colorToBackground(props.color, props.color2, props.gradientType)
|
37 |
-
}}
|
38 |
-
>
|
39 |
-
{props.color === null && (props.gradientType === GradientTypes.SOLID || props.color2 === null) ? (
|
40 |
-
<img
|
41 |
-
className={styles.swatchIcon}
|
42 |
-
draggable={false}
|
43 |
-
src={noFillIcon}
|
44 |
-
/>
|
45 |
-
) : ((props.color === MIXED || (props.gradientType !== GradientTypes.SOLID && props.color2 === MIXED) ? (
|
46 |
-
<img
|
47 |
-
className={styles.swatchIcon}
|
48 |
-
draggable={false}
|
49 |
-
src={mixedFillIcon}
|
50 |
-
/>
|
51 |
-
) : null))}
|
52 |
-
</div>
|
53 |
-
<div className={styles.colorButtonArrow}>▾</div>
|
54 |
-
</div>
|
55 |
-
);
|
56 |
-
|
57 |
-
ColorButtonComponent.propTypes = {
|
58 |
-
color: PropTypes.string,
|
59 |
-
color2: PropTypes.string,
|
60 |
-
gradientType: PropTypes.oneOf(Object.keys(GradientTypes)).isRequired,
|
61 |
-
onClick: PropTypes.func.isRequired,
|
62 |
-
outline: PropTypes.bool.isRequired
|
63 |
-
};
|
64 |
-
|
65 |
-
ColorButtonComponent.defaultProps = {
|
66 |
-
outline: false
|
67 |
-
};
|
68 |
-
|
69 |
-
export default ColorButtonComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import classNames from 'classnames';
|
4 |
+
|
5 |
+
import {MIXED} from '../../helper/style-path';
|
6 |
+
|
7 |
+
import noFillIcon from './no-fill.svg';
|
8 |
+
import mixedFillIcon from './mixed-fill.svg';
|
9 |
+
import styles from './color-button.css';
|
10 |
+
import GradientTypes from '../../lib/gradient-types';
|
11 |
+
import log from '../../log/log';
|
12 |
+
|
13 |
+
const colorToBackground = (color, color2, gradientType) => {
|
14 |
+
if (color === MIXED || (gradientType !== GradientTypes.SOLID && color2 === MIXED)) return 'white';
|
15 |
+
if (color === null) color = 'white';
|
16 |
+
if (color2 === null) color2 = 'white';
|
17 |
+
switch (gradientType) {
|
18 |
+
case GradientTypes.SOLID: return color;
|
19 |
+
case GradientTypes.HORIZONTAL: return `linear-gradient(to right, ${color}, ${color2})`;
|
20 |
+
case GradientTypes.VERTICAL: return `linear-gradient(${color}, ${color2})`;
|
21 |
+
case GradientTypes.RADIAL: return `radial-gradient(${color}, ${color2})`;
|
22 |
+
default: log.error(`Unrecognized gradient type: ${gradientType}`);
|
23 |
+
}
|
24 |
+
};
|
25 |
+
|
26 |
+
const ColorButtonComponent = props => (
|
27 |
+
<div
|
28 |
+
className={styles.colorButton}
|
29 |
+
onClick={props.onClick}
|
30 |
+
>
|
31 |
+
<div
|
32 |
+
className={classNames(styles.colorButtonSwatch, {
|
33 |
+
[styles.outlineSwatch]: props.outline && !(props.color === MIXED)
|
34 |
+
})}
|
35 |
+
style={{
|
36 |
+
background: colorToBackground(props.color, props.color2, props.gradientType)
|
37 |
+
}}
|
38 |
+
>
|
39 |
+
{props.color === null && (props.gradientType === GradientTypes.SOLID || props.color2 === null) ? (
|
40 |
+
<img
|
41 |
+
className={styles.swatchIcon}
|
42 |
+
draggable={false}
|
43 |
+
src={noFillIcon}
|
44 |
+
/>
|
45 |
+
) : ((props.color === MIXED || (props.gradientType !== GradientTypes.SOLID && props.color2 === MIXED) ? (
|
46 |
+
<img
|
47 |
+
className={styles.swatchIcon}
|
48 |
+
draggable={false}
|
49 |
+
src={mixedFillIcon}
|
50 |
+
/>
|
51 |
+
) : null))}
|
52 |
+
</div>
|
53 |
+
<div className={styles.colorButtonArrow}>▾</div>
|
54 |
+
</div>
|
55 |
+
);
|
56 |
+
|
57 |
+
ColorButtonComponent.propTypes = {
|
58 |
+
color: PropTypes.string,
|
59 |
+
color2: PropTypes.string,
|
60 |
+
gradientType: PropTypes.oneOf(Object.keys(GradientTypes)).isRequired,
|
61 |
+
onClick: PropTypes.func.isRequired,
|
62 |
+
outline: PropTypes.bool.isRequired
|
63 |
+
};
|
64 |
+
|
65 |
+
ColorButtonComponent.defaultProps = {
|
66 |
+
outline: false
|
67 |
+
};
|
68 |
+
|
69 |
+
export default ColorButtonComponent;
|
src/components/color-button/mixed-fill.svg
CHANGED
|
|
src/components/color-button/no-fill.svg
CHANGED
|
|
src/components/color-indicator.jsx
CHANGED
@@ -1,63 +1,63 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import Popover from 'react-popover';
|
4 |
-
|
5 |
-
import ColorButton from './color-button/color-button.jsx';
|
6 |
-
import ColorPicker from '../containers/color-picker.jsx';
|
7 |
-
import InputGroup from './input-group/input-group.jsx';
|
8 |
-
import Label from './forms/label.jsx';
|
9 |
-
|
10 |
-
import GradientTypes from '../lib/gradient-types';
|
11 |
-
|
12 |
-
const ColorIndicatorComponent = props => (
|
13 |
-
<InputGroup
|
14 |
-
className={props.className}
|
15 |
-
disabled={props.disabled}
|
16 |
-
>
|
17 |
-
<Popover
|
18 |
-
body={
|
19 |
-
<ColorPicker
|
20 |
-
color={props.color}
|
21 |
-
color2={props.color2}
|
22 |
-
gradientType={props.gradientType}
|
23 |
-
shouldShowGradientTools={props.shouldShowGradientTools}
|
24 |
-
onChangeColor={props.onChangeColor}
|
25 |
-
onChangeGradientType={props.onChangeGradientType}
|
26 |
-
onSwap={props.onSwap}
|
27 |
-
/>
|
28 |
-
}
|
29 |
-
isOpen={props.colorModalVisible}
|
30 |
-
preferPlace="below"
|
31 |
-
onOuterAction={props.onCloseColor}
|
32 |
-
>
|
33 |
-
<Label text={props.label}>
|
34 |
-
<ColorButton
|
35 |
-
color={props.color}
|
36 |
-
color2={props.color2}
|
37 |
-
gradientType={props.gradientType}
|
38 |
-
onClick={props.onOpenColor}
|
39 |
-
outline={props.outline}
|
40 |
-
/>
|
41 |
-
</Label>
|
42 |
-
</Popover>
|
43 |
-
</InputGroup>
|
44 |
-
);
|
45 |
-
|
46 |
-
ColorIndicatorComponent.propTypes = {
|
47 |
-
className: PropTypes.string,
|
48 |
-
disabled: PropTypes.bool.isRequired,
|
49 |
-
color: PropTypes.string,
|
50 |
-
color2: PropTypes.string,
|
51 |
-
colorModalVisible: PropTypes.bool.isRequired,
|
52 |
-
gradientType: PropTypes.oneOf(Object.keys(GradientTypes)).isRequired,
|
53 |
-
label: PropTypes.string.isRequired,
|
54 |
-
onChangeColor: PropTypes.func.isRequired,
|
55 |
-
onChangeGradientType: PropTypes.func.isRequired,
|
56 |
-
onCloseColor: PropTypes.func.isRequired,
|
57 |
-
onOpenColor: PropTypes.func.isRequired,
|
58 |
-
onSwap: PropTypes.func.isRequired,
|
59 |
-
outline: PropTypes.bool.isRequired,
|
60 |
-
shouldShowGradientTools: PropTypes.bool.isRequired
|
61 |
-
};
|
62 |
-
|
63 |
-
export default ColorIndicatorComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import Popover from 'react-popover';
|
4 |
+
|
5 |
+
import ColorButton from './color-button/color-button.jsx';
|
6 |
+
import ColorPicker from '../containers/color-picker.jsx';
|
7 |
+
import InputGroup from './input-group/input-group.jsx';
|
8 |
+
import Label from './forms/label.jsx';
|
9 |
+
|
10 |
+
import GradientTypes from '../lib/gradient-types';
|
11 |
+
|
12 |
+
const ColorIndicatorComponent = props => (
|
13 |
+
<InputGroup
|
14 |
+
className={props.className}
|
15 |
+
disabled={props.disabled}
|
16 |
+
>
|
17 |
+
<Popover
|
18 |
+
body={
|
19 |
+
<ColorPicker
|
20 |
+
color={props.color}
|
21 |
+
color2={props.color2}
|
22 |
+
gradientType={props.gradientType}
|
23 |
+
shouldShowGradientTools={props.shouldShowGradientTools}
|
24 |
+
onChangeColor={props.onChangeColor}
|
25 |
+
onChangeGradientType={props.onChangeGradientType}
|
26 |
+
onSwap={props.onSwap}
|
27 |
+
/>
|
28 |
+
}
|
29 |
+
isOpen={props.colorModalVisible}
|
30 |
+
preferPlace="below"
|
31 |
+
onOuterAction={props.onCloseColor}
|
32 |
+
>
|
33 |
+
<Label text={props.label}>
|
34 |
+
<ColorButton
|
35 |
+
color={props.color}
|
36 |
+
color2={props.color2}
|
37 |
+
gradientType={props.gradientType}
|
38 |
+
onClick={props.onOpenColor}
|
39 |
+
outline={props.outline}
|
40 |
+
/>
|
41 |
+
</Label>
|
42 |
+
</Popover>
|
43 |
+
</InputGroup>
|
44 |
+
);
|
45 |
+
|
46 |
+
ColorIndicatorComponent.propTypes = {
|
47 |
+
className: PropTypes.string,
|
48 |
+
disabled: PropTypes.bool.isRequired,
|
49 |
+
color: PropTypes.string,
|
50 |
+
color2: PropTypes.string,
|
51 |
+
colorModalVisible: PropTypes.bool.isRequired,
|
52 |
+
gradientType: PropTypes.oneOf(Object.keys(GradientTypes)).isRequired,
|
53 |
+
label: PropTypes.string.isRequired,
|
54 |
+
onChangeColor: PropTypes.func.isRequired,
|
55 |
+
onChangeGradientType: PropTypes.func.isRequired,
|
56 |
+
onCloseColor: PropTypes.func.isRequired,
|
57 |
+
onOpenColor: PropTypes.func.isRequired,
|
58 |
+
onSwap: PropTypes.func.isRequired,
|
59 |
+
outline: PropTypes.bool.isRequired,
|
60 |
+
shouldShowGradientTools: PropTypes.bool.isRequired
|
61 |
+
};
|
62 |
+
|
63 |
+
export default ColorIndicatorComponent;
|
src/components/color-picker/color-picker.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
@import "../../css/units";
|
2 |
@import "../../css/colors";
|
3 |
|
4 |
/* Popover styles */
|
@@ -87,7 +87,7 @@ body :global(.Popover) {
|
|
87 |
}
|
88 |
|
89 |
.active-swatch {
|
90 |
-
border: 1px solid #
|
91 |
box-shadow: 0px 0px 0px 3px hsla(194, 100%, 50%, 0.2);
|
92 |
}
|
93 |
|
|
|
1 |
+
@import "../../css/units";
|
2 |
@import "../../css/colors";
|
3 |
|
4 |
/* Popover styles */
|
|
|
87 |
}
|
88 |
|
89 |
.active-swatch {
|
90 |
+
border: 1px solid #625edb;
|
91 |
box-shadow: 0px 0px 0px 3px hsla(194, 100%, 50%, 0.2);
|
92 |
}
|
93 |
|
src/components/color-picker/color-picker.jsx
CHANGED
@@ -1,397 +1,397 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import {defineMessages, FormattedMessage, injectIntl, intlShape} from 'react-intl';
|
4 |
-
|
5 |
-
import classNames from 'classnames';
|
6 |
-
import parseColor from 'parse-color';
|
7 |
-
|
8 |
-
import Slider, {CONTAINER_WIDTH, HANDLE_WIDTH} from '../forms/slider.jsx';
|
9 |
-
import LabeledIconButton from '../labeled-icon-button/labeled-icon-button.jsx';
|
10 |
-
import styles from './color-picker.css';
|
11 |
-
import GradientTypes from '../../lib/gradient-types';
|
12 |
-
import {MIXED} from '../../helper/style-path';
|
13 |
-
|
14 |
-
import eyeDropperIcon from './icons/eye-dropper.svg';
|
15 |
-
import noFillIcon from '../color-button/no-fill.svg';
|
16 |
-
import mixedFillIcon from '../color-button/mixed-fill.svg';
|
17 |
-
import fillHorzGradientIcon from './icons/fill-horz-gradient-enabled.svg';
|
18 |
-
import fillRadialIcon from './icons/fill-radial-enabled.svg';
|
19 |
-
import fillSolidIcon from './icons/fill-solid-enabled.svg';
|
20 |
-
import fillVertGradientIcon from './icons/fill-vert-gradient-enabled.svg';
|
21 |
-
import swapIcon from './icons/swap.svg';
|
22 |
-
import Modes from '../../lib/modes';
|
23 |
-
import alphaBackground from './alpha.png';
|
24 |
-
import BufferedInputHOC from '../forms/buffered-input-hoc.jsx';
|
25 |
-
import Input from '../forms/input.jsx';
|
26 |
-
import {makeAlphaComponent} from '../../lib/tw-color-utils';
|
27 |
-
import TWColorReadout from '../tw-color-readout/tw-color-readout.jsx';
|
28 |
-
|
29 |
-
const BufferedInput = BufferedInputHOC(Input);
|
30 |
-
|
31 |
-
const hsvToHex = (h, s, v) =>
|
32 |
-
// Scale hue back up to [0, 360] from [0, 100]
|
33 |
-
parseColor(`hsv(${3.6 * h}, ${s}, ${v})`).hex
|
34 |
-
;
|
35 |
-
|
36 |
-
const messages = defineMessages({
|
37 |
-
swap: {
|
38 |
-
defaultMessage: 'Swap',
|
39 |
-
description: 'Label for button that swaps the two colors in a gradient',
|
40 |
-
id: 'paint.colorPicker.swap'
|
41 |
-
}
|
42 |
-
});
|
43 |
-
class ColorPickerComponent extends React.Component {
|
44 |
-
_makeBackground (channel) {
|
45 |
-
const stops = [];
|
46 |
-
// Generate the color slider background CSS gradients by adding
|
47 |
-
// color stops depending on the slider.
|
48 |
-
for (let n = 100; n >= 0; n -= 10) {
|
49 |
-
switch (channel) {
|
50 |
-
case 'hue':
|
51 |
-
stops.push(hsvToHex(n, this.props.saturation, this.props.brightness));
|
52 |
-
break;
|
53 |
-
case 'saturation':
|
54 |
-
stops.push(hsvToHex(this.props.hue, n, this.props.brightness));
|
55 |
-
break;
|
56 |
-
case 'brightness':
|
57 |
-
stops.push(hsvToHex(this.props.hue, this.props.saturation, n));
|
58 |
-
break;
|
59 |
-
case 'alpha': {
|
60 |
-
const alpha = makeAlphaComponent(n / 100);
|
61 |
-
stops.push(`${hsvToHex(this.props.hue, this.props.saturation, this.props.brightness)}${alpha}`);
|
62 |
-
break;
|
63 |
-
}
|
64 |
-
default:
|
65 |
-
throw new Error(`Unknown channel for color sliders: ${channel}`);
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
// The sliders are a rounded capsule shape, and the slider handles are circles. As a consequence, when the
|
70 |
-
// slider handle is fully to one side, its center is actually moved away from the start/end of the slider by
|
71 |
-
// the slider handle's radius, meaning that the effective range of the slider excludes the rounded caps.
|
72 |
-
// To compensate for this, position the first stop to where the rounded cap ends, and position the last stop
|
73 |
-
// to where the rounded cap begins.
|
74 |
-
const halfHandleWidth = HANDLE_WIDTH / 2;
|
75 |
-
stops[0] += ` 0 ${halfHandleWidth}px`;
|
76 |
-
stops[stops.length - 1] += ` ${CONTAINER_WIDTH - halfHandleWidth}px 100%`;
|
77 |
-
|
78 |
-
let css = `linear-gradient(to left, ${stops.join(',')})`;
|
79 |
-
if (channel === 'alpha') {
|
80 |
-
css = `${css}, url("${alphaBackground}")`;
|
81 |
-
}
|
82 |
-
return css;
|
83 |
-
}
|
84 |
-
render () {
|
85 |
-
return (
|
86 |
-
<div
|
87 |
-
className={styles.colorPickerContainer}
|
88 |
-
dir={this.props.rtl ? 'rtl' : 'ltr'}
|
89 |
-
>
|
90 |
-
{this.props.shouldShowGradientTools ? (
|
91 |
-
<div>
|
92 |
-
<div className={styles.row}>
|
93 |
-
<div className={styles.gradientPickerRow}>
|
94 |
-
<img
|
95 |
-
className={classNames({
|
96 |
-
[styles.inactiveGradient]: this.props.gradientType !== GradientTypes.SOLID,
|
97 |
-
[styles.clickable]: true
|
98 |
-
})}
|
99 |
-
draggable={false}
|
100 |
-
src={fillSolidIcon}
|
101 |
-
onClick={this.props.onChangeGradientTypeSolid}
|
102 |
-
width={20}
|
103 |
-
height={20}
|
104 |
-
/>
|
105 |
-
<img
|
106 |
-
className={classNames({
|
107 |
-
[styles.inactiveGradient]:
|
108 |
-
this.props.gradientType !== GradientTypes.HORIZONTAL,
|
109 |
-
[styles.clickable]: true
|
110 |
-
})}
|
111 |
-
draggable={false}
|
112 |
-
src={fillHorzGradientIcon}
|
113 |
-
onClick={this.props.onChangeGradientTypeHorizontal}
|
114 |
-
width={20}
|
115 |
-
height={20}
|
116 |
-
/>
|
117 |
-
<img
|
118 |
-
className={classNames({
|
119 |
-
[styles.inactiveGradient]: this.props.gradientType !== GradientTypes.VERTICAL,
|
120 |
-
[styles.clickable]: true
|
121 |
-
})}
|
122 |
-
draggable={false}
|
123 |
-
src={fillVertGradientIcon}
|
124 |
-
onClick={this.props.onChangeGradientTypeVertical}
|
125 |
-
width={20}
|
126 |
-
height={20}
|
127 |
-
/>
|
128 |
-
<img
|
129 |
-
className={classNames({
|
130 |
-
[styles.inactiveGradient]: this.props.gradientType !== GradientTypes.RADIAL,
|
131 |
-
[styles.clickable]: true
|
132 |
-
})}
|
133 |
-
draggable={false}
|
134 |
-
src={fillRadialIcon}
|
135 |
-
onClick={this.props.onChangeGradientTypeRadial}
|
136 |
-
width={20}
|
137 |
-
height={20}
|
138 |
-
/>
|
139 |
-
</div>
|
140 |
-
</div>
|
141 |
-
<div className={styles.divider} />
|
142 |
-
{this.props.gradientType === GradientTypes.SOLID ? null : (
|
143 |
-
<div className={styles.row}>
|
144 |
-
<div
|
145 |
-
className={classNames(
|
146 |
-
styles.gradientPickerRow,
|
147 |
-
styles.gradientSwatchesRow
|
148 |
-
)}
|
149 |
-
>
|
150 |
-
<div
|
151 |
-
className={classNames({
|
152 |
-
[styles.clickable]: true,
|
153 |
-
[styles.swatch]: true,
|
154 |
-
[styles.largeSwatch]: true,
|
155 |
-
[styles.activeSwatch]: this.props.colorIndex === 0
|
156 |
-
})}
|
157 |
-
style={{
|
158 |
-
backgroundColor: this.props.color === null || this.props.color === MIXED ?
|
159 |
-
'white' : this.props.color
|
160 |
-
}}
|
161 |
-
onClick={this.props.onSelectColor}
|
162 |
-
>
|
163 |
-
{this.props.color === null ? (
|
164 |
-
<img
|
165 |
-
className={styles.largeSwatchIcon}
|
166 |
-
draggable={false}
|
167 |
-
src={noFillIcon}
|
168 |
-
/>
|
169 |
-
) : this.props.color === MIXED ? (
|
170 |
-
<img
|
171 |
-
className={styles.largeSwatchIcon}
|
172 |
-
draggable={false}
|
173 |
-
src={mixedFillIcon}
|
174 |
-
/>
|
175 |
-
) : null}
|
176 |
-
</div>
|
177 |
-
<LabeledIconButton
|
178 |
-
className={styles.swapButton}
|
179 |
-
imgSrc={swapIcon}
|
180 |
-
title={this.props.intl.formatMessage(messages.swap)}
|
181 |
-
onClick={this.props.onSwap}
|
182 |
-
/>
|
183 |
-
<div
|
184 |
-
className={classNames({
|
185 |
-
[styles.clickable]: true,
|
186 |
-
[styles.swatch]: true,
|
187 |
-
[styles.largeSwatch]: true,
|
188 |
-
[styles.activeSwatch]: this.props.colorIndex === 1
|
189 |
-
})}
|
190 |
-
style={{
|
191 |
-
backgroundColor: this.props.color2 === null || this.props.color2 === MIXED ?
|
192 |
-
'white' : this.props.color2
|
193 |
-
}}
|
194 |
-
onClick={this.props.onSelectColor2}
|
195 |
-
>
|
196 |
-
{this.props.color2 === null ? (
|
197 |
-
<img
|
198 |
-
className={styles.largeSwatchIcon}
|
199 |
-
draggable={false}
|
200 |
-
src={noFillIcon}
|
201 |
-
/>
|
202 |
-
) : this.props.color2 === MIXED ? (
|
203 |
-
<img
|
204 |
-
className={styles.largeSwatchIcon}
|
205 |
-
draggable={false}
|
206 |
-
src={mixedFillIcon}
|
207 |
-
/>
|
208 |
-
) : null}
|
209 |
-
</div>
|
210 |
-
</div>
|
211 |
-
</div>
|
212 |
-
)}
|
213 |
-
</div>
|
214 |
-
) : null}
|
215 |
-
<div className={styles.row}>
|
216 |
-
<div className={styles.rowHeader}>
|
217 |
-
<span className={styles.labelName}>
|
218 |
-
<FormattedMessage
|
219 |
-
defaultMessage="Color"
|
220 |
-
description="Label for the hue component in the color picker"
|
221 |
-
id="paint.paintEditor.hue"
|
222 |
-
/>
|
223 |
-
</span>
|
224 |
-
<TWColorReadout
|
225 |
-
value={this.props.hue}
|
226 |
-
onChange={this.props.onHueChange}
|
227 |
-
/>
|
228 |
-
</div>
|
229 |
-
<div className={styles.rowSlider}>
|
230 |
-
<Slider
|
231 |
-
background={this._makeBackground('hue')}
|
232 |
-
value={this.props.hue}
|
233 |
-
onChange={this.props.onHueChange}
|
234 |
-
/>
|
235 |
-
</div>
|
236 |
-
</div>
|
237 |
-
<div className={styles.row}>
|
238 |
-
<div className={styles.rowHeader}>
|
239 |
-
<span className={styles.labelName}>
|
240 |
-
<FormattedMessage
|
241 |
-
defaultMessage="Saturation"
|
242 |
-
description="Label for the saturation component in the color picker"
|
243 |
-
id="paint.paintEditor.saturation"
|
244 |
-
/>
|
245 |
-
</span>
|
246 |
-
<TWColorReadout
|
247 |
-
value={this.props.saturation}
|
248 |
-
onChange={this.props.onSaturationChange}
|
249 |
-
/>
|
250 |
-
</div>
|
251 |
-
<div className={styles.rowSlider}>
|
252 |
-
<Slider
|
253 |
-
background={this._makeBackground('saturation')}
|
254 |
-
value={this.props.saturation}
|
255 |
-
onChange={this.props.onSaturationChange}
|
256 |
-
/>
|
257 |
-
</div>
|
258 |
-
</div>
|
259 |
-
<div className={styles.row}>
|
260 |
-
<div className={styles.rowHeader}>
|
261 |
-
<span className={styles.labelName}>
|
262 |
-
<FormattedMessage
|
263 |
-
defaultMessage="Brightness"
|
264 |
-
description="Label for the brightness component in the color picker"
|
265 |
-
id="paint.paintEditor.brightness"
|
266 |
-
/>
|
267 |
-
</span>
|
268 |
-
<TWColorReadout
|
269 |
-
value={this.props.brightness}
|
270 |
-
onChange={this.props.onBrightnessChange}
|
271 |
-
/>
|
272 |
-
</div>
|
273 |
-
<div className={styles.rowSlider}>
|
274 |
-
<Slider
|
275 |
-
background={this._makeBackground('brightness')}
|
276 |
-
value={this.props.brightness}
|
277 |
-
onChange={this.props.onBrightnessChange}
|
278 |
-
/>
|
279 |
-
</div>
|
280 |
-
</div>
|
281 |
-
<div className={styles.row}>
|
282 |
-
<div className={styles.rowHeader}>
|
283 |
-
<span className={styles.labelName}>
|
284 |
-
<FormattedMessage
|
285 |
-
defaultMessage="Opacity"
|
286 |
-
description="Label for the transparency component in the color picker"
|
287 |
-
id="tw.paint.alpha"
|
288 |
-
/>
|
289 |
-
</span>
|
290 |
-
<TWColorReadout
|
291 |
-
value={this.props.alpha}
|
292 |
-
onChange={this.props.onAlphaChange}
|
293 |
-
/>
|
294 |
-
</div>
|
295 |
-
<div className={styles.rowSlider}>
|
296 |
-
<Slider
|
297 |
-
lastSlider
|
298 |
-
background={this._makeBackground('alpha')}
|
299 |
-
value={this.props.alpha}
|
300 |
-
onChange={this.props.onAlphaChange}
|
301 |
-
/>
|
302 |
-
</div>
|
303 |
-
</div>
|
304 |
-
<div className={styles.pickerRow}>
|
305 |
-
<Input
|
306 |
-
type="color"
|
307 |
-
className={styles.pickerColor}
|
308 |
-
// HTML color input does not understand transparency
|
309 |
-
value={this.props.hexColor ? this.props.hexColor.substr(0, 7) : '#000000'}
|
310 |
-
onChange={this.props.onHexColorChange}
|
311 |
-
/>
|
312 |
-
<BufferedInput
|
313 |
-
type="text"
|
314 |
-
className={styles.pickerText}
|
315 |
-
value={this.props.hexColor || '#00000000'}
|
316 |
-
onSubmit={this.props.onHexColorChange}
|
317 |
-
placeholder="#123abc"
|
318 |
-
/>
|
319 |
-
</div>
|
320 |
-
<div className={styles.swatchRow}>
|
321 |
-
<div className={styles.swatches}>
|
322 |
-
{this.props.mode === Modes.BIT_LINE ||
|
323 |
-
this.props.mode === Modes.BIT_RECT ||
|
324 |
-
this.props.mode === Modes.BIT_OVAL ||
|
325 |
-
this.props.mode === Modes.BIT_TEXT ? null :
|
326 |
-
(<div
|
327 |
-
className={classNames({
|
328 |
-
[styles.clickable]: true,
|
329 |
-
[styles.swatch]: true,
|
330 |
-
[styles.activeSwatch]:
|
331 |
-
(this.props.colorIndex === 0 && this.props.color === null) ||
|
332 |
-
(this.props.colorIndex === 1 && this.props.color2 === null)
|
333 |
-
})}
|
334 |
-
onClick={this.props.onTransparent}
|
335 |
-
>
|
336 |
-
<img
|
337 |
-
className={styles.swatchIcon}
|
338 |
-
draggable={false}
|
339 |
-
src={noFillIcon}
|
340 |
-
/>
|
341 |
-
</div>)
|
342 |
-
}
|
343 |
-
</div>
|
344 |
-
<div className={styles.swatches}>
|
345 |
-
<div
|
346 |
-
className={classNames({
|
347 |
-
[styles.clickable]: true,
|
348 |
-
[styles.swatch]: true,
|
349 |
-
[styles.activeSwatch]: this.props.isEyeDropping
|
350 |
-
})}
|
351 |
-
onClick={this.props.onActivateEyeDropper}
|
352 |
-
>
|
353 |
-
<img
|
354 |
-
className={styles.swatchIcon}
|
355 |
-
draggable={false}
|
356 |
-
src={eyeDropperIcon}
|
357 |
-
/>
|
358 |
-
</div>
|
359 |
-
</div>
|
360 |
-
</div>
|
361 |
-
</div>
|
362 |
-
);
|
363 |
-
}
|
364 |
-
}
|
365 |
-
|
366 |
-
ColorPickerComponent.propTypes = {
|
367 |
-
alpha: PropTypes.number.isRequired,
|
368 |
-
onAlphaChange: PropTypes.func.isRequired,
|
369 |
-
hexColor: PropTypes.string,
|
370 |
-
onHexColorChange: PropTypes.func,
|
371 |
-
brightness: PropTypes.number.isRequired,
|
372 |
-
color: PropTypes.string,
|
373 |
-
color2: PropTypes.string,
|
374 |
-
colorIndex: PropTypes.number.isRequired,
|
375 |
-
gradientType: PropTypes.oneOf(Object.keys(GradientTypes)).isRequired,
|
376 |
-
hue: PropTypes.number.isRequired,
|
377 |
-
intl: intlShape.isRequired,
|
378 |
-
isEyeDropping: PropTypes.bool.isRequired,
|
379 |
-
mode: PropTypes.oneOf(Object.keys(Modes)),
|
380 |
-
onActivateEyeDropper: PropTypes.func.isRequired,
|
381 |
-
onBrightnessChange: PropTypes.func.isRequired,
|
382 |
-
onChangeGradientTypeHorizontal: PropTypes.func.isRequired,
|
383 |
-
onChangeGradientTypeRadial: PropTypes.func.isRequired,
|
384 |
-
onChangeGradientTypeSolid: PropTypes.func.isRequired,
|
385 |
-
onChangeGradientTypeVertical: PropTypes.func.isRequired,
|
386 |
-
onHueChange: PropTypes.func.isRequired,
|
387 |
-
onSaturationChange: PropTypes.func.isRequired,
|
388 |
-
onSelectColor: PropTypes.func.isRequired,
|
389 |
-
onSelectColor2: PropTypes.func.isRequired,
|
390 |
-
onSwap: PropTypes.func,
|
391 |
-
onTransparent: PropTypes.func.isRequired,
|
392 |
-
rtl: PropTypes.bool.isRequired,
|
393 |
-
saturation: PropTypes.number.isRequired,
|
394 |
-
shouldShowGradientTools: PropTypes.bool.isRequired
|
395 |
-
};
|
396 |
-
|
397 |
-
export default injectIntl(ColorPickerComponent);
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import {defineMessages, FormattedMessage, injectIntl, intlShape} from 'react-intl';
|
4 |
+
|
5 |
+
import classNames from 'classnames';
|
6 |
+
import parseColor from 'parse-color';
|
7 |
+
|
8 |
+
import Slider, {CONTAINER_WIDTH, HANDLE_WIDTH} from '../forms/slider.jsx';
|
9 |
+
import LabeledIconButton from '../labeled-icon-button/labeled-icon-button.jsx';
|
10 |
+
import styles from './color-picker.css';
|
11 |
+
import GradientTypes from '../../lib/gradient-types';
|
12 |
+
import {MIXED} from '../../helper/style-path';
|
13 |
+
|
14 |
+
import eyeDropperIcon from './icons/eye-dropper.svg';
|
15 |
+
import noFillIcon from '../color-button/no-fill.svg';
|
16 |
+
import mixedFillIcon from '../color-button/mixed-fill.svg';
|
17 |
+
import fillHorzGradientIcon from './icons/fill-horz-gradient-enabled.svg';
|
18 |
+
import fillRadialIcon from './icons/fill-radial-enabled.svg';
|
19 |
+
import fillSolidIcon from './icons/fill-solid-enabled.svg';
|
20 |
+
import fillVertGradientIcon from './icons/fill-vert-gradient-enabled.svg';
|
21 |
+
import swapIcon from './icons/swap.svg';
|
22 |
+
import Modes from '../../lib/modes';
|
23 |
+
import alphaBackground from './alpha.png';
|
24 |
+
import BufferedInputHOC from '../forms/buffered-input-hoc.jsx';
|
25 |
+
import Input from '../forms/input.jsx';
|
26 |
+
import {makeAlphaComponent} from '../../lib/tw-color-utils';
|
27 |
+
import TWColorReadout from '../tw-color-readout/tw-color-readout.jsx';
|
28 |
+
|
29 |
+
const BufferedInput = BufferedInputHOC(Input);
|
30 |
+
|
31 |
+
const hsvToHex = (h, s, v) =>
|
32 |
+
// Scale hue back up to [0, 360] from [0, 100]
|
33 |
+
parseColor(`hsv(${3.6 * h}, ${s}, ${v})`).hex
|
34 |
+
;
|
35 |
+
|
36 |
+
const messages = defineMessages({
|
37 |
+
swap: {
|
38 |
+
defaultMessage: 'Swap',
|
39 |
+
description: 'Label for button that swaps the two colors in a gradient',
|
40 |
+
id: 'paint.colorPicker.swap'
|
41 |
+
}
|
42 |
+
});
|
43 |
+
class ColorPickerComponent extends React.Component {
|
44 |
+
_makeBackground (channel) {
|
45 |
+
const stops = [];
|
46 |
+
// Generate the color slider background CSS gradients by adding
|
47 |
+
// color stops depending on the slider.
|
48 |
+
for (let n = 100; n >= 0; n -= 10) {
|
49 |
+
switch (channel) {
|
50 |
+
case 'hue':
|
51 |
+
stops.push(hsvToHex(n, this.props.saturation, this.props.brightness));
|
52 |
+
break;
|
53 |
+
case 'saturation':
|
54 |
+
stops.push(hsvToHex(this.props.hue, n, this.props.brightness));
|
55 |
+
break;
|
56 |
+
case 'brightness':
|
57 |
+
stops.push(hsvToHex(this.props.hue, this.props.saturation, n));
|
58 |
+
break;
|
59 |
+
case 'alpha': {
|
60 |
+
const alpha = makeAlphaComponent(n / 100);
|
61 |
+
stops.push(`${hsvToHex(this.props.hue, this.props.saturation, this.props.brightness)}${alpha}`);
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
default:
|
65 |
+
throw new Error(`Unknown channel for color sliders: ${channel}`);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
// The sliders are a rounded capsule shape, and the slider handles are circles. As a consequence, when the
|
70 |
+
// slider handle is fully to one side, its center is actually moved away from the start/end of the slider by
|
71 |
+
// the slider handle's radius, meaning that the effective range of the slider excludes the rounded caps.
|
72 |
+
// To compensate for this, position the first stop to where the rounded cap ends, and position the last stop
|
73 |
+
// to where the rounded cap begins.
|
74 |
+
const halfHandleWidth = HANDLE_WIDTH / 2;
|
75 |
+
stops[0] += ` 0 ${halfHandleWidth}px`;
|
76 |
+
stops[stops.length - 1] += ` ${CONTAINER_WIDTH - halfHandleWidth}px 100%`;
|
77 |
+
|
78 |
+
let css = `linear-gradient(to left, ${stops.join(',')})`;
|
79 |
+
if (channel === 'alpha') {
|
80 |
+
css = `${css}, url("${alphaBackground}")`;
|
81 |
+
}
|
82 |
+
return css;
|
83 |
+
}
|
84 |
+
render () {
|
85 |
+
return (
|
86 |
+
<div
|
87 |
+
className={styles.colorPickerContainer}
|
88 |
+
dir={this.props.rtl ? 'rtl' : 'ltr'}
|
89 |
+
>
|
90 |
+
{this.props.shouldShowGradientTools ? (
|
91 |
+
<div>
|
92 |
+
<div className={styles.row}>
|
93 |
+
<div className={styles.gradientPickerRow}>
|
94 |
+
<img
|
95 |
+
className={classNames({
|
96 |
+
[styles.inactiveGradient]: this.props.gradientType !== GradientTypes.SOLID,
|
97 |
+
[styles.clickable]: true
|
98 |
+
})}
|
99 |
+
draggable={false}
|
100 |
+
src={fillSolidIcon}
|
101 |
+
onClick={this.props.onChangeGradientTypeSolid}
|
102 |
+
width={20}
|
103 |
+
height={20}
|
104 |
+
/>
|
105 |
+
<img
|
106 |
+
className={classNames({
|
107 |
+
[styles.inactiveGradient]:
|
108 |
+
this.props.gradientType !== GradientTypes.HORIZONTAL,
|
109 |
+
[styles.clickable]: true
|
110 |
+
})}
|
111 |
+
draggable={false}
|
112 |
+
src={fillHorzGradientIcon}
|
113 |
+
onClick={this.props.onChangeGradientTypeHorizontal}
|
114 |
+
width={20}
|
115 |
+
height={20}
|
116 |
+
/>
|
117 |
+
<img
|
118 |
+
className={classNames({
|
119 |
+
[styles.inactiveGradient]: this.props.gradientType !== GradientTypes.VERTICAL,
|
120 |
+
[styles.clickable]: true
|
121 |
+
})}
|
122 |
+
draggable={false}
|
123 |
+
src={fillVertGradientIcon}
|
124 |
+
onClick={this.props.onChangeGradientTypeVertical}
|
125 |
+
width={20}
|
126 |
+
height={20}
|
127 |
+
/>
|
128 |
+
<img
|
129 |
+
className={classNames({
|
130 |
+
[styles.inactiveGradient]: this.props.gradientType !== GradientTypes.RADIAL,
|
131 |
+
[styles.clickable]: true
|
132 |
+
})}
|
133 |
+
draggable={false}
|
134 |
+
src={fillRadialIcon}
|
135 |
+
onClick={this.props.onChangeGradientTypeRadial}
|
136 |
+
width={20}
|
137 |
+
height={20}
|
138 |
+
/>
|
139 |
+
</div>
|
140 |
+
</div>
|
141 |
+
<div className={styles.divider} />
|
142 |
+
{this.props.gradientType === GradientTypes.SOLID ? null : (
|
143 |
+
<div className={styles.row}>
|
144 |
+
<div
|
145 |
+
className={classNames(
|
146 |
+
styles.gradientPickerRow,
|
147 |
+
styles.gradientSwatchesRow
|
148 |
+
)}
|
149 |
+
>
|
150 |
+
<div
|
151 |
+
className={classNames({
|
152 |
+
[styles.clickable]: true,
|
153 |
+
[styles.swatch]: true,
|
154 |
+
[styles.largeSwatch]: true,
|
155 |
+
[styles.activeSwatch]: this.props.colorIndex === 0
|
156 |
+
})}
|
157 |
+
style={{
|
158 |
+
backgroundColor: this.props.color === null || this.props.color === MIXED ?
|
159 |
+
'white' : this.props.color
|
160 |
+
}}
|
161 |
+
onClick={this.props.onSelectColor}
|
162 |
+
>
|
163 |
+
{this.props.color === null ? (
|
164 |
+
<img
|
165 |
+
className={styles.largeSwatchIcon}
|
166 |
+
draggable={false}
|
167 |
+
src={noFillIcon}
|
168 |
+
/>
|
169 |
+
) : this.props.color === MIXED ? (
|
170 |
+
<img
|
171 |
+
className={styles.largeSwatchIcon}
|
172 |
+
draggable={false}
|
173 |
+
src={mixedFillIcon}
|
174 |
+
/>
|
175 |
+
) : null}
|
176 |
+
</div>
|
177 |
+
<LabeledIconButton
|
178 |
+
className={styles.swapButton}
|
179 |
+
imgSrc={swapIcon}
|
180 |
+
title={this.props.intl.formatMessage(messages.swap)}
|
181 |
+
onClick={this.props.onSwap}
|
182 |
+
/>
|
183 |
+
<div
|
184 |
+
className={classNames({
|
185 |
+
[styles.clickable]: true,
|
186 |
+
[styles.swatch]: true,
|
187 |
+
[styles.largeSwatch]: true,
|
188 |
+
[styles.activeSwatch]: this.props.colorIndex === 1
|
189 |
+
})}
|
190 |
+
style={{
|
191 |
+
backgroundColor: this.props.color2 === null || this.props.color2 === MIXED ?
|
192 |
+
'white' : this.props.color2
|
193 |
+
}}
|
194 |
+
onClick={this.props.onSelectColor2}
|
195 |
+
>
|
196 |
+
{this.props.color2 === null ? (
|
197 |
+
<img
|
198 |
+
className={styles.largeSwatchIcon}
|
199 |
+
draggable={false}
|
200 |
+
src={noFillIcon}
|
201 |
+
/>
|
202 |
+
) : this.props.color2 === MIXED ? (
|
203 |
+
<img
|
204 |
+
className={styles.largeSwatchIcon}
|
205 |
+
draggable={false}
|
206 |
+
src={mixedFillIcon}
|
207 |
+
/>
|
208 |
+
) : null}
|
209 |
+
</div>
|
210 |
+
</div>
|
211 |
+
</div>
|
212 |
+
)}
|
213 |
+
</div>
|
214 |
+
) : null}
|
215 |
+
<div className={styles.row}>
|
216 |
+
<div className={styles.rowHeader}>
|
217 |
+
<span className={styles.labelName}>
|
218 |
+
<FormattedMessage
|
219 |
+
defaultMessage="Color"
|
220 |
+
description="Label for the hue component in the color picker"
|
221 |
+
id="paint.paintEditor.hue"
|
222 |
+
/>
|
223 |
+
</span>
|
224 |
+
<TWColorReadout
|
225 |
+
value={this.props.hue}
|
226 |
+
onChange={this.props.onHueChange}
|
227 |
+
/>
|
228 |
+
</div>
|
229 |
+
<div className={styles.rowSlider}>
|
230 |
+
<Slider
|
231 |
+
background={this._makeBackground('hue')}
|
232 |
+
value={this.props.hue}
|
233 |
+
onChange={this.props.onHueChange}
|
234 |
+
/>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
<div className={styles.row}>
|
238 |
+
<div className={styles.rowHeader}>
|
239 |
+
<span className={styles.labelName}>
|
240 |
+
<FormattedMessage
|
241 |
+
defaultMessage="Saturation"
|
242 |
+
description="Label for the saturation component in the color picker"
|
243 |
+
id="paint.paintEditor.saturation"
|
244 |
+
/>
|
245 |
+
</span>
|
246 |
+
<TWColorReadout
|
247 |
+
value={this.props.saturation}
|
248 |
+
onChange={this.props.onSaturationChange}
|
249 |
+
/>
|
250 |
+
</div>
|
251 |
+
<div className={styles.rowSlider}>
|
252 |
+
<Slider
|
253 |
+
background={this._makeBackground('saturation')}
|
254 |
+
value={this.props.saturation}
|
255 |
+
onChange={this.props.onSaturationChange}
|
256 |
+
/>
|
257 |
+
</div>
|
258 |
+
</div>
|
259 |
+
<div className={styles.row}>
|
260 |
+
<div className={styles.rowHeader}>
|
261 |
+
<span className={styles.labelName}>
|
262 |
+
<FormattedMessage
|
263 |
+
defaultMessage="Brightness"
|
264 |
+
description="Label for the brightness component in the color picker"
|
265 |
+
id="paint.paintEditor.brightness"
|
266 |
+
/>
|
267 |
+
</span>
|
268 |
+
<TWColorReadout
|
269 |
+
value={this.props.brightness}
|
270 |
+
onChange={this.props.onBrightnessChange}
|
271 |
+
/>
|
272 |
+
</div>
|
273 |
+
<div className={styles.rowSlider}>
|
274 |
+
<Slider
|
275 |
+
background={this._makeBackground('brightness')}
|
276 |
+
value={this.props.brightness}
|
277 |
+
onChange={this.props.onBrightnessChange}
|
278 |
+
/>
|
279 |
+
</div>
|
280 |
+
</div>
|
281 |
+
<div className={styles.row}>
|
282 |
+
<div className={styles.rowHeader}>
|
283 |
+
<span className={styles.labelName}>
|
284 |
+
<FormattedMessage
|
285 |
+
defaultMessage="Opacity"
|
286 |
+
description="Label for the transparency component in the color picker"
|
287 |
+
id="tw.paint.alpha"
|
288 |
+
/>
|
289 |
+
</span>
|
290 |
+
<TWColorReadout
|
291 |
+
value={this.props.alpha}
|
292 |
+
onChange={this.props.onAlphaChange}
|
293 |
+
/>
|
294 |
+
</div>
|
295 |
+
<div className={styles.rowSlider}>
|
296 |
+
<Slider
|
297 |
+
lastSlider
|
298 |
+
background={this._makeBackground('alpha')}
|
299 |
+
value={this.props.alpha}
|
300 |
+
onChange={this.props.onAlphaChange}
|
301 |
+
/>
|
302 |
+
</div>
|
303 |
+
</div>
|
304 |
+
<div className={styles.pickerRow}>
|
305 |
+
<Input
|
306 |
+
type="color"
|
307 |
+
className={styles.pickerColor}
|
308 |
+
// HTML color input does not understand transparency
|
309 |
+
value={this.props.hexColor ? this.props.hexColor.substr(0, 7) : '#000000'}
|
310 |
+
onChange={this.props.onHexColorChange}
|
311 |
+
/>
|
312 |
+
<BufferedInput
|
313 |
+
type="text"
|
314 |
+
className={styles.pickerText}
|
315 |
+
value={this.props.hexColor || '#00000000'}
|
316 |
+
onSubmit={this.props.onHexColorChange}
|
317 |
+
placeholder="#123abc"
|
318 |
+
/>
|
319 |
+
</div>
|
320 |
+
<div className={styles.swatchRow}>
|
321 |
+
<div className={styles.swatches}>
|
322 |
+
{this.props.mode === Modes.BIT_LINE ||
|
323 |
+
this.props.mode === Modes.BIT_RECT ||
|
324 |
+
this.props.mode === Modes.BIT_OVAL ||
|
325 |
+
this.props.mode === Modes.BIT_TEXT ? null :
|
326 |
+
(<div
|
327 |
+
className={classNames({
|
328 |
+
[styles.clickable]: true,
|
329 |
+
[styles.swatch]: true,
|
330 |
+
[styles.activeSwatch]:
|
331 |
+
(this.props.colorIndex === 0 && this.props.color === null) ||
|
332 |
+
(this.props.colorIndex === 1 && this.props.color2 === null)
|
333 |
+
})}
|
334 |
+
onClick={this.props.onTransparent}
|
335 |
+
>
|
336 |
+
<img
|
337 |
+
className={styles.swatchIcon}
|
338 |
+
draggable={false}
|
339 |
+
src={noFillIcon}
|
340 |
+
/>
|
341 |
+
</div>)
|
342 |
+
}
|
343 |
+
</div>
|
344 |
+
<div className={styles.swatches}>
|
345 |
+
<div
|
346 |
+
className={classNames({
|
347 |
+
[styles.clickable]: true,
|
348 |
+
[styles.swatch]: true,
|
349 |
+
[styles.activeSwatch]: this.props.isEyeDropping
|
350 |
+
})}
|
351 |
+
onClick={this.props.onActivateEyeDropper}
|
352 |
+
>
|
353 |
+
<img
|
354 |
+
className={styles.swatchIcon}
|
355 |
+
draggable={false}
|
356 |
+
src={eyeDropperIcon}
|
357 |
+
/>
|
358 |
+
</div>
|
359 |
+
</div>
|
360 |
+
</div>
|
361 |
+
</div>
|
362 |
+
);
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
ColorPickerComponent.propTypes = {
|
367 |
+
alpha: PropTypes.number.isRequired,
|
368 |
+
onAlphaChange: PropTypes.func.isRequired,
|
369 |
+
hexColor: PropTypes.string,
|
370 |
+
onHexColorChange: PropTypes.func,
|
371 |
+
brightness: PropTypes.number.isRequired,
|
372 |
+
color: PropTypes.string,
|
373 |
+
color2: PropTypes.string,
|
374 |
+
colorIndex: PropTypes.number.isRequired,
|
375 |
+
gradientType: PropTypes.oneOf(Object.keys(GradientTypes)).isRequired,
|
376 |
+
hue: PropTypes.number.isRequired,
|
377 |
+
intl: intlShape.isRequired,
|
378 |
+
isEyeDropping: PropTypes.bool.isRequired,
|
379 |
+
mode: PropTypes.oneOf(Object.keys(Modes)),
|
380 |
+
onActivateEyeDropper: PropTypes.func.isRequired,
|
381 |
+
onBrightnessChange: PropTypes.func.isRequired,
|
382 |
+
onChangeGradientTypeHorizontal: PropTypes.func.isRequired,
|
383 |
+
onChangeGradientTypeRadial: PropTypes.func.isRequired,
|
384 |
+
onChangeGradientTypeSolid: PropTypes.func.isRequired,
|
385 |
+
onChangeGradientTypeVertical: PropTypes.func.isRequired,
|
386 |
+
onHueChange: PropTypes.func.isRequired,
|
387 |
+
onSaturationChange: PropTypes.func.isRequired,
|
388 |
+
onSelectColor: PropTypes.func.isRequired,
|
389 |
+
onSelectColor2: PropTypes.func.isRequired,
|
390 |
+
onSwap: PropTypes.func,
|
391 |
+
onTransparent: PropTypes.func.isRequired,
|
392 |
+
rtl: PropTypes.bool.isRequired,
|
393 |
+
saturation: PropTypes.number.isRequired,
|
394 |
+
shouldShowGradientTools: PropTypes.bool.isRequired
|
395 |
+
};
|
396 |
+
|
397 |
+
export default injectIntl(ColorPickerComponent);
|
src/components/color-picker/icons/eye-dropper.svg
CHANGED
|
|
src/components/color-picker/icons/fill-horz-gradient-enabled.svg
CHANGED
|
|
src/components/color-picker/icons/fill-radial-enabled.svg
CHANGED
|
|
src/components/color-picker/icons/fill-solid-enabled.svg
CHANGED
|
|
src/components/color-picker/icons/fill-vert-gradient-enabled.svg
CHANGED
|
|
src/components/color-picker/icons/swap.svg
CHANGED
|
|
src/components/coming-soon/coming-soon.jsx
CHANGED
@@ -1,147 +1,147 @@
|
|
1 |
-
/* DO NOT EDIT
|
2 |
-
@todo This file is copied from GUI and should be pulled out into a shared library.
|
3 |
-
See #13 */
|
4 |
-
|
5 |
-
import bindAll from 'lodash.bindall';
|
6 |
-
import classNames from 'classnames';
|
7 |
-
import {defineMessages, injectIntl, intlShape, FormattedMessage} from 'react-intl';
|
8 |
-
import PropTypes from 'prop-types';
|
9 |
-
import React from 'react';
|
10 |
-
import ReactTooltip from 'react-tooltip';
|
11 |
-
|
12 |
-
import styles from './coming-soon.css';
|
13 |
-
|
14 |
-
import awwCatIcon from './aww-cat.png';
|
15 |
-
import coolCatIcon from './cool-cat.png';
|
16 |
-
|
17 |
-
const messages = defineMessages({
|
18 |
-
message1: {
|
19 |
-
defaultMessage: 'Don\'t worry, we\'re on it {emoji}',
|
20 |
-
description: 'One of the "coming soon" random messages for yet-to-be-done features',
|
21 |
-
id: 'gui.comingSoon.message1'
|
22 |
-
},
|
23 |
-
message2: {
|
24 |
-
defaultMessage: 'Coming Soon...',
|
25 |
-
description: 'One of the "coming soon" random messages for yet-to-be-done features',
|
26 |
-
id: 'gui.comingSoon.message2'
|
27 |
-
},
|
28 |
-
message3: {
|
29 |
-
defaultMessage: 'We\'re working on it {emoji}',
|
30 |
-
description: 'One of the "coming soon" random messages for yet-to-be-done features',
|
31 |
-
id: 'gui.comingSoon.message3'
|
32 |
-
}
|
33 |
-
});
|
34 |
-
|
35 |
-
class ComingSoonContent extends React.Component {
|
36 |
-
constructor (props) {
|
37 |
-
super(props);
|
38 |
-
bindAll(this, [
|
39 |
-
'setHide',
|
40 |
-
'setShow',
|
41 |
-
'getRandomMessage'
|
42 |
-
]);
|
43 |
-
this.state = {
|
44 |
-
isShowing: false
|
45 |
-
};
|
46 |
-
}
|
47 |
-
setShow () {
|
48 |
-
// needed to set the opacity to 1, since the default is .9 on show
|
49 |
-
this.setState({isShowing: true});
|
50 |
-
}
|
51 |
-
setHide () {
|
52 |
-
this.setState({isShowing: false});
|
53 |
-
}
|
54 |
-
getRandomMessage () {
|
55 |
-
// randomly chooses a messages from `messages` to display in the tooltip.
|
56 |
-
const images = [awwCatIcon, coolCatIcon];
|
57 |
-
const messageNumber = Math.floor(Math.random() * Object.keys(messages).length) + 1;
|
58 |
-
const imageNumber = Math.floor(Math.random() * Object.keys(images).length);
|
59 |
-
return (
|
60 |
-
<FormattedMessage
|
61 |
-
{...messages[`message${messageNumber}`]}
|
62 |
-
values={{
|
63 |
-
emoji: (
|
64 |
-
<img
|
65 |
-
className={styles.comingSoonImage}
|
66 |
-
src={images[imageNumber]}
|
67 |
-
/>
|
68 |
-
)
|
69 |
-
}}
|
70 |
-
/>
|
71 |
-
);
|
72 |
-
}
|
73 |
-
render () {
|
74 |
-
return (
|
75 |
-
<ReactTooltip
|
76 |
-
afterHide={this.setHide}
|
77 |
-
afterShow={this.setShow}
|
78 |
-
className={classNames(
|
79 |
-
styles.comingSoon,
|
80 |
-
this.props.className,
|
81 |
-
{
|
82 |
-
[styles.show]: (this.state.isShowing),
|
83 |
-
[styles.left]: (this.props.place === 'left'),
|
84 |
-
[styles.right]: (this.props.place === 'right'),
|
85 |
-
[styles.top]: (this.props.place === 'top'),
|
86 |
-
[styles.bottom]: (this.props.place === 'bottom')
|
87 |
-
}
|
88 |
-
)}
|
89 |
-
getContent={this.getRandomMessage}
|
90 |
-
id={this.props.tooltipId}
|
91 |
-
/>
|
92 |
-
);
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
ComingSoonContent.propTypes = {
|
97 |
-
className: PropTypes.string,
|
98 |
-
intl: intlShape,
|
99 |
-
place: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
100 |
-
tooltipId: PropTypes.string.isRequired
|
101 |
-
};
|
102 |
-
|
103 |
-
ComingSoonContent.defaultProps = {
|
104 |
-
place: 'bottom'
|
105 |
-
};
|
106 |
-
|
107 |
-
const ComingSoon = injectIntl(ComingSoonContent);
|
108 |
-
|
109 |
-
const ComingSoonTooltip = props => (
|
110 |
-
<div className={props.className}>
|
111 |
-
<div
|
112 |
-
data-delay-hide={props.delayHide}
|
113 |
-
data-delay-show={props.delayShow}
|
114 |
-
data-effect="solid"
|
115 |
-
data-for={props.tooltipId}
|
116 |
-
data-place={props.place}
|
117 |
-
data-tip="tooltip"
|
118 |
-
>
|
119 |
-
{props.children}
|
120 |
-
</div>
|
121 |
-
<ComingSoon
|
122 |
-
className={props.tooltipClassName}
|
123 |
-
place={props.place}
|
124 |
-
tooltipId={props.tooltipId}
|
125 |
-
/>
|
126 |
-
</div>
|
127 |
-
);
|
128 |
-
|
129 |
-
ComingSoonTooltip.propTypes = {
|
130 |
-
children: PropTypes.node.isRequired,
|
131 |
-
className: PropTypes.string,
|
132 |
-
delayHide: PropTypes.number,
|
133 |
-
delayShow: PropTypes.number,
|
134 |
-
place: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
135 |
-
tooltipClassName: PropTypes.string,
|
136 |
-
tooltipId: PropTypes.string.isRequired
|
137 |
-
};
|
138 |
-
|
139 |
-
ComingSoonTooltip.defaultProps = {
|
140 |
-
delayHide: 0,
|
141 |
-
delayShow: 0
|
142 |
-
};
|
143 |
-
|
144 |
-
export {
|
145 |
-
ComingSoon as ComingSoonComponent,
|
146 |
-
ComingSoonTooltip
|
147 |
-
};
|
|
|
1 |
+
/* DO NOT EDIT
|
2 |
+
@todo This file is copied from GUI and should be pulled out into a shared library.
|
3 |
+
See #13 */
|
4 |
+
|
5 |
+
import bindAll from 'lodash.bindall';
|
6 |
+
import classNames from 'classnames';
|
7 |
+
import {defineMessages, injectIntl, intlShape, FormattedMessage} from 'react-intl';
|
8 |
+
import PropTypes from 'prop-types';
|
9 |
+
import React from 'react';
|
10 |
+
import ReactTooltip from 'react-tooltip';
|
11 |
+
|
12 |
+
import styles from './coming-soon.css';
|
13 |
+
|
14 |
+
import awwCatIcon from './aww-cat.png';
|
15 |
+
import coolCatIcon from './cool-cat.png';
|
16 |
+
|
17 |
+
const messages = defineMessages({
|
18 |
+
message1: {
|
19 |
+
defaultMessage: 'Don\'t worry, we\'re on it {emoji}',
|
20 |
+
description: 'One of the "coming soon" random messages for yet-to-be-done features',
|
21 |
+
id: 'gui.comingSoon.message1'
|
22 |
+
},
|
23 |
+
message2: {
|
24 |
+
defaultMessage: 'Coming Soon...',
|
25 |
+
description: 'One of the "coming soon" random messages for yet-to-be-done features',
|
26 |
+
id: 'gui.comingSoon.message2'
|
27 |
+
},
|
28 |
+
message3: {
|
29 |
+
defaultMessage: 'We\'re working on it {emoji}',
|
30 |
+
description: 'One of the "coming soon" random messages for yet-to-be-done features',
|
31 |
+
id: 'gui.comingSoon.message3'
|
32 |
+
}
|
33 |
+
});
|
34 |
+
|
35 |
+
class ComingSoonContent extends React.Component {
|
36 |
+
constructor (props) {
|
37 |
+
super(props);
|
38 |
+
bindAll(this, [
|
39 |
+
'setHide',
|
40 |
+
'setShow',
|
41 |
+
'getRandomMessage'
|
42 |
+
]);
|
43 |
+
this.state = {
|
44 |
+
isShowing: false
|
45 |
+
};
|
46 |
+
}
|
47 |
+
setShow () {
|
48 |
+
// needed to set the opacity to 1, since the default is .9 on show
|
49 |
+
this.setState({isShowing: true});
|
50 |
+
}
|
51 |
+
setHide () {
|
52 |
+
this.setState({isShowing: false});
|
53 |
+
}
|
54 |
+
getRandomMessage () {
|
55 |
+
// randomly chooses a messages from `messages` to display in the tooltip.
|
56 |
+
const images = [awwCatIcon, coolCatIcon];
|
57 |
+
const messageNumber = Math.floor(Math.random() * Object.keys(messages).length) + 1;
|
58 |
+
const imageNumber = Math.floor(Math.random() * Object.keys(images).length);
|
59 |
+
return (
|
60 |
+
<FormattedMessage
|
61 |
+
{...messages[`message${messageNumber}`]}
|
62 |
+
values={{
|
63 |
+
emoji: (
|
64 |
+
<img
|
65 |
+
className={styles.comingSoonImage}
|
66 |
+
src={images[imageNumber]}
|
67 |
+
/>
|
68 |
+
)
|
69 |
+
}}
|
70 |
+
/>
|
71 |
+
);
|
72 |
+
}
|
73 |
+
render () {
|
74 |
+
return (
|
75 |
+
<ReactTooltip
|
76 |
+
afterHide={this.setHide}
|
77 |
+
afterShow={this.setShow}
|
78 |
+
className={classNames(
|
79 |
+
styles.comingSoon,
|
80 |
+
this.props.className,
|
81 |
+
{
|
82 |
+
[styles.show]: (this.state.isShowing),
|
83 |
+
[styles.left]: (this.props.place === 'left'),
|
84 |
+
[styles.right]: (this.props.place === 'right'),
|
85 |
+
[styles.top]: (this.props.place === 'top'),
|
86 |
+
[styles.bottom]: (this.props.place === 'bottom')
|
87 |
+
}
|
88 |
+
)}
|
89 |
+
getContent={this.getRandomMessage}
|
90 |
+
id={this.props.tooltipId}
|
91 |
+
/>
|
92 |
+
);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
ComingSoonContent.propTypes = {
|
97 |
+
className: PropTypes.string,
|
98 |
+
intl: intlShape,
|
99 |
+
place: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
100 |
+
tooltipId: PropTypes.string.isRequired
|
101 |
+
};
|
102 |
+
|
103 |
+
ComingSoonContent.defaultProps = {
|
104 |
+
place: 'bottom'
|
105 |
+
};
|
106 |
+
|
107 |
+
const ComingSoon = injectIntl(ComingSoonContent);
|
108 |
+
|
109 |
+
const ComingSoonTooltip = props => (
|
110 |
+
<div className={props.className}>
|
111 |
+
<div
|
112 |
+
data-delay-hide={props.delayHide}
|
113 |
+
data-delay-show={props.delayShow}
|
114 |
+
data-effect="solid"
|
115 |
+
data-for={props.tooltipId}
|
116 |
+
data-place={props.place}
|
117 |
+
data-tip="tooltip"
|
118 |
+
>
|
119 |
+
{props.children}
|
120 |
+
</div>
|
121 |
+
<ComingSoon
|
122 |
+
className={props.tooltipClassName}
|
123 |
+
place={props.place}
|
124 |
+
tooltipId={props.tooltipId}
|
125 |
+
/>
|
126 |
+
</div>
|
127 |
+
);
|
128 |
+
|
129 |
+
ComingSoonTooltip.propTypes = {
|
130 |
+
children: PropTypes.node.isRequired,
|
131 |
+
className: PropTypes.string,
|
132 |
+
delayHide: PropTypes.number,
|
133 |
+
delayShow: PropTypes.number,
|
134 |
+
place: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
135 |
+
tooltipClassName: PropTypes.string,
|
136 |
+
tooltipId: PropTypes.string.isRequired
|
137 |
+
};
|
138 |
+
|
139 |
+
ComingSoonTooltip.defaultProps = {
|
140 |
+
delayHide: 0,
|
141 |
+
delayShow: 0
|
142 |
+
};
|
143 |
+
|
144 |
+
export {
|
145 |
+
ComingSoon as ComingSoonComponent,
|
146 |
+
ComingSoonTooltip
|
147 |
+
};
|
src/components/dragon-mode/dragon-mode.jsx
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import dragonIcon from './icon.svg';
|
6 |
-
|
7 |
-
const DragonModeComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.dragon}
|
10 |
-
imgSrc={dragonIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
/>
|
14 |
-
);
|
15 |
-
|
16 |
-
DragonModeComponent.propTypes = {
|
17 |
-
isSelected: PropTypes.bool.isRequired,
|
18 |
-
onMouseDown: PropTypes.func.isRequired
|
19 |
-
};
|
20 |
-
|
21 |
-
export default DragonModeComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import dragonIcon from './icon.svg';
|
6 |
+
|
7 |
+
const DragonModeComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.dragon}
|
10 |
+
imgSrc={dragonIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
/>
|
14 |
+
);
|
15 |
+
|
16 |
+
DragonModeComponent.propTypes = {
|
17 |
+
isSelected: PropTypes.bool.isRequired,
|
18 |
+
onMouseDown: PropTypes.func.isRequired
|
19 |
+
};
|
20 |
+
|
21 |
+
export default DragonModeComponent;
|
src/components/dropdown/dropdown-caret.svg
CHANGED
|
|
src/components/dropdown/dropdown.jsx
CHANGED
@@ -1,79 +1,79 @@
|
|
1 |
-
import bindAll from 'lodash.bindall';
|
2 |
-
import classNames from 'classnames';
|
3 |
-
import Popover from 'react-popover';
|
4 |
-
import PropTypes from 'prop-types';
|
5 |
-
import React from 'react';
|
6 |
-
|
7 |
-
import styles from './dropdown.css';
|
8 |
-
|
9 |
-
import dropdownIcon from './dropdown-caret.svg';
|
10 |
-
|
11 |
-
class Dropdown extends React.Component {
|
12 |
-
constructor (props) {
|
13 |
-
super(props);
|
14 |
-
bindAll(this, [
|
15 |
-
'handleClosePopover',
|
16 |
-
'handleToggleOpenState',
|
17 |
-
'isOpen'
|
18 |
-
]);
|
19 |
-
this.state = {
|
20 |
-
isOpen: false
|
21 |
-
};
|
22 |
-
}
|
23 |
-
handleClosePopover () {
|
24 |
-
this.setState({
|
25 |
-
isOpen: false
|
26 |
-
});
|
27 |
-
}
|
28 |
-
handleToggleOpenState () {
|
29 |
-
const newState = !this.state.isOpen;
|
30 |
-
this.setState({
|
31 |
-
isOpen: newState
|
32 |
-
});
|
33 |
-
if (newState && this.props.onOpen) {
|
34 |
-
this.props.onOpen();
|
35 |
-
}
|
36 |
-
}
|
37 |
-
isOpen () {
|
38 |
-
return this.state.isOpen;
|
39 |
-
}
|
40 |
-
render () {
|
41 |
-
return (
|
42 |
-
<Popover
|
43 |
-
body={this.props.popoverContent}
|
44 |
-
isOpen={this.state.isOpen}
|
45 |
-
preferPlace="below"
|
46 |
-
onOuterAction={this.props.onOuterAction ?
|
47 |
-
this.props.onOuterAction : this.handleClosePopover}
|
48 |
-
{...this.props}
|
49 |
-
>
|
50 |
-
<div
|
51 |
-
className={classNames(styles.dropdown, this.props.className, {
|
52 |
-
[styles.modOpen]: this.state.isOpen,
|
53 |
-
[styles.modClosed]: !this.state.isOpen
|
54 |
-
})}
|
55 |
-
onClick={this.handleToggleOpenState}
|
56 |
-
>
|
57 |
-
{this.props.children}
|
58 |
-
<img
|
59 |
-
className={classNames(styles.dropdownIcon, {
|
60 |
-
[styles.modCaretUp]: this.state.isOpen
|
61 |
-
})}
|
62 |
-
draggable={false}
|
63 |
-
src={dropdownIcon}
|
64 |
-
/>
|
65 |
-
</div>
|
66 |
-
</Popover>
|
67 |
-
);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
Dropdown.propTypes = {
|
72 |
-
children: PropTypes.node.isRequired,
|
73 |
-
className: PropTypes.string,
|
74 |
-
onOpen: PropTypes.func,
|
75 |
-
onOuterAction: PropTypes.func,
|
76 |
-
popoverContent: PropTypes.node.isRequired
|
77 |
-
};
|
78 |
-
|
79 |
-
export default Dropdown;
|
|
|
1 |
+
import bindAll from 'lodash.bindall';
|
2 |
+
import classNames from 'classnames';
|
3 |
+
import Popover from 'react-popover';
|
4 |
+
import PropTypes from 'prop-types';
|
5 |
+
import React from 'react';
|
6 |
+
|
7 |
+
import styles from './dropdown.css';
|
8 |
+
|
9 |
+
import dropdownIcon from './dropdown-caret.svg';
|
10 |
+
|
11 |
+
class Dropdown extends React.Component {
|
12 |
+
constructor (props) {
|
13 |
+
super(props);
|
14 |
+
bindAll(this, [
|
15 |
+
'handleClosePopover',
|
16 |
+
'handleToggleOpenState',
|
17 |
+
'isOpen'
|
18 |
+
]);
|
19 |
+
this.state = {
|
20 |
+
isOpen: false
|
21 |
+
};
|
22 |
+
}
|
23 |
+
handleClosePopover () {
|
24 |
+
this.setState({
|
25 |
+
isOpen: false
|
26 |
+
});
|
27 |
+
}
|
28 |
+
handleToggleOpenState () {
|
29 |
+
const newState = !this.state.isOpen;
|
30 |
+
this.setState({
|
31 |
+
isOpen: newState
|
32 |
+
});
|
33 |
+
if (newState && this.props.onOpen) {
|
34 |
+
this.props.onOpen();
|
35 |
+
}
|
36 |
+
}
|
37 |
+
isOpen () {
|
38 |
+
return this.state.isOpen;
|
39 |
+
}
|
40 |
+
render () {
|
41 |
+
return (
|
42 |
+
<Popover
|
43 |
+
body={this.props.popoverContent}
|
44 |
+
isOpen={this.state.isOpen}
|
45 |
+
preferPlace="below"
|
46 |
+
onOuterAction={this.props.onOuterAction ?
|
47 |
+
this.props.onOuterAction : this.handleClosePopover}
|
48 |
+
{...this.props}
|
49 |
+
>
|
50 |
+
<div
|
51 |
+
className={classNames(styles.dropdown, this.props.className, {
|
52 |
+
[styles.modOpen]: this.state.isOpen,
|
53 |
+
[styles.modClosed]: !this.state.isOpen
|
54 |
+
})}
|
55 |
+
onClick={this.handleToggleOpenState}
|
56 |
+
>
|
57 |
+
{this.props.children}
|
58 |
+
<img
|
59 |
+
className={classNames(styles.dropdownIcon, {
|
60 |
+
[styles.modCaretUp]: this.state.isOpen
|
61 |
+
})}
|
62 |
+
draggable={false}
|
63 |
+
src={dropdownIcon}
|
64 |
+
/>
|
65 |
+
</div>
|
66 |
+
</Popover>
|
67 |
+
);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
Dropdown.propTypes = {
|
72 |
+
children: PropTypes.node.isRequired,
|
73 |
+
className: PropTypes.string,
|
74 |
+
onOpen: PropTypes.func,
|
75 |
+
onOuterAction: PropTypes.func,
|
76 |
+
popoverContent: PropTypes.node.isRequired
|
77 |
+
};
|
78 |
+
|
79 |
+
export default Dropdown;
|
src/components/eraser-mode/eraser-mode.jsx
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import eraserIcon from './eraser.svg';
|
6 |
-
|
7 |
-
const EraserModeComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.eraser}
|
10 |
-
imgSrc={eraserIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
keybinding="E"
|
14 |
-
/>
|
15 |
-
);
|
16 |
-
|
17 |
-
EraserModeComponent.propTypes = {
|
18 |
-
isSelected: PropTypes.bool.isRequired,
|
19 |
-
onMouseDown: PropTypes.func.isRequired
|
20 |
-
};
|
21 |
-
|
22 |
-
export default EraserModeComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import eraserIcon from './eraser.svg';
|
6 |
+
|
7 |
+
const EraserModeComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.eraser}
|
10 |
+
imgSrc={eraserIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
keybinding="E"
|
14 |
+
/>
|
15 |
+
);
|
16 |
+
|
17 |
+
EraserModeComponent.propTypes = {
|
18 |
+
isSelected: PropTypes.bool.isRequired,
|
19 |
+
onMouseDown: PropTypes.func.isRequired
|
20 |
+
};
|
21 |
+
|
22 |
+
export default EraserModeComponent;
|
src/components/eraser-mode/eraser.svg
CHANGED
|
|
src/components/fill-mode/fill-mode.jsx
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import PropTypes from 'prop-types';
|
3 |
-
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
-
import messages from '../../lib/messages.js';
|
5 |
-
import fillIcon from './fill.svg';
|
6 |
-
|
7 |
-
const FillModeComponent = props => (
|
8 |
-
<ToolSelectComponent
|
9 |
-
imgDescriptor={messages.fill}
|
10 |
-
imgSrc={fillIcon}
|
11 |
-
isSelected={props.isSelected}
|
12 |
-
onMouseDown={props.onMouseDown}
|
13 |
-
keybinding="F"
|
14 |
-
/>
|
15 |
-
);
|
16 |
-
|
17 |
-
FillModeComponent.propTypes = {
|
18 |
-
isSelected: PropTypes.bool.isRequired,
|
19 |
-
onMouseDown: PropTypes.func.isRequired
|
20 |
-
};
|
21 |
-
|
22 |
-
export default FillModeComponent;
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import PropTypes from 'prop-types';
|
3 |
+
import ToolSelectComponent from '../tool-select-base/tool-select-base.jsx';
|
4 |
+
import messages from '../../lib/messages.js';
|
5 |
+
import fillIcon from './fill.svg';
|
6 |
+
|
7 |
+
const FillModeComponent = props => (
|
8 |
+
<ToolSelectComponent
|
9 |
+
imgDescriptor={messages.fill}
|
10 |
+
imgSrc={fillIcon}
|
11 |
+
isSelected={props.isSelected}
|
12 |
+
onMouseDown={props.onMouseDown}
|
13 |
+
keybinding="F"
|
14 |
+
/>
|
15 |
+
);
|
16 |
+
|
17 |
+
FillModeComponent.propTypes = {
|
18 |
+
isSelected: PropTypes.bool.isRequired,
|
19 |
+
onMouseDown: PropTypes.func.isRequired
|
20 |
+
};
|
21 |
+
|
22 |
+
export default FillModeComponent;
|
src/components/fill-mode/fill.svg
CHANGED
|
|
src/components/fixed-tools/fixed-tools.jsx
CHANGED
@@ -1,325 +1,325 @@
|
|
1 |
-
import classNames from 'classnames';
|
2 |
-
import {connect} from 'react-redux';
|
3 |
-
import PropTypes from 'prop-types';
|
4 |
-
import React from 'react';
|
5 |
-
import MediaQuery from 'react-responsive';
|
6 |
-
|
7 |
-
import {shouldShowGroup, shouldShowUngroup} from '../../helper/group';
|
8 |
-
import {shouldShowBringForward, shouldShowSendBackward} from '../../helper/order';
|
9 |
-
|
10 |
-
import BufferedInputHOC from '../forms/buffered-input-hoc.jsx';
|
11 |
-
import Button from '../button/button.jsx';
|
12 |
-
import ButtonGroup from '../button-group/button-group.jsx';
|
13 |
-
import Dropdown from '../dropdown/dropdown.jsx';
|
14 |
-
import {defineMessages, injectIntl, intlShape} from 'react-intl';
|
15 |
-
import Formats, {isVector} from '../../lib/format';
|
16 |
-
import Input from '../forms/input.jsx';
|
17 |
-
import InputGroup from '../input-group/input-group.jsx';
|
18 |
-
import Label from '../forms/label.jsx';
|
19 |
-
import LabeledIconButton from '../labeled-icon-button/labeled-icon-button.jsx';
|
20 |
-
import layout from '../../lib/layout-constants';
|
21 |
-
import {hideLabel} from '../../lib/hide-label';
|
22 |
-
import styles from './fixed-tools.css';
|
23 |
-
|
24 |
-
import groupIcon from './icons/group.svg';
|
25 |
-
import redoIcon from './icons/redo.svg';
|
26 |
-
import sendBackIcon from './icons/send-back.svg';
|
27 |
-
import sendBackwardIcon from './icons/send-backward.svg';
|
28 |
-
import sendForwardIcon from './icons/send-forward.svg';
|
29 |
-
import sendFrontIcon from './icons/send-front.svg';
|
30 |
-
import undoIcon from './icons/undo.svg';
|
31 |
-
import ungroupIcon from './icons/ungroup.svg';
|
32 |
-
|
33 |
-
const BufferedInput = BufferedInputHOC(Input);
|
34 |
-
const messages = defineMessages({
|
35 |
-
costume: {
|
36 |
-
id: 'paint.paintEditor.costume',
|
37 |
-
description: 'Label for the name of a costume',
|
38 |
-
defaultMessage: 'Costume'
|
39 |
-
},
|
40 |
-
group: {
|
41 |
-
defaultMessage: 'Group',
|
42 |
-
description: 'Label for the button to group shapes',
|
43 |
-
id: 'paint.paintEditor.group'
|
44 |
-
},
|
45 |
-
ungroup: {
|
46 |
-
defaultMessage: 'Ungroup',
|
47 |
-
description: 'Label for the button to ungroup shapes',
|
48 |
-
id: 'paint.paintEditor.ungroup'
|
49 |
-
},
|
50 |
-
undo: {
|
51 |
-
defaultMessage: 'Undo',
|
52 |
-
description: 'Alt to image for the button to undo an action',
|
53 |
-
id: 'paint.paintEditor.undo'
|
54 |
-
},
|
55 |
-
redo: {
|
56 |
-
defaultMessage: 'Redo',
|
57 |
-
description: 'Alt to image for the button to redo an action',
|
58 |
-
id: 'paint.paintEditor.redo'
|
59 |
-
},
|
60 |
-
forward: {
|
61 |
-
defaultMessage: 'Forward',
|
62 |
-
description: 'Label for the `Send forward on canvas` button',
|
63 |
-
id: 'paint.paintEditor.forward'
|
64 |
-
},
|
65 |
-
backward: {
|
66 |
-
defaultMessage: 'Backward',
|
67 |
-
description: 'Label for the `Send backward on canvas` button',
|
68 |
-
id: 'paint.paintEditor.backward'
|
69 |
-
},
|
70 |
-
front: {
|
71 |
-
defaultMessage: 'Front',
|
72 |
-
description: 'Label for the `Send to front of canvas` button',
|
73 |
-
id: 'paint.paintEditor.front'
|
74 |
-
},
|
75 |
-
back: {
|
76 |
-
defaultMessage: 'Back',
|
77 |
-
description: 'Label for the `Send to back of canvas` button',
|
78 |
-
id: 'paint.paintEditor.back'
|
79 |
-
},
|
80 |
-
more: {
|
81 |
-
defaultMessage: 'More',
|
82 |
-
description: 'Label for dropdown to access more action buttons',
|
83 |
-
id: 'paint.paintEditor.more'
|
84 |
-
}
|
85 |
-
});
|
86 |
-
|
87 |
-
const FixedToolsComponent = props => {
|
88 |
-
const redoDisabled = !props.canRedo();
|
89 |
-
const undoDisabled = !props.canUndo();
|
90 |
-
|
91 |
-
return (
|
92 |
-
<div className={styles.row}>
|
93 |
-
{/* Name field */}
|
94 |
-
<InputGroup>
|
95 |
-
<MediaQuery minWidth={layout.fullSizeEditorMinWidth + (props.width - layout.referenceWidth)}>
|
96 |
-
<Label text={props.intl.formatMessage(messages.costume)}>
|
97 |
-
<BufferedInput
|
98 |
-
className={styles.costumeInput}
|
99 |
-
type="text"
|
100 |
-
value={props.name}
|
101 |
-
onSubmit={props.onUpdateName}
|
102 |
-
/>
|
103 |
-
</Label>
|
104 |
-
</MediaQuery>
|
105 |
-
<MediaQuery maxWidth={layout.fullSizeEditorMinWidth + (props.width - layout.referenceWidth) - 1}>
|
106 |
-
<BufferedInput
|
107 |
-
className={styles.costumeInput}
|
108 |
-
type="text"
|
109 |
-
value={props.name}
|
110 |
-
onSubmit={props.onUpdateName}
|
111 |
-
/>
|
112 |
-
</MediaQuery>
|
113 |
-
</InputGroup>
|
114 |
-
|
115 |
-
{/* Undo/Redo */}
|
116 |
-
<InputGroup>
|
117 |
-
<ButtonGroup>
|
118 |
-
<Button
|
119 |
-
className={
|
120 |
-
classNames(
|
121 |
-
styles.buttonGroupButton,
|
122 |
-
{
|
123 |
-
[styles.modNoEndBorder]: !redoDisabled
|
124 |
-
}
|
125 |
-
)
|
126 |
-
}
|
127 |
-
disabled={undoDisabled}
|
128 |
-
onClick={props.onUndo}
|
129 |
-
>
|
130 |
-
<img
|
131 |
-
alt={props.intl.formatMessage(messages.undo)}
|
132 |
-
className={classNames(
|
133 |
-
styles.buttonGroupButtonIcon,
|
134 |
-
styles.undoIcon
|
135 |
-
)}
|
136 |
-
draggable={false}
|
137 |
-
src={undoIcon}
|
138 |
-
/>
|
139 |
-
</Button>
|
140 |
-
<Button
|
141 |
-
className={
|
142 |
-
classNames(
|
143 |
-
styles.buttonGroupButton,
|
144 |
-
{
|
145 |
-
[styles.modStartBorder]: !redoDisabled
|
146 |
-
}
|
147 |
-
)
|
148 |
-
}
|
149 |
-
disabled={redoDisabled}
|
150 |
-
onClick={props.onRedo}
|
151 |
-
>
|
152 |
-
<img
|
153 |
-
alt={props.intl.formatMessage(messages.redo)}
|
154 |
-
className={styles.buttonGroupButtonIcon}
|
155 |
-
draggable={false}
|
156 |
-
src={redoIcon}
|
157 |
-
/>
|
158 |
-
</Button>
|
159 |
-
</ButtonGroup>
|
160 |
-
</InputGroup>
|
161 |
-
|
162 |
-
{/* Group/Ungroup */}
|
163 |
-
{isVector(props.format) ?
|
164 |
-
<InputGroup className={styles.modDashedBorder}>
|
165 |
-
<LabeledIconButton
|
166 |
-
disabled={!shouldShowGroup()}
|
167 |
-
hideLabel={hideLabel(props.intl.locale)}
|
168 |
-
imgSrc={groupIcon}
|
169 |
-
title={props.intl.formatMessage(messages.group)}
|
170 |
-
onClick={props.onGroup}
|
171 |
-
/>
|
172 |
-
<LabeledIconButton
|
173 |
-
disabled={!shouldShowUngroup()}
|
174 |
-
hideLabel={hideLabel(props.intl.locale)}
|
175 |
-
imgSrc={ungroupIcon}
|
176 |
-
title={props.intl.formatMessage(messages.ungroup)}
|
177 |
-
onClick={props.onUngroup}
|
178 |
-
/>
|
179 |
-
</InputGroup> : null
|
180 |
-
}
|
181 |
-
|
182 |
-
{/* Forward/Backward */}
|
183 |
-
{isVector(props.format) ?
|
184 |
-
<InputGroup className={styles.modDashedBorder}>
|
185 |
-
<LabeledIconButton
|
186 |
-
disabled={!shouldShowBringForward()}
|
187 |
-
hideLabel={hideLabel(props.intl.locale)}
|
188 |
-
imgSrc={sendForwardIcon}
|
189 |
-
title={props.intl.formatMessage(messages.forward)}
|
190 |
-
onClick={props.onSendForward}
|
191 |
-
/>
|
192 |
-
<LabeledIconButton
|
193 |
-
disabled={!shouldShowSendBackward()}
|
194 |
-
hideLabel={hideLabel(props.intl.locale)}
|
195 |
-
imgSrc={sendBackwardIcon}
|
196 |
-
title={props.intl.formatMessage(messages.backward)}
|
197 |
-
onClick={props.onSendBackward}
|
198 |
-
/>
|
199 |
-
</InputGroup> : null
|
200 |
-
}
|
201 |
-
|
202 |
-
{isVector(props.format) ?
|
203 |
-
<MediaQuery minWidth={layout.fullSizeEditorMinWidth}>
|
204 |
-
<InputGroup className={styles.row}>
|
205 |
-
<LabeledIconButton
|
206 |
-
disabled={!shouldShowBringForward()}
|
207 |
-
hideLabel={hideLabel(props.intl.locale)}
|
208 |
-
imgSrc={sendFrontIcon}
|
209 |
-
title={props.intl.formatMessage(messages.front)}
|
210 |
-
onClick={props.onSendToFront}
|
211 |
-
/>
|
212 |
-
<LabeledIconButton
|
213 |
-
disabled={!shouldShowSendBackward()}
|
214 |
-
hideLabel={hideLabel(props.intl.locale)}
|
215 |
-
imgSrc={sendBackIcon}
|
216 |
-
title={props.intl.formatMessage(messages.back)}
|
217 |
-
onClick={props.onSendToBack}
|
218 |
-
/>
|
219 |
-
</InputGroup>
|
220 |
-
|
221 |
-
{/* To be rotation point */}
|
222 |
-
{/* <InputGroup>
|
223 |
-
<LabeledIconButton
|
224 |
-
imgAlt="Rotation Point"
|
225 |
-
imgSrc={rotationPointIcon}
|
226 |
-
title="Rotation Point"
|
227 |
-
onClick={function () {}}
|
228 |
-
/>
|
229 |
-
</InputGroup> */}
|
230 |
-
</MediaQuery> : null
|
231 |
-
}
|
232 |
-
{isVector(props.format) ?
|
233 |
-
<MediaQuery maxWidth={layout.fullSizeEditorMinWidth - 1}>
|
234 |
-
<InputGroup>
|
235 |
-
<Dropdown
|
236 |
-
className={styles.modUnselect}
|
237 |
-
enterExitTransitionDurationMs={20}
|
238 |
-
popoverContent={
|
239 |
-
<InputGroup
|
240 |
-
className={styles.modContextMenu}
|
241 |
-
rtl={props.rtl}
|
242 |
-
>
|
243 |
-
<Button
|
244 |
-
className={classNames(styles.modMenuItem, {
|
245 |
-
[styles.modDisabled]: !shouldShowBringForward()
|
246 |
-
})}
|
247 |
-
disabled={!shouldShowBringForward()}
|
248 |
-
onClick={props.onSendToFront}
|
249 |
-
>
|
250 |
-
<img
|
251 |
-
className={styles.menuItemIcon}
|
252 |
-
draggable={false}
|
253 |
-
src={sendFrontIcon}
|
254 |
-
/>
|
255 |
-
<span>{props.intl.formatMessage(messages.front)}</span>
|
256 |
-
</Button>
|
257 |
-
<Button
|
258 |
-
className={classNames(styles.modMenuItem, {
|
259 |
-
[styles.modDisabled]: !shouldShowSendBackward()
|
260 |
-
})}
|
261 |
-
disabled={!shouldShowSendBackward()}
|
262 |
-
onClick={props.onSendToBack}
|
263 |
-
>
|
264 |
-
<img
|
265 |
-
className={styles.menuItemIcon}
|
266 |
-
draggable={false}
|
267 |
-
src={sendBackIcon}
|
268 |
-
/>
|
269 |
-
<span>{props.intl.formatMessage(messages.back)}</span>
|
270 |
-
</Button>
|
271 |
-
|
272 |
-
{/* To be rotation point */}
|
273 |
-
{/* <Button
|
274 |
-
className={classNames(styles.modMenuItem, styles.modTopDivider)}
|
275 |
-
onClick={function () {}}
|
276 |
-
>
|
277 |
-
<img
|
278 |
-
className={styles.menuItemIcon}
|
279 |
-
draggable={false}
|
280 |
-
src={rotationPointIcon}
|
281 |
-
/>
|
282 |
-
<span>{'Rotation Point'}</span>
|
283 |
-
</Button> */}
|
284 |
-
</InputGroup>
|
285 |
-
}
|
286 |
-
tipSize={.01}
|
287 |
-
>
|
288 |
-
{props.intl.formatMessage(messages.more)}
|
289 |
-
</Dropdown>
|
290 |
-
</InputGroup>
|
291 |
-
</MediaQuery> : null
|
292 |
-
}
|
293 |
-
</div>
|
294 |
-
);
|
295 |
-
};
|
296 |
-
|
297 |
-
FixedToolsComponent.propTypes = {
|
298 |
-
canRedo: PropTypes.func.isRequired,
|
299 |
-
canUndo: PropTypes.func.isRequired,
|
300 |
-
format: PropTypes.oneOf(Object.keys(Formats)),
|
301 |
-
intl: intlShape,
|
302 |
-
name: PropTypes.string,
|
303 |
-
onGroup: PropTypes.func.isRequired,
|
304 |
-
onRedo: PropTypes.func.isRequired,
|
305 |
-
onSendBackward: PropTypes.func.isRequired,
|
306 |
-
onSendForward: PropTypes.func.isRequired,
|
307 |
-
onSendToBack: PropTypes.func.isRequired,
|
308 |
-
onSendToFront: PropTypes.func.isRequired,
|
309 |
-
onUndo: PropTypes.func.isRequired,
|
310 |
-
onUngroup: PropTypes.func.isRequired,
|
311 |
-
onUpdateName: PropTypes.func.isRequired,
|
312 |
-
rtl: PropTypes.bool.isRequired,
|
313 |
-
width: PropTypes.number
|
314 |
-
};
|
315 |
-
|
316 |
-
const mapStateToProps = state => ({
|
317 |
-
format: state.scratchPaint.format,
|
318 |
-
rtl: state.scratchPaint.layout.rtl,
|
319 |
-
selectedItems: state.scratchPaint.selectedItems,
|
320 |
-
undoState: state.scratchPaint.undo
|
321 |
-
});
|
322 |
-
|
323 |
-
export default connect(
|
324 |
-
mapStateToProps
|
325 |
-
)(injectIntl(FixedToolsComponent));
|
|
|
1 |
+
import classNames from 'classnames';
|
2 |
+
import {connect} from 'react-redux';
|
3 |
+
import PropTypes from 'prop-types';
|
4 |
+
import React from 'react';
|
5 |
+
import MediaQuery from 'react-responsive';
|
6 |
+
|
7 |
+
import {shouldShowGroup, shouldShowUngroup} from '../../helper/group';
|
8 |
+
import {shouldShowBringForward, shouldShowSendBackward} from '../../helper/order';
|
9 |
+
|
10 |
+
import BufferedInputHOC from '../forms/buffered-input-hoc.jsx';
|
11 |
+
import Button from '../button/button.jsx';
|
12 |
+
import ButtonGroup from '../button-group/button-group.jsx';
|
13 |
+
import Dropdown from '../dropdown/dropdown.jsx';
|
14 |
+
import {defineMessages, injectIntl, intlShape} from 'react-intl';
|
15 |
+
import Formats, {isVector} from '../../lib/format';
|
16 |
+
import Input from '../forms/input.jsx';
|
17 |
+
import InputGroup from '../input-group/input-group.jsx';
|
18 |
+
import Label from '../forms/label.jsx';
|
19 |
+
import LabeledIconButton from '../labeled-icon-button/labeled-icon-button.jsx';
|
20 |
+
import layout from '../../lib/layout-constants';
|
21 |
+
import {hideLabel} from '../../lib/hide-label';
|
22 |
+
import styles from './fixed-tools.css';
|
23 |
+
|
24 |
+
import groupIcon from './icons/group.svg';
|
25 |
+
import redoIcon from './icons/redo.svg';
|
26 |
+
import sendBackIcon from './icons/send-back.svg';
|
27 |
+
import sendBackwardIcon from './icons/send-backward.svg';
|
28 |
+
import sendForwardIcon from './icons/send-forward.svg';
|
29 |
+
import sendFrontIcon from './icons/send-front.svg';
|
30 |
+
import undoIcon from './icons/undo.svg';
|
31 |
+
import ungroupIcon from './icons/ungroup.svg';
|
32 |
+
|
33 |
+
const BufferedInput = BufferedInputHOC(Input);
|
34 |
+
const messages = defineMessages({
|
35 |
+
costume: {
|
36 |
+
id: 'paint.paintEditor.costume',
|
37 |
+
description: 'Label for the name of a costume',
|
38 |
+
defaultMessage: 'Costume'
|
39 |
+
},
|
40 |
+
group: {
|
41 |
+
defaultMessage: 'Group',
|
42 |
+
description: 'Label for the button to group shapes',
|
43 |
+
id: 'paint.paintEditor.group'
|
44 |
+
},
|
45 |
+
ungroup: {
|
46 |
+
defaultMessage: 'Ungroup',
|
47 |
+
description: 'Label for the button to ungroup shapes',
|
48 |
+
id: 'paint.paintEditor.ungroup'
|
49 |
+
},
|
50 |
+
undo: {
|
51 |
+
defaultMessage: 'Undo',
|
52 |
+
description: 'Alt to image for the button to undo an action',
|
53 |
+
id: 'paint.paintEditor.undo'
|
54 |
+
},
|
55 |
+
redo: {
|
56 |
+
defaultMessage: 'Redo',
|
57 |
+
description: 'Alt to image for the button to redo an action',
|
58 |
+
id: 'paint.paintEditor.redo'
|
59 |
+
},
|
60 |
+
forward: {
|
61 |
+
defaultMessage: 'Forward',
|
62 |
+
description: 'Label for the `Send forward on canvas` button',
|
63 |
+
id: 'paint.paintEditor.forward'
|
64 |
+
},
|
65 |
+
backward: {
|
66 |
+
defaultMessage: 'Backward',
|
67 |
+
description: 'Label for the `Send backward on canvas` button',
|
68 |
+
id: 'paint.paintEditor.backward'
|
69 |
+
},
|
70 |
+
front: {
|
71 |
+
defaultMessage: 'Front',
|
72 |
+
description: 'Label for the `Send to front of canvas` button',
|
73 |
+
id: 'paint.paintEditor.front'
|
74 |
+
},
|
75 |
+
back: {
|
76 |
+
defaultMessage: 'Back',
|
77 |
+
description: 'Label for the `Send to back of canvas` button',
|
78 |
+
id: 'paint.paintEditor.back'
|
79 |
+
},
|
80 |
+
more: {
|
81 |
+
defaultMessage: 'More',
|
82 |
+
description: 'Label for dropdown to access more action buttons',
|
83 |
+
id: 'paint.paintEditor.more'
|
84 |
+
}
|
85 |
+
});
|
86 |
+
|
87 |
+
const FixedToolsComponent = props => {
|
88 |
+
const redoDisabled = !props.canRedo();
|
89 |
+
const undoDisabled = !props.canUndo();
|
90 |
+
|
91 |
+
return (
|
92 |
+
<div className={styles.row}>
|
93 |
+
{/* Name field */}
|
94 |
+
<InputGroup>
|
95 |
+
<MediaQuery minWidth={layout.fullSizeEditorMinWidth + (props.width - layout.referenceWidth)}>
|
96 |
+
<Label text={props.intl.formatMessage(messages.costume)}>
|
97 |
+
<BufferedInput
|
98 |
+
className={styles.costumeInput}
|
99 |
+
type="text"
|
100 |
+
value={props.name}
|
101 |
+
onSubmit={props.onUpdateName}
|
102 |
+
/>
|
103 |
+
</Label>
|
104 |
+
</MediaQuery>
|
105 |
+
<MediaQuery maxWidth={layout.fullSizeEditorMinWidth + (props.width - layout.referenceWidth) - 1}>
|
106 |
+
<BufferedInput
|
107 |
+
className={styles.costumeInput}
|
108 |
+
type="text"
|
109 |
+
value={props.name}
|
110 |
+
onSubmit={props.onUpdateName}
|
111 |
+
/>
|
112 |
+
</MediaQuery>
|
113 |
+
</InputGroup>
|
114 |
+
|
115 |
+
{/* Undo/Redo */}
|
116 |
+
<InputGroup>
|
117 |
+
<ButtonGroup>
|
118 |
+
<Button
|
119 |
+
className={
|
120 |
+
classNames(
|
121 |
+
styles.buttonGroupButton,
|
122 |
+
{
|
123 |
+
[styles.modNoEndBorder]: !redoDisabled
|
124 |
+
}
|
125 |
+
)
|
126 |
+
}
|
127 |
+
disabled={undoDisabled}
|
128 |
+
onClick={props.onUndo}
|
129 |
+
>
|
130 |
+
<img
|
131 |
+
alt={props.intl.formatMessage(messages.undo)}
|
132 |
+
className={classNames(
|
133 |
+
styles.buttonGroupButtonIcon,
|
134 |
+
styles.undoIcon
|
135 |
+
)}
|
136 |
+
draggable={false}
|
137 |
+
src={undoIcon}
|
138 |
+
/>
|
139 |
+
</Button>
|
140 |
+
<Button
|
141 |
+
className={
|
142 |
+
classNames(
|
143 |
+
styles.buttonGroupButton,
|
144 |
+
{
|
145 |
+
[styles.modStartBorder]: !redoDisabled
|
146 |
+
}
|
147 |
+
)
|
148 |
+
}
|
149 |
+
disabled={redoDisabled}
|
150 |
+
onClick={props.onRedo}
|
151 |
+
>
|
152 |
+
<img
|
153 |
+
alt={props.intl.formatMessage(messages.redo)}
|
154 |
+
className={styles.buttonGroupButtonIcon}
|
155 |
+
draggable={false}
|
156 |
+
src={redoIcon}
|
157 |
+
/>
|
158 |
+
</Button>
|
159 |
+
</ButtonGroup>
|
160 |
+
</InputGroup>
|
161 |
+
|
162 |
+
{/* Group/Ungroup */}
|
163 |
+
{isVector(props.format) ?
|
164 |
+
<InputGroup className={styles.modDashedBorder}>
|
165 |
+
<LabeledIconButton
|
166 |
+
disabled={!shouldShowGroup()}
|
167 |
+
hideLabel={hideLabel(props.intl.locale)}
|
168 |
+
imgSrc={groupIcon}
|
169 |
+
title={props.intl.formatMessage(messages.group)}
|
170 |
+
onClick={props.onGroup}
|
171 |
+
/>
|
172 |
+
<LabeledIconButton
|
173 |
+
disabled={!shouldShowUngroup()}
|
174 |
+
hideLabel={hideLabel(props.intl.locale)}
|
175 |
+
imgSrc={ungroupIcon}
|
176 |
+
title={props.intl.formatMessage(messages.ungroup)}
|
177 |
+
onClick={props.onUngroup}
|
178 |
+
/>
|
179 |
+
</InputGroup> : null
|
180 |
+
}
|
181 |
+
|
182 |
+
{/* Forward/Backward */}
|
183 |
+
{isVector(props.format) ?
|
184 |
+
<InputGroup className={styles.modDashedBorder}>
|
185 |
+
<LabeledIconButton
|
186 |
+
disabled={!shouldShowBringForward()}
|
187 |
+
hideLabel={hideLabel(props.intl.locale)}
|
188 |
+
imgSrc={sendForwardIcon}
|
189 |
+
title={props.intl.formatMessage(messages.forward)}
|
190 |
+
onClick={props.onSendForward}
|
191 |
+
/>
|
192 |
+
<LabeledIconButton
|
193 |
+
disabled={!shouldShowSendBackward()}
|
194 |
+
hideLabel={hideLabel(props.intl.locale)}
|
195 |
+
imgSrc={sendBackwardIcon}
|
196 |
+
title={props.intl.formatMessage(messages.backward)}
|
197 |
+
onClick={props.onSendBackward}
|
198 |
+
/>
|
199 |
+
</InputGroup> : null
|
200 |
+
}
|
201 |
+
|
202 |
+
{isVector(props.format) ?
|
203 |
+
<MediaQuery minWidth={layout.fullSizeEditorMinWidth}>
|
204 |
+
<InputGroup className={styles.row}>
|
205 |
+
<LabeledIconButton
|
206 |
+
disabled={!shouldShowBringForward()}
|
207 |
+
hideLabel={hideLabel(props.intl.locale)}
|
208 |
+
imgSrc={sendFrontIcon}
|
209 |
+
title={props.intl.formatMessage(messages.front)}
|
210 |
+
onClick={props.onSendToFront}
|
211 |
+
/>
|
212 |
+
<LabeledIconButton
|
213 |
+
disabled={!shouldShowSendBackward()}
|
214 |
+
hideLabel={hideLabel(props.intl.locale)}
|
215 |
+
imgSrc={sendBackIcon}
|
216 |
+
title={props.intl.formatMessage(messages.back)}
|
217 |
+
onClick={props.onSendToBack}
|
218 |
+
/>
|
219 |
+
</InputGroup>
|
220 |
+
|
221 |
+
{/* To be rotation point */}
|
222 |
+
{/* <InputGroup>
|
223 |
+
<LabeledIconButton
|
224 |
+
imgAlt="Rotation Point"
|
225 |
+
imgSrc={rotationPointIcon}
|
226 |
+
title="Rotation Point"
|
227 |
+
onClick={function () {}}
|
228 |
+
/>
|
229 |
+
</InputGroup> */}
|
230 |
+
</MediaQuery> : null
|
231 |
+
}
|
232 |
+
{isVector(props.format) ?
|
233 |
+
<MediaQuery maxWidth={layout.fullSizeEditorMinWidth - 1}>
|
234 |
+
<InputGroup>
|
235 |
+
<Dropdown
|
236 |
+
className={styles.modUnselect}
|
237 |
+
enterExitTransitionDurationMs={20}
|
238 |
+
popoverContent={
|
239 |
+
<InputGroup
|
240 |
+
className={styles.modContextMenu}
|
241 |
+
rtl={props.rtl}
|
242 |
+
>
|
243 |
+
<Button
|
244 |
+
className={classNames(styles.modMenuItem, {
|
245 |
+
[styles.modDisabled]: !shouldShowBringForward()
|
246 |
+
})}
|
247 |
+
disabled={!shouldShowBringForward()}
|
248 |
+
onClick={props.onSendToFront}
|
249 |
+
>
|
250 |
+
<img
|
251 |
+
className={styles.menuItemIcon}
|
252 |
+
draggable={false}
|
253 |
+
src={sendFrontIcon}
|
254 |
+
/>
|
255 |
+
<span>{props.intl.formatMessage(messages.front)}</span>
|
256 |
+
</Button>
|
257 |
+
<Button
|
258 |
+
className={classNames(styles.modMenuItem, {
|
259 |
+
[styles.modDisabled]: !shouldShowSendBackward()
|
260 |
+
})}
|
261 |
+
disabled={!shouldShowSendBackward()}
|
262 |
+
onClick={props.onSendToBack}
|
263 |
+
>
|
264 |
+
<img
|
265 |
+
className={styles.menuItemIcon}
|
266 |
+
draggable={false}
|
267 |
+
src={sendBackIcon}
|
268 |
+
/>
|
269 |
+
<span>{props.intl.formatMessage(messages.back)}</span>
|
270 |
+
</Button>
|
271 |
+
|
272 |
+
{/* To be rotation point */}
|
273 |
+
{/* <Button
|
274 |
+
className={classNames(styles.modMenuItem, styles.modTopDivider)}
|
275 |
+
onClick={function () {}}
|
276 |
+
>
|
277 |
+
<img
|
278 |
+
className={styles.menuItemIcon}
|
279 |
+
draggable={false}
|
280 |
+
src={rotationPointIcon}
|
281 |
+
/>
|
282 |
+
<span>{'Rotation Point'}</span>
|
283 |
+
</Button> */}
|
284 |
+
</InputGroup>
|
285 |
+
}
|
286 |
+
tipSize={.01}
|
287 |
+
>
|
288 |
+
{props.intl.formatMessage(messages.more)}
|
289 |
+
</Dropdown>
|
290 |
+
</InputGroup>
|
291 |
+
</MediaQuery> : null
|
292 |
+
}
|
293 |
+
</div>
|
294 |
+
);
|
295 |
+
};
|
296 |
+
|
297 |
+
FixedToolsComponent.propTypes = {
|
298 |
+
canRedo: PropTypes.func.isRequired,
|
299 |
+
canUndo: PropTypes.func.isRequired,
|
300 |
+
format: PropTypes.oneOf(Object.keys(Formats)),
|
301 |
+
intl: intlShape,
|
302 |
+
name: PropTypes.string,
|
303 |
+
onGroup: PropTypes.func.isRequired,
|
304 |
+
onRedo: PropTypes.func.isRequired,
|
305 |
+
onSendBackward: PropTypes.func.isRequired,
|
306 |
+
onSendForward: PropTypes.func.isRequired,
|
307 |
+
onSendToBack: PropTypes.func.isRequired,
|
308 |
+
onSendToFront: PropTypes.func.isRequired,
|
309 |
+
onUndo: PropTypes.func.isRequired,
|
310 |
+
onUngroup: PropTypes.func.isRequired,
|
311 |
+
onUpdateName: PropTypes.func.isRequired,
|
312 |
+
rtl: PropTypes.bool.isRequired,
|
313 |
+
width: PropTypes.number
|
314 |
+
};
|
315 |
+
|
316 |
+
const mapStateToProps = state => ({
|
317 |
+
format: state.scratchPaint.format,
|
318 |
+
rtl: state.scratchPaint.layout.rtl,
|
319 |
+
selectedItems: state.scratchPaint.selectedItems,
|
320 |
+
undoState: state.scratchPaint.undo
|
321 |
+
});
|
322 |
+
|
323 |
+
export default connect(
|
324 |
+
mapStateToProps
|
325 |
+
)(injectIntl(FixedToolsComponent));
|
src/components/fixed-tools/icons/group.svg
CHANGED
|
|