about summary refs log tree commit diff
path: root/src/view/com/composer/AltTextCounterWrapper.tsx
blob: da3c14920fd9566b6e6f4a4a9f663981577e43ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {View} from 'react-native'
import type React from 'react'

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>
  )
}