Skip to content

Commit

Permalink
Merge pull request #1848 from bgoonz/master
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoonz authored Mar 11, 2022
2 parents f7efc7d + b4ec2df commit 7812828
Show file tree
Hide file tree
Showing 32 changed files with 1,951 additions and 1,453 deletions.
36 changes: 13 additions & 23 deletions src/components/ActionLink.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
import _ from 'lodash';
import React from 'react';
import { classNames, Link, withPrefix } from '../utils';
import Icon from './Icon';
import _ from 'lodash';

import {Link, withPrefix, classNames} from '../utils';
import Icon from './Icon';

export default class ActionLink extends React.Component {
render() {
let action = _.get(this.props, 'action', null);
return (
<Link
to={withPrefix(_.get(action, 'url', null))}
{...(_.get(action, 'new_window', null) ? { target: '_blank' } : null)}
{...(_.get(action, 'new_window', null) || _.get(action, 'no_follow', null)
? { rel: (_.get(action, 'new_window', null) ? 'noopener ' : '') + (_.get(action, 'no_follow', null) ? 'nofollow' : '') }
: null)}
className={classNames({
button: _.get(action, 'style', null) !== 'link',
'button-secondary': _.get(action, 'style', null) === 'secondary',
'button-icon': _.get(action, 'style', null) === 'icon'
})}
>
{_.get(action, 'style', null) === 'icon' && _.get(action, 'icon_class', null) ? (
<React.Fragment>
<Icon {...this.props} icon={_.get(action, 'icon_class', null)} />
<span className="screen-reader-text">{_.get(action, 'label', null)}</span>
</React.Fragment>
) : (
_.get(action, 'label', null)
)}
<Link to={withPrefix(_.get(action, 'url', null))}
{...(_.get(action, 'new_window', null) ? ({target: '_blank'}) : null)}
{...((_.get(action, 'new_window', null) || _.get(action, 'no_follow', null)) ? ({rel: (_.get(action, 'new_window', null) ? ('noopener ') : '') + (_.get(action, 'no_follow', null) ? ('nofollow') : '')}) : null)}
className={classNames({'button': _.get(action, 'style', null) !== 'link', 'button-secondary': _.get(action, 'style', null) === 'secondary', 'button-icon': _.get(action, 'style', null) === 'icon'})}>
{((_.get(action, 'style', null) === 'icon') && _.get(action, 'icon_class', null)) ? (<React.Fragment>
<Icon {...this.props} icon={_.get(action, 'icon_class', null)} />
<span className="screen-reader-text">{_.get(action, 'label', null)}</span>
</React.Fragment>) :
_.get(action, 'label', null)
}
</Link>
);
}
Expand Down
28 changes: 10 additions & 18 deletions src/components/CtaButtons.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import _ from 'lodash';
import React from 'react';
import { classNames, Link, withPrefix } from '../utils';
import _ from 'lodash';

import {Link, withPrefix, classNames} from '../utils';

export default class CtaButtons extends React.Component {
render() {
let actions = _.get(this.props, 'actions', null);
return _.map(actions, (action, action_idx) => (
<Link
key={action_idx}
to={withPrefix(_.get(action, 'url', null))}
{...(_.get(action, 'new_window', null) ? { target: '_blank' } : null)}
{...(_.get(action, 'new_window', null) || _.get(action, 'no_follow', null)
? { rel: (_.get(action, 'new_window', null) ? 'noopener ' : '') + (_.get(action, 'no_follow', null) ? 'nofollow' : '') }
: null)}
className={classNames({
button: _.get(action, 'style', null) === 'primary' || _.get(action, 'style', null) === 'secondary',
'button-secondary': _.get(action, 'style', null) === 'secondary'
})}
>
{_.get(action, 'label', null)}
</Link>
));
return (
_.map(actions, (action, action_idx) => (
<Link key={action_idx} to={withPrefix(_.get(action, 'url', null))}
{...(_.get(action, 'new_window', null) ? ({target: '_blank'}) : null)}
{...((_.get(action, 'new_window', null) || _.get(action, 'no_follow', null)) ? ({rel: (_.get(action, 'new_window', null) ? ('noopener ') : '') + (_.get(action, 'no_follow', null) ? ('nofollow') : '')}) : null)}
className={classNames({'button': (_.get(action, 'style', null) === 'primary') || (_.get(action, 'style', null) === 'secondary'), 'button-secondary': _.get(action, 'style', null) === 'secondary'})}>{_.get(action, 'label', null)}</Link>
))
);
}
}
12 changes: 8 additions & 4 deletions src/components/DocsMenu.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _ from 'lodash';
import React from 'react';
import { classNames, getPage, getPages, Link, pathJoin, withPrefix } from '../utils';
import DocsSubmenu from './DocsSubmenu';
import _ from 'lodash';

import { getPage, classNames, Link, withPrefix, pathJoin, getPages } from '../utils';
import DocsSubmenu from './DocsSubmenu';

export default class DocsMenu extends React.Component {
render() {
Expand All @@ -19,7 +19,11 @@ export default class DocsMenu extends React.Component {
</button>
<div className="docs-nav-menu">
<ul id="docs-menu" className="docs-menu">
<li className={classNames('docs-menu-item', { current: _.get(page, 'url', null) === _.get(root_page, 'url', null) })}>
<li
className={classNames('docs-menu-item', {
current: _.get(page, 'url', null) === _.get(root_page, 'url', null)
})}
>
<Link to={withPrefix(_.get(root_page, 'url', null))}>{_.get(root_page, 'frontmatter.title', null)}</Link>
</li>
{_.map(_.get(site, 'data.doc_sections.sections', null), (section, section_idx) => {
Expand Down
11 changes: 8 additions & 3 deletions src/components/DocsSubmenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import React from 'react';
import { classNames, Link, withPrefix } from '../utils';
import _ from 'lodash';

import { classNames, Link, withPrefix } from '../utils';

export default class DocsSubmenu extends React.Component {
render() {
Expand All @@ -10,7 +10,12 @@ export default class DocsSubmenu extends React.Component {
return (
<ul className="docs-submenu">
{_.map(child_pages, (child_page, child_page_idx) => (
<li key={child_page_idx} className={classNames('docs-menu-item', { current: _.get(page, 'url', null) === _.get(child_page, 'url', null) })}>
<li
key={child_page_idx}
className={classNames('docs-menu-item', {
current: _.get(page, 'url', null) === _.get(child_page, 'url', null)
})}
>
<Link to={withPrefix(_.get(child_page, 'url', null))}>{_.get(child_page, 'frontmatter.title', null)}</Link>
</li>
))}
Expand Down
Loading

0 comments on commit 7812828

Please sign in to comment.