-
Notifications
You must be signed in to change notification settings - Fork 2
fix(blog): improve responsive post layout #525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,21 @@ | ||
| import React from 'react'; | ||
| import clsx from 'clsx'; | ||
| import Link from '@docusaurus/Link'; | ||
| import { useBlogPost } from '@docusaurus/plugin-content-blog/client'; | ||
| import styles from './styles.module.css'; | ||
| import React from 'react' | ||
| import clsx from 'clsx' | ||
| import Link from '@docusaurus/Link' | ||
| import { useBlogPost } from '@docusaurus/plugin-content-blog/client' | ||
| import styles from './styles.module.css' | ||
| export default function BlogPostItemHeaderTitle({ className }) { | ||
| const { metadata, isBlogPostPage } = useBlogPost(); | ||
| const { permalink, title } = metadata; | ||
| const TitleHeading = isBlogPostPage ? 'h1' : 'h2'; | ||
| const { metadata, isBlogPostPage } = useBlogPost() | ||
| const { permalink, title } = metadata | ||
| const TitleHeading = isBlogPostPage ? 'h1' : 'h2' | ||
| return ( | ||
| <TitleHeading className={clsx(styles.title, className, isBlogPostPage && "pt-10")}> | ||
| <TitleHeading | ||
| className={clsx( | ||
| styles.title, | ||
| isBlogPostPage && styles.postTitle, | ||
| className | ||
| )} | ||
| > | ||
| {isBlogPostPage ? title : <Link to={permalink}>{title}</Link>} | ||
| </TitleHeading> | ||
| ); | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,20 @@ | ||
| import React from 'react'; | ||
| import BlogPostItemHeaderTitle from '@theme/BlogPostItem/Header/Title'; | ||
| import BlogPostItemHeaderInfo from '@theme/BlogPostItem/Header/Info'; | ||
| import BlogPostItemHeaderAuthors from '@theme/BlogPostItem/Header/Authors'; | ||
| import { useBlogPost } from '@docusaurus/plugin-content-blog/client'; | ||
| import clsx from 'clsx'; | ||
| import React from 'react' | ||
| import BlogPostItemHeaderTitle from '@theme/BlogPostItem/Header/Title' | ||
| import BlogPostItemHeaderInfo from '@theme/BlogPostItem/Header/Info' | ||
| import BlogPostItemHeaderAuthors from '@theme/BlogPostItem/Header/Authors' | ||
| import { useBlogPost } from '@docusaurus/plugin-content-blog/client' | ||
| import clsx from 'clsx' | ||
| import styles from './styles.module.css' | ||
|
|
||
| export default function BlogPostItemHeader() { | ||
| const { isBlogPostPage } = useBlogPost() | ||
|
|
||
| return ( | ||
| <header className={clsx()}> | ||
| {/* Blog: {blog} */} | ||
| <header className={clsx(isBlogPostPage && styles.postHeader)}> | ||
| {isBlogPostPage && <BlogPostItemHeaderInfo className={styles.postInfo} />} | ||
| <BlogPostItemHeaderTitle /> | ||
| <BlogPostItemHeaderInfo /> | ||
| <BlogPostItemHeaderAuthors short={true} /> | ||
| {!isBlogPostPage && <BlogPostItemHeaderInfo />} | ||
| {!isBlogPostPage && <BlogPostItemHeaderAuthors short={true} />} | ||
| </header> | ||
| ); | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| .postHeader { | ||
|
adityathebe marked this conversation as resolved.
|
||
| width: min(100%, calc(100vw - 2rem)); | ||
| max-width: 1100px; | ||
| box-sizing: border-box; | ||
| margin: 0 auto; | ||
| padding: clamp(4rem, 9vw, 7rem) 1rem clamp(2rem, 4vw, 3rem); | ||
| text-align: center; | ||
| } | ||
|
|
||
| .postInfo { | ||
| margin-bottom: 2rem; | ||
| color: var(--ifm-color-emphasis-700); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,41 @@ | ||
| import React from 'react'; | ||
| import clsx from 'clsx'; | ||
| import {useBlogPost} from '@docusaurus/plugin-content-blog/client'; | ||
| import BlogPostItemContainer from '@theme/BlogPostItem/Container'; | ||
| import BlogPostItemHeader from '@theme/BlogPostItem/Header'; | ||
| import BlogPostItemContent from '@theme/BlogPostItem/Content'; | ||
| import BlogPostItemFooter from '@theme/BlogPostItem/Footer'; | ||
| // apply a bottom margin in list view | ||
| import React from 'react' | ||
| import clsx from 'clsx' | ||
| import { useBlogPost } from '@docusaurus/plugin-content-blog/client' | ||
| import BlogPostItemContainer from '@theme/BlogPostItem/Container' | ||
| import BlogPostItemHeader from '@theme/BlogPostItem/Header' | ||
| import BlogPostItemContent from '@theme/BlogPostItem/Content' | ||
| import BlogPostItemFooter from '@theme/BlogPostItem/Footer' | ||
| import styles from './styles.module.css' | ||
|
|
||
| function useContainerClassName() { | ||
| const {isBlogPostPage} = useBlogPost(); | ||
| return !isBlogPostPage ? 'margin-bottom--xl' : undefined; | ||
| const { isBlogPostPage } = useBlogPost() | ||
| return !isBlogPostPage ? 'margin-bottom--xl' : undefined | ||
| } | ||
| export default function BlogPostItem({children, className}) { | ||
| const containerClassName = useContainerClassName(); | ||
| export default function BlogPostItem({ children, className, toc }) { | ||
| const containerClassName = useContainerClassName() | ||
|
|
||
| if (toc) { | ||
| return ( | ||
| <BlogPostItemContainer | ||
| className={clsx(containerClassName, className, styles.postArticle)} | ||
| > | ||
| <BlogPostItemHeader /> | ||
| <div className={styles.postBody}> | ||
| <div className={styles.postContent}> | ||
| <BlogPostItemContent>{children}</BlogPostItemContent> | ||
| <BlogPostItemFooter /> | ||
| </div> | ||
| <aside className={styles.postToc}>{toc}</aside> | ||
| </div> | ||
| </BlogPostItemContainer> | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <BlogPostItemContainer className={clsx(containerClassName, className)}> | ||
| <BlogPostItemHeader /> | ||
| <BlogPostItemContent>{children}</BlogPostItemContent> | ||
| <BlogPostItemFooter /> | ||
| </BlogPostItemContainer> | ||
| ); | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| .postArticle.postArticle { | ||
| width: calc(100vw - 2rem); | ||
|
adityathebe marked this conversation as resolved.
|
||
| max-width: 1200px; | ||
| } | ||
|
|
||
| .postBody { | ||
| display: grid; | ||
| grid-template-columns: minmax(0, 900px) minmax(180px, 220px); | ||
| gap: 3rem; | ||
| align-items: start; | ||
| } | ||
|
|
||
| .postContent { | ||
| min-width: 0; | ||
| } | ||
|
|
||
| .postToc { | ||
| min-width: 0; | ||
| align-self: stretch; | ||
| } | ||
|
|
||
| @media (max-width: 996px) { | ||
| .postBody { | ||
| display: block; | ||
| } | ||
|
|
||
| .postToc { | ||
| display: none; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.