move Tag, update styling

This commit is contained in:
Eric Bailey
2023-09-28 11:00:50 -05:00
parent e0c614bfb7
commit 804a393ff8
3 changed files with 99 additions and 33 deletions
+2 -26
View File
@@ -5,7 +5,6 @@ import {
StyleSheet,
NativeSyntheticEvent,
TextInputKeyPressEventData,
Pressable,
} from 'react-native'
import {
FontAwesomeIcon,
@@ -13,8 +12,8 @@ import {
} from '@fortawesome/react-native-fontawesome'
import {isWeb} from 'platform/detection'
import {Text} from 'view/com/util/text/Text'
import {usePalette} from 'lib/hooks/usePalette'
import {EditableTag} from 'view/com/Tag'
function uniq(tags: string[]) {
return Array.from(new Set(tags))
@@ -34,29 +33,6 @@ function sanitize(tagString: string) {
return tagString.trim().replace(/^#/, '')
}
function Tag({
tag,
removeTag,
}: {
tag: string
removeTag: (tag: string) => void
}) {
const pal = usePalette('default')
return (
<Pressable
accessibilityRole="button"
onPress={() => removeTag(tag)}
style={state => ({
opacity: state.hovered || state.pressed || state.focused ? 0.8 : 1,
outline: 0,
})}>
<Text type="xs-medium" style={[styles.tag, pal.viewLight, pal.textLight]}>
#{tag}
</Text>
</Pressable>
)
}
export function TagInput({
max = 8,
onChangeTags,
@@ -130,7 +106,7 @@ export function TagInput({
/>
)}
{tags.map(tag => (
<Tag key={tag} tag={tag} removeTag={removeTag} />
<EditableTag key={tag} value={tag} onRemove={removeTag} />
))}
{tags.length >= max ? null : (
<TextInput