mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
intial commit
This commit is contained in:
parent
1d82241d2c
commit
44e10599d7
25 changed files with 17375 additions and 0 deletions
14
src/components/SomeComponent/index.tsx
Normal file
14
src/components/SomeComponent/index.tsx
Normal file
|
@ -0,0 +1,14 @@
|
|||
import * as React from 'react';
|
||||
const styles = require("./styles.scss");
|
||||
|
||||
interface ISomeComponentProps {}
|
||||
|
||||
export const SomeComponent: React.FunctionComponent<ISomeComponentProps> = (props) => {
|
||||
const { } = props;
|
||||
|
||||
return (
|
||||
<div className={styles.main}>This is some component</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SomeComponent;
|
2
src/components/SomeComponent/styles.scss
Normal file
2
src/components/SomeComponent/styles.scss
Normal file
|
@ -0,0 +1,2 @@
|
|||
.main {
|
||||
}
|
48
src/containers/App.tsx
Normal file
48
src/containers/App.tsx
Normal file
|
@ -0,0 +1,48 @@
|
|||
import * as React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { hot } from 'react-hot-loader';
|
||||
import { SomeComponent } from '$components/SomeComponent';
|
||||
import { ConnectedRouter } from "connected-react-router";
|
||||
import { history } from "$redux/store";
|
||||
import { NavLink, Switch, Route } from 'react-router-dom';
|
||||
|
||||
interface IAppProps {}
|
||||
interface IAppState {}
|
||||
|
||||
class Component extends React.Component<IAppProps, IAppState> {
|
||||
state = { };
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ConnectedRouter history={history}>
|
||||
<div>
|
||||
<div>
|
||||
<NavLink exact to="/" activeClassName="active">
|
||||
Root
|
||||
</NavLink>
|
||||
<NavLink to="/somepath" activeClassName="active">
|
||||
Something
|
||||
</NavLink>
|
||||
</div>
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path="/"
|
||||
component={SomeComponent}
|
||||
/>
|
||||
<Route
|
||||
path="/somepath"
|
||||
component={SomeComponent}
|
||||
/>
|
||||
</Switch>
|
||||
</div>
|
||||
</ConnectedRouter>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, props) => ({ });
|
||||
const mapDispatchToProps = (dispatch) => bindActionCreators({}, dispatch);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(hot(module)(Component));
|
13
src/index.html
Normal file
13
src/index.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
25
src/index.tsx
Normal file
25
src/index.tsx
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
LAYOUT PACKING:
|
||||
https://github.com/rexxars/react-layout-pack
|
||||
https://github.com/gxapplications/react-gridifier
|
||||
https://github.com/STRML/react-grid-layout
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import { PersistGate } from 'redux-persist/integration/react';
|
||||
import { configureStore } from '$redux/store';
|
||||
import App from '$containers/App';
|
||||
|
||||
require('./styles/main.scss');
|
||||
|
||||
const { store, persistor } = configureStore();
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<PersistGate loading={null} persistor={persistor}>
|
||||
<App />
|
||||
</PersistGate>
|
||||
</Provider>,
|
||||
document.getElementById('app')
|
||||
);
|
45
src/redux/store.ts
Normal file
45
src/redux/store.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { createStore, applyMiddleware, combineReducers, compose, Store } from 'redux';
|
||||
|
||||
import { persistStore, persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import { connectRouter } from 'connected-react-router'
|
||||
import userReducer from '$redux/user/reducer';
|
||||
import userSaga from '$redux/user/sagas';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { PersistConfig, Persistor } from "redux-persist/es/types";
|
||||
import { routerMiddleware } from 'connected-react-router'
|
||||
|
||||
const userPersistConfig: PersistConfig = {
|
||||
key: 'user',
|
||||
whitelist: ['user', 'logo', 'provider', 'speed'],
|
||||
storage,
|
||||
};
|
||||
|
||||
export const sagaMiddleware = createSagaMiddleware();
|
||||
export const history = createBrowserHistory();
|
||||
|
||||
const composeEnhancers =
|
||||
typeof window === 'object' &&
|
||||
(<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||
: compose;
|
||||
|
||||
export const store = createStore(
|
||||
combineReducers({
|
||||
user: persistReducer(userPersistConfig, userReducer),
|
||||
router: connectRouter(history),
|
||||
}),
|
||||
composeEnhancers(applyMiddleware(
|
||||
routerMiddleware(history),
|
||||
sagaMiddleware
|
||||
))
|
||||
);
|
||||
|
||||
export function configureStore(): { store: Store<any>, persistor: Persistor } {
|
||||
sagaMiddleware.run(userSaga);
|
||||
|
||||
const persistor = persistStore(store);
|
||||
|
||||
return { store, persistor };
|
||||
}
|
3
src/redux/user/actions.ts
Normal file
3
src/redux/user/actions.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { USER_ACTIONS } from "$redux/user/constants";
|
||||
|
||||
export const someAction = () => ({ type: USER_ACTIONS.SOME_ACTION });
|
3
src/redux/user/constants.ts
Normal file
3
src/redux/user/constants.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export const USER_ACTIONS = {
|
||||
SOME_ACTION: 'SOME_ACTION',
|
||||
};
|
28
src/redux/user/reducer.ts
Normal file
28
src/redux/user/reducer.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { createReducer } from 'reduxsauce';
|
||||
import * as ACTIONS from "$redux/user/actions";
|
||||
import { USER_ACTIONS } from "$redux/user/constants";
|
||||
|
||||
export type IRootState = Readonly<{
|
||||
// key: string
|
||||
}>;
|
||||
|
||||
type UnsafeReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
|
||||
interface ActionHandler<T> {
|
||||
(state: IRootState, payload: UnsafeReturnType<T>): IRootState;
|
||||
}
|
||||
|
||||
const someActionHandler: ActionHandler<typeof ACTIONS.someAction> = (state) => {
|
||||
return { ...state };
|
||||
};
|
||||
|
||||
const HANDLERS = {
|
||||
[USER_ACTIONS.SOME_ACTION]: someActionHandler,
|
||||
};
|
||||
|
||||
const INITIAL_STATE: IRootState = {
|
||||
// key: val,
|
||||
// key: val,
|
||||
// key: val
|
||||
};
|
||||
|
||||
export default createReducer(INITIAL_STATE, HANDLERS);
|
25
src/redux/user/sagas.ts
Normal file
25
src/redux/user/sagas.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { call, put, takeEvery, takeLatest } from 'redux-saga/effects';
|
||||
import { delay } from 'redux-saga';
|
||||
import { USER_ACTIONS } from "$redux/user/constants";
|
||||
|
||||
// Worker Saga for SET_EDITOR_LOCATION_INPUT reducer
|
||||
/*
|
||||
function* fetchSuggestions({ payload }) {
|
||||
const { value } = payload;
|
||||
|
||||
yield delay(300);
|
||||
try {
|
||||
const results = yield call(someFunction, arguments);
|
||||
yield put({ type: TYPES.ANOTHER_ACTION, payload: { results } });
|
||||
} catch (e) {
|
||||
yield put({ type: TYPES.ANOTHER_ACTION, payload: { results } });
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
function* mySaga() {
|
||||
// fetch autocompletion on location input
|
||||
//yield takeLatest(TYPES.ACTION, function);
|
||||
}
|
||||
|
||||
export default mySaga;
|
1
src/styles/colors.scss
Normal file
1
src/styles/colors.scss
Normal file
|
@ -0,0 +1 @@
|
|||
|
2
src/styles/global.scss
Normal file
2
src/styles/global.scss
Normal file
|
@ -0,0 +1,2 @@
|
|||
body {
|
||||
}
|
2
src/styles/main.scss
Normal file
2
src/styles/main.scss
Normal file
|
@ -0,0 +1,2 @@
|
|||
@import 'reset.scss';
|
||||
@import 'global.scss';
|
48
src/styles/reset.scss
Normal file
48
src/styles/reset.scss
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* http://meyerweb.com/eric/tools/css/reset/
|
||||
v2.0 | 20110126
|
||||
License: none (public domain)
|
||||
*/
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
1
src/styles/variables.scss
Normal file
1
src/styles/variables.scss
Normal file
|
@ -0,0 +1 @@
|
|||
@import 'colors';
|
Loading…
Add table
Add a link
Reference in a new issue