From 60c49f18389ff625177a57277ef8f292a31097bf Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Sat, 28 Oct 2023 17:12:58 +0200
Subject: refactor(providers,hooks): rewrite PrismThemeProvider & usePrismTheme

* reuse Theme provider logic
* move DOM mutation from provider to hook
* add a script to init theme before page load
---
 src/utils/hooks/use-add-classname.tsx | 32 --------------------------------
 1 file changed, 32 deletions(-)
 delete mode 100644 src/utils/hooks/use-add-classname.tsx

(limited to 'src/utils/hooks/use-add-classname.tsx')

diff --git a/src/utils/hooks/use-add-classname.tsx b/src/utils/hooks/use-add-classname.tsx
deleted file mode 100644
index 8b0f6d6..0000000
--- a/src/utils/hooks/use-add-classname.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { useCallback, useEffect } from 'react';
-
-export type UseAddClassNameProps = {
-  className: string;
-  element?: HTMLElement;
-  elements?: NodeListOf<HTMLElement> | HTMLElement[];
-};
-
-/**
- * Add className to the given element(s).
- *
- * @param {UseAddClassNameProps} props - An object with classnames and one or more elements.
- */
-export const useAddClassName = ({
-  className,
-  element,
-  elements,
-}: UseAddClassNameProps) => {
-  const classNames = className.split(' ').filter((string) => string !== '');
-
-  const setClassName = useCallback(
-    (el: HTMLElement) => {
-      el.classList.add(...classNames);
-    },
-    [classNames]
-  );
-
-  useEffect(() => {
-    if (element) setClassName(element);
-    if (elements && elements.length > 0) elements.forEach(setClassName);
-  }, [element, elements, setClassName]);
-};
-- 
cgit v1.2.3

