Skip to content

Commit

Permalink
Merge pull request #13299 from Expensify/rocio-BackgroundColorWindows
Browse files Browse the repository at this point in the history
Clean up the code when adding colors for the Picker
  • Loading branch information
tgolen authored Dec 5, 2022
2 parents 6380fe8 + 3024576 commit 2e69dac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/components/Picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import Icon from '../Icon';
import * as Expensicons from '../Icon/Expensicons';
import FormHelpMessage from '../FormHelpMessage';
import Text from '../Text';
import CONST from '../../CONST';
import styles from '../../styles/styles';
import variables from '../../styles/variables';
import pickerStyles from './pickerStyles';
import getOperatingSystem from '../../libs/getOperatingSystem';

const propTypes = {
/** Picker label */
Expand Down Expand Up @@ -104,28 +103,23 @@ class Picker extends PureComponent {
};

this.onInputChange = this.onInputChange.bind(this);
this.placeholder = this.props.placeholder;
this.items = this.props.items;

// Windows will reuse the text color of the select for each one of the options
// so we might need to color accordingly so it doesn't blend with the background.
this.placeholder = _.isEmpty(this.props.placeholder) ? {} : {
...this.props.placeholder,
color: variables.pickerOptionsTextColor,
};
this.items = _.map(this.props.items, item => (
{
...item,
color: variables.pickerOptionsTextColor,
}
));
}

componentDidMount() {
this.setDefaultValue();

// Windows will reuse the text color of the select for each one of the options
// so we might need to color accordingly so it doesn't blend with the background.
if (getOperatingSystem() === CONST.OS.WINDOWS) {
this.placeholder = _.isEmpty(this.placeholder) ? {} : {
...this.placeholder,
color: '#002140',
};

this.items = _.map(this.items, item => (
{
...item,
color: '#002140',
}
));
}
}

componentDidUpdate(prevProps) {
Expand Down
1 change: 1 addition & 0 deletions src/styles/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ export default {
INACTIVE_LABEL_TRANSLATE_Y: getValueUsingPixelRatio(16, 21),
sliderBarHeight: 8,
sliderKnobSize: 26,
pickerOptionsTextColor: '#002140',
};

0 comments on commit 2e69dac

Please sign in to comment.