Skip to content
This repository was archived by the owner on Apr 5, 2020. It is now read-only.

Commit fc42898

Browse files
authored
Merge pull request #3 from joekrump/component-syntax-updates
Component syntax updates
2 parents 3408b37 + 1c32fc0 commit fc42898

File tree

22 files changed

+306
-314
lines changed

22 files changed

+306
-314
lines changed

src/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import APIClient from './http/requests'
1+
import APIClient from "./http/requests";
22

33
module.exports = {
44

src/components/App.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class App extends React.Component {
1515
auth.login(null, null, this.props.loginUser, this.props.dispatch)
1616
}
1717
}
18+
1819
shouldComponentUpdate(nextProps, nextState) {
1920
if(nextProps.pageStatus !== this.props.pageStatus) {
2021
return true;
@@ -26,6 +27,7 @@ class App extends React.Component {
2627
return false
2728
}
2829
}
30+
2931
renderContent() {
3032
if(this.props.loggedIn) {
3133
if(this.props.pageStatus === 401) {
@@ -37,6 +39,7 @@ class App extends React.Component {
3739
return (<Page location={this.props.location} />)
3840
}
3941
}
42+
4043
render() {
4144
return (
4245
<div id="app">

src/components/Pages/Page/Edit.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { replace } from 'react-router-redux'
55
import APIClient from '../../../http/requests'
66
import Editor from "../../Editor/Editor"
77
import s from '../../Editor/styles/content-tools.scss';
8-
9-
// Available templates
10-
import * as Templates from '../Templates/Pages';
118
import TextField from 'material-ui/TextField';
129
import Toggle from 'material-ui/Toggle';
1310
import EditDrawer from '../../Menu/EditDrawer';
@@ -18,6 +15,9 @@ import AppConfig from '../../../../app_config/app';
1815
import defaultImage from '../Templates/Pages/home-bg.jpg';
1916
import { getTemplateName } from '../../../helpers/PageHelper';
2017

18+
// Available templates
19+
import * as Templates from '../Templates/Pages';
20+
2121
class PageEdit extends React.Component {
2222

2323
constructor(props) {
@@ -29,7 +29,7 @@ class PageEdit extends React.Component {
2929
editContext: this.props.editContext,
3030
full_path: '/',
3131
name: null,
32-
resourceURL: props.resourceNamePlural + '/' + props.resourceId,
32+
resourceURL: `${props.resourceNamePlural}/${props.resourceId}`,
3333
show_title: false,
3434
slug: props.slug ? props.slug : '',
3535
explicitSlug: props.slug ? true : false,
@@ -93,7 +93,7 @@ class PageEdit extends React.Component {
9393
resourceURL: this.props.submitUrl
9494
});
9595

96-
let client = new APIClient(this.props.dispatch)
96+
const client = new APIClient(this.props.dispatch)
9797

9898
if(this.props.editContext === 'edit'){
9999
// if the Context is Edit, then get the existing data for the PageTemplate so it may be loaded into the page.
@@ -435,17 +435,11 @@ const mapDispatchToProps = (dispatch) => {
435435
notificationType
436436
})
437437
},
438-
updateEditorData: (newData) => {
439-
dispatch({
440-
type: 'UPDATE_ADMIN_EDITOR_DATA',
441-
newData
442-
})
443-
},
444-
deleteEditorData: () => {
445-
dispatch({
446-
type: 'DELETE_ADMIN_EDITOR_DATA'
447-
})
448-
},
438+
updateEditorData: (newData) => dispatch({
439+
type: 'UPDATE_ADMIN_EDITOR_DATA',
440+
newData
441+
}),
442+
deleteEditorData: () => dispatch({ type: 'DELETE_ADMIN_EDITOR_DATA'}),
449443
dispatch
450444
}
451445
}

src/components/Pages/Page/Page.js

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import React from 'react';
2-
3-
import * as Templates from '../Templates/Pages';
4-
5-
import PageNotFound from '../Errors/404/404';
6-
import APIClient from '../../../http/requests';
7-
import FrontendPage from '../../Layout/FrontendPage';
8-
import { connect } from 'react-redux';
9-
import AppConfig from '../../../../app_config/app';
10-
import { push } from 'react-router-redux';
11-
import Helmet from 'react-helmet';
12-
import defaultImage from '../Templates/Pages/home-bg.jpg';
13-
import { getTemplateName } from '../../../helpers/PageHelper';
1+
import React from "react";
2+
import * as Templates from "../Templates/Pages";
3+
import PageNotFound from "../Errors/404/404";
4+
import APIClient from "../../../http/requests";
5+
import FrontendPage from "../../Layout/FrontendPage";
6+
import { connect } from "react-redux";
7+
import AppConfig from "../../../../app_config/app";
8+
import { push } from "react-router-redux";
9+
import Helmet from "react-helmet";
10+
import defaultImage from "../Templates/Pages/home-bg.jpg";
11+
import { getTemplateName } from "../../../helpers/PageHelper";
1412

1513
class Page extends React.Component {
1614

@@ -23,7 +21,7 @@ class Page extends React.Component {
2321
}
2422

2523
isAdminPage() {
26-
return (this.props.pathname.substring(1, 6).toLowerCase() === 'admin')
24+
return (this.props.pathname.substring(1, 6).toLowerCase() === "admin")
2725
}
2826

2927
componentWillMount() {
@@ -35,7 +33,7 @@ class Page extends React.Component {
3533
loadPageContent(pathname) {
3634
const client = new APIClient(this.props.dispatch);
3735

38-
client.get('page', false, {params: {fullpath: pathname}}).then((res) => {
36+
client.get("page", false, {params: {fullpath: pathname}}).then((res) => {
3937
this.resolveDataFetch(res, this.setPreExistingPageData)
4038
}, this.rejectDataFetch).catch(this.rejectDataFetch)
4139
}
@@ -46,7 +44,7 @@ class Page extends React.Component {
4644

4745
navigateViaRouter = (event) => {
4846
event.preventDefault();
49-
this.props.dispatch(push(event.currentTarget.getAttribute('href')));
47+
this.props.dispatch(push(event.currentTarget.getAttribute("href")));
5048
}
5149

5250
setPreExistingPageData = (res) => {
@@ -72,13 +70,13 @@ class Page extends React.Component {
7270

7371
addLinkBehaviorToAnchorElements(anchorElements) {
7472
anchorElements.forEach((anchorElement) => {
75-
anchorElement.addEventListener('click', this.navigateViaRouter, false);
73+
anchorElement.addEventListener("click", this.navigateViaRouter, false);
7674
})
7775
}
7876

7977
getInteralLinks() {
80-
if(typeof(document) !== 'undefined') {
81-
const pageTemplate = document.getElementsByClassName('page');
78+
if(typeof(document) !== "undefined") {
79+
const pageTemplate = document.getElementsByClassName("page");
8280
let internalLinks = [];
8381
if(pageTemplate.length > 0) {
8482
let contentAnchors = pageTemplate[0].getElementsByTagName("a");
@@ -100,7 +98,7 @@ class Page extends React.Component {
10098
if(res.statusCode && res.statusCode >= 300) {
10199
this.props.updatePageStatusCode(res.statusCode);
102100
} else {
103-
console.warn('Error: ', res)
101+
console.warn("Error: ", res)
104102
}
105103
}
106104

@@ -135,19 +133,19 @@ class Page extends React.Component {
135133

136134
makeHelmetMeta() {
137135
let headerMeta = [
138-
{property: 'og:title', content: this.state.name},
139-
{property: 'og:url', content: this.getPageURL()},
136+
{property: "og:title", content: this.state.name},
137+
{property: "og:url", content: this.getPageURL()},
140138
];
141139

142140
if(this.state.image_url) {
143-
headerMeta.push({property: 'og:image', content: this.state.image_url});
141+
headerMeta.push({property: "og:image", content: this.state.image_url});
144142
}
145143

146144
return headerMeta;
147145
}
148146

149147
getPageURL() {
150-
return (typeof(window) !== 'undefined') ? window.location.href : `${AppConfig.baseUrl}/${this.props.pathname}`;
148+
return (typeof(window) !== "undefined") ? window.location.href : `${AppConfig.baseUrl}/${this.props.pathname}`;
151149
}
152150

153151
getPageTitle() {
@@ -179,18 +177,19 @@ const mapDispatchToProps = (dispatch) => {
179177
return {
180178
updatePageStatusCode: (statusCode) => {
181179
dispatch ({
182-
type: 'UPDATE_PAGE_STATUS_CODE',
180+
type: "UPDATE_PAGE_STATUS_CODE",
183181
statusCode
184182
})
185183
},
186184
dispatch
187185
}
188-
}
186+
};
187+
189188
const mapStateToProps = (state, ownProps) => {
190189
return {
191190
pathname: state.routing.locationBeforeTransitions.pathname,
192191
statusCode: state.page.statusCode
193192
}
194-
}
193+
};
195194

196-
export default connect(mapStateToProps, mapDispatchToProps)(Page)
195+
export default connect(mapStateToProps, mapDispatchToProps)(Page);

src/components/Pages/Page/RoundSocialLinks.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react';
2-
import withStyles from 'isomorphic-style-loader/lib/withStyles';
3-
import s from './RoundSocialLinks.scss';
1+
import React from "react";
2+
import withStyles from "isomorphic-style-loader/lib/withStyles";
3+
import s from "./RoundSocialLinks.scss";
44

55
import {
66
ShareButtons,
77
ShareCounts,
88
generateShareIcon,
9-
} from 'react-share';
9+
} from "react-share";
1010

1111
const {
1212
FacebookShareButton,
@@ -23,11 +23,11 @@ const {
2323
PinterestShareCount,
2424
} = ShareCounts;
2525

26-
const FacebookIcon = generateShareIcon('facebook');
27-
const TwitterIcon = generateShareIcon('twitter');
28-
const GooglePlusIcon = generateShareIcon('google');
29-
const LinkedinIcon = generateShareIcon('linkedin');
30-
const PinterestIcon = generateShareIcon('pinterest');
26+
const FacebookIcon = generateShareIcon("facebook");
27+
const TwitterIcon = generateShareIcon("twitter");
28+
const GooglePlusIcon = generateShareIcon("google");
29+
const LinkedinIcon = generateShareIcon("linkedin");
30+
const PinterestIcon = generateShareIcon("pinterest");
3131

3232
const RoundSocialLinks = (props) => (
3333
<div className={`social-container ${props.className}`}>
@@ -112,8 +112,7 @@ const RoundSocialLinks = (props) => (
112112
url={props.url}
113113
className="share-count" />
114114
</div>
115-
116115
</div>
117116
);
118117

119-
export default withStyles(s)(RoundSocialLinks);
118+
export default withStyles(s)(RoundSocialLinks);

src/components/Pages/Templates/Pages/ContactTemplate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import s from './ContactPageTemplate.scss';
66
const ContactTemplate = (props) => (
77
<div className="page contact">
88
<div className="page-container">
9-
<div data-editable data-name="name" className="big-box" onInput={props.handleNameChanged ? props.handleNameChanged : undefined}>
10-
<h1 className="page-title" data-ce-placeholder="Page Title">{props.name ? props.name : ''}</h1>
9+
<div data-editable data-name="name" onInput={props.handleNameChanged ? props.handleNameChanged : undefined}>
10+
<h1 className="page-title big-box" data-ce-placeholder="Page Title">{props.name ? props.name : ''}</h1>
1111
</div>
1212
<div className="page-content" data-editable data-name="content" data-ce-placeholder="Content..." dangerouslySetInnerHTML={{__html: props.content}} />
1313
</div>

0 commit comments

Comments
 (0)