Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
fix: imports of color (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBlomgren authored May 9, 2019
1 parent ca236c5 commit 7916fac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
13 changes: 7 additions & 6 deletions src/components/flag/flag.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import PropTypes from 'prop-types';
import React from 'react';
import { withTheme } from 'react-jss';
import { SvgFlag, CurrencyFlag } from './flags';
import FlagDeprecated from './flag-deprecated';
import color from '../../styles/color';
import { deprecatedProps } from '../deprecate';

const addBorder = props => !props.hideBorder && !props.round && !props.secondaryCountryCode;

const Flag = props => {
const borderColor = props.borderColor ? props.borderColor : props.theme.palette.gray7;
/** Will be deprecated. This is here just for backwards compatibility. */
const extendedStyle = {
...props.style,
border: addBorder(props) ? `1px solid ${props.borderColor}` : null,
backgroundColor: addBorder(props) ? props.borderColor : 'rgba(0,0,0,0)', // "fix" errors with subpixel coloring between flag and border
border: addBorder(props) ? `1px solid ${borderColor}` : null,
backgroundColor: addBorder(props) ? borderColor : 'rgba(0,0,0,0)', // "fix" errors with subpixel coloring between flag and border
};

/** Will be deprecated. */
Expand All @@ -28,7 +29,6 @@ const Flag = props => {
size,
round,
hideBorder,
borderColor,
...rest
} = props;

Expand Down Expand Up @@ -61,7 +61,7 @@ Flag.defaultProps = {
size: 32,
round: false,
hideBorder: false,
borderColor: color.gray7,
borderColor: null,
};

const countryCodes = [
Expand Down Expand Up @@ -109,6 +109,7 @@ Flag.propTypes = {
hideBorder: PropTypes.bool,
/** Will be deprecated. borderColor can be passed together with `styles` object. */
borderColor: PropTypes.string,
theme: PropTypes.shape(),
};
export { Flag as Component };
export default deprecatedProps('Flag', [
Expand All @@ -117,4 +118,4 @@ export default deprecatedProps('Flag', [
message:
"size in Flag as a number is deprecated. Please use one of 'xs', 'sm', 'md', 'lg' instead",
},
])(Flag);
])(withTheme(Flag));
10 changes: 6 additions & 4 deletions src/components/input/checkbox.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { withTheme } from 'react-jss';
import { Icon } from '../..';
import color from '../../styles/color';

function Checkbox(props) {
const { checked, disabled } = props;
const { checked, disabled, theme } = props;

const classes = classNames(
'checkbox',
Expand All @@ -16,7 +16,7 @@ function Checkbox(props) {
props.className,
);

const icon = <Icon.Checkmark stroke={color.white} style={{ display: 'block' }} />;
const icon = <Icon.Checkmark stroke={theme.palette.white} style={{ display: 'block' }} />;

return <span className={classes}>{checked ? icon : null}</span>;
}
Expand All @@ -25,6 +25,8 @@ Checkbox.propTypes = {
checked: PropTypes.bool,
disabled: PropTypes.bool,
className: PropTypes.string,
theme: PropTypes.shape(),
};

export default Checkbox;
export { Checkbox as Component };
export default withTheme(Checkbox);
5 changes: 3 additions & 2 deletions src/components/input/checkbox.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { shallow } from 'enzyme';
import Checkbox from './checkbox';
import { Component as Checkbox } from './checkbox';

const renderComponent = props => shallow(<Checkbox {...props} />);
const renderComponent = props =>
shallow(<Checkbox {...props} theme={{ palette: { color: { white: '#FFFFFF' } } }} />);

describe('<Checkbox />', () => {
test('has class checkbox', () => {
Expand Down
9 changes: 4 additions & 5 deletions src/components/table/tr/tr-styles.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import styleUtils from '../style-utilities';
import color from '../../../styles/color';

const normal = theme => {
const { mixins, typography } = theme;
const { mixins, typography, palette } = theme;

return {
tr: {
Expand All @@ -20,13 +19,13 @@ const normal = theme => {
border: {
borderStyle: 'solid',
borderWidth: 1,
borderColor: color.grayLight,
borderColor: palette.gray5,
},
sticky: {
'& td': {
position: 'sticky',
top: 0,
backgroundColor: color.white,
backgroundColor: palette.white,
},
},
stickyBorder: {
Expand All @@ -37,7 +36,7 @@ const normal = theme => {
left: 0,
bottom: 0,
width: '100%',
borderBottom: `2px solid ${color.grayDarker}`,
borderBottom: `2px solid ${palette.gray2}`,
},
},
};
Expand Down

1 comment on commit 7916fac

@vercel
Copy link

@vercel vercel bot commented on 7916fac May 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.