Skip to content

Commit

Permalink
Merge pull request #7 from ansh-saini/main
Browse files Browse the repository at this point in the history
fix: svg re-render on theme change
  • Loading branch information
anup-a authored Oct 16, 2020
2 parents c83e874 + a212025 commit 29fed9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
dist
debug.log
16 changes: 10 additions & 6 deletions src/components/home.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h } from 'preact';
import { useRef, useState } from 'preact/hooks'
import { h } from 'preact'
import { useRef, useState, useEffect } from 'preact/hooks'
import Canvas from './canvas'
import CustomBar from './customBar'
import Navbar from './nav'
Expand All @@ -25,8 +25,13 @@ function Home({ isDark, toggleDarkMode }) {
strokeColor: 'none',
})

const waveSvg = waveInit(wave)
const { height, width, xmlns, path } = waveSvg.svg
const [waveSvg, setWaveSvg] = useState(waveInit(wave))

useEffect(() => {
setWaveSvg(waveInit(wave))
}, [wave])

const { height, xmlns, path } = waveSvg.svg
const num_waves = path.length
const opac = OPACITY_ARR.slice(MAX_WAVES - num_waves)

Expand Down Expand Up @@ -77,7 +82,7 @@ function Home({ isDark, toggleDarkMode }) {

return (
<div className="relative h-screen dark:bg-darkish-black">
<Navbar isDark={isDark} toggleDarkMode={toggleDarkMode} color={bgColor}/>
<Navbar isDark={isDark} toggleDarkMode={toggleDarkMode} color={bgColor} />
<div
className="flex flex-col items-center justify-center h-screen p-0 dark:bg-darkish-black "
style={{ backgroundColor: isDark ? '#131e2b66' : `${bgColor}33` }}
Expand All @@ -103,7 +108,6 @@ function Home({ isDark, toggleDarkMode }) {
<div className="z-20 flex h-12 text-lg font-bold text-black footer dark:text-white">
Made with ❤ - by <a href="https://www.anup.tech" className="ml-2 underline"> Anup</a>
</div>

</div>
</div>
)
Expand Down

1 comment on commit 29fed9b

@vercel
Copy link

@vercel vercel bot commented on 29fed9b Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.