Skip to content

Commit a891dda

Browse files
feat(evm-bridge): add cookies disclaimer (#9040)
Closes #9021 Depends on [#9041](#9041), as it includes updates to the docs and the @boxfish-studio/react-cookie-manager package version required for manypkg consistency
1 parent ac2f4b9 commit a891dda

File tree

9 files changed

+183
-16
lines changed

9 files changed

+183
-16
lines changed

apps/evm-bridge/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@amplitude/analytics-browser": "^1.10.3",
28+
"@boxfish-studio/react-cookie-manager": "^1.0.5",
2829
"@growthbook/growthbook": "^1.0.0",
2930
"@growthbook/growthbook-react": "^1.0.0",
3031
"@hookform/resolvers": "^3.9.0",

apps/evm-bridge/src/App.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DirectionalArrowsSvg } from './components/svgs/DirectionalArrows';
66
import { FaucetButton } from './components/FaucetButton';
77
import { useEffect } from 'react';
88
import { initAmplitude } from './shared/analytics';
9+
import { CookiePolicy } from './components/disclaimer/CookiePolicy';
910

1011
const TITLE = 'Seamlessly transfer funds between IOTA & IOTA EVM';
1112

@@ -14,29 +15,36 @@ export default function App() {
1415
initAmplitude();
1516
}, []);
1617

