mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-30 17:37:09 +02:00
CSS revamp - Improve typography and overall styling (#757)
* Improve CSS code * Fix blog layout * Fix * Refactor onPageNav * More fixes * Fix docs nav * Use alternative hack * Tweak clearfix
This commit is contained in:
parent
169a5e6ded
commit
1094dbd352
18 changed files with 1474 additions and 1114 deletions
|
@ -31,13 +31,14 @@ class BlogPageLayout extends React.Component {
|
|||
title="Blog"
|
||||
language="en"
|
||||
config={this.props.config}
|
||||
className="blog"
|
||||
metadata={{blog: true, blogListing: true}}>
|
||||
<div className="docMainWrapper wrapper">
|
||||
<BlogSidebar
|
||||
language={this.props.language}
|
||||
config={this.props.config}
|
||||
/>
|
||||
<Container className="mainContainer documentContainer postContainer blogContainer">
|
||||
<Container className="mainContainer postContainer blogContainer">
|
||||
<div className="posts">
|
||||
{MetadataBlog.slice(page * perPage, (page + 1) * perPage).map(
|
||||
post => {
|
||||
|
|
|
@ -45,7 +45,7 @@ class BlogPost extends React.Component {
|
|||
const post = this.props.post;
|
||||
const className =
|
||||
'authorPhoto' +
|
||||
(post.author && post.authorTitle ? ' authorPhoto-big' : '');
|
||||
(post.author && post.authorTitle ? ' authorPhotoBig' : '');
|
||||
if (post.authorFBID) {
|
||||
return (
|
||||
<div className={className}>
|
||||
|
@ -77,7 +77,7 @@ class BlogPost extends React.Component {
|
|||
renderTitle() {
|
||||
const post = this.props.post;
|
||||
return (
|
||||
<h1>
|
||||
<h1 className="postHeaderTitle">
|
||||
<a
|
||||
href={
|
||||
this.props.config.baseUrl +
|
||||
|
|
|
@ -12,6 +12,7 @@ const Container = require('./Container.js');
|
|||
const Site = require('./Site.js');
|
||||
const OnPageNav = require('./nav/OnPageNav.js');
|
||||
const utils = require('./utils.js');
|
||||
const classNames = require('classnames');
|
||||
|
||||
// used for entire blog posts, i.e., each written blog article with sidebar with site header/footer
|
||||
class BlogPostLayout extends React.Component {
|
||||
|
@ -40,7 +41,7 @@ class BlogPostLayout extends React.Component {
|
|||
const fbLike = this.props.config.facebookAppId && (
|
||||
<div className="blogSocialSectionItem">
|
||||
<div
|
||||
className="fb-like"
|
||||
className="fbLike"
|
||||
data-href={
|
||||
this.props.config.url +
|
||||
this.props.config.baseUrl +
|
||||
|
@ -84,7 +85,7 @@ class BlogPostLayout extends React.Component {
|
|||
}
|
||||
|
||||
getDescription() {
|
||||
var descLines = this.props.children.trim().split('\n');
|
||||
const descLines = this.props.children.trim().split('\n');
|
||||
for (var i = 0; i < descLines.length; i++) {
|
||||
// Don't want blank lines or descriptions that are raw image rendering strings
|
||||
if (descLines[i] && !descLines[i].startsWith('![')) {
|
||||
|
@ -95,12 +96,15 @@ class BlogPostLayout extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
let post = this.props.metadata;
|
||||
const hasOnPageNav = this.props.config.onPageNav === 'separate';
|
||||
const post = this.props.metadata;
|
||||
post.path = utils.getPath(post.path, this.props.config.cleanUrl);
|
||||
let blogSidebarTitleConfig = this.props.config.blogSidebarTitle || {};
|
||||
return (
|
||||
<Site
|
||||
className="sideNavVisible"
|
||||
className={classNames('sideNavVisible', {
|
||||
separateOnPageNav: hasOnPageNav,
|
||||
})}
|
||||
url={'blog/' + post.path}
|
||||
title={this.props.metadata.title}
|
||||
language={'en'}
|
||||
|
@ -113,7 +117,7 @@ class BlogPostLayout extends React.Component {
|
|||
current={post}
|
||||
config={this.props.config}
|
||||
/>
|
||||
<Container className="mainContainer documentContainer postContainer blogContainer">
|
||||
<Container className="mainContainer postContainer blogContainer">
|
||||
<div className="lonePost">
|
||||
<BlogPost
|
||||
post={post}
|
||||
|
@ -129,7 +133,7 @@ class BlogPostLayout extends React.Component {
|
|||
</a>
|
||||
</div>
|
||||
</Container>
|
||||
{this.props.config.onPageNav == 'separate' && (
|
||||
{hasOnPageNav && (
|
||||
<nav className="onPageNav">
|
||||
<OnPageNav rawContent={this.props.children} />
|
||||
</nav>
|
||||
|
|
|
@ -65,7 +65,9 @@ class Doc extends React.Component {
|
|||
<div className="post">
|
||||
<header className="postHeader">
|
||||
{editLink}
|
||||
{!this.props.hideTitle && <h1>{this.props.title}</h1>}
|
||||
{!this.props.hideTitle && (
|
||||
<h1 className="postHeaderTitle">{this.props.title}</h1>
|
||||
)}
|
||||
</header>
|
||||
<article>
|
||||
<MarkdownBlock>{this.props.content}</MarkdownBlock>
|
||||
|
|
|
@ -12,6 +12,7 @@ const DocsSidebar = require('./DocsSidebar.js');
|
|||
const OnPageNav = require('./nav/OnPageNav.js');
|
||||
const Site = require('./Site.js');
|
||||
const translation = require('../server/translation.js');
|
||||
const classNames = require('classnames');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
|
@ -43,10 +44,13 @@ class DocsLayout extends React.Component {
|
|||
this.props.metadata.localized_id
|
||||
] || this.props.metadata.title
|
||||
: this.props.metadata.title;
|
||||
const hasOnPageNav = this.props.config.onPageNav === 'separate';
|
||||
return (
|
||||
<Site
|
||||
config={this.props.config}
|
||||
className="sideNavVisible doc"
|
||||
className={classNames('sideNavVisible', {
|
||||
separateOnPageNav: hasOnPageNav,
|
||||
})}
|
||||
title={title}
|
||||
description={content.trim().split('\n')[0]}
|
||||
language={metadata.language}
|
||||
|
@ -106,7 +110,7 @@ class DocsLayout extends React.Component {
|
|||
)}
|
||||
</div>
|
||||
</Container>
|
||||
{this.props.config.onPageNav == 'separate' && (
|
||||
{hasOnPageNav && (
|
||||
<nav className="onPageNav">
|
||||
<OnPageNav rawContent={this.props.children} />
|
||||
</nav>
|
||||
|
|
|
@ -43,17 +43,11 @@ class Site extends React.Component {
|
|||
}
|
||||
|
||||
// We do not want a lang attribute for the html tag if we don't have a language set
|
||||
let htmlElementProps;
|
||||
const htmlElementProps = {};
|
||||
if (this.props.language) {
|
||||
htmlElementProps = {
|
||||
lang: this.props.language,
|
||||
};
|
||||
} else {
|
||||
htmlElementProps = {};
|
||||
htmlElementProps.lang = this.props.language;
|
||||
}
|
||||
|
||||
const className = this.props.className || '';
|
||||
|
||||
return (
|
||||
<html {...htmlElementProps}>
|
||||
<Head
|
||||
|
@ -64,11 +58,7 @@ class Site extends React.Component {
|
|||
language={this.props.language}
|
||||
version={this.props.version}
|
||||
/>
|
||||
<body
|
||||
className={classNames({
|
||||
[className]: className,
|
||||
separateOnPageNav: this.props.config.onPageNav == 'separate',
|
||||
})}>
|
||||
<body className={this.props.className}>
|
||||
<HeaderNav
|
||||
config={this.props.config}
|
||||
baseUrl={this.props.config.baseUrl}
|
||||
|
|
|
@ -70,14 +70,18 @@ class SideNav extends React.Component {
|
|||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
renderCategory(category) {
|
||||
return (
|
||||
<div className="navGroup navGroupActive" key={category.name}>
|
||||
<h3>{this.getLocalizedCategoryString(category.name)}</h3>
|
||||
<div className="navGroup" key={category.name}>
|
||||
<h3 className="navGroupCategoryTitle">
|
||||
{this.getLocalizedCategoryString(category.name)}
|
||||
</h3>
|
||||
<ul>{category.links.map(this.renderItemLink, this)}</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// return appropriately translated category string
|
||||
getLocalizedCategoryString(category) {
|
||||
let categoryString = translation[this.props.language]
|
||||
|
@ -86,6 +90,7 @@ class SideNav extends React.Component {
|
|||
: category;
|
||||
return categoryString;
|
||||
}
|
||||
|
||||
// return appropriately translated label to use for doc/blog in sidebar
|
||||
getLocalizedString(metadata) {
|
||||
let localizedString;
|
||||
|
@ -123,23 +128,23 @@ class SideNav extends React.Component {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
renderItemLink(link) {
|
||||
const itemClasses = classNames('navListItem', {
|
||||
navListItemActive: link.id === this.props.current.id,
|
||||
});
|
||||
const linkClasses = classNames('navItem', {
|
||||
navItemActive: link.id === this.props.current.id,
|
||||
});
|
||||
return (
|
||||
<li className={itemClasses} key={link.id}>
|
||||
<a className={linkClasses} href={this.getLink(link)}>
|
||||
<a className="navItem" href={this.getLink(link)}>
|
||||
{this.getLocalizedString(link)}
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SideNav.defaultProps = {
|
||||
contents: [],
|
||||
};
|
||||
|
||||
module.exports = SideNav;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue