Skip to content
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

CSS revamp - Improve typography and overall styling #757

Merged
merged 8 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/api-doc-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: doc-markdown
title: Markdown Features
---

Find out more about Docusaurus-specific fields when writing Markdown.

## Markdown Headers

### Documents
Expand Down Expand Up @@ -124,8 +126,8 @@ Text describing my function
will lead to a table of contents of the functions:

```md
* `docusaurus.function(a, b)`
* `docdoc(file)`
- `docusaurus.function(a, b)`
- `docdoc(file)`
```

and each function will link to their corresponding sections in the page.
Expand Down
2 changes: 1 addition & 1 deletion docs/guides-blog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
id: blog
id: adding-blog
title: Adding a Blog
---

Expand Down
2 changes: 1 addition & 1 deletion examples/basics/pages/en/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Help extends React.Component {
<Container className="mainContainer documentContainer postContainer">
<div className="post">
<header className="postHeader">
<h2>Need help?</h2>
<h1>Need help?</h1>
</header>
<p>This project is maintained by a dedicated group of people.</p>
<GridBlock contents={supportLinks} layout="threeColumn" />
Expand Down
3 changes: 2 additions & 1 deletion lib/core/BlogPageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
4 changes: 2 additions & 2 deletions lib/core/BlogPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}>
Expand Down Expand Up @@ -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 +
Expand Down
16 changes: 10 additions & 6 deletions lib/core/BlogPostLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 +
Expand Down Expand Up @@ -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('![')) {
Expand All @@ -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'}
Expand All @@ -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}
Expand All @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion lib/core/Doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 6 additions & 2 deletions lib/core/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

// component used to generate whole webpage for docs, including sidebar/header/footer
Expand Down Expand Up @@ -39,10 +40,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}
Expand Down Expand Up @@ -102,7 +106,7 @@ class DocsLayout extends React.Component {
)}
</div>
</Container>
{this.props.config.onPageNav == 'separate' && (
{hasOnPageNav && (
<nav className="onPageNav">
<OnPageNav rawContent={this.props.children} />
</nav>
Expand Down
16 changes: 3 additions & 13 deletions lib/core/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -62,11 +56,7 @@ class Site extends React.Component {
title={title}
url={url}
/>
<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}
Expand Down
17 changes: 11 additions & 6 deletions lib/core/nav/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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;
Expand Down Expand Up @@ -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;
7 changes: 0 additions & 7 deletions lib/server/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,6 @@ async function execute() {
const color = siteConfig.colors[key];
cssContent = cssContent.replace(new RegExp('\\$' + key, 'g'), color);
});
const codeColor = color(siteConfig.colors.primaryColor)
.alpha(0.07)
.string();
cssContent = cssContent.replace(
new RegExp('\\$codeColor', 'g'),
codeColor
);

if (siteConfig.fonts) {
Object.keys(siteConfig.fonts).forEach(key => {
Expand Down
4 changes: 0 additions & 4 deletions lib/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,6 @@ function execute(port, options) {
const color = siteConfig.colors[key];
cssContent = cssContent.replace(new RegExp('\\$' + key, 'g'), color);
});
const codeColor = color(siteConfig.colors.primaryColor)
.alpha(0.07)
.string();
cssContent = cssContent.replace(new RegExp('\\$codeColor', 'g'), codeColor);

if (siteConfig.fonts) {
Object.keys(siteConfig.fonts).forEach(key => {
Expand Down
Loading