Skip to content

Instantly share code, notes, and snippets.

@t-laird
Created February 5, 2018 02:12
Show Gist options
  • Save t-laird/d767d69969a9b80a3230d0dc24a5557d to your computer and use it in GitHub Desktop.
Save t-laird/d767d69969a9b80a3230d0dc24a5557d to your computer and use it in GitHub Desktop.
//from GitPoint's fontsize helper https://github.com/gitpoint/git-point/blob/master/src/config/normalize-text.js
export const normalize = size => {
if (pixelRatio === 2) {
if (deviceWidth < 360) {
return size * 0.95;
}
if (deviceHeight < 667) {
return size;
} else if (deviceHeight >= 667 && deviceHeight <= 735) {
return size * 1.15;
}
return size * 1.25;
}
if (pixelRatio === 3) {
if (deviceWidth <= 360) {
return size;
}
if (deviceHeight < 667) {
return size * 1.15;
}
if (deviceHeight >= 667 && deviceHeight <= 735) {
return size * 1.2;
}
return size * 1.27;
}
if (pixelRatio === 3.5) {
if (deviceWidth <= 360) {
return size;
}
if (deviceHeight < 667) {
return size * 1.2;
}
if (deviceHeight >= 667 && deviceHeight <= 735) {
return size * 1.25;
}
return size * 1.4;
}
return size;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment