diff --git a/docs/src/components/DocumentMetadata/index.tsx b/docs/src/components/DocumentMetadata/index.tsx index 117214748cb..c23ba392152 100644 --- a/docs/src/components/DocumentMetadata/index.tsx +++ b/docs/src/components/DocumentMetadata/index.tsx @@ -17,7 +17,7 @@ interface TranslatedMetadata { commitHash: string } -const style = { marginTop: '1em' } +const style = { marginBottom: '1em' } const renderMetadata = ({ lastUpdatedAt, commitHash }: Metadata) => { let link = `https://github.com/input-output-hk/hydra-poc/commit/${commitHash}` diff --git a/docs/src/theme/DocItemFooter/index.js b/docs/src/theme/DocItemFooter/index.js index c1d1ed4d06d..a90dc04bb54 100644 --- a/docs/src/theme/DocItemFooter/index.js +++ b/docs/src/theme/DocItemFooter/index.js @@ -1,12 +1,83 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ import React from 'react'; -import DocItemFooter from '@theme-original/DocItemFooter'; +import clsx from 'clsx'; +import LastUpdated from '@theme/LastUpdated'; +import EditThisPage from '@theme/EditThisPage'; +import TagsListInline from '@theme/TagsListInline'; +import styles from './styles.module.css'; +import {ThemeClassNames} from '@docusaurus/theme-common'; import DocumentMetadata from '@site/src/components/DocumentMetadata'; -export default function DocItemFooterWrapper(props) { +function TagsRow(props) { return ( - <> +
+
+ +
+
+ ); +} + +function EditMetaRow({ + editUrl, + lastUpdatedAt, + lastUpdatedBy, + formattedLastUpdatedAt, +}) { + return ( +
+
{editUrl && }
+ +
+ {(lastUpdatedAt || lastUpdatedBy) && ( + + )} +
+
+ ); +} + +export default function DocItemFooter(props) { + const {content: DocContent} = props; + const {metadata} = DocContent; + const {editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, tags} = + metadata; + const canDisplayTagsRow = tags.length > 0; + const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy); + const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow; + + if (!canDisplayFooter) { + return null; + } + + return ( + ); } diff --git a/docs/src/theme/DocItemFooter/styles.module.css b/docs/src/theme/DocItemFooter/styles.module.css new file mode 100644 index 00000000000..7d05961b1e4 --- /dev/null +++ b/docs/src/theme/DocItemFooter/styles.module.css @@ -0,0 +1,18 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +.lastUpdated { + margin-top: 0.2rem; + font-style: italic; + font-size: smaller; +} + +@media (min-width: 997px) { + .lastUpdated { + text-align: right; + } +}