about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/util/numbers.js
diff options
context:
space:
mode:
authorpluralcafe-docker <docker@plural.cafe>2018-08-23 06:16:14 +0000
committerpluralcafe-docker <docker@plural.cafe>2018-08-23 06:16:14 +0000
commit0fa521de89168ef33423fc7306a33d4a1c3badf3 (patch)
treece3663d75ca93ea2d32e10de532eb18a230cf6e0 /app/javascript/flavours/glitch/util/numbers.js
parenta4935a8e24dcfa865fb330693d8ec90beca1aa98 (diff)
parent8aa58e34bb2b62192a997ac7ea8919b22fc45f80 (diff)
Merge branch 'glitch'
Diffstat (limited to 'app/javascript/flavours/glitch/util/numbers.js')
-rw-r--r--app/javascript/flavours/glitch/util/numbers.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/util/numbers.js b/app/javascript/flavours/glitch/util/numbers.js
new file mode 100644
index 000000000..fdd8269ae
--- /dev/null
+++ b/app/javascript/flavours/glitch/util/numbers.js
@@ -0,0 +1,10 @@
+import React, { Fragment } from 'react';
+import { FormattedNumber } from 'react-intl';
+
+export const shortNumberFormat = number => {
+  if (number < 1000) {
+    return <FormattedNumber value={number} />;
+  } else {
+    return <Fragment><FormattedNumber value={number / 1000} maximumFractionDigits={1} />K</Fragment>;
+  }
+};