-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
useMarkdownStyle.ts
63 lines (59 loc) · 2.02 KB
/
useMarkdownStyle.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type {MarkdownStyle} from '@expensify/react-native-live-markdown';
import {useMemo} from 'react';
import {containsOnlyEmojis} from '@libs/EmojiUtils';
import FontUtils from '@styles/utils/FontUtils';
import variables from '@styles/variables';
import useTheme from './useTheme';
function useMarkdownStyle(message: string | null = null): MarkdownStyle {
const theme = useTheme();
const emojiFontSize = containsOnlyEmojis(message ?? '') ? variables.fontSizeOnlyEmojis : variables.fontSizeNormal;
const markdownStyle = useMemo(
() => ({
syntax: {
color: theme.syntax,
},
link: {
color: theme.link,
},
h1: {
fontSize: variables.fontSizeLarge,
},
emoji: {
fontSize: emojiFontSize,
},
blockquote: {
borderColor: theme.border,
borderWidth: 4,
marginLeft: 0,
paddingLeft: 6,
},
code: {
fontFamily: FontUtils.fontFamily.platform.MONOSPACE,
fontSize: 13, // TODO: should be 15 if inside h1, see StyleUtils.getCodeFontSize
color: theme.text,
backgroundColor: 'transparent',
},
pre: {
fontFamily: FontUtils.fontFamily.platform.MONOSPACE,
fontSize: 13,
color: theme.text,
backgroundColor: 'transparent',
},
mentionHere: {
color: theme.ourMentionText,
backgroundColor: theme.ourMentionBG,
},
mentionUser: {
color: theme.mentionText,
backgroundColor: theme.mentionBG,
},
mentionReport: {
color: theme.mentionText,
backgroundColor: theme.mentionBG,
},
}),
[theme, emojiFontSize],
);
return markdownStyle;
}
export default useMarkdownStyle;