Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default font size for emojis in live markdown input #39597

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/Composer/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ function Composer(
// user can read new chats without the keyboard in the way of the view.
// On Android the selection prop is required on the TextInput but this prop has issues on IOS
selection,
value,
...props
}: ComposerProps,
ref: ForwardedRef<TextInput>,
) {
const textInput = useRef<AnimatedMarkdownTextInputRef | null>(null);
const {isFocused, shouldResetFocus} = useResetComposerFocus(textInput);
const theme = useTheme();
const markdownStyle = useMarkdownStyle();
const markdownStyle = useMarkdownStyle(value);
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();

Expand Down Expand Up @@ -73,6 +74,7 @@ function Composer(
autoComplete="off"
placeholderTextColor={theme.placeholderText}
ref={setTextInputRef}
value={value}
onContentSizeChange={(e) => ComposerUtils.updateNumberOfLines({maxLines, isComposerFullSize, isDisabled, setIsFullComposerAvailable}, e, styles)}
rejectResponderTermination={false}
smartInsertDelete={false}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Composer(
) {
const theme = useTheme();
const styles = useThemeStyles();
const markdownStyle = useMarkdownStyle();
const markdownStyle = useMarkdownStyle(value);
const StyleUtils = useStyleUtils();
const {windowWidth} = useWindowDimensions();
const textRef = useRef<HTMLElement & RNText>(null);
Expand Down
9 changes: 7 additions & 2 deletions src/hooks/useMarkdownStyle.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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(): MarkdownStyle {
function useMarkdownStyle(message: string | null = null): MarkdownStyle {
const theme = useTheme();
const emojiFontSize = containsOnlyEmojis(message ?? '') ? variables.fontSizeOnlyEmojis : variables.fontSizeNormal;

const markdownStyle = useMemo(
() => ({
Expand All @@ -18,6 +20,9 @@ function useMarkdownStyle(): MarkdownStyle {
h1: {
fontSize: variables.fontSizeLarge,
},
emoji: {
fontSize: emojiFontSize,
},
blockquote: {
borderColor: theme.border,
borderWidth: 4,
Expand Down Expand Up @@ -45,7 +50,7 @@ function useMarkdownStyle(): MarkdownStyle {
backgroundColor: theme.mentionBG,
},
}),
[theme],
[theme, emojiFontSize],
);

return markdownStyle;
Expand Down
Loading