Skip to content

Commit 92066f1

Browse files
committed
fix: Terms of Use aligned with the new design
1 parent 60361c2 commit 92066f1

File tree

2 files changed

+85
-3
lines changed

2 files changed

+85
-3
lines changed

app/component-library/components/Modals/ModalMandatory/ModalMandatory.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ const styleSheet = (params: { theme: Theme }) => {
7676
alignItems: 'center',
7777
zIndex: 10,
7878
position: 'absolute',
79-
bottom: 175,
80-
right: 32,
79+
bottom: 160,
80+
right: 16,
8181
boxShadow: `0px 3px 8px ${colors.icon.default}`,
8282
},
8383
footerHelpText: {

app/component-library/components/Modals/ModalMandatory/ModalMandatory.tsx

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,66 @@ const ModalMandatory = ({ route }: MandatoryModalProps) => {
8181
}
8282
}})();`;
8383

84+
const themeCSS = useMemo(() => {
85+
const sanitizeColor = (color: string): string =>
86+
color.replace(/[^#a-fA-F0-9(),.\s%]/g, '');
87+
88+
const safeColors = {
89+
bg: sanitizeColor(colors.background.default),
90+
text: sanitizeColor(colors.text.alternative),
91+
primary: sanitizeColor(colors.primary.default),
92+
primaryAlt: sanitizeColor(colors.primary.alternative),
93+
bgAlt: sanitizeColor(colors.background.alternative),
94+
border: sanitizeColor(colors.border.default),
95+
};
96+
97+
return `
98+
<style>
99+
:root {
100+
--bg: ${safeColors.bg};
101+
--text: ${safeColors.text};
102+
--primary: ${safeColors.primary};
103+
--primary-alt: ${safeColors.primaryAlt};
104+
--bg-alt: ${safeColors.bgAlt};
105+
--border: ${safeColors.border};
106+
}
107+
body {
108+
background-color: var(--bg) !important;
109+
color: var(--text) !important;
110+
font-family: Geist, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
111+
margin: 0;
112+
font-size: 14px;
113+
font-weight: 400;
114+
padding: 0px !important;
115+
line-height: 1.5;
116+
margin-top: -50px !important;
117+
}
118+
body > div > div > div > div {
119+
max-width: 100% !important;
120+
}
121+
*, *::before, *::after {
122+
background-color: var(--bg) !important;
123+
color: var(--text) !important;
124+
padding: 0px;
125+
}
126+
h1, h2, h3, h4, h5, h6, p, div, span, section, article, header, footer, main, ul, ol, li {
127+
color: var(--text) !important;
128+
}
129+
a { color: var(--primary) !important; }
130+
a:visited { color: var(--primary-alt) !important; }
131+
table, th, td {
132+
background-color: var(--bg) !important;
133+
color: var(--text) !important;
134+
border-color: var(--border) !important;
135+
}
136+
pre, code {
137+
background-color: var(--bg-alt) !important;
138+
color: var(--text) !important;
139+
}
140+
</style>
141+
`;
142+
}, [colors]);
143+
84144
const scrollToEndWebView = () => {
85145
if (isWebViewLoaded) {
86146
webViewRef.current?.injectJavaScript(scrollToEndJS);
@@ -191,11 +251,33 @@ const ModalMandatory = ({ route }: MandatoryModalProps) => {
191251
[isCloseToBottom],
192252
);
193253

254+
const removeElements = (html: string) => {
255+
html = html.replace(/<[^>]*class=["']title["'][^>]*>.*?<\/[^>]*>/g, '');
256+
html = html.replace(/<[^>]*class=["']sub-title["'][^>]*>.*?<\/[^>]*>/g, '');
257+
return html;
258+
};
259+
194260
const renderWebView = (webviewBody: BodyWebView) => {
195261
const source = isBodyWebViewUri(webviewBody)
196262
? { uri: webviewBody.uri }
197263
: { html: webviewBody.html };
198264

265+
if (source.html) {
266+
const themedHTML = `
267+
<!DOCTYPE html>
268+
<html>
269+
<head>
270+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
271+
${themeCSS}
272+
</head>
273+
<body>
274+
${source.html}
275+
</body>
276+
</html>
277+
`;
278+
source.html = removeElements(themedHTML);
279+
}
280+
199281
return (
200282
<WebView
201283
ref={webViewRef}
@@ -248,7 +330,7 @@ const ModalMandatory = ({ route }: MandatoryModalProps) => {
248330
testID={TermsOfUseModalSelectorsIDs.CHECKBOX}
249331
>
250332
<Checkbox onPress={handleSelect} isChecked={isCheckboxSelected} />
251-
<Text variant={TextVariant.BodySMMedium} color={TextColor.Default}>
333+
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
252334
{checkboxText}
253335
</Text>
254336
</TouchableOpacity>

0 commit comments

Comments
 (0)