Skip to content

Commit

Permalink
use non styling values for overwriting excluded styles
Browse files Browse the repository at this point in the history
  • Loading branch information
robertKozik committed May 14, 2024
1 parent 5b46503 commit 5500e45
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/hooks/useMarkdownStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import FontUtils from '@styles/utils/FontUtils';
import variables from '@styles/variables';
import useTheme from './useTheme';

const nonStylingDefaultValues: Record<string, string|number> = {
color: 'black',
backgroundColor: 'transparent',
marginLeft: 0,
paddingLeft: 0,
borderColor: 'transparent',
borderWidth: 0,
}


function useMarkdownStyle(message: string | null = null, excludeStyles: Array<keyof MarkdownStyle> = []): MarkdownStyle {
const theme = useTheme();
const emojiFontSize = containsOnlyEmojis(message ?? '') ? variables.fontSizeOnlyEmojis : variables.fontSizeNormal;
Expand Down Expand Up @@ -60,7 +70,7 @@ function useMarkdownStyle(message: string | null = null, excludeStyles: Array<ke
const style: Record<string, unknown> = styling[key];
if (style) {
Object.keys(style).forEach((styleKey) => {
style[styleKey] = undefined;
style[styleKey] = nonStylingDefaultValues[styleKey] ?? style[styleKey];
});
}
});
Expand Down

0 comments on commit 5500e45

Please sign in to comment.