|
@@ -10,18 +10,18 @@ import { useCurrentPagePath, useCurrentUser } from '~/stores/context';
|
|
|
import { usePageCreateModal } from '~/stores/modal';
|
|
import { usePageCreateModal } from '~/stores/modal';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
-import CreatePageIcon from './Icons/CreatePageIcon';
|
|
|
|
|
-import ReturnTopIcon from './Icons/ReturnTopIcon';
|
|
|
|
|
|
|
+import { CreatePageIcon } from './Icons/CreatePageIcon';
|
|
|
|
|
+import { ReturnTopIcon } from './Icons/ReturnTopIcon';
|
|
|
|
|
|
|
|
import styles from './Fab.module.scss';
|
|
import styles from './Fab.module.scss';
|
|
|
|
|
|
|
|
-const logger = loggerFactory('growi:cli:Fab');
|
|
|
|
|
|
|
+// const logger = loggerFactory('growi:cli:Fab');
|
|
|
|
|
|
|
|
-const Fab = () => {
|
|
|
|
|
- const { data: currentUser } = useCurrentUser();
|
|
|
|
|
|
|
+export const Fab = (): JSX.Element => {
|
|
|
|
|
|
|
|
- const { open: openCreateModal } = usePageCreateModal();
|
|
|
|
|
|
|
+ const { data: currentUser } = useCurrentUser();
|
|
|
const { data: currentPath = '' } = useCurrentPagePath();
|
|
const { data: currentPath = '' } = useCurrentPagePath();
|
|
|
|
|
+ const { open: openCreateModal } = usePageCreateModal();
|
|
|
|
|
|
|
|
const [animateClasses, setAnimateClasses] = useState('invisible');
|
|
const [animateClasses, setAnimateClasses] = useState('invisible');
|
|
|
const [buttonClasses, setButtonClasses] = useState('');
|
|
const [buttonClasses, setButtonClasses] = useState('');
|
|
@@ -30,32 +30,39 @@ const Fab = () => {
|
|
|
const createBtnRef = useRef(null);
|
|
const createBtnRef = useRef(null);
|
|
|
useRipple(createBtnRef, { rippleColor: 'rgba(255, 255, 255, 0.3)' });
|
|
useRipple(createBtnRef, { rippleColor: 'rgba(255, 255, 255, 0.3)' });
|
|
|
|
|
|
|
|
- const stickyChangeHandler = useCallback((event) => {
|
|
|
|
|
- logger.debug('StickyEvents.CHANGE detected');
|
|
|
|
|
-
|
|
|
|
|
- const newAnimateClasses = event.detail.isSticky ? 'animated fadeInUp faster' : 'animated fadeOut faster';
|
|
|
|
|
- const newButtonClasses = event.detail.isSticky ? '' : 'disabled grw-pointer-events-none';
|
|
|
|
|
-
|
|
|
|
|
- setAnimateClasses(newAnimateClasses);
|
|
|
|
|
- setButtonClasses(newButtonClasses);
|
|
|
|
|
- }, []);
|
|
|
|
|
-
|
|
|
|
|
- // setup effect by sticky event
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- // sticky
|
|
|
|
|
- // See: https://github.com/ryanwalters/sticky-events
|
|
|
|
|
- const stickyEvents = new StickyEvents({ stickySelector: '#grw-fav-sticky-trigger' });
|
|
|
|
|
- const { stickySelector } = stickyEvents;
|
|
|
|
|
- const elem = document.querySelector(stickySelector);
|
|
|
|
|
- elem.addEventListener(StickyEvents.CHANGE, stickyChangeHandler);
|
|
|
|
|
-
|
|
|
|
|
- // return clean up handler
|
|
|
|
|
- return () => {
|
|
|
|
|
- elem.removeEventListener(StickyEvents.CHANGE, stickyChangeHandler);
|
|
|
|
|
- };
|
|
|
|
|
- }, [stickyChangeHandler]);
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Comment out to prevent err >>> TypeError: Cannot read properties of null (reading 'bottom')
|
|
|
|
|
+ */
|
|
|
|
|
+ // const stickyChangeHandler = useCallback((event) => {
|
|
|
|
|
+ // logger.debug('StickyEvents.CHANGE detected');
|
|
|
|
|
+
|
|
|
|
|
+ // const newAnimateClasses = event.detail.isSticky ? 'animated fadeInUp faster' : 'animated fadeOut faster';
|
|
|
|
|
+ // const newButtonClasses = event.detail.isSticky ? '' : 'disabled grw-pointer-events-none';
|
|
|
|
|
+
|
|
|
|
|
+ // setAnimateClasses(newAnimateClasses);
|
|
|
|
|
+ // setButtonClasses(newButtonClasses);
|
|
|
|
|
+ // }, []);
|
|
|
|
|
+
|
|
|
|
|
+ // // setup effect by sticky event
|
|
|
|
|
+ // useEffect(() => {
|
|
|
|
|
+ // // sticky
|
|
|
|
|
+ // // See: https://github.com/ryanwalters/sticky-events
|
|
|
|
|
+ // const stickyEvents = new StickyEvents({ stickySelector: '#grw-fav-sticky-trigger' });
|
|
|
|
|
+ // const { stickySelector } = stickyEvents;
|
|
|
|
|
+ // const elem = document.querySelector(stickySelector);
|
|
|
|
|
+ // elem.addEventListener(StickyEvents.CHANGE, stickyChangeHandler);
|
|
|
|
|
+
|
|
|
|
|
+ // // return clean up handler
|
|
|
|
|
+ // return () => {
|
|
|
|
|
+ // elem.removeEventListener(StickyEvents.CHANGE, stickyChangeHandler);
|
|
|
|
|
+ // };
|
|
|
|
|
+ // }, [stickyChangeHandler]);
|
|
|
|
|
+
|
|
|
|
|
+ if (currentPath == null) {
|
|
|
|
|
+ return <></>;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- function renderPageCreateButton() {
|
|
|
|
|
|
|
+ const renderPageCreateButton = () => {
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<div className={`rounded-circle position-absolute ${animateClasses}`} style={{ bottom: '2.3rem', right: '4rem' }}>
|
|
<div className={`rounded-circle position-absolute ${animateClasses}`} style={{ bottom: '2.3rem', right: '4rem' }}>
|
|
@@ -70,7 +77,7 @@ const Fab = () => {
|
|
|
</div>
|
|
</div>
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={`${styles['grw-fab']} grw-fab d-none d-md-block d-edit-none`} data-testid="grw-fab">
|
|
<div className={`${styles['grw-fab']} grw-fab d-none d-md-block d-edit-none`} data-testid="grw-fab">
|
|
@@ -88,5 +95,3 @@ const Fab = () => {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
-export default Fab;
|
|
|