Skip to content

Commit

Permalink
Fix the Picker styles for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
parasharrajat committed Aug 26, 2021
1 parent bf73f5c commit 1fb5be3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/CONST.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion src/components/Picker/pickerStyles/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import CONST from '../../../CONST';
import getBrowser from '../../../libs/getBrowser';
import styles from '../../../styles/styles';

const pickerStyles = disabled => styles.expensiPicker(disabled);
const pickerStylesWeb = () => {
if ([CONST.BROWSER.FIREFOX].includes(getBrowser())) {
return {
textIndent: -2,
};
}
return {};
};

const pickerStyles = disabled => ({
...styles.expensiPicker(disabled),
inputWeb: {
...styles.expensiPicker(disabled).inputWeb,
...pickerStylesWeb(),
},
});

export default pickerStyles;
1 change: 1 addition & 0 deletions src/libs/getBrowser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => '';
51 changes: 51 additions & 0 deletions src/libs/getBrowser/index.web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import CONST from '../../CONST';

/**
* fetch Browser Name and version from UA string
*
* @return {String} e.g. Chrome 80
*/
function getBrowserVersion() {
const {userAgent} = window.navigator;
let match = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
let temp;

if (/trident/i.test(match[1])) {
temp = /\brv[ :]+(\d+)/g.exec(userAgent) || [];

return `IE ${temp[1] || ''}`;
}

if (match[1] === 'Chrome') {
temp = userAgent.match(/\b(OPR|Edge)\/(\d+)/);

if (temp !== null) {
return temp.slice(1).join(' ').replace('OPR', 'Opera');
}

temp = userAgent.match(/\b(Edg)\/(\d+)/);

if (temp !== null) {
return temp.slice(1).join(' ').replace('Edg', 'Edge');
}
}

match = match[2] ? [match[1], match[2]] : [navigator.appName, navigator.appVersion, '-?'];
temp = userAgent.match(/version\/(\d+)/i);

if (temp !== null) {
match.splice(1, 1, temp[1]);
}

return match.join(' ');
}

/**
* Get the Browser name
* @returns {String}
*/
export default () => {
const browserAndVersion = getBrowserVersion();
const [browser] = browserAndVersion.split(' ');
return browser ? browser.toLowerCase() : CONST.BROWSER.OTHER;
};

0 comments on commit 1fb5be3

Please sign in to comment.