exploration of tag styles

This commit is contained in:
Eric Bailey
2023-09-28 11:42:23 -05:00
parent 804a393ff8
commit 16206df6b2
4 changed files with 61 additions and 31 deletions
+52 -5
View File
@@ -6,15 +6,61 @@ import {
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {Text} from 'view/com/util/text/Text' import {Text, CustomTextProps} from 'view/com/util/text/Text'
import {Link} from 'view/com/util/Link'
export function Tag({value}: {value: string}) { export function Tag({
value,
textSize,
}: {
value: string
textSize?: CustomTextProps['type']
}) {
const pal = usePalette('default') const pal = usePalette('default')
const type = textSize || 'xs-medium'
return ( return (
<Text type="xs-medium" style={[styles.tag, pal.viewLight, pal.textLight]}> <Link
asAnchor
accessible
anchorNoUnderline
href={`/search?q=${value}`}
style={[pal.border, styles.tag]}>
<Text type={type} style={[pal.textLight]}>
#{value} #{value}
</Text> </Text>
</Link>
)
}
export function InlineTag({
value,
textSize,
}: {
value: string
textSize?: CustomTextProps['type']
}) {
const pal = usePalette('default')
const type = textSize || 'xs-medium'
return (
<Link
asAnchor
accessible
anchorNoUnderline
href={`/search?q=${value}`}
style={[
pal.border,
styles.tag,
{
paddingTop: 0,
paddingBottom: 2,
},
]}>
<Text type={type} style={[pal.textLight]}>
#{value}
</Text>
</Link>
) )
} }
@@ -74,8 +120,9 @@ const styles = StyleSheet.create({
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
gap: 4, gap: 4,
paddingVertical: 3, paddingTop: 1,
paddingHorizontal: 8, paddingBottom: 2,
paddingHorizontal: 6,
borderRadius: 20, borderRadius: 20,
overflow: 'hidden', overflow: 'hidden',
borderWidth: 1, borderWidth: 1,
+2 -12
View File
@@ -36,6 +36,7 @@ import {TimeElapsed} from 'view/com/util/TimeElapsed'
import {makeProfileLink} from 'lib/routes/links' import {makeProfileLink} from 'lib/routes/links'
import {isDesktopWeb} from 'platform/detection' import {isDesktopWeb} from 'platform/detection'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {Tag} from 'view/com/Tag'
export const PostThreadItem = observer(function PostThreadItem({ export const PostThreadItem = observer(function PostThreadItem({
item, item,
@@ -339,18 +340,7 @@ export const PostThreadItem = observer(function PostThreadItem({
paddingBottom: 12, paddingBottom: 12,
}}> }}>
{item.post.record.tags.map(tag => ( {item.post.record.tags.map(tag => (
<Link <Tag key={tag} value={tag} textSize="post-text-lg" />
key={tag}
asAnchor
accessible
anchorNoUnderline
href={`/search?q=${tag}`}>
<Text
type="xs-medium"
style={[styles.tag, pal.viewLight, pal.textLight]}>
#{tag}
</Text>
</Link>
))} ))}
</View> </View>
) : null} ) : null}
+2 -10
View File
@@ -7,6 +7,7 @@ import {lh} from 'lib/styles'
import {toShortUrl} from 'lib/strings/url-helpers' import {toShortUrl} from 'lib/strings/url-helpers'
import {useTheme, TypographyVariant} from 'lib/ThemeContext' import {useTheme, TypographyVariant} from 'lib/ThemeContext'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {InlineTag} from 'view/com/Tag'
const WORD_WRAP = {wordWrap: 1} const WORD_WRAP = {wordWrap: 1}
@@ -93,16 +94,7 @@ export function RichText({
/>, />,
) )
} else if (tag && AppBskyRichtextFacet.validateTag(tag).success) { } else if (tag && AppBskyRichtextFacet.validateTag(tag).success) {
els.push( els.push(<InlineTag key={key} value={tag.tag} textSize={type} />)
<TextLink
key={key}
type={type}
text={segment.text}
href={`/search?q=${tag.tag}`}
style={[style, lineHeightStyle, pal.link]}
dataSet={WORD_WRAP}
/>,
)
} else { } else {
els.push(segment.text) els.push(segment.text)
} }
+3 -2
View File
@@ -116,6 +116,7 @@
} }
.ProseMirror p { .ProseMirror p {
margin: 0; margin: 0;
line-height: 1.5;
} }
.ProseMirror p.is-editor-empty:first-child::before { .ProseMirror p.is-editor-empty:first-child::before {
color: #8d8e96; color: #8d8e96;
@@ -155,8 +156,8 @@
.ProseMirror .mention::after { .ProseMirror .mention::after {
content: ''; content: '';
position: absolute; position: absolute;
top: -1px; top: 0;
bottom: -3px; bottom: -2px;
left: -8px; left: -8px;
right: -8px; right: -8px;
z-index: -1; z-index: -1;