From 89d2b398231a47ccc0de44035f770f89c8a701ce Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 9 Aug 2019 22:48:58 +1000 Subject: [PATCH] account wip --- client/assets/styles/account.less | 58 ++++++++++++ client/assets/styles/colours.less | 1 + client/assets/styles/game.less | 1 + client/assets/styles/styles.less | 52 +++++------ client/index.js | 1 + client/src/components/account.management.jsx | 90 +++++++++++++++++++ client/src/components/account.page.jsx | 33 +++++++ client/src/components/account.status.jsx | 79 ++-------------- client/src/components/controls.jsx | 2 +- client/src/components/inventory.jsx | 14 ++- client/src/components/main.jsx | 2 + client/src/components/stripe.buttons.jsx | 54 +++++++++++ client/src/components/team.jsx | 4 +- .../mnml.gg.STAGING.SAMPLE.nginx.conf | 56 ++++++++---- server/src/names.rs | 12 ++- 15 files changed, 336 insertions(+), 123 deletions(-) create mode 100644 client/assets/styles/account.less create mode 100644 client/src/components/account.management.jsx create mode 100644 client/src/components/account.page.jsx create mode 100644 client/src/components/stripe.buttons.jsx diff --git a/client/assets/styles/account.less b/client/assets/styles/account.less new file mode 100644 index 00000000..a5e763c3 --- /dev/null +++ b/client/assets/styles/account.less @@ -0,0 +1,58 @@ +@import 'colours.less'; + +.account-page { + height: 100%; + display: grid; + + grid-template-rows: minmax(min-content, 2fr) 1fr; + grid-template-columns: 1fr; + + grid-template-areas: + "team" + "account"; + + button { + display: block; + height: 3em; + width: 75%; + } + + input { + width: 75%; + height: 3em; + display: block; + } + + .team { + grid-area: team; + + /* poor man's
*/ + border-bottom: 0.1em solid #444; + } + + .account { + margin: 2em 2em 0 0; + grid-area: account; + + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr; + grid-gap: 0 1em; + } +} + +.stripe-btn { + background: @yellow; + color: black; + border-radius: 2px; + border-width: 0; + + &:active, &:focus, &:hover { + color: black; + } + + &[disabled] { + border: 1px solid @yellow; + color: @yellow; + background: black; + } +} diff --git a/client/assets/styles/colours.less b/client/assets/styles/colours.less index 8ffce257..d7e0fc49 100644 --- a/client/assets/styles/colours.less +++ b/client/assets/styles/colours.less @@ -4,6 +4,7 @@ @blue: #3050f8; @white: #f5f5f5; // whitesmoke @purple: #9355b5; // 6lack - that far cover +@yellow: #ffa100; @black: black; @gray: #222; diff --git a/client/assets/styles/game.less b/client/assets/styles/game.less index 29a71047..a2949889 100644 --- a/client/assets/styles/game.less +++ b/client/assets/styles/game.less @@ -1,3 +1,4 @@ +@import 'colours.less'; /* GAME */ .game { diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less index 3ba42538..12bde5a2 100644 --- a/client/assets/styles/styles.less +++ b/client/assets/styles/styles.less @@ -90,6 +90,10 @@ nav { padding-left: 2em; margin-right: 2em; max-height: 100%; + + h1 { + margin-bottom: 0.5em; + } } nav h2:first-child { @@ -166,17 +170,17 @@ button, input { transition-duration: 0.25s; transition-delay: 0; transition-timing-function: ease; -} -button:hover { - color: whitesmoke; - border-color: @gray-hover; -} + &:hover { + color: whitesmoke; + border-color: @gray-hover; + } -button:focus { - /*colour necesary to bash skellington*/ - color: @gray-focus; - border-color: @gray-focus; + &:focus { + /*colour necesary to bash skellington*/ + color: @gray-focus; + border-color: @gray-focus; + } } a { @@ -327,16 +331,12 @@ header { margin-bottom: 1.5em; } -.account { - margin: 1em 0; -} - .header-title { flex: 1; letter-spacing: 0.05em; } -.account-status { +.account-info { display: flex; } @@ -346,7 +346,7 @@ header { display: inline; } -.account-status svg { +.account-info svg { margin: 0.5em 0 0 1em; height: 1em; background-color: black; @@ -481,6 +481,10 @@ header { display: grid; grid-template-columns: 1fr 1fr; + h1 { + margin-bottom: 0.5em; + } + .list { letter-spacing: 0.25em; text-transform: uppercase; @@ -504,19 +508,6 @@ header { font-size: 1.2em; } -.stripe-btn { - width: 100%; - padding: 0 0.5em; - margin: 0.25em 0; - background: whitesmoke; - color: black; - border-radius: 2px; -} - -.stripe-btn:hover { - color: black; -} - .play-btn { font-size: 150%; } @@ -566,6 +557,11 @@ main .top button { width: 100%; } +.credits { + color: @yellow; + font-weight: 800; +} + .timer-container { display: flex; flex: 1 1 100%; diff --git a/client/index.js b/client/index.js index a3db2940..da09b74d 100644 --- a/client/index.js +++ b/client/index.js @@ -3,6 +3,7 @@ require('./assets/styles/instance.less'); require('./assets/styles/vbox.less'); require('./assets/styles/game.less'); require('./assets/styles/controls.less'); +require('./assets/styles/account.less'); require('./assets/styles/styles.mobile.css'); require('./assets/styles/instance.mobile.css'); diff --git a/client/src/components/account.management.jsx b/client/src/components/account.management.jsx new file mode 100644 index 00000000..102b846b --- /dev/null +++ b/client/src/components/account.management.jsx @@ -0,0 +1,90 @@ +const { connect } = require('preact-redux'); +const preact = require('preact'); + +const { postData } = require('./../utils'); +const actions = require('../actions'); + +const addState = connect( + function receiveState(state) { + const { + account, + ping, + } = state; + + + function logout() { + postData('/logout').then(() => window.location.reload(true)); + } + + return { + account, + ping, + logout, + }; + }, +); + + +function AccountStatus(args) { + const { + account, + ping, + logout, + } = args; + + if (!account) return null; + + return ( +
+
+

{account.name}

+
+
Subscription
+
{account.subscribed ? 'some date' : 'unsubscribed'}
+
+ +
+
+ + + + +
+
+ + + + + +
+
+ ); +} + +module.exports = addState(AccountStatus); diff --git a/client/src/components/account.page.jsx b/client/src/components/account.page.jsx new file mode 100644 index 00000000..17474fe8 --- /dev/null +++ b/client/src/components/account.page.jsx @@ -0,0 +1,33 @@ +const { connect } = require('preact-redux'); +const preact = require('preact'); + +const Team = require('./team'); +const AccountManagement = require('./account.management'); + +const addState = connect( + function receiveState(state) { + const { + ws, + account, + } = state; + + return { + account, + }; + }, +); + +function Account(args) { + const { + account, + } = args; + + return ( +
+ + +
+ ); +} + +module.exports = addState(Account); diff --git a/client/src/components/account.status.jsx b/client/src/components/account.status.jsx index 025022b9..6b5826c4 100644 --- a/client/src/components/account.status.jsx +++ b/client/src/components/account.status.jsx @@ -1,9 +1,7 @@ const { connect } = require('preact-redux'); const preact = require('preact'); -const { Elements, injectStripe } = require('react-stripe-elements'); const { saw } = require('./shapes'); -const { postData } = require('./../utils'); const actions = require('../actions'); function pingColour(ping) { @@ -12,55 +10,6 @@ function pingColour(ping) { return 'red'; } -function BitsBtn(args) { - const { - stripe, - account, - } = args; - function subscribeClick(e) { - stripe.redirectToCheckout({ - items: [{plan: 'plan_FGmRwawcOJJ7Nv', quantity: 1}], - successUrl: 'http://localhost/api/payments/success', - cancelUrl: 'http://localhost/api/payments/cancel', - clientReferenceId: account.id - }); - } - - function bitsClick(e) { - stripe.redirectToCheckout({ - items: [{sku: 'sku_FHUfNEhWQaVDaT', quantity: 1}], - successUrl: 'http://localhost/payments/success', - cancelUrl: 'http://localhost/payments/cancel', - clientReferenceId: account.id - }); - } - - const subscription = account.subscribed - ?

Subscribed

- : ; - - return ( -
-
- {subscription} - - -
- ); -} - -const StripeBitsBtn = injectStripe(BitsBtn); - const addState = connect( function receiveState(state) { const { @@ -68,23 +17,18 @@ const addState = connect( ping, } = state; - - function logout() { - postData('/logout').then(() => window.location.reload(true)); - } - return { account, ping, - logout, }; }, function receiveDispatch(dispatch) { - function selectConstructs() { - return dispatch(actions.setNav('team')); + function accountPage() { + return dispatch(actions.setNav('account')); } + return { - selectConstructs, + accountPage, }; } ); @@ -94,25 +38,20 @@ function AccountStatus(args) { const { account, ping, - logout, - selectConstructs, + accountPage, } = args; if (!account) return null; return ( -
-