Run Prettier

This commit is contained in:
Frank Li 2017-07-10 16:38:35 -07:00
parent a7b5148e06
commit fbae29b0ff
29 changed files with 1311 additions and 987 deletions

View file

@ -7,16 +7,16 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
const React = require('react');
const React = require("react");
const siteConfig = require(process.cwd() + '/siteConfig.js');
const siteConfig = require(process.cwd() + "/siteConfig.js");
class LanguageDropDown extends React.Component {
render() {
const enabledLanguages = [];
let currentLanguage = 'English';
let currentLanguage = "English";
siteConfig['languages'].map(lang => {
siteConfig["languages"].map(lang => {
if (lang.tag == this.props.language) {
currentLanguage = lang.name;
}
@ -48,7 +48,7 @@ class LanguageDropDown extends React.Component {
<a id="languages-menu" href="#">
<img
className="languages-icon"
src={this.props.baseUrl + 'img/language.svg'}
src={this.props.baseUrl + "img/language.svg"}
/>
{currentLanguage}
</a>
@ -70,7 +70,7 @@ class LanguageDropDown extends React.Component {
languagesDropDown.className = "hide";
}
});
`,
`
}}
/>
</span>
@ -82,21 +82,24 @@ class HeaderNav extends React.Component {
constructor() {
super();
this.state = {
slideoutActive: false,
slideoutActive: false
};
}
makeLinks(link) {
const linkWithLang = link.href.replace(
/\/LANGUAGE\//,
'\/' + this.props.language + '\/'
"/" + this.props.language + "/"
);
return (
<li key={link.section}>
<a
href={linkWithLang}
className={link.section === this.props.section ? 'active' : ''}>
{siteConfig[this.props.language] ? siteConfig[this.props.language]['localized-strings'][link.text] : link.text}
className={link.section === this.props.section ? "active" : ""}
>
{siteConfig[this.props.language]
? siteConfig[this.props.language]["localized-strings"][link.text]
: link.text}
</a>
</li>
);
@ -109,7 +112,9 @@ class HeaderNav extends React.Component {
<header>
<a href={this.props.baseUrl}>
<img src={this.props.baseUrl + siteConfig.headerIcon} />
<h2>{this.props.title}</h2>
<h2>
{this.props.title}
</h2>
</a>
{this.renderResponsiveNav()}
</header>
@ -130,9 +135,12 @@ class HeaderNav extends React.Component {
/>
{this.props.config.algolia &&
<li className="navSearchWrapper reactNavSearchWrapper">
<input id="search_input_react" type="text" placeholder="Search" />
</li>
}
<input
id="search_input_react"
type="text"
placeholder="Search"
/>
</li>}
{this.props.config.headerLinksExternal.map(this.makeLinks, this)}
</ul>
</nav>

View file

@ -7,10 +7,10 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
const React = require('react');
const classNames = require('classnames');
const React = require("react");
const classNames = require("classnames");
const siteConfig = require(process.cwd() + '/siteConfig.js');
const siteConfig = require(process.cwd() + "/siteConfig.js");
class SideNav extends React.Component {
render() {
@ -19,10 +19,14 @@ class SideNav extends React.Component {
<div className="toggleNav">
<section className="navWrapper wrapper">
<div className="navBreadcrumb wrapper">
<div className="navToggle" id="navToggler"><i /></div>
<div className="navToggle" id="navToggler">
<i />
</div>
<h2>
<i></i>
<span>{this.props.current.category}</span>
<span>
{this.props.current.category}
</span>
</h2>
</div>
<div className="navGroups">
@ -38,7 +42,7 @@ class SideNav extends React.Component {
toggler.onclick = function() {
nav.classList.toggle('docsSliderActive');
};
`,
`
}}
/>
</nav>
@ -47,7 +51,9 @@ class SideNav extends React.Component {
renderCategory(category) {
return (
<div className="navGroup navGroupActive" key={category.name}>
<h3>{this.getLocalizedCategoryString(category.name)}</h3>
<h3>
{this.getLocalizedCategoryString(category.name)}
</h3>
<ul>
{category.links.map(this.renderItemLink, this)}
</ul>
@ -55,16 +61,17 @@ class SideNav extends React.Component {
);
}
getLocalizedCategoryString(category) {
let categoryString =
siteConfig[this.props.language] ?
siteConfig[this.props.language]['localized-strings'][category] || category
let categoryString = siteConfig[this.props.language]
? siteConfig[this.props.language]["localized-strings"][category] ||
category
: category;
return categoryString;
}
getLocalizedString(metadata) {
let localizedString =
siteConfig[this.props.language] ?
siteConfig[this.props.language]['localized-strings'][metadata.localized_id] || metadata.title
let localizedString = siteConfig[this.props.language]
? siteConfig[this.props.language]["localized-strings"][
metadata.localized_id
] || metadata.title
: metadata.title;
return localizedString;
@ -74,19 +81,19 @@ class SideNav extends React.Component {
if (metadata.permalink.match(/^https?:/)) {
return metadata.permalink;
}
return siteConfig.baseUrl + metadata.permalink + '#content';
return siteConfig.baseUrl + metadata.permalink + "#content";
}
if (metadata.path) {
return siteConfig.baseUrl + 'blog/' + metadata.path;
return siteConfig.baseUrl + "blog/" + metadata.path;
}
return null;
}
renderItemLink(link) {
const itemClasses = classNames('navListItem', {
navListItemActive: link.id === this.props.current.id,
const itemClasses = classNames("navListItem", {
navListItemActive: link.id === this.props.current.id
});
const linkClasses = classNames('navItem', {
navItemActive: link.id === this.props.current.id,
const linkClasses = classNames("navItem", {
navItemActive: link.id === this.props.current.id
});
return (
<li className={itemClasses} key={link.id}>
@ -98,6 +105,6 @@ class SideNav extends React.Component {
}
}
SideNav.defaultProps = {
contents: [],
contents: []
};
module.exports = SideNav;