Skip to content

Commit

Permalink
refactor: Split component to make social login buttons
Browse files Browse the repository at this point in the history
see: #8
  • Loading branch information
sujinleeme committed Jul 11, 2018
1 parent abdc963 commit cfb85cd
Show file tree
Hide file tree
Showing 21 changed files with 50 additions and 309 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dist
yarn-error.log
.idea
package-lock.json
git rm -r --cached .
src/social-config.json
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const AsyncNoMatch = importedComponent(() =>
LoadingComponent: Loading
})

const Signup = importedComponent(() => import(/* webpackChunkName:'Login' */ "./signup"), {
const Signup = importedComponent(() => import(/* webpackChunkName:'Login' */ "./sign-up"), {
LoadingComponent: Loading
})

Expand Down
29 changes: 5 additions & 24 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import React from "react"
import PropTypes from "prop-types"

import { withStyles } from "@material-ui/core/styles"
import { connect } from "react-redux"
import AppBar from "@material-ui/core/AppBar"
import Toolbar from "@material-ui/core/Toolbar"
import Typography from "@material-ui/core/Typography"
import Button from "@material-ui/core/Button"
import Icon from '@material-ui/core/Icon';

import IconButton from "@material-ui/core/IconButton"
import MenuIcon from "@material-ui/icons/Menu"
import { Link } from "react-router-dom"
import { withStyles } from "@material-ui/core/styles"
import { AppBar, Toolbar, Typography, Button } from "@material-ui/core"
import { modalRequest } from "../modal/actions"
import { SIGN_IN_MODAL } from "../modal/constants"

const styles = {
root: {
Expand All @@ -39,7 +32,7 @@ const Header = (props) => {
</Typography>
</Link>
<Button
onClick={ () => props.modalRequest({modalProps: true, modalType: "SIGN_IN"}) }
onClick={ () => modalRequest({modalProps: true, modalType: SIGN_IN_MODAL}) }
color="inherit">Sign in</Button>
</Toolbar>
</AppBar>
Expand All @@ -50,19 +43,7 @@ const Header = (props) => {
Header.propTypes = {
classes: PropTypes.object.isRequired
}
//
// const mapDispatchToProps = (dispatch) => {
// return {
// // showModal: () => dispatch(showModal({
// // modalType: "SINGIN",
// // modalProps: true
// // }))
// openModal: () => dispatch(openModal({
// modalType: "SIGN_IN",
// modalProps: true
// }))
// }
// }


export default withStyles(styles)(connect(null, {modalRequest})(Header))

Empty file removed src/login/constants.js
Empty file.
Empty file removed src/login/index.js
Empty file.
Empty file removed src/login/reducer.js
Empty file.
Empty file removed src/login/saga.js
Empty file.
2 changes: 1 addition & 1 deletion src/modal/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MODAL_REQUESTING, MODAL_SUCCESS, MODAL_FAIL } from "./constants"
import { MODAL_REQUESTING } from "./constants"

export const modalRequest = ({modalProps, modalType}) => {
return {
Expand Down
11 changes: 11 additions & 0 deletions src/modal/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// signin-signup contents
export const INIT_MODAL = "INIT_MODAL"
export const SIGN_IN_MODAL = "SIGN_IN_MODAL"
export const SIGN_UP_MODAL = "SING_UP_MODAL"

/**
* sagas
*/

// show or hide modal
export const MODAL_REQUESTING = "MODAL_REQUESTING"
export const MODAL_SUCCESS = "MODAL_SUCCESS"
export const MODAL_FAIL = "MODAL_FAIL"

10 changes: 6 additions & 4 deletions src/modal/contents.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SIGN_IN_MODAL, SIGN_UP_MODAL} from "./constants"

export const modalContents = ({state}) => {
const initState = {
title: "",
Expand All @@ -10,26 +12,26 @@ export const modalContents = ({state}) => {
}

switch (state) {
case "SIGN_IN":
case SIGN_IN_MODAL:
return {
title: "Welcome back.",
subtitle: "Sign in to make your karaoke vocal music and record your singing.",
facebook: "Sign in with facebook",
google: "Sign in with Google",
bottom: "No account?",
button: "Create one.",
nextView: "SIGN_UP"
nextView: SIGN_UP_MODAL

}
case "SIGN_UP":
case SIGN_UP_MODAL:
return {
title: "Join!",
subtitle: "Sign up to make your karaoke vocal music and record your singing.",
facebook: "Sign up with facebook",
google: "Sign up with Google",
bottom: "Already have an account?",
button: "Sign in.",
nextView: "SIGN_IN"
nextView: SIGN_IN_MODAL
}
default:
return initState
Expand Down
41 changes: 15 additions & 26 deletions src/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { withStyles } from "@material-ui/core/styles"
import { Modal, Button, IconButton, Typography, Icon } from "@material-ui/core"
import CloseIcon from "@material-ui/icons/Close"
import { modalRequest } from "./actions"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { modalContents } from "./contents"

import Signup from "../sign-up"

import { alignStyle } from "../common-styles"

const styles = theme => ({
Expand Down Expand Up @@ -51,16 +53,7 @@ const getModalStyle = () => {
}
}

// Signin.propTypes = {
// classes: PropTypes.object.isRequired,
// view: PropTypes.string.isRequired,
// modalRequest: PropTypes.func.isRequired
// }

const Signin = (props) => {

const {classes, modalRequest, view} = props

const Signin = ({classes, modalRequest, view}) => {
const body = modalContents({state: view})
return (
<div className={ classes.container }>
Expand All @@ -71,18 +64,10 @@ const Signin = (props) => {
{ body.subtitle }
</Typography>
<div className={ `${classes.container} ${classes.buttonGroup}` }>
<Button variant="outlined" className={ classes.social }>
<FontAwesomeIcon
icon={ ["fab", "facebook"] }
className={ classes.icon }/>
{ body.facebook }
</Button>
<Button variant="outlined" className={ classes.social }>
<FontAwesomeIcon
className={ classes.icon }
icon={ ["fab", "google"] }/>
{ body.google }
</Button>
<Signup
textButton={ {facebook: body.facebook, google: body.google} }
classes={ classes }
/>
</div>
<div>
<Button disabled={ true }>{ body.bottom }</Button>
Expand All @@ -95,6 +80,12 @@ const Signin = (props) => {
)
}

// Signin.propTypes = {
// classes: PropTypes.object.isRequired,
// view: PropTypes.string.isRequired,
// modalRequest: PropTypes.func.isRequired
// }

// SigninModal.propTypes = {
// classes: PropTypes.object.isRequired,
// _isOpen: PropTypes.bool.isRequired,
Expand All @@ -113,19 +104,17 @@ class SigninModal extends React.Component {
>
<div style={ getModalStyle() } className={ classes.paper }>
<div className={ classes.closeButton }>

<IconButton className={ classes.button }
aria-label="SING_IN"
onClick={ () => modalRequest({modalProps: false}) }
>
<CloseIcon/>

</IconButton>
</div>
<Signin
classes={ classes }
modalRequest={ modalRequest }
view={ modalView }
modalRequest={ modalRequest }
/>
</div>
</Modal>
Expand Down
3 changes: 2 additions & 1 deletion src/modal/reducer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
INIT_MODAL,
MODAL_REQUESTING, MODAL_SUCCESS, MODAL_FAIL
} from "./constants"

const initialState = {
modalType: null,
modalType: INIT_MODAL,
modalProps: false,
requesting: false,
successful: false,
Expand Down
1 change: 0 additions & 1 deletion src/modal/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { call, put, takeLatest, takeEvery } from "redux-saga/effects"
import { MODAL_REQUESTING, MODAL_SUCCESS, MODAL_FAIL } from "./constants"

function* modalFlow(action) {
console.log(action)
try {
const { modalProps, modalType } = action
yield put({ type: MODAL_SUCCESS, modalProps, modalType })
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { combineReducers } from "redux"
import { routerReducer } from "react-router-redux"
import signup from '../signup/reducer'
import signup from '../sign-up/reducer'
import modal from "../modal/reducer"
export default combineReducers({
routing: routerReducer,
Expand Down
4 changes: 3 additions & 1 deletion src/sagas/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { all } from "redux-saga/effects"
import ModalSaga from "../modal/sagas"
import SignupSaga from "../sign-up/sagas"

export default function* rootSagas() {

yield all([
ModalSaga()
ModalSaga(),
SignupSaga()
])
}
12 changes: 0 additions & 12 deletions src/signup/actions.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/signup/constants.js

This file was deleted.

113 changes: 0 additions & 113 deletions src/signup/index.js

This file was deleted.

Loading

0 comments on commit cfb85cd

Please sign in to comment.