Skip to content

Commit a99d2b8

Browse files
committed
Add theming to common/icons
1 parent 81cf415 commit a99d2b8

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

Diff for: client/common/Icons.jsx

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import styled from 'styled-components';
4+
import { remSize, prop } from '../theme';
35
import SortArrowUp from '../images/sort-arrow-up.svg';
46
import SortArrowDown from '../images/sort-arrow-down.svg';
57
import Github from '../images/github.svg';
68
import Google from '../images/google.svg';
79
import Plus from '../images/plus-icon.svg';
810
import Close from '../images/close.svg';
11+
import Exit from '../images/exit.svg';
912
import DropdownArrow from '../images/down-filled-triangle.svg';
1013

1114
// HOC that adds the right web accessibility props
@@ -15,16 +18,33 @@ import DropdownArrow from '../images/down-filled-triangle.svg';
1518
// Need to add size to these - like small icon, medium icon, large icon. etc.
1619
function withLabel(SvgComponent) {
1720
const Icon = (props) => {
21+
const StyledIcon = styled(SvgComponent)`
22+
&&& {
23+
color: ${prop('Icon.default')};
24+
& g, & path, & polygon {
25+
opacity: 1;
26+
fill: ${prop('Icon.default')};
27+
}
28+
&:hover {
29+
color: ${prop('Icon.hover')};
30+
& g, & path, & polygon {
31+
opacity: 1;
32+
fill: ${prop('Icon.hover')};
33+
}
34+
}
35+
}
36+
`;
37+
1838
const { 'aria-label': ariaLabel } = props;
1939
if (ariaLabel) {
20-
return (<SvgComponent
40+
return (<StyledIcon
2141
{...props}
2242
aria-label={ariaLabel}
2343
role="img"
2444
focusable="false"
2545
/>);
2646
}
27-
return (<SvgComponent
47+
return (<StyledIcon
2848
{...props}
2949
aria-hidden
3050
focusable="false"
@@ -48,4 +68,5 @@ export const GithubIcon = withLabel(Github);
4868
export const GoogleIcon = withLabel(Google);
4969
export const PlusIcon = withLabel(Plus);
5070
export const CloseIcon = withLabel(Close);
71+
export const ExitIcon = withLabel(Exit);
5172
export const DropdownArrowIcon = withLabel(DropdownArrow);

Diff for: client/common/icons.jsx

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import styled from 'styled-components';
4+
import { remSize, prop } from '../theme';
35
import SortArrowUp from '../images/sort-arrow-up.svg';
46
import SortArrowDown from '../images/sort-arrow-down.svg';
57
import Github from '../images/github.svg';
68
import Google from '../images/google.svg';
79
import Plus from '../images/plus-icon.svg';
810
import Close from '../images/close.svg';
11+
import Exit from '../images/exit.svg';
912
import DropdownArrow from '../images/down-filled-triangle.svg';
1013

1114
// HOC that adds the right web accessibility props
@@ -15,16 +18,33 @@ import DropdownArrow from '../images/down-filled-triangle.svg';
1518
// Need to add size to these - like small icon, medium icon, large icon. etc.
1619
function withLabel(SvgComponent) {
1720
const Icon = (props) => {
21+
const StyledIcon = styled(SvgComponent)`
22+
&&& {
23+
color: ${prop('Icon.default')};
24+
& g, & path, & polygon {
25+
opacity: 1;
26+
fill: ${prop('Icon.default')};
27+
}
28+
&:hover {
29+
color: ${prop('Icon.hover')};
30+
& g, & path, & polygon {
31+
opacity: 1;
32+
fill: ${prop('Icon.hover')};
33+
}
34+
}
35+
}
36+
`;
37+
1838
const { 'aria-label': ariaLabel } = props;
1939
if (ariaLabel) {
20-
return (<SvgComponent
40+
return (<StyledIcon
2141
{...props}
2242
aria-label={ariaLabel}
2343
role="img"
2444
focusable="false"
2545
/>);
2646
}
27-
return (<SvgComponent
47+
return (<StyledIcon
2848
{...props}
2949
aria-hidden
3050
focusable="false"
@@ -48,4 +68,5 @@ export const GithubIcon = withLabel(Github);
4868
export const GoogleIcon = withLabel(Google);
4969
export const PlusIcon = withLabel(Plus);
5070
export const CloseIcon = withLabel(Close);
71+
export const ExitIcon = withLabel(Exit);
5172
export const DropdownArrowIcon = withLabel(DropdownArrow);

Diff for: client/modules/IDE/pages/IDEViewMobile.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { getHTMLFile } from '../reducers/files';
2121
// Local Imports
2222
import Editor from '../components/Editor';
2323
import { prop, remSize } from '../../../theme';
24-
import { CloseIcon } from '../../../common/Icons';
24+
import { ExitIcon } from '../../../common/icons';
2525

2626
const background = prop('Button.default.background');
2727
const textColor = prop('primaryTextColor');
@@ -98,7 +98,7 @@ const IDEViewMobile = (props) => {
9898
<Screen>
9999
<Header>
100100
<IconLinkWrapper to="/" aria-label="Return to original editor">
101-
<CloseIcon viewBox="20 21 60 60" />
101+
<ExitIcon />
102102
</IconLinkWrapper>
103103
<div>
104104
<h2>{project.name}</h2>

Diff for: client/theme.js

+12
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export default {
8585
border: grays.middleLight,
8686
},
8787
},
88+
Icon: {
89+
default: grays.middleGray,
90+
hover: grays.darker
91+
}
8892
},
8993
[Theme.dark]: {
9094
colors,
@@ -113,6 +117,10 @@ export default {
113117
border: grays.middleDark,
114118
},
115119
},
120+
Icon: {
121+
default: grays.middleLight,
122+
hover: grays.lightest
123+
}
116124
},
117125
[Theme.contrast]: {
118126
colors,
@@ -141,5 +149,9 @@ export default {
141149
border: grays.middleDark,
142150
},
143151
},
152+
Icon: {
153+
default: grays.mediumLight,
154+
hover: colors.yellow
155+
}
144156
},
145157
};

0 commit comments

Comments
 (0)