11import { css } from '@emotion/react' ;
2- import { isUndefined , removeCookie , setCookie , storage } from '@guardian/libs' ;
2+ import { isUndefined , storage } from '@guardian/libs' ;
33import { article17 , palette } from '@guardian/source/foundations' ;
44import { type SetStateAction , useEffect , useState } from 'react' ;
55import { useConfig } from './ConfigContext' ;
@@ -19,10 +19,6 @@ const bold = css`
1919 font-weight : bold;
2020` ;
2121
22- // This is hard coded, and must be changed if the experiment bucket changes
23- // https://github.com/guardian/frontend/blob/09f49b80/common/app/experiments/Experiments.scala#L57
24- const darkModeCookieName = 'X-GU-Experiment-0perc-D' ;
25-
2622const PreferenceToggle = ( {
2723 label,
2824 checked,
@@ -90,30 +86,6 @@ export const Accessibility = () => {
9086 true ,
9187 ) ;
9288
93- const [ shouldParticipate , setParticipate ] =
94- useState < boolean > ( darkModeAvailable ) ;
95-
96- useEffect ( ( ) => {
97- if ( shouldParticipate ) {
98- setCookie ( {
99- name : darkModeCookieName ,
100- value : 'true' ,
101- } ) ;
102- } else {
103- removeCookie ( { name : darkModeCookieName } ) ;
104- }
105-
106- const timeout = setTimeout ( ( ) => {
107- // we must reload the page for the preference to take effect,
108- // as this relies on a server-side test & cookie combination
109- if ( shouldParticipate !== darkModeAvailable ) {
110- window . location . reload ( ) ;
111- }
112- } , 1200 ) ;
113-
114- return ( ) => clearTimeout ( timeout ) ;
115- } , [ shouldParticipate , darkModeAvailable ] ) ;
116-
11789 const togglePreference = (
11890 preferenceCallback : ( value : SetStateAction < boolean > ) => void ,
11991 ) : void => {
@@ -154,29 +126,36 @@ export const Accessibility = () => {
154126
155127 < br />
156128
157- < fieldset css = { formStyle } >
129+ < div css = { formStyle } >
158130 < p >
159131 We offer beta support for a dark colour scheme on the
160132 web. The colour scheme preference will follow your
161133 system settings.
162134 </ p >
163- < label >
164- < input
165- type = "checkbox"
166- checked = { shouldParticipate }
167- onChange = { ( e ) => {
168- setParticipate ( e . target . checked ) ;
169- } }
170- data-link-name = "prefers-colour-scheme"
171- />
172- < span css = { bold } >
173- Participate in the dark colour scheme beta{ ' ' }
174- </ span >
175- { shouldParticipate
176- ? ' Untick this to opt out (browser will refresh)'
177- : ' Tick this to opt in (browser will refresh)' }
178- </ label >
179- </ fieldset >
135+ { darkModeAvailable ? (
136+ < >
137+ < p css = { bold } >
138+ You are currently participating in the dark
139+ colour scheme beta.
140+ </ p >
141+ < a href = "/ab-tests/opt-out/webx-dark-mode-web:enable" >
142+ Click here to opt out (this will redirect you to
143+ the homepage)
144+ </ a >
145+ </ >
146+ ) : (
147+ < >
148+ < p css = { bold } >
149+ You are not currently participating in the dark
150+ colour scheme beta.
151+ </ p >
152+ < a href = "/ab-tests/opt-in/webx-dark-mode-web:enable" >
153+ Click here to opt in (this will redirect you to
154+ the homepage)
155+ </ a >
156+ </ >
157+ ) }
158+ </ div >
180159 </ form >
181160 </ FrontSection >
182161 ) ;
0 commit comments