-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathActionIcon.js
72 lines (61 loc) · 1.98 KB
/
ActionIcon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import styled from 'styled-components';
import { Div } from 'ui/components/common/base';
import remove from '!!raw-loader!ui/icons/trash.svg';
import record from '!!raw-loader!ui/icons/rec.svg';
import recording from '!!raw-loader!ui/icons/recording.svg';
import search from '!!raw-loader!ui/icons/loupe.svg';
import add from '!!raw-loader!ui/icons/new.svg';
import clear from '!!raw-loader!ui/icons/clear.svg';
import expand from '!!raw-loader!ui/icons/expanded.svg';
import close from '!!raw-loader!ui/icons/close.svg';
import halfScreen from '!!raw-loader!ui/icons/half-size.svg';
import fullScreen from '!!raw-loader!ui/icons/full-size.svg';
import collapseAll from '!!raw-loader!ui/icons/collapse-all.svg';
import expandAll from '!!raw-loader!ui/icons/expand-all.svg';
import help from '!!raw-loader!ui/icons/help.svg';
import undo from '!!raw-loader!ui/icons/undo.svg';
import settings from '!!raw-loader!ui/icons/settings.svg';
const fill = (props) => {
if (props.disabled) {
return props.theme.darkGray;
}
if (props.active) {
return 'white';
}
return 'black';
};
const hoverFill = (props) => {
if (props.disabled) {
return props.theme.darkGray;
}
if (props.active) {
return 'white';
}
return props.theme.blue;
};
const Icon = styled(Div)`
display: inline-block;
cursor: ${(props) => props.disabled ? 'default' : 'pointer'};
width: 16px;
height: 16px;
line-height: 16px;
user-select: none;
fill: ${(props) => fill(props)};
&:hover {
fill: ${(props) => hoverFill(props)};
}
`;
const ICONS = {
remove, record, recording, search, add, clear, expand, close, help, settings,
halfScreen, fullScreen, collapseAll, expandAll, undo
};
const ActionIcon = ({ action, active, disabled, onClick, style }) => (
<Icon action={ action }
active={ active }
style={ style }
disabled={ disabled }
dangerouslySetInnerHTML={{ __html: ICONS[action] }}
onClick={ onClick }/>
);
export default ActionIcon;