about summary refs log tree commit diff
path: root/src/view/com/composer/AltTextCounterWrapper.tsx
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-10-05 05:58:04 -0500
committerGitHub <noreply@github.com>2024-10-05 19:58:04 +0900
commit76d63f9967a9a59193652487d2a10f41eac22268 (patch)
treee70fcda6005d4501f87309d70fa574d24f51c96c /src/view/com/composer/AltTextCounterWrapper.tsx
parent6dfd57e6218eb32fcf700f1fbbd0339705940679 (diff)
downloadvoidsky-76d63f9967a9a59193652487d2a10f41eac22268.tar.zst
Add alt text limit to image dialog (#5611)
* Add alt text limit to image dialog

* GIF alt text too

* Fix

* tweaks, save alt on dialog dismiss

* simplify close behavior

* use state in gif alt

* state

---------

Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/view/com/composer/AltTextCounterWrapper.tsx')
-rw-r--r--src/view/com/composer/AltTextCounterWrapper.tsx33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/view/com/composer/AltTextCounterWrapper.tsx b/src/view/com/composer/AltTextCounterWrapper.tsx
new file mode 100644
index 000000000..d69252f4b
--- /dev/null
+++ b/src/view/com/composer/AltTextCounterWrapper.tsx
@@ -0,0 +1,33 @@
+import React from 'react'
+import {View} from 'react-native'
+
+import {MAX_ALT_TEXT} from '#/lib/constants'
+import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
+import {atoms as a, useTheme} from '#/alf'
+
+export function AltTextCounterWrapper({
+  altText,
+  children,
+}: {
+  altText?: string
+  children: React.ReactNode
+}) {
+  const t = useTheme()
+  return (
+    <View style={[a.flex_row]}>
+      <CharProgress
+        style={[
+          a.flex_col_reverse,
+          a.align_center,
+          a.mr_xs,
+          {minWidth: 50, gap: 1},
+        ]}
+        textStyle={[{marginRight: 0}, a.text_sm, t.atoms.text_contrast_medium]}
+        size={26}
+        count={altText?.length || 0}
+        max={MAX_ALT_TEXT}
+      />
+      {children}
+    </View>
+  )
+}