diff --git a/src/GlobalData.js b/src/GlobalData.js new file mode 100644 index 0000000..3f4e9b9 --- /dev/null +++ b/src/GlobalData.js @@ -0,0 +1,12 @@ +import User from './classes/User.js'; +import Coordinates from "./classes/Coordinates.js"; + +let globalData = { + user: new User( + "test", + "123", + new Coordinates() + ) +}; + +export default globalData; \ No newline at end of file diff --git a/src/classes/User.js b/src/classes/User.js index deb3ce2..bd48e47 100644 --- a/src/classes/User.js +++ b/src/classes/User.js @@ -1,12 +1,14 @@ /* Denna klass är en modell för användare. - deviceId : String (Enhetens ID) + name : String (Användarnamn) + deviceId : Int (Enhetens ID) location : Coordinates (Användarens koordinater) */ class User { - constructor(deviceId, location) { + constructor(name, deviceId, location) { + this.name = name; this.deviceId = deviceId; this.location = location; this.stoppointgid = stoppointgid; diff --git a/src/components/Button.js b/src/components/Button.js index d6c6a90..873dc00 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -1,14 +1,30 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; + +import './css/Button.css'; + class Button extends Component { - render() { + // Multiple onClick functions + onClick = () => { + if (this.props.onClick !== null + && this.props.onClick !== undefined) { + if (Array.isArray(this.props.onClick)) { + this.props.onClick.forEach(func => { + func(); + }); + } else { + console.log("Error when parsing Button onClick functions."); + } + } + } + render() { return ( - - {this.props.title} - + ); } } -// TODO Add css -export default Button + +export default Button; \ No newline at end of file diff --git a/src/components/DisruptionButton.js b/src/components/DisruptionButton.js index e29fc2f..c88e5ca 100644 --- a/src/components/DisruptionButton.js +++ b/src/components/DisruptionButton.js @@ -1,24 +1,29 @@ import addNotification from "react-push-notification"; +import Button from './Button.js'; import disruptIcon from '../img/flash.svg'; -const DisruptionButton = () => { - const genDisrupt = () => { - addNotification({ - title: "Warning", - subtitle: "This is a subtitle", - message: "This is a very long message", - theme: "blue", - native: true, // when using native, your OS will handle theming. - }); - }; - return ( - - ); -}; +class DisruptionButton extends Button { + genDisrupt = () => { + addNotification({ + title: "Warning", + subtitle: "This is a subtitle", + message: "This is a very long message", + theme: "blue", + native: true, // when using native, your OS will handle theming. + }); + } + + render() { + return ( + + ); + } +} + export default DisruptionButton; diff --git a/src/components/MenuButton.js b/src/components/MenuButton.js index 0c78162..0ab96d0 100644 --- a/src/components/MenuButton.js +++ b/src/components/MenuButton.js @@ -1,20 +1,21 @@ -import React, { Component } from 'react'; +import Button from './Button.js'; -class MenuButton extends Component { + +class MenuButton extends Button { render() { if (this.props.childOrderReverse) { return ( - + ); } else { return ( - + ); } } diff --git a/src/components/NavigationDrawer.js b/src/components/NavigationDrawer.js index 1b963b0..de49e86 100644 --- a/src/components/NavigationDrawer.js +++ b/src/components/NavigationDrawer.js @@ -1,12 +1,21 @@ import React, { Component } from 'react'; -import './css/NavigationDrawer.css'; +import globalData from '../GlobalData.js'; import DisruptionButton from "./DisruptionButton.js"; +import Popup from './Popup.js'; +import Button from './Button.js'; + +import './css/NavigationDrawer.css'; import userIcon from '../img/user.svg'; class NavigationDrawer extends Component { + constructor(props) { + super(props); + this.popupElem = React.createRef(); + } + state = { open: false }; @@ -30,17 +39,31 @@ class NavigationDrawer extends Component { }); }; + showPopup = () => { + this.popupElem.current.show(); + }; + render() { return ( <> + +

Välj hållplats:

+ +
+