|
|
@@ -10,18 +10,18 @@ import { useCurrentPagePath, useCurrentUser } from '~/stores/context';
|
|
|
import { usePageCreateModal } from '~/stores/modal';
|
|
|
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';
|
|
|
|
|
|
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 { open: openCreateModal } = usePageCreateModal();
|
|
|
|
|
|
const [animateClasses, setAnimateClasses] = useState('invisible');
|
|
|
const [buttonClasses, setButtonClasses] = useState('');
|
|
|
@@ -55,7 +55,11 @@ const Fab = () => {
|
|
|
};
|
|
|
}, [stickyChangeHandler]);
|
|
|
|
|
|
- function renderPageCreateButton() {
|
|
|
+ if (currentPath == null) {
|
|
|
+ return <></>;
|
|
|
+ }
|
|
|
+
|
|
|
+ const renderPageCreateButton = () => {
|
|
|
return (
|
|
|
<>
|
|
|
<div className={`rounded-circle position-absolute ${animateClasses}`} style={{ bottom: '2.3rem', right: '4rem' }}>
|
|
|
@@ -70,7 +74,7 @@ const Fab = () => {
|
|
|
</div>
|
|
|
</>
|
|
|
);
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
|
<div className={`${styles['grw-fab']} grw-fab d-none d-md-block d-edit-none`} data-testid="grw-fab">
|
|
|
@@ -88,5 +92,3 @@ const Fab = () => {
|
|
|
);
|
|
|
|
|
|
};
|
|
|
-
|
|
|
-export default Fab;
|