Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const styleSheet = (params: { theme: Theme }) => {
alignItems: 'center',
zIndex: 10,
position: 'absolute',
bottom: 175,
right: 32,
bottom: 160,
right: 16,
boxShadow: `0px 3px 8px ${colors.icon.default}`,
},
footerHelpText: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,66 @@ const ModalMandatory = ({ route }: MandatoryModalProps) => {
}
}})();`;

const themeCSS = useMemo(() => {
const sanitizeColor = (color: string): string =>
color.replace(/[^#a-fA-F0-9(),.\s%]/g, '');

const safeColors = {
bg: sanitizeColor(colors.background.default),
text: sanitizeColor(colors.text.alternative),
primary: sanitizeColor(colors.primary.default),
primaryAlt: sanitizeColor(colors.primary.alternative),
bgAlt: sanitizeColor(colors.background.alternative),
border: sanitizeColor(colors.border.default),
};

return `
<style>
:root {
--bg: ${safeColors.bg};
--text: ${safeColors.text};
--primary: ${safeColors.primary};
--primary-alt: ${safeColors.primaryAlt};
--bg-alt: ${safeColors.bgAlt};
--border: ${safeColors.border};
}
body {
background-color: var(--bg) !important;
color: var(--text) !important;
font-family: Geist, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
margin: 0;
font-size: 14px;
font-weight: 400;
padding: 0px !important;
line-height: 1.5;
margin-top: -50px !important;
}
body > div > div > div > div {
max-width: 100% !important;
}
*, *::before, *::after {
background-color: var(--bg) !important;
color: var(--text) !important;
padding: 0px;
}
h1, h2, h3, h4, h5, h6, p, div, span, section, article, header, footer, main, ul, ol, li {
color: var(--text) !important;
}
a { color: var(--primary) !important; }
a:visited { color: var(--primary-alt) !important; }
table, th, td {
background-color: var(--bg) !important;
color: var(--text) !important;
border-color: var(--border) !important;
}
pre, code {
background-color: var(--bg-alt) !important;
color: var(--text) !important;
}
</style>
`;
}, [colors]);

const scrollToEndWebView = () => {
if (isWebViewLoaded) {
webViewRef.current?.injectJavaScript(scrollToEndJS);
Expand Down Expand Up @@ -191,11 +251,33 @@ const ModalMandatory = ({ route }: MandatoryModalProps) => {
[isCloseToBottom],
);

const removeElements = (html: string) => {
html = html.replace(/<h1 class="title">.*?<\/h1>/gs, '');
html = html.replace(/<p class="sub-title">.*?<\/p>/gs, '');
return html;
};

const renderWebView = (webviewBody: BodyWebView) => {
const source = isBodyWebViewUri(webviewBody)
? { uri: webviewBody.uri }
: { html: webviewBody.html };

if (source.html) {
const themedHTML = `
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
${themeCSS}
</head>
<body>
${source.html}
</body>
</html>
`;
source.html = removeElements(themedHTML);
}

return (
<WebView
ref={webViewRef}
Expand Down Expand Up @@ -248,7 +330,7 @@ const ModalMandatory = ({ route }: MandatoryModalProps) => {
testID={TermsOfUseModalSelectorsIDs.CHECKBOX}
>
<Checkbox onPress={handleSelect} isChecked={isCheckboxSelected} />
<Text variant={TextVariant.BodySMMedium} color={TextColor.Default}>
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{checkboxText}
</Text>
</TouchableOpacity>
Expand Down
Loading