Просмотр исходного кода

delete CommentLinkButton and add it in ContentLinkButtons instead

kaori 5 лет назад
Родитель
Сommit
b324cff9d6

+ 0 - 36
src/client/js/components/CommentLinkButton.jsx

@@ -1,36 +0,0 @@
-import React, { useMemo } from 'react';
-import PropTypes from 'prop-types';
-
-import NavigationContainer from '../services/NavigationContainer';
-
-import { withUnstatedContainers } from './UnstatedUtils';
-
-const WIKI_HEADER_LINK = 120;
-
-const CommentLinkButton = (props) => {
-
-  const { navigationContainer } = props;
-
-  // get element for smoothScroll
-  const getCommentListDom = useMemo(() => { return document.getElementById('page-comments-list') }, []);
-
-  return (
-    <div className="mt-3">
-      <button
-        type="button"
-        className="btn btn-outline-secondary btn-sm w-100"
-        onClick={() => navigationContainer.smoothScrollIntoView(getCommentListDom, WIKI_HEADER_LINK)}
-      >
-        <i className="mr-2 icon-fw icon-bubbles"></i>
-        <span>Comments</span>
-      </button>
-    </div>
-  );
-
-};
-
-CommentLinkButton.propTypes = {
-  navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
-};
-
-export default withUnstatedContainers(CommentLinkButton, [NavigationContainer]);

+ 30 - 1
src/client/js/components/ContentLinkButtons.jsx

@@ -49,7 +49,35 @@ const WIKI_HEADER_LINK = 120;
 // };
 
 
-export const BookMarkListLinkButton = (props) => {
+const CommentLinkButton = (props) => {
+  const { navigationContainer } = props;
+
+  // get element for smoothScroll
+  const getCommentListDom = useMemo(() => { return document.getElementById('page-comments-list') }, []);
+
+  return (
+    <div className="mt-3">
+      <button
+        type="button"
+        className="btn btn-outline-secondary btn-sm w-100"
+        onClick={() => navigationContainer.smoothScrollIntoView(getCommentListDom, WIKI_HEADER_LINK)}
+      >
+        <i className="mr-2 icon-fw icon-bubbles"></i>
+        <span>Comments</span>
+      </button>
+    </div>
+  );
+
+};
+
+CommentLinkButton.propTypes = {
+  navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
+};
+
+const CommentLinkButtonWrapper = withUnstatedContainers(CommentLinkButton, [NavigationContainer]);
+export { CommentLinkButtonWrapper };
+
+const BookMarkListLinkButton = (props) => {
   const getBookMarkListHeaderDom = useMemo(() => { return document.getElementById('bookmarks-list') }, []);
   const { navigationContainer } = props;
 
@@ -72,6 +100,7 @@ BookMarkListLinkButton.propTypes = {
 const BookMarkListLinkButtonWrapper = withUnstatedContainers(BookMarkListLinkButton, [NavigationContainer]);
 export { BookMarkListLinkButtonWrapper };
 
+
 const RecentlyCreatedLinkButton = (props) => {
   const getRecentlyCreatedListHeaderDom = useMemo(() => { return document.getElementById('recently-created-list') }, []);
   const { navigationContainer } = props;

+ 5 - 2
src/client/js/components/Page/DisplaySwitcher.jsx

@@ -8,11 +8,14 @@ import Editor from '../PageEditor';
 import Page from '../Page';
 import UserInfo from '../User/UserInfo';
 import TableOfContents from '../TableOfContents';
-import { BookMarkListLinkButtonWrapper as BookMarkListLinkButton, RecentlyCreatedLinkButtonWrapper as RecentlyCreatedLinkButton } from '../ContentLinkButtons';
+import {
+  BookMarkListLinkButtonWrapper as BookMarkListLinkButton,
+  RecentlyCreatedLinkButtonWrapper as RecentlyCreatedLinkButton,
+  CommentLinkButtonWrapper as CommentLinkButton,
+} from '../ContentLinkButtons';
 import PageAccessories from '../PageAccessories';
 import PageEditorByHackmd from '../PageEditorByHackmd';
 import EditorNavbarBottom from '../PageEditor/EditorNavbarBottom';
-import CommentLinkButton from '../CommentLinkButton';
 
 
 const DisplaySwitcher = (props) => {