Skip to content

Commit

Permalink
fix: svg animation on system theme (#84)
Browse files Browse the repository at this point in the history
* fix: svg animation on system theme

* chore: change prettier config

* chore: rename prettier config name
  • Loading branch information
kimmyxpow authored Feb 19, 2024
1 parent 378d887 commit c6612df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/landing-svg/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useTheme } from "next-themes";
import { SVGProps, useEffect } from "react";

const LandingSvg = (props: SVGProps<SVGSVGElement>) => {
const { theme } = useTheme();
const { theme, systemTheme } = useTheme();
const currentTheme = theme === "system" ? systemTheme : theme;

useEffect(() => {
const paths = document.querySelectorAll<SVGPathElement>("#landing-svg path");
Expand All @@ -16,13 +17,13 @@ const LandingSvg = (props: SVGProps<SVGSVGElement>) => {
const delay = Math.random() * 50000;

setTimeout(() => {
path.style.animation = `landing-svg-anim-${theme} 5s ease-in-out infinite`;
path.style.animation = `landing-svg-anim-${currentTheme} 5s ease-in-out infinite`;
path.style.strokeDashoffset = length;
}, delay);
}

paths.forEach((path) => animatePath(path));
}, [theme]);
}, [currentTheme]);

return (
<svg viewBox="0 0 750 750" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import("prettier").Options} */
const config = {
printWidth: 120,
trailingComma: "none",
importOrderSeparation: true,
importOrderSortSpecifiers: true,
importOrderCaseInsensitive: true,
importOrderParserPlugins: ["typescript", "jsx", "mdx"],
importOrder: ["^@/constants/(.*)$", "^@/stores/(.*)$", "^@/utils/(.*)$", "^@/components/(.*)$", "^[./]"],
plugins: [require.resolve("@trivago/prettier-plugin-sort-imports"), require.resolve("prettier-plugin-tailwindcss")]
};

export default config;

0 comments on commit c6612df

Please sign in to comment.