diff --git a/browser/main/Containers/UserContainer.jsx b/browser/main/Containers/UserContainer.jsx
index 731dc1fe..c4a4c1c7 100644
--- a/browser/main/Containers/UserContainer.jsx
+++ b/browser/main/Containers/UserContainer.jsx
@@ -1,54 +1,12 @@
+/* global localStorage */
var React = require('react/addons')
var ReactRouter = require('react-router')
-var Link = ReactRouter.Link
var RouteHandler = ReactRouter.RouteHandler
+var UserNavigator = require('../Components/UserNavigator')
+
var AuthStore = require('../Stores/AuthStore')
-
-var UserNavigator = React.createClass({
- mixins: [ReactRouter.Navigation],
- propTypes: {
- currentPlanet: React.PropTypes.object,
- currentUser: React.PropTypes.object
- },
- componentDidMount: function () {
- this.unsubscribe = AuthStore.listen(this.onLogout)
- },
- componentWillUnmount: function () {
- this.unsubscribe()
- },
- onLogout: function () {
- this.transitionTo('login')
- },
- render: function () {
- var planets = this.props.currentUser.Planets.map(function (planet, index) {
- return (
-
- {planet.name[0]}
- ⌘{index + 1}
-
- )
- }.bind(this))
- if (this.props.currentUser == null) {
- return (
-
-
- )
- }
-
- return (
-
-
-

-
-
-
-
- )
- }
-})
+var PlanetStore = require('../Stores/PlanetStore')
module.exports = React.createClass({
mixins: [React.addons.LinkedStateMixin, ReactRouter.Navigation],
@@ -57,9 +15,29 @@ module.exports = React.createClass({
planetName: React.PropTypes.string
})
},
+ getInitialState: function () {
+ return {
+ currentUser: AuthStore.getUser()
+ }
+ },
+ componentDidMount: function () {
+ this.unsubscribe = PlanetStore.listen(this.onListen)
+ },
+ componentWillUnmount: function () {
+ this.unsubscribe()
+ },
+ onListen: function (res) {
+ if (res.status === 'planetCreated') {
+ var currentUser = this.state.currentUser
+ currentUser.Planets.push(res.data)
+
+ localStorage.setItem('user', JSON.stringify(currentUser))
+ this.setState({currentUser: currentUser})
+ }
+ },
render: function () {
var currentPlanetName = this.props.params.planetName
- var currentUser = AuthStore.getUser()
+ var currentUser = this.state.currentUser
// user must be logged in
if (currentUser == null) return (
)
diff --git a/browser/main/Stores/PlanetStore.js b/browser/main/Stores/PlanetStore.js
index 4b42ba87..04616a1d 100644
--- a/browser/main/Stores/PlanetStore.js
+++ b/browser/main/Stores/PlanetStore.js
@@ -8,6 +8,7 @@ var apiUrl = 'http://localhost:8000/'
var PlanetStore = Reflux.createStore({
init: function () {
+ this.listenTo(PlanetActions.createPlanet, this.createPlanet)
this.listenTo(PlanetActions.fetchPlanet, this.fetchPlanet)
this.listenTo(PlanetActions.createSnippet, this.createSnippet)
this.listenTo(PlanetActions.updateSnippet, this.updateSnippet)
@@ -16,6 +17,31 @@ var PlanetStore = Reflux.createStore({
this.listenTo(PlanetActions.updateBlueprint, this.updateBlueprint)
this.listenTo(PlanetActions.deleteBlueprint, this.deleteBlueprint)
},
+ createPlanet: function (input) {
+ request
+ .post(apiUrl + 'planets/create')
+ .set({
+ Authorization: 'Bearer ' + localStorage.getItem('token')
+ })
+ .send(input)
+ .end(function (err, res) {
+ if (err) {
+ console.error(err)
+ this.trigger(null)
+ return
+ }
+
+ var planet = res.body
+ planet.Snippets = []
+ planet.Blueprints = []
+ planet.Articles = []
+
+ this.trigger({
+ status: 'planetCreated',
+ data: planet
+ })
+ }.bind(this))
+ },
fetchPlanet: function (planetName) {
request
.get(apiUrl + planetName)
diff --git a/browser/styles/main/containers/UserContainer.styl b/browser/styles/main/containers/UserContainer.styl
new file mode 100644
index 00000000..0812db57
--- /dev/null
+++ b/browser/styles/main/containers/UserContainer.styl
@@ -0,0 +1,95 @@
+.UserContainer
+ .UserNavigator
+ background-color planetNavBgColor
+ absolute left top bottom
+ width 50px
+ text-align center
+ box-sizing border-box
+ a.userConfig
+ display block
+ width 50px
+ height 50px
+ background-color black
+ img
+ transition 0.1s
+ opacity 0.6
+ box-sizing border-box
+ &.active, &:active, &.focus, &:focus, &.hover, &:hover
+ img
+ opacity 1
+ ul>li
+ padding 10px 3px
+ .shortCut
+ margin-top 5px
+ color lighten(textColor, 5%)
+ font-size 0.8em
+ &.active
+ a
+ background-color planetAnchorActiveBgColor
+ color planetAnchorActiveColor
+ a
+ display block
+ width 44px
+ height 44px
+ text-align center
+ background-color planetAnchorBgColor
+ text-decoration none
+ color planetAnchorColor
+ line-height 44px
+ font-size 1.1em
+ cursor pointer
+ circle()
+ transition 0.1s
+ &:hover, &:active
+ background-color white
+ img
+ circle()
+ width 44px
+ height 44px
+ button.newPlanet
+ display block
+ margin 0 auto
+ width 30px
+ height 30px
+ circle()
+ border solid 1px lightButtonColor
+ color lightButtonColor
+ text-align center
+ font-size 1
+ background-image none
+ background-color transparent
+ box-sizing border-box
+ absolute left bottom right
+ bottom 15px
+ &:hover, &.hover, &:focus, &.focus
+ border-color darken(lightButtonColor, 50%)
+ color darken(lightButtonColor, 50%)
+ &:active, &.active
+ border-color darken(brandBorderColor, 10%)
+ background-color brandColor
+ color white
+.PlanetCreateModal.modal
+ padding 60px 0
+ .nameInput
+ width 80%
+ font-size 1.3em
+ margin 35px auto
+ text-align center
+ .submitButton
+ display block
+ margin 0 auto
+ box-sizing border-box
+ width 55px
+ height 55px
+ border-style solid
+ border-width 1px
+ circle()
+ border-color brandBorderColor
+ background-color transparent
+ color brandColor
+ &:hover, &.hover, &:focus, &.focus
+ border-color darken(brandBorderColor, 30%)
+ color darken(brandColor, 30%)
+ &:active, &.active
+ background-color brandColor
+ color white
diff --git a/browser/styles/main/index.styl b/browser/styles/main/index.styl
index 44b31a80..5479d5c3 100644
--- a/browser/styles/main/index.styl
+++ b/browser/styles/main/index.styl
@@ -90,77 +90,7 @@ textarea.block-input
resize vertical
height 125px
border-radius 5px
- padding 0 10px
+ padding 5px 10px
#content
fullsize()
-
-.UserNavigator
- background-color planetNavBgColor
- absolute left top bottom
- width 50px
- text-align center
- box-sizing border-box
- a.userConfig
- display block
- width 50px
- height 50px
- background-color black
- img
- transition 0.1s
- opacity 0.6
- box-sizing border-box
- &.active, &:active, &.focus, &:focus, &.hover, &:hover
- img
- opacity 1
- ul>li
- padding 10px 3px
- .shortCut
- margin-top 5px
- color lighten(textColor, 5%)
- font-size 0.8em
- &.active
- a
- background-color planetAnchorActiveBgColor
- color planetAnchorActiveColor
- a
- display block
- width 44px
- height 44px
- text-align center
- background-color planetAnchorBgColor
- text-decoration none
- color planetAnchorColor
- line-height 44px
- font-size 1.1em
- cursor pointer
- circle()
- transition 0.1s
- &:hover, &:active
- background-color white
- img
- circle()
- width 44px
- height 44px
- button.newPlanet
- display block
- margin 0 auto
- width 30px
- height 30px
- circle()
- border solid 2px lightButtonColor
- color lightButtonColor
- text-align center
- font-size 1
- background-image none
- background-color transparent
- box-sizing border-box
- absolute left bottom right
- bottom 15px
- &:hover, &.hover, &:focus, &.focus
- border-color darken(lightButtonColor, 25%)
- color darken(lightButtonColor, 25%)
- &:active, &.active
- border-color darken(brandBorderColor, 10%)
- background-color brandColor
- color white
diff --git a/browser/styles/shared/modal.styl b/browser/styles/shared/modal.styl
index cdf073ba..43b4803a 100644
--- a/browser/styles/shared/modal.styl
+++ b/browser/styles/shared/modal.styl
@@ -9,7 +9,7 @@
display none
.modal
width 500px
- margin 25px auto 0
+ margin 50px auto 0
absolute top left right
background-color white
border-radius 10px