fork
Configure Feed
Select the types of activity you want to include in your feed.
mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
fork
Configure Feed
Select the types of activity you want to include in your feed.
1import {UITextView} from 'react-native-uitextview'
2
3import {logger} from '#/logger'
4import {atoms, flatten, useAlf, useTheme, web} from '#/alf'
5import {
6 childHasEmoji,
7 normalizeTextStyles,
8 renderChildrenWithEmoji,
9 TextProps,
10} from '#/alf/typography'
11export type {TextProps}
12
13/**
14 * Our main text component. Use this most of the time.
15 */
16export function Text({
17 children,
18 emoji,
19 style,
20 selectable,
21 title,
22 dataSet,
23 ...rest
24}: TextProps) {
25 const {fonts, flags} = useAlf()
26 const t = useTheme()
27 const s = normalizeTextStyles([atoms.text_sm, t.atoms.text, flatten(style)], {
28 fontScale: fonts.scaleMultiplier,
29 fontFamily: fonts.family,
30 flags,
31 })
32
33 if (__DEV__) {
34 if (!emoji && childHasEmoji(children)) {
35 logger.warn(
36 `Text: emoji detected but emoji not enabled: "${children}"\n\nPlease add <Text emoji />'`,
37 )
38 }
39 }
40
41 const shared = {
42 uiTextView: true,
43 selectable,
44 style: s,
45 dataSet: Object.assign({tooltip: title}, dataSet || {}),
46 ...rest,
47 }
48
49 return (
50 <UITextView {...shared}>
51 {renderChildrenWithEmoji(children, shared, emoji ?? false)}
52 </UITextView>
53 )
54}
55
56function createHeadingElement({level}: {level: number}) {
57 return function HeadingElement({style, ...rest}: TextProps) {
58 const attr =
59 web({
60 role: 'heading',
61 'aria-level': level,
62 }) || {}
63 return <Text {...attr} {...rest} style={style} />
64 }
65}
66
67/*
68 * Use semantic components when it's beneficial to the user or to a web scraper
69 */
70export const H1 = createHeadingElement({level: 1})
71export const H2 = createHeadingElement({level: 2})
72export const H3 = createHeadingElement({level: 3})
73export const H4 = createHeadingElement({level: 4})
74export const H5 = createHeadingElement({level: 5})
75export const H6 = createHeadingElement({level: 6})
76export function P({style, ...rest}: TextProps) {
77 const attr =
78 web({
79 role: 'paragraph',
80 }) || {}
81 return (
82 <Text
83 {...attr}
84 {...rest}
85 style={[atoms.text_md, atoms.leading_normal, flatten(style)]}
86 />
87 )
88}