Skip to content

Commit

Permalink
refactor(v2): make little better doc details info UI (#4865)
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 authored Jun 2, 2021
1 parent 15d4519 commit d2e4e60
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 44 deletions.
24 changes: 11 additions & 13 deletions packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,20 @@ function DocItem(props: Props): JSX.Element {
</div>
</article>
{(editUrl || lastUpdatedAt || lastUpdatedBy) && (
<div className="margin-vert--xl">
<div className="row">
<div className="col">
{editUrl && <EditThisPage editUrl={editUrl} />}
</div>
{(lastUpdatedAt || lastUpdatedBy) && (
<LastUpdated
lastUpdatedAt={lastUpdatedAt}
formattedLastUpdatedAt={formattedLastUpdatedAt}
lastUpdatedBy={lastUpdatedBy}
/>
)}
<div className={clsx('row', styles.docUpdateDetails)}>
<div className="col">
{editUrl && <EditThisPage editUrl={editUrl} />}
</div>
{(lastUpdatedAt || lastUpdatedBy) && (
<LastUpdated
lastUpdatedAt={lastUpdatedAt}
formattedLastUpdatedAt={formattedLastUpdatedAt}
lastUpdatedBy={lastUpdatedBy}
/>
)}
</div>
)}
<div className="margin-vert--lg">
<div className={styles.docPaginator}>
<DocPaginator metadata={metadata} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
padding: 0 0.5rem;
}

.docUpdateDetails,
.docPaginator {
margin-top: 3rem;
}

@media only screen and (min-width: 997px) {
.docItemCol {
max-width: 75% !important;
Expand Down
59 changes: 28 additions & 31 deletions packages/docusaurus-theme-classic/src/theme/LastUpdated/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React from 'react';
import clsx from 'clsx';
import styles from './styles.module.css';
import Translate from '@docusaurus/Translate';
import type {Props} from '@theme/LastUpdated';
Expand Down Expand Up @@ -58,37 +59,33 @@ export default function LastUpdated({
lastUpdatedBy,
}: Props): JSX.Element {
return (
<div className="col text--right">
<em>
<small>
<Translate
id="theme.lastUpdated.lastUpdatedAtBy"
description="The sentence used to display when a page has been last updated, and by who"
values={{
atDate:
lastUpdatedAt && formattedLastUpdatedAt ? (
<LastUpdatedAtDate
lastUpdatedAt={lastUpdatedAt}
formattedLastUpdatedAt={formattedLastUpdatedAt}
/>
) : (
''
),
byUser: lastUpdatedBy ? (
<LastUpdatedByUser lastUpdatedBy={lastUpdatedBy} />
) : (
''
),
}}>
{'Last updated{atDate}{byUser}'}
</Translate>
{process.env.NODE_ENV === 'development' && (
<div>
<small> (Simulated during dev for better perf)</small>
</div>
)}
</small>
</em>
<div className={clsx('col', styles.lastUpdated)}>
<Translate
id="theme.lastUpdated.lastUpdatedAtBy"
description="The sentence used to display when a page has been last updated, and by who"
values={{
atDate:
lastUpdatedAt && formattedLastUpdatedAt ? (
<LastUpdatedAtDate
lastUpdatedAt={lastUpdatedAt}
formattedLastUpdatedAt={formattedLastUpdatedAt}
/>
) : (
''
),
byUser: lastUpdatedBy ? (
<LastUpdatedByUser lastUpdatedBy={lastUpdatedBy} />
) : (
''
),
}}>
{'Last updated{atDate}{byUser}'}
</Translate>
{process.env.NODE_ENV === 'development' && (
<div>
<small> (Simulated during dev for better perf)</small>
</div>
)}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
* LICENSE file in the root directory of this source tree.
*/

.lastUpdated {
margin-top: 0.2rem;
font-style: italic;
font-size: smaller;
}

@media only screen and (min-width: 997px) {
.lastUpdated {
text-align: right;
}
}

.lastUpdatedDate {
font-weight: bold;
}

0 comments on commit d2e4e60

Please sign in to comment.