@@ -76,10 +72,4 @@ class Footer extends React.Component {
}
}
-const mapStateToProps = (state) => {
- return {
- code: state.language.code
- }
-}
-
-export default connect(mapStateToProps)(Footer);
+export default withLanguage(Footer);
diff --git a/public/components/nav/menu/HamburgerMenu.jsx b/public/components/nav/menu/HamburgerMenu.jsx
index 551ab20..fd3b6da 100644
--- a/public/components/nav/menu/HamburgerMenu.jsx
+++ b/public/components/nav/menu/HamburgerMenu.jsx
@@ -24,63 +24,56 @@
import React from 'react';
import { connect } from 'react-redux';
import { NavLink } from 'react-router-dom';
+import { withLanguage } from '@public/language/Language';
+import * as MenuActions from '@public/actions/MenuActions';
import Styles from './HamburgerMenu.scss';
-import Language from '@public/language/Language';
-import * as MenuActions from '@public/actions/MenuActions';
-
-const HamburerMenuItem = (props) => {
+const HamburerMenuItem = props => {
let { lang, link, className } = props;
- className = className || "";
return (
-
-
- { Language.get(lang) }
+
+ { lang }
);
}
-class HamburgerMenu extends React.Component {
- constructor(props) {
- super(props);
- }
+const HamburgerMenu = props => {
+ let { open, className, toggleMenu, lang } = props;
- render() {
- let { open, className, toggleMenu } = this.props;
+ let clazz = "c-hamburger-menu";
+ if(open) clazz += " is-open";
+ if(className) clazz += ` ${className}`;
- let clazz = "c-hamburger-menu";
- if(open) clazz += " is-open";
- if(className) clazz += ` ${className}`;
+ return (
+
+
- return (
-
-
-
-
-
- );
- }
+
+
+ );
}
-const mapStateToProps = (state) => {
+const mapStateToProps = state => {
return {
- open: state.menu.open,
- language: state.language.code
+ open: state.menu.open
}
}
-const mapDispatchToProps = (dispatch) => {
+const mapDispatchToProps = dispatch => {
return {
toggleMenu: function(theme) {
dispatch(MenuActions.toggleMenu());
@@ -88,4 +81,4 @@ const mapDispatchToProps = (dispatch) => {
}
}
-export default connect(mapStateToProps, mapDispatchToProps)(HamburgerMenu);
+export default connect(mapStateToProps, mapDispatchToProps)(withLanguage(HamburgerMenu));
diff --git a/public/components/nav/navbar/Navbar.jsx b/public/components/nav/navbar/Navbar.jsx
index 25ef075..202537c 100644
--- a/public/components/nav/navbar/Navbar.jsx
+++ b/public/components/nav/navbar/Navbar.jsx
@@ -22,68 +22,58 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import React from 'react';
-import { withRouter } from 'react-router';
-import { connect } from 'react-redux';
import { NavLink } from 'react-router-dom'
-import Styles from './Navbar.scss';
+import { withLanguage } from '@public/language/Language';
-import Language from '@public/language/Language';
+import Styles from './Navbar.scss';
import { PageBoundary } from '@components/page/Page';
import HamburgerMenu from './../menu/HamburgerMenu';
import Image from '@objects/image/Image';
-const NavbarLink = function(props) {
+const NavbarLink = props => {
+ let { to, exact, title } = props;
+
return (
-
- { Language.get("navbar." + props.title) }
+
+ { title }
);
+};
+
+
+const Navbar = props => {
+ let { lang } = props;
+
+ return (
+
+
+
+
+
+ );
}
-
-class Navbar extends React.Component {
- constructor(props) {
- super(props);
- }
-
- render() {
- return (
-
-
-
-
-
- );
- }
-}
-
-const mapStateToProps = function(state) {
- return {
- code: state.language.code
- }
-}
-
-export default withRouter(connect(mapStateToProps)(Navbar));
+export default withLanguage(Navbar);
diff --git a/public/language/Language.jsx b/public/language/Language.jsx
index 825e47e..2cc9748 100644
--- a/public/language/Language.jsx
+++ b/public/language/Language.jsx
@@ -21,9 +21,13 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+import React from 'react';
+import { connect } from 'react-redux';
+import LanguageActions from './../actions/LanguageActions';
+
import enAU from './en-AU.jsx';
-const LANGUAGES = {
+export const LANGUAGES = {
'en-AU': enAU
}
@@ -70,17 +74,30 @@ class Language {
return Object.keys(LANGUAGES);
}
}
-
const lang = new Language();
-
export default lang;
-const LanguageTools = {
+export const LanguageTools = {
random: function(someArray) {
return someArray[Math.floor(Math.random() * someArray.length)];
}
}
-export {
- LanguageTools
-}
+export const withLanguage = Wrapped => {
+ let LanguageWrapper = props => {
+ return ;
+ };
+
+ return connect(state => {
+ return {
+ language: state.language.code,
+ lang: lang.data
+ }
+ }, dispatch => {
+ return {
+ setLanguage: language => {
+ dispatch(LanguageActions.setLanguage(language));
+ }
+ };
+ })(LanguageWrapper);
+};