diff --git a/config/webpack/base/webpack.base.client.config.js b/config/webpack/base/webpack.base.client.config.js index 7f90dff..d72032c 100644 --- a/config/webpack/base/webpack.base.client.config.js +++ b/config/webpack/base/webpack.base.client.config.js @@ -36,13 +36,14 @@ module.exports = { plugins: [ new WebpackPwaManifest({ filename: 'manifest.json', - name: 'MMT Management Manager', + name: 'MMTPWA', short_name: 'MMTPWA', description: 'Manage your MMT Management in this PWA!', background_color: '#ffffff', + theme_color: '#ec2821', orientation: 'portrait', display: 'standalone', - publicPath: '/', + start_url: '/', icons: [ { src: resolve('src/assets/mmt.png'), diff --git a/package-lock.json b/package-lock.json index f35c1ad..ff8e0c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,9 +72,10 @@ "dev": true }, "@types/node": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.0.2.tgz", - "integrity": "sha512-DPbG0qQ5kdvXBK0jGdv1yd8vGN7hwH8sB2Q1z1kGaxtCnXkSxYJ009VccGlcgknYoLeMTYu4TTzOditDJMdP2Q==", + + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.0.3.tgz", + "integrity": "sha512-J7nx6JzxmtT4zyvfLipYL7jNaxvlCWpyG7JhhCQ4fQyG+AGfovAHoYR55TFx+X8akfkUJYpt5JG6GPeFMjZaCQ==", "dev": true }, "abab": { @@ -4698,7 +4699,7 @@ "is-string": "1.0.4", "is-subset": "0.1.1", "lodash": "4.17.10", - "object-inspect": "1.5.0", + "object-inspect": "1.6.0", "object-is": "1.0.1", "object.assign": "4.1.0", "object.entries": "1.0.4", @@ -11091,7 +11092,7 @@ "dev": true, "requires": { "unist-util-modify-children": "1.1.2", - "unist-util-visit": "1.3.0" + "unist-util-visit": "1.3.1" } }, "mdn-data": { @@ -12532,9 +12533,9 @@ } }, "object-inspect": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.5.0.tgz", - "integrity": "sha512-UmOFbHbwvv+XHj7BerrhVq+knjceBdkvU5AriwLMvhv2qi+e7DJzxfBeFpILEjVzCp+xA+W/pIf06RGPWlZNfw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", + "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", "dev": true }, "object-is": { @@ -13065,7 +13066,7 @@ "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", "dev": true, "requires": { - "@types/node": "10.0.2" + "@types/node": "10.0.3" } }, "parseurl": { @@ -14038,7 +14039,7 @@ "requires": { "htmlparser2": "3.9.2", "remark": "8.0.0", - "unist-util-find-all-after": "1.0.1" + "unist-util-find-all-after": "1.0.2" } }, "postcss-less": { @@ -15919,7 +15920,7 @@ "requires": { "remark-parse": "4.0.0", "remark-stringify": "4.0.0", - "unified": "6.1.6" + "unified": "6.2.0" } }, "remark-parse": { @@ -19160,9 +19161,9 @@ } }, "unified": { - "version": "6.1.6", - "resolved": "https://registry.npmjs.org/unified/-/unified-6.1.6.tgz", - "integrity": "sha512-pW2f82bCIo2ifuIGYcV12fL96kMMYgw7JKVEgh7ODlrM9rj6vXSY3BV+H6lCcv1ksxynFf582hwWLnA1qRFy4w==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/unified/-/unified-6.2.0.tgz", + "integrity": "sha512-1k+KPhlVtqmG99RaTbAv/usu85fcSRu3wY8X+vnsEhIxNP5VbVIDiXnLqyKIG+UMdyTg0ZX9EI6k2AfjJkHPtA==", "dev": true, "requires": { "bail": "1.0.3", @@ -19268,9 +19269,9 @@ } }, "unist-util-find-all-after": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unist-util-find-all-after/-/unist-util-find-all-after-1.0.1.tgz", - "integrity": "sha1-TlUSq/734GFnga7Pex7XUcAK+Qg=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unist-util-find-all-after/-/unist-util-find-all-after-1.0.2.tgz", + "integrity": "sha512-nDl79mKpffXojLpCimVXnxhlH/jjaTnDuScznU9J4jjsaUtBdDbxmlc109XtcqxY4SDO0SwzngsxxW8DIISt1w==", "dev": true, "requires": { "unist-util-is": "2.1.2" @@ -19297,7 +19298,7 @@ "integrity": "sha512-XxoNOBvq1WXRKXxgnSYbtCF76TJrRoe5++pD4cCBsssSiWSnPEktyFrFLE8LTk3JW5mt9hB0Sk5zn4x/JeWY7Q==", "dev": true, "requires": { - "unist-util-visit": "1.3.0" + "unist-util-visit": "1.3.1" } }, "unist-util-stringify-position": { @@ -19307,9 +19308,9 @@ "dev": true }, "unist-util-visit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.3.0.tgz", - "integrity": "sha512-9ntYcxPFtl44gnwXrQKZ5bMqXMY0ZHzUpqMFiU4zcc8mmf/jzYm8GhYgezuUlX4cJIM1zIDYaO6fG/fI+L6iiQ==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.3.1.tgz", + "integrity": "sha512-0fdB9EQJU0tho5tK0VzOJzAQpPv2LyLZ030b10GxuzAWEfvd54mpY7BMjQ1L69k2YNvL+SvxRzH0yUIehOO8aA==", "dev": true, "requires": { "unist-util-is": "2.1.2" diff --git a/src/assets/mmt1024.png b/src/assets/mmt1024.png new file mode 100644 index 0000000..d8376a5 Binary files /dev/null and b/src/assets/mmt1024.png differ diff --git a/src/components/Button/Button.js b/src/components/Button/Button.js new file mode 100644 index 0000000..1a6f09b --- /dev/null +++ b/src/components/Button/Button.js @@ -0,0 +1,12 @@ +import React from 'react' +import './Button.scss' + +const Button = ({ isActive = false, buttonText = 'Submit', buttonAction = null}) => { + return ( + + ) +} + +export default Button \ No newline at end of file diff --git a/src/components/Button/Button.scss b/src/components/Button/Button.scss new file mode 100644 index 0000000..f5e1d36 --- /dev/null +++ b/src/components/Button/Button.scss @@ -0,0 +1,51 @@ +$activated-colour: #ec2821; +$deactive-colour: grey; + +.button { + width: 100%; + display: block; + border: 2px solid $deactive-colour; + background-color: $deactive-colour; + padding: 12px; + text-transform: uppercase; + margin: 12px 0; + color: white; + transition: .3s; +} + +.is-active { + width: 100%; + display: block; + border: 2px solid $activated-colour; + background-color: transparent; + padding: 12px; + text-transform: uppercase; + margin: 12px 0; + position: relative; + color: $activated-colour; + transition: .3s; + transform: translateZ(0); + overflow: hidden; + cursor: pointer; + + &:after { + position: absolute; + content: ''; + height: 100%; + width: 0; + top: 0; + left: 50%; + transform: translateX(-50%); + transition: .3s; + background-color: $activated-colour; + z-index: -1; + } + + &:hover { + color: white; + + &:after { + width: 100%; + } + } +} diff --git a/src/components/PushSubscribeExample/PushSubscribeExample.js b/src/components/PushSubscribeExample/PushSubscribeExample.js new file mode 100644 index 0000000..068a74a --- /dev/null +++ b/src/components/PushSubscribeExample/PushSubscribeExample.js @@ -0,0 +1,41 @@ +import React, { Component } from 'react' +import { subscribeUser, swRegistration } from '../../services/serviceWorker/serviceWorker' +import Button from '../Button/Button'; + +class PushSubscribeExample extends Component { + state = { + userSubscribed : false + } + + componentDidMount () { + navigator.serviceWorker.ready.then((swRegistration) => { + swRegistration.pushManager.getSubscription() + .then((subscription) => { + if(subscription) { + this.setState({ + userSubscribed : true + }) + } + }) + }) + } + + buttonClicked = () => { + if(!this.state.userSubscribed) { + subscribeUser() + this.setState({ + userSubscribed : true + }) + } + } + + render () { + return ( +
+
+ ) + } +} + +export default PushSubscribeExample \ No newline at end of file diff --git a/src/components/pushNotificationExample/PushNotificationExample.js b/src/components/pushNotificationExample/PushNotificationExample.js new file mode 100644 index 0000000..be24bfe --- /dev/null +++ b/src/components/pushNotificationExample/PushNotificationExample.js @@ -0,0 +1,60 @@ +import React, { Component } from 'react' +import { swRegistration } from '../../services/serviceWorker/serviceWorker' +import Button from '../Button/Button' +import './PushNotificationExample.scss' + +class PushNotificationExample extends Component { + state = { + title: '', + message: '' + } + + handleChange = ({ target }) => { + const { value, name } = target + this.setState({ [name] : value }) + } + + resetState () { + this.setState({ + title: '', + message: '' + }) + } + + handleSubmit = (event) => { + event.preventDefault() + const title = this.state.title + const options = { + body: this.state.message, + icon: '../../assets/mmt.png', + badge: '../../assets/mmt.png' + } + swRegistration.showNotification(title, options) + this.resetState() + } + + render () { + return ( +
+ +