18+
const isCookiePolicyPage =
19+
typeof window !== 'undefined' && window.location.pathname === '/cookie-policy';
20+
1721
return (
1822
<>
1923
<div className="relative overflow-x-hidden" id="app">
2024
<Header />
2125

2226
<main className="flex flex-col min-h-screen container justify-center pt-24 flex-1">
23-
<div className="flex flex-col items-center md:flex-row gap-lg h-full py-20">
24-
<div className="flex-1 pb-2xl flex flex-col items-center md:items-start justify-center">
25-
<div className="flex flex-col max-md:items-center max-md:text-center md:flex-col gap-10 pb-[72px] ">
26-
<DirectionalArrowsSvg />
27-
<h1 className="text-display-md text-balance text-iota-neutral-10 dark:text-iota-neutral-92 max-w-lg">
28-
{TITLE}
29-
</h1>
30-
</div>
31-
<div>
32-
<FaucetButton />
27+
{isCookiePolicyPage ? (
28+
<CookiePolicy />
29+
) : (
30+
<div className="flex flex-col items-center md:flex-row gap-lg h-full py-20">
31+
<div className="flex-1 pb-2xl flex flex-col items-center md:items-start justify-center">
32+
<div className="flex flex-col max-md:items-center max-md:text-center md:flex-col gap-10 pb-[72px] ">
33+
<DirectionalArrowsSvg />
34+
<h1 className="text-display-md text-balance text-iota-neutral-10 dark:text-iota-neutral-92 max-w-lg">
35+
{TITLE}
36+
</h1>
37+
</div>
38+
<div>
39+
<FaucetButton />
40+
</div>
3341
</div>
34-
</div>
3542

36-
<div className="w-full max-w-[500px] md:w-2/5">
37-
<Bridge />
43+
<div className="w-full max-w-[500px] md:w-2/5">
44+
<Bridge />
45+
</div>
3846
</div>
39-
</div>
47+
)}
4048
</main>
4149
</div>
4250

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#skcm-cookie-disclaimer#skcm-cookie-disclaimer {
2+
@apply dark:bg-iota-neutral-0;
3+
@apply bg-iota-neutral-100;
4+
@apply max-w-none w-full;
5+
@apply flex flex-col;
6+
@apply py-6 px-8;
7+
@apply max-md:space-y-4;
8+
@apply bottom-0 right-0;
9+
@apply rounded-none;
10+
@apply shadow-2xl;
11+
@apply max-md:px-0;
12+
@apply md:flex-row md:space-x-4 md:py-4 md:px-6 md:bottom-6 md:right-6 md:rounded-md md:max-w-lg;
13+
border: 1px solid transparent;
14+
15+
#skcm-policy-link__button {
16+
@apply text-iota-primary-40;
17+
}
18+
19+
#skcm-cookie-disclaimer__body {
20+
@apply max-md:container;
21+
@apply flex flex-col;
22+
@apply items-center justify-center md:items-start;
23+
24+
#skcm-body {
25+
@apply m-0;
26+
@apply dark:text-iota-neutral-92;
27+
@apply text-iota-neutral-10;
28+
29+
a {
30+
@apply text-iota-primary-40;
31+
}
32+
}
33+
}
34+
35+
#skcm-cookie-disclaimer__buttons {
36+
@apply max-md:container;
37+
@apply flex flex-col;
38+
@apply space-y-0;
39+
40+
button {
41+
@apply rounded-full;
42+
@apply bg-iota-primary-30;
43+
@apply text-iota-neutral-92;
44+
@apply py-3 px-[20px];
45+
@apply text-label-lg normal-case;
46+
@apply transition-colors;
47+
@apply w-full;
48+
@apply min-w-[120px];
49+
}
50+
}
51+
}
52+
53+
.cookie-policy-page {
54+
#skcm-cookie-library {
55+
h4,
56+
p,
57+
td,
58+
label {
59+
@apply text-iota-neutral-10;
60+
}
61+
}
62+
#skcm-cookie-library__preferences__button {
63+
@apply bg-iota-primary-30;
64+
}
65+
}
66+
67+
.dark-theme.dark {
68+
.cookie-policy-page {
69+
#skcm-cookie-library {
70+
h4,
71+
p,
72+
td,
73+
label {
74+
@apply text-iota-neutral-92;
75+
}
76+
}
77+
#skcm-cookie-library__preferences__button {
78+
@apply bg-iota-primary-30;
79+
}
80+
}
81+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { CookieManager, type SKCMConfiguration } from '@boxfish-studio/react-cookie-manager';
5+
import { useCookiesManager } from './useCookiesManager';
6+
7+
const COOKIES_KEY = 'AMP_COOKIES_ACCEPTED';
8+
9+
export function CookieDisclaimer() {
10+
const { onAcceptCookies, onDeclineCookies } = useCookiesManager();
11+
const configuration: SKCMConfiguration = {
12+
disclaimer: {
13+
title: undefined,
14+
body: 'We use cookies and analytics tools to help us improve your experience. ',
15+
policyText: 'Read our Cookie Policy',
16+
policyUrl: '/cookie-policy',
17+
},
18+
services: {
19+
customNecessaryCookies: [
20+
{
21+
name: COOKIES_KEY,
22+
purpose:
23+
'Flag indicating that Amplitude analytics cookies may be created after consent',
24+
expiry: '1 year',
25+
type: 'http',
26+
showDisclaimerIfMissing: true,
27+
},
28+
],
29+
},
30+
onAcceptCookies,
31+
onDeclineCookies,
32+
};
33+
return (
34+
<>
35+
<CookieManager configuration={configuration} />
36+
</>
37+
);
38+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
import { CookieLibrary } from '@boxfish-studio/react-cookie-manager';
4+
import { useCookiesManager } from './useCookiesManager';
5+
6+
export function CookiePolicy(): React.JSX.Element {
7+
const { onAcceptCookies, onDeclineCookies } = useCookiesManager();
8+
return (
9+
<section className="py-16 max-w-3xl mx-auto cookie-policy-page">
10+
<CookieLibrary
11+
configuration={{
12+
onAcceptCookies,
13+
onDeclineCookies,
14+
}}
15+
/>
16+
</section>
17+
);
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export function useCookiesManager() {
5+
const onAcceptCookies = () => {
6+
document.cookie = `AMP_COOKIES_ACCEPTED=true; max-age=31536000`;
7+
};
8+
const onDeclineCookies = () => {
9+
document.cookie = `AMP_COOKIES_ACCEPTED=false; max-age=31536000`;
10+
};
11+
return { onAcceptCookies, onDeclineCookies };
12+
}

apps/evm-bridge/src/globals.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import '@iota/apps-ui-kit/styles';
2+
@import './components/disclaimer/CookieDisclaimer.css';
23

34
@tailwind base;
45
@tailwind components;

apps/evm-bridge/src/main.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import './globals.css';
44

55
import React from 'react';
66
import ReactDOM from 'react-dom/client';
7+
import { CookieManagerProvider } from '@boxfish-studio/react-cookie-manager';
78
import {
89
getDefaultConfig,
910
darkTheme as rainbowDarkTheme,
@@ -13,6 +14,7 @@ import {
1314
} from '@rainbow-me/rainbowkit';
1415
import { darkTheme, IotaClientProvider, lightTheme, WalletProvider } from '@iota/dapp-kit';
1516
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
17+
import { CookieDisclaimer } from './components/disclaimer/CookieDisclaimer';
1618
import App from './App.tsx';
1719
import { ThemeProvider } from './providers/ThemeProvider.tsx';
1820
import { WagmiProvider } from 'wagmi';
@@ -77,8 +79,11 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
7779
>
7880
<ThemeProvider appId="IOTA-evm-bridge">
7981
<RainbowKit>
80-
<App />
81-
<Toaster />
82+
<CookieManagerProvider>
83+
<App />
84+
<Toaster />
85+
<CookieDisclaimer />
86+
</CookieManagerProvider>
8287
</RainbowKit>
8388
</ThemeProvider>
8489
</WalletProvider>

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)