summaryrefslogtreecommitdiff
path: root/frontend/app/utils
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2019-03-11 21:00:02 +0400
committerAndrew <saintruler@gmail.com>2019-03-11 21:00:02 +0400
commit7e7dd5244e8d26485ad7950a89c04c98c4fef83f (patch)
tree810730c4650392080fb87a78d3b527201e89fe4b /frontend/app/utils
Initial commit/
Diffstat (limited to 'frontend/app/utils')
-rw-r--r--frontend/app/utils/scale.js13
-rw-r--r--frontend/app/utils/textUtils.js5
2 files changed, 18 insertions, 0 deletions
diff --git a/frontend/app/utils/scale.js b/frontend/app/utils/scale.js
new file mode 100644
index 0000000..f754d48
--- /dev/null
+++ b/frontend/app/utils/scale.js
@@ -0,0 +1,13 @@
+import { Dimensions } from 'react-native';
+
+const { width, height } = Dimensions.get('window');
+
+// Guideline sizes are based on standard ~5" screen mobile device
+const guidelineBaseWidth = 350;
+const guidelineBaseHeight = 680;
+
+const scale = size => (width / guidelineBaseWidth) * size;
+const scaleVertical = size => (height / guidelineBaseHeight) * size;
+const scaleModerate = (size, factor = 0.5) => size + ((scale(size) - size) * factor);
+
+export { scale, scaleVertical, scaleModerate };
diff --git a/frontend/app/utils/textUtils.js b/frontend/app/utils/textUtils.js
new file mode 100644
index 0000000..589f48f
--- /dev/null
+++ b/frontend/app/utils/textUtils.js
@@ -0,0 +1,5 @@
+function formatNumber(num) {
+ return num > 999 ? `${(num / 1000).toFixed(1)}k` : num;
+}
+
+export default formatNumber;