about summary refs log tree commit diff
path: root/src/view/com/composer/char-progress/CharProgress.tsx
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2023-05-30 20:41:56 -0400
committerGitHub <noreply@github.com>2023-05-30 19:41:56 -0500
commit7458b6f600a3d25812a64d93096b2a94676a7bb6 (patch)
tree637a70ae7b3b53e4406a85a5435c27995e16061d /src/view/com/composer/char-progress/CharProgress.tsx
parent023922579647ce08f716e1b566cc974b8d491a06 (diff)
downloadvoidsky-7458b6f600a3d25812a64d93096b2a94676a7bb6.tar.zst
Move MAX_GRAPHEME_LENGTH to constants.ts (#735)
Diffstat (limited to 'src/view/com/composer/char-progress/CharProgress.tsx')
-rw-r--r--src/view/com/composer/char-progress/CharProgress.tsx15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/view/com/composer/char-progress/CharProgress.tsx b/src/view/com/composer/char-progress/CharProgress.tsx
index eaaaea5e5..6b3b98e47 100644
--- a/src/view/com/composer/char-progress/CharProgress.tsx
+++ b/src/view/com/composer/char-progress/CharProgress.tsx
@@ -7,9 +7,9 @@ import ProgressCircle from 'react-native-progress/Circle'
 import ProgressPie from 'react-native-progress/Pie'
 import {s} from 'lib/styles'
 import {usePalette} from 'lib/hooks/usePalette'
+import {MAX_GRAPHEME_LENGTH} from 'lib/constants'
 
-const MAX_LENGTH = 300
-const DANGER_LENGTH = MAX_LENGTH
+const DANGER_LENGTH = MAX_GRAPHEME_LENGTH
 
 export function CharProgress({count}: {count: number}) {
   const pal = usePalette('default')
@@ -17,7 +17,9 @@ export function CharProgress({count}: {count: number}) {
   const circleColor = count > DANGER_LENGTH ? '#e60000' : pal.colors.link
   return (
     <>
-      <Text style={[s.mr10, {color: textColor}]}>{MAX_LENGTH - count}</Text>
+      <Text style={[s.mr10, {color: textColor}]}>
+        {MAX_GRAPHEME_LENGTH - count}
+      </Text>
       <View>
         {count > DANGER_LENGTH ? (
           <ProgressPie
@@ -25,7 +27,10 @@ export function CharProgress({count}: {count: number}) {
             borderWidth={4}
             borderColor={circleColor}
             color={circleColor}
-            progress={Math.min((count - MAX_LENGTH) / MAX_LENGTH, 1)}
+            progress={Math.min(
+              (count - MAX_GRAPHEME_LENGTH) / MAX_GRAPHEME_LENGTH,
+              1,
+            )}
           />
         ) : (
           <ProgressCircle
@@ -33,7 +38,7 @@ export function CharProgress({count}: {count: number}) {
             borderWidth={1}
             borderColor={pal.colors.border}
             color={circleColor}
-            progress={count / MAX_LENGTH}
+            progress={count / MAX_GRAPHEME_LENGTH}
           />
         )}
       </View>