Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa143ae

Browse files
committed
#000 okan relayout project structure (wip)
1 parent9b7130d commitfa143ae

File tree

19 files changed

+205
-143
lines changed

19 files changed

+205
-143
lines changed

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"react":"^15.2.1",
1010
"react-dom":"^15.2.1",
1111
"react-router":"^2.6.1",
12-
"react-tap-event-plugin":"^1.0.0"
12+
"react-tap-event-plugin":"^1.0.0",
13+
"ts-helpers":"^1.1.1"
1314
},
1415
"devDependencies": {
1516
"html-webpack-plugin":"^2.22.0",

‎src/app/actions/index.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import{ChangeTheme}from"./layout"
2+
3+
export{
4+
ChangeTheme
5+
}

‎src/app/actions/layout.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import{Action}from'redux'
2+
// import { CHANGE_THEME } from '../constants/actionTypes'
3+
4+
// export function changeTheme(): Action {
5+
// return {
6+
// type: CHANGE_THEME
7+
// };
8+
// }
9+
10+
exportclassChangeThemeimplementsAction{
11+
type:string="CHANGE_THEME";
12+
statictype="CHANGE_THEME";
13+
}

‎src/app/actions/root.tsx‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎src/app/app.tsx‎

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,14 @@
11
import*asReactfrom'react';
22
import*asReactDOMfrom'react-dom';
33

4-
import{Provider}from'react-redux'
5-
import{Router,hashHistory}from'react-router'
6-
import{syncHistoryWithStore,routerMiddleware,routerReducer}from'react-router-redux'
7-
8-
importrootReducerfrom"./reducers/root"
9-
104
import*asinjectTapEventPluginfrom'react-tap-event-plugin';
5+
import'ts-helpers'
116

12-
import{StoreBuilder}from"./store/builder"
13-
importroutesfrom"./routes/routes"
7+
importRootfrom'./containers/Root'
148

159

16-
// import * as todos from "./todos"
1710
// Needed for onTouchTap
1811
// http://stackoverflow.com/a/34015469/988941
1912
injectTapEventPlugin();
2013

21-
conststore=newStoreBuilder()
22-
.withMiddleware(routerMiddleware(hashHistory))
23-
.withReducer("routing",routerReducer)
24-
.withReducer("root",rootReducer)
25-
// .withInitialState({
26-
// root: {
27-
// useDarkTheme: false
28-
// }
29-
// })
30-
.build();
31-
32-
consthistory=syncHistoryWithStore(hashHistory,store);
33-
34-
35-
ReactDOM.render(
36-
<Providerstore={store}>
37-
<Routerhistory={history}>
38-
{routes}
39-
</Router>
40-
</Provider>
41-
,document.getElementById('app'));
42-
43-
// todos.test();
14+
ReactDOM.render(<Root/>,document.getElementById('app'));

‎src/app/constants/actionTypes.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
exportconstCHANGE_THEME='CHANGE_THEME'
File renamed without changes.

‎src/app/routes/root.tsx‎renamed to ‎src/app/containers/Layout.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ import { connect } from 'react-redux'
44
importMuiThemeProviderfrom'material-ui/styles/MuiThemeProvider';
55
import{mpTheme}from"../components/mpTheme"
66

7+
import{StoreState}from'../reducers'
78

8-
interfaceRootProps{
9+
interfaceLayoutProps{
910
useDarkTheme:boolean;
1011
}
1112

12-
functionmapStateToProps(state:any){
13+
functionmapStateToProps(state:StoreState):LayoutProps{
1314
return{
14-
useDarkTheme:state.root.useDarkTheme
15+
useDarkTheme:state.layout.useDarkTheme
1516
};
1617
}
1718

18-
classRootextendsReact.Component<RootProps,any>
19+
classLayoutextendsReact.Component<LayoutProps,any>
1920
{
2021
render(){
2122
return(
@@ -28,4 +29,4 @@ class Root extends React.Component<RootProps, any>
2829
}
2930
}
3031

31-
exportdefaultconnect(mapStateToProps)(Root)
32+
exportdefaultconnect(mapStateToProps)(Layout)

‎src/app/routes/public/login/login.tsx‎renamed to ‎src/app/containers/Login.tsx‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import*asReactfrom'react';
2-
import{Router,IRouterContext}from'../../../decorators/router'
2+
3+
import{connect}from'react-redux'
4+
import{Dispatch}from"redux";
5+
import{StoreState}from'../reducers'
6+
import{push}from'react-router-redux'
7+
38
importPaperfrom'material-ui/Paper';
49
importTextFieldfrom'material-ui/TextField';
510
importRaisedButtonfrom'material-ui/RaisedButton';
611

712

8-
@Router
9-
exportdefaultclassLoginextendsReact.Component<any,any>{
13+
interfaceLoginProps{
14+
dispatch:Dispatch<any>;
15+
}
16+
17+
classLoginextendsReact.Component<LoginProps,any>{
1018

1119
constructor(){
1220
super();
@@ -20,14 +28,12 @@ export default class Login extends React.Component<any, any>{
2028
password?:TextField
2129
}
2230

23-
context:IRouterContext;
24-
2531
login(){
2632
varusername=this.refs.username.getValue();
2733
varpassword=this.refs.password.getValue();
2834

2935
localStorage.setItem("auth","auth");
30-
this.context.router.push("dashboard");
36+
this.props.dispatch(push("dashboard"))
3137
}
3238

3339
render(){
@@ -66,4 +72,6 @@ export default class Login extends React.Component<any, any>{
6672
</Paper>
6773
);
6874
}
69-
}
75+
}
76+
77+
exportdefaultconnect()(Login)

‎src/app/routes/secure/main/main.tsx‎renamed to ‎src/app/containers/Main.tsx‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import*asReactfrom'react';
2-
import{Router,IRouterContext}from'../../../decorators/router'
32

43
import{connect}from'react-redux'
5-
import{Dispatch,Action}from"redux";
6-
import{changeTheme}from'../../../actions/root'
4+
import{Dispatch}from"redux";
5+
import{StoreState}from'../reducers'
6+
import{ChangeTheme}from'../actions'
7+
import{push}from'react-router-redux'
78

89
importTogglefrom'material-ui/Toggle';
910
importDrawerfrom'material-ui/Drawer';
@@ -25,18 +26,17 @@ interface MainState {
2526
value?:any
2627
}
2728

28-
functionmapStateToProps(state:any){
29-
return{
30-
useDarkTheme:state.root.useDarkTheme
31-
};
32-
}
33-
3429
interfaceMainProps{
3530
dispatch:Dispatch<any>;
3631
useDarkTheme:boolean;
3732
}
3833

39-
@Router
34+
functionmapStateToProps(state:StoreState){
35+
return{
36+
useDarkTheme:state.layout.useDarkTheme
37+
};
38+
}
39+
4040
classMainextendsReact.Component<MainProps,MainState>{
4141

4242
constructor(){
@@ -50,8 +50,6 @@ class Main extends React.Component<MainProps, MainState> {
5050
this.logout=this.logout.bind(this);
5151
}
5252

53-
context:IRouterContext;
54-
5553
handleToggleSideMenu(open:boolean){
5654
this.setState({
5755
sideBarOpen:open
@@ -60,7 +58,7 @@ class Main extends React.Component<MainProps, MainState> {
6058

6159
logout(){
6260
localStorage.removeItem("auth");
63-
this.context.router.push("dashboard");
61+
this.props.dispatch(push("dashboard"));
6462
}
6563

6664
render(){
@@ -108,7 +106,7 @@ class Main extends React.Component<MainProps, MainState> {
108106

109107
varswithTheme=
110108
<Toggle
111-
onToggle={()=>{this.props.dispatch(changeTheme())}}
109+
onToggle={()=>{this.props.dispatch(newChangeTheme())}}
112110
label={"dark:"+this.props.useDarkTheme}
113111
toggled={this.props.useDarkTheme}
114112
/>;
@@ -143,4 +141,5 @@ class Main extends React.Component<MainProps, MainState> {
143141
}
144142
}
145143

146-
exportdefaultconnect(mapStateToProps)(Main)
144+
exportdefaultconnect(mapStateToProps)(Main)
145+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp