allow lightning animation to be disabled

This commit is contained in:
keyan 2022-10-04 17:34:28 -05:00
parent 729bcead69
commit dbf66b4dd7
3 changed files with 43 additions and 10 deletions

View File

@ -10,6 +10,8 @@ import Link from 'next/link'
import useDarkMode from 'use-dark-mode'
import Sun from '../svgs/sun-fill.svg'
import Moon from '../svgs/moon-fill.svg'
import No from '../svgs/no.svg'
import Bolt from '../svgs/bolt.svg'
import { useEffect, useState } from 'react'
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@ -111,7 +113,6 @@ export default function Footer ({ noLinks }) {
connectAddress
}
`
const { data } = useQuery(query, { fetchPolicy: 'cache-first' })
const darkMode = useDarkMode(false, {
@ -120,11 +121,26 @@ export default function Footer ({ noLinks }) {
})
const [mounted, setMounted] = useState()
const [lightning, setLightning] = useState(undefined)
useEffect(() => {
setMounted(true)
setLightning(localStorage.getItem('lnAnimate') || 'yes')
})
const toggleLightning = () => {
if (lightning === 'yes') {
localStorage.setItem('lnAnimate', 'no')
setLightning('no')
} else {
localStorage.setItem('lnAnimate', 'yes')
setLightning('yes')
}
}
const DarkModeIcon = darkMode.value ? Sun : Moon
const LnIcon = lightning === 'yes' ? No : Bolt
return (
<footer>
<Container className='mb-3 mt-4'>
@ -132,9 +148,8 @@ export default function Footer ({ noLinks }) {
<>
{mounted &&
<div className='mb-2'>
{darkMode.value
? <Sun onClick={() => darkMode.toggle()} className='fill-grey theme' />
: <Moon onClick={() => darkMode.toggle()} className='fill-grey theme' />}
<DarkModeIcon onClick={() => darkMode.toggle()} className='fill-grey theme' />
<LnIcon onClick={toggleLightning} width={24} height={24} className='ml-2 fill-grey theme' />
</div>}
<div className='mb-0' style={{ fontWeight: 500 }}>
<OverlayTrigger trigger='click' placement='top' overlay={AnalyticsPopover} rootClose>

View File

@ -10,12 +10,15 @@ export class LightningProvider extends React.Component {
state = {
bolts: 0,
strike: (repeat) => {
this.setState(state => {
return {
...this.state,
bolts: this.state.bolts + 1
}
})
const should = localStorage.getItem('lnAnimate') || 'yes'
if (should === 'yes') {
this.setState(state => {
return {
...this.state,
bolts: this.state.bolts + 1
}
})
}
}
}

15
svgs/no.svg Normal file
View File

@ -0,0 +1,15 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(-60.643 -52.091)">
<g transform="matrix(.26458 0 0 .26458 3.7594 105.64)" fill="none">
<path d="m66.532 0-39.532 65.935h79.06z"/>
<path d="m50 44v12l48 119.5h79l-114-126.5z"/>
<path d="m177 324-86.787-176h-90.213z"/>
</g>
<g transform="matrix(.26885 0 0 .2689 44.339 38.084)">
<path d="m105.05 52.121c-0.0141 0.0141-0.59972 0.0635-1.2982 0.10584-4.3462 0.28222-8.255 1.0513-12.199 2.4059-8.6219 2.9492-16.277 8.5443-21.858 15.981-8.8124 11.748-11.395 27.213-6.8298 40.957 2.2507 6.7733 5.8138 12.46 10.936 17.448 3.2738 3.1891 6.7874 5.6727 10.901 7.7047 5.1364 2.5329 10.485 4.0005 16.087 4.4097 0.58561 0.0423 1.3476 0.10583 1.7074 0.14111 0.85372 0.0917 2.3777 0.0917 3.5137 0 3.7536-0.31044 4.9953-0.46567 7.2319-0.91722 6.9568-1.4111 13.427-4.4097 19.099-8.8688 0.508-0.39512 0.98777-0.72673 1.0583-0.72673 0.0705 0 0.5715-0.4445 1.15-1.0301 0.56445-0.56444 1.6369-1.6016 2.3848-2.3001 0.76906-0.72672 1.3547-1.3335 1.3547-1.404 0-0.0706 0.23283-0.38806 0.51505-0.71262 6.2724-7.2178 10.174-16.538 10.908-26.091 0.0423-0.52211 0.11289-1.3829 0.15523-1.905 0.13405-1.4958-0.0212-4.5579-0.3669-7.2672-1.4605-11.628-7.5706-22.147-16.976-29.217-6.5476-4.9248-14.619-7.9375-22.811-8.5302-0.59973-0.0423-1.3829-0.10583-1.7427-0.14111-0.62088-0.0706-2.8575-0.0988-2.921-0.0423zm3.6195 6.8157c8.0363 0.54328 15.311 3.4431 21.442 8.5443 1.1359 0.94544 3.5066 3.3161 4.4379 4.4379 4.4873 5.4046 7.232 11.571 8.255 18.556 0.29634 2.0602 0.42334 5.3481 0.28928 7.4083-0.19756 2.9139-0.56444 5.1576-1.2771 7.8317-1.2347 4.5932-3.4996 9.2357-6.4135 13.123-0.78316 1.0513-1.7568 2.2154-1.8697 2.2437-0.16228 0.0353-6.1383-6.1948-32.604-33.994-9.6591-10.146-17.829-18.725-18.147-19.064-0.32455-0.33161-0.58561-0.635-0.58561-0.67027 0-0.16228 2.7658-2.1026 4.2686-2.9986 1.1924-0.70556 1.3335-0.77612 2.6388-1.4323 4.5579-2.2719 9.5179-3.6266 14.612-3.9793 1.2065-0.0847 3.7253-0.0847 4.953-7e-3zm-28.709 15.981c1.3264 1.397 2.8293 2.9704 3.3373 3.4925 1.9685 2.025 19.262 20.228 19.431 20.447 0.15522 0.20461 1.7568 1.8838 9.4192 9.8566 0.86077 0.889 4.4803 4.6849 8.0433 8.4314 3.563 3.7465 6.5334 6.8157 6.604 6.8298 0.16227 0.0282 1.8415 1.778 1.8062 1.8838-0.0847 0.254-3.5066 2.6317-5.1294 3.5631-4.2757 2.4624-9.4968 4.2263-14.288 4.833-3.1186 0.38806-6.4064 0.41628-9.3486 0.0635-6.7733-0.80433-13.088-3.3796-18.38-7.5-6.0466-4.7061-10.52-11.303-12.629-18.627-0.86783-3.0339-1.3194-5.8138-1.4393-8.9676-0.33867-8.6078 2.2013-16.962 7.3025-24.066 0.635-0.889 1.7639-2.3072 2.2225-2.801l0.28928-0.30339 0.17639 0.16227c0.09878 0.0917 1.2629 1.3053 2.5823 2.7023z"/>
<g transform="matrix(.26458 0 0 .26458 77.32 55.676)">
<path d="m56 0 51.606 131h-107.61l177 176-70.021-142h93.021z"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB