mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
removed redux completely
This commit is contained in:
parent
26e6d8d41b
commit
a4bb07e9cf
323 changed files with 2464 additions and 3348 deletions
|
@ -1,4 +1,4 @@
|
|||
import { useCallback } from "react";
|
||||
import { useCallback } from 'react';
|
||||
|
||||
/** wraps text inside textarea with tags */
|
||||
export const useFormatWrapper = (onChange: (val: string) => void) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect } from "react";
|
||||
import { useFlowStore } from "~/store/flow/useFlowStore";
|
||||
import { hideLoader } from "~/utils/dom/hideLoader";
|
||||
import { useFlowLoader } from "~/hooks/flow/useFlowLoader";
|
||||
import { useEffect } from 'react';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { hideLoader } from '~/utils/dom/hideLoader';
|
||||
import { useFlowLoader } from '~/hooks/flow/useFlowLoader';
|
||||
|
||||
/** simply waits for all data to settle and then show the app */
|
||||
export const useGlobalLoader = () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { useCallback } from "react";
|
||||
import { getImageFromPaste } from "~/utils/uploader";
|
||||
import { useCallback } from 'react';
|
||||
import { getImageFromPaste } from '~/utils/uploader';
|
||||
|
||||
// useInputPasteUpload attaches event listener to input, that calls onUpload if user pasted any image
|
||||
export const useInputPasteUpload = (onUpload: (files: File[]) => void) => {
|
||||
|
|
|
@ -2,18 +2,21 @@ import { useEffect } from 'react';
|
|||
import { NEW_COMMENT_CLASSNAME } from '~/constants/comment';
|
||||
|
||||
export const useScrollToTop = (deps?: any[]) => {
|
||||
useEffect(() => {
|
||||
const targetElement = document.querySelector(`.${NEW_COMMENT_CLASSNAME}`);
|
||||
useEffect(
|
||||
() => {
|
||||
const targetElement = document.querySelector(`.${NEW_COMMENT_CLASSNAME}`);
|
||||
|
||||
if (!targetElement) {
|
||||
window.scrollTo(0, 0);
|
||||
return;
|
||||
}
|
||||
if (!targetElement) {
|
||||
window.scrollTo(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
const bounds = targetElement.getBoundingClientRect();
|
||||
window.scrollTo({
|
||||
top: bounds.top - 100,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}, deps || []);
|
||||
const bounds = targetElement.getBoundingClientRect();
|
||||
window.scrollTo({
|
||||
top: bounds.top - 100,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
},
|
||||
deps && Array.isArray(deps) ? deps : []
|
||||
);
|
||||
};
|
||||
|
|
16
src/hooks/dom/useScrollTop.ts
Normal file
16
src/hooks/dom/useScrollTop.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const useScrollTop = () => {
|
||||
const [top, setTop] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const onScroll = () => {
|
||||
setTop(window.scrollY);
|
||||
};
|
||||
|
||||
window.addEventListener('scroll', onScroll);
|
||||
return () => window.removeEventListener('scroll', onScroll);
|
||||
}, []);
|
||||
|
||||
return top;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue