1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

code cleanup

This commit is contained in:
muerwre 2019-07-23 19:00:48 +07:00
parent 606c88d777
commit ef71e55543
23 changed files with 108 additions and 109 deletions

View file

@ -0,0 +1,26 @@
import React, { FC } from 'react';
import * as styles from './styles.scss';
interface IProps {
height?: number;
width?: number;
title?: string;
}
const Cell: FC<IProps> = ({
width = 1,
height = 1,
title,
}) => (
<div
className={styles.cell}
style={{
gridRowEnd: `span ${height}`,
gridColumnEnd: `span ${width}`,
}}
>
{ title && <div className={styles.title}>{title}</div> }
</div>
);
export { Cell };

View file

@ -0,0 +1,17 @@
.cell {
padding: $gap / 4;
box-sizing: border-box;
display: flex;
flex: 0 0;
background: $cell_bg;
border-radius: 4px;
@include outer_shadow();
}
.title {
font-family: 'Montserrat';
font-weight: 700;
font-size: 32px;
text-transform: uppercase;
}

View file

@ -1,19 +1,20 @@
import * as React from 'react'; import * as React from 'react';
import classnames from 'classnames'; import classnames from 'classnames';
import { Cell } from "~/components/flow/Cell";
const style = require('./style.scss'); const style = require('./style.scss');
export const TestGrid = () => ( export const TestGrid = () => (
<div className={style.grid_test}> <div className={style.grid_test}>
<div className={classnames([style.cell, style.vert_1, style.hor_4])} key="b" /> <Cell
<div className={classnames([style.cell, style.vert_2, style.hor_1, style.pad_last])} key="a" /> height={1}
<div className={classnames([style.cell, style.vert_1, style.hor_1])} key="c" /> width={4}
<div className={classnames([style.cell, style.vert_1, style.hor_1])} key="d" /> title="Example cell"
<div className={classnames([style.cell, style.vert_2, style.hor_3])} key="e" /> />
<div className={classnames([style.cell, style.vert_2, style.hor_2])} key="f" />
<div className={classnames([style.cell, style.vert_2, style.hor_1])} key="g" /> <Cell />
<div className={classnames([style.cell, style.vert_2, style.hor_1])} key="h" /> <Cell height={2} />
<div className={classnames([style.cell, style.vert_4, style.hor_1])} key="i" /> <Cell width={2} />
<div className={classnames([style.cell, style.vert_1, style.hor_1])} key="j" /> <Cell />
</div> </div>
); );

View file

@ -18,47 +18,6 @@ $cols: $content_width / $cell;
grid-row-gap: $grid_line; grid-row-gap: $grid_line;
} }
.cell {
padding: $gap / 4;
box-sizing: border-box;
display: flex;
flex: 0 0;
background: $cell_bg;
border-radius: 4px;
@include outer_shadow();
//&::after {
// content: ' ';
// background: transparentize(white, 0.9);
// width: 100%;
// height: 100%;
//}
}
.vert_2 {
grid-row-end: span 2;
}
.vert_3 {
grid-row-end: span 3;
}
.vert_4 {
grid-row-end: span 3;
}
.hor_2 {
grid-column-end: span 2;
}
.hor_3 {
grid-column-end: span 3;
}
.hor_4 {
grid-column-end: span 4;
}
.pad_last { .pad_last {
grid-column-end: $cols + 1; grid-column-end: $cols + 1;
} }

View file

@ -1,13 +1,13 @@
import * as React from 'react'; import * as React from 'react';
import { TextInput } from "$components/input/TextInput"; import { TextInput } from "~/components/input/TextInput";
import { Button } from "$components/input/Button"; import { Button } from "~/components/input/Button";
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from "redux"; import { bindActionCreators } from "redux";
import { userSendLoginRequest, userSetLoginError } from "$redux/user/actions"; import { userSendLoginRequest, userSetLoginError } from "~/redux/user/actions";
import { IUserFormStateLogin, IUserState } from "$redux/user/reducer"; import { IUserFormStateLogin, IUserState } from "~/redux/user/reducer";
import { Info } from "$components/input/Info"; import { Info } from "~/components/input/Info";
const login = require('$containers/LoginLayout/style'); const login = require('~/containers/LoginLayout/style');
const style = require('./style.scss'); const style = require('./style.scss');
interface ILoginFormProps { interface ILoginFormProps {

View file

@ -1,7 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { Logo } from "$components/main/Logo"; import { Logo } from "~/components/main/Logo";
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { IUserProfile, IUserState } from "$redux/user/reducer"; import { IUserProfile, IUserState } from "~/redux/user/reducer";
const style = require('./style.scss'); const style = require('./style.scss');

View file

@ -21,6 +21,7 @@ export const SidePane = ({ }) => {
return ( return (
<div className={styles.pane} style={{ left }}> <div className={styles.pane} style={{ left }}>
<div className={classNames(styles.group, 'logo')} /> <div className={classNames(styles.group, 'logo')} />
<div className={styles.group}> <div className={styles.group}>
<div className={styles.btn} /> <div className={styles.btn} />
<div className={styles.btn} /> <div className={styles.btn} />

View file

@ -21,7 +21,8 @@
&:global(.logo) { &:global(.logo) {
color: white; color: white;
height: (54px * 1.5) + $gap / 2; height: (54px * 1.5) + $gap / 2;
background: url('http://vault48.org/pixmaps/logo.png') no-repeat -20px -40px #191919; //background: url('http://vault48.org/pixmaps/logo.png') no-repeat -20px -40px #191919;
background: white;
// #c1543d // #c1543d
background-size: 140px; background-size: 140px;
font-weight: 600; font-weight: 600;

View file

@ -3,10 +3,10 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { hot } from 'react-hot-loader'; import { hot } from 'react-hot-loader';
import { ConnectedRouter } from "connected-react-router"; import { ConnectedRouter } from "connected-react-router";
import { history } from "$redux/store"; import { history } from "~/redux/store";
import { NavLink, Switch, Route } from 'react-router-dom'; import { NavLink, Switch, Route } from 'react-router-dom';
import { FlowLayout } from "$containers/FlowLayout"; import { FlowLayout } from "~/containers/FlowLayout";
import { LoginLayout } from "$containers/LoginLayout"; import { LoginLayout } from "~/containers/LoginLayout";
interface IAppProps {} interface IAppProps {}
interface IAppState {} interface IAppState {}

View file

@ -1,7 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { MainLayout } from "$containers/MainLayout"; import { MainLayout } from "~/containers/MainLayout";
import { HeroPlaceholder } from "$components/flow/HeroPlaceholder"; import { HeroPlaceholder } from "~/components/flow/HeroPlaceholder";
import { TestGrid } from "$components/flow/TestGrid"; import { TestGrid } from "~/components/flow/TestGrid";
// const style = require('./style.scss'); // const style = require('./style.scss');
export const FlowLayout = () => ( export const FlowLayout = () => (

View file

@ -1,7 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { LoginForm } from '$components/login/LoginForm'; import { LoginForm } from '~/components/login/LoginForm';
import { Header } from "$components/main/Header"; import { Header } from "~/components/main/Header";
import { GodRays } from "$components/main/GodRays"; import { GodRays } from "~/components/main/GodRays";
const style = require('./style.scss'); const style = require('./style.scss');

View file

@ -1,10 +1,11 @@
import * as React from 'react'; import * as React from 'react';
import { SidePane } from "$components/main/SidePane"; import { SidePane } from "~/components/main/SidePane";
import { Header } from "~/components/main/Header";
const style = require('./style.scss'); import * as styles from './styles.scss';
export const MainLayout = ({ children }) => ( export const MainLayout = ({ children }) => (
<div className={style.wrapper}> <div className={styles.wrapper}>
{ {
// <Header /> // <Header />
} }

View file

@ -4,6 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Montserrat+Alternates&display=swap" rel="stylesheet">
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
</head> </head>
<body> <body>

View file

@ -8,8 +8,8 @@ import * as React from 'react';
import { render } from 'react-dom'; import { render } from 'react-dom';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react'; import { PersistGate } from 'redux-persist/integration/react';
import { configureStore } from '$redux/store'; import { configureStore } from '~/redux/store';
import App from '$containers/App'; import App from '~/containers/App';
require('./styles/main.scss'); require('./styles/main.scss');

View file

@ -4,8 +4,8 @@ import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage'; import storage from 'redux-persist/lib/storage';
import createSagaMiddleware from 'redux-saga'; import createSagaMiddleware from 'redux-saga';
import { connectRouter } from 'connected-react-router' import { connectRouter } from 'connected-react-router'
import userReducer from '$redux/user/reducer'; import userReducer from '~/redux/user/reducer';
import userSaga from '$redux/user/sagas'; import userSaga from '~/redux/user/sagas';
import { createBrowserHistory } from 'history'; import { createBrowserHistory } from 'history';
import { PersistConfig, Persistor } from "redux-persist/es/types"; import { PersistConfig, Persistor } from "redux-persist/es/types";
import { routerMiddleware } from 'connected-react-router' import { routerMiddleware } from 'connected-react-router'

View file

@ -1,5 +1,5 @@
import { USER_ACTIONS } from "$redux/user/constants"; import { USER_ACTIONS } from "~/redux/user/constants";
import { IUserProfile } from "$redux/user/reducer"; import { IUserProfile } from "~/redux/user/reducer";
export const userSendLoginRequest = ({ export const userSendLoginRequest = ({
username, password username, password

View file

@ -1,6 +1,6 @@
import { api, authMiddleware } from "$utils/api"; import { api, authMiddleware } from "~/utils/api";
import { API } from "$constants/api"; import { API } from "~/constants/api";
import { IApiUser } from "$redux/user/constants"; import { IApiUser } from "~/redux/user/constants";
export const apiUserLogin = ( export const apiUserLogin = (
{ username, password }: { username, password }:

View file

@ -1,6 +1,6 @@
import { createReducer } from 'reduxsauce'; import { createReducer } from 'reduxsauce';
import * as ActionCreators from "$redux/user/actions"; import * as ActionCreators from "~/redux/user/actions";
import { USER_ACTIONS } from "$redux/user/constants"; import { USER_ACTIONS } from "~/redux/user/constants";
export interface IUserProfile { export interface IUserProfile {
id: number, id: number,

View file

@ -1,9 +1,9 @@
import { call, put, takeLatest } from 'redux-saga/effects'; import { call, put, takeLatest } from 'redux-saga/effects';
import { SagaIterator } from 'redux-saga'; import { SagaIterator } from 'redux-saga';
import { IApiUser, USER_ACTIONS, USER_ERRORS, USER_STATUSES } from "$redux/user/constants"; import { IApiUser, USER_ACTIONS, USER_ERRORS, USER_STATUSES } from "~/redux/user/constants";
import * as ActionCreators from '$redux/user/actions'; import * as ActionCreators from '~/redux/user/actions';
import { apiUserLogin } from "$redux/user/api"; import { apiUserLogin } from "~/redux/user/api";
import { userSetLoginError, userSetUser } from "$redux/user/actions"; import { userSetLoginError, userSetUser } from "~/redux/user/actions";
import { push } from 'connected-react-router' import { push } from 'connected-react-router'
function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>): SagaIterator { function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>): SagaIterator {

View file

@ -1,6 +1,6 @@
import axios from 'axios'; import axios from 'axios';
import { API } from "$constants/api"; import { API } from "~/constants/api";
import { store } from '$redux/store'; import { store } from '~/redux/store';
import { push } from "connected-react-router"; import { push } from "connected-react-router";
export const authMiddleware = r => { export const authMiddleware = r => {

View file

@ -5,25 +5,24 @@
"sourceMap": true, "sourceMap": true,
"noImplicitAny": false, "noImplicitAny": false,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"esModuleInterop": true, "removeComments": true,
"module": "commonjs", "module": "commonjs",
"target": "es6", "moduleResolution": "node",
"esModuleInterop": true,
"target": "es2018",
"isolatedModules": true,
"jsx": "react", "jsx": "react",
"lib": [ "es2015", "DOM", "es6" ], "lib": [ "es2015", "DOM", "es6" ],
"baseUrl": "./", "baseUrl": ".",
"paths": { "paths": {
"$components/*": [ "src/components/*" ], "~/*": ["src/*"]
"$containers/*": [ "src/containers/*" ],
"$constants/*": [ "src/constants/*" ],
"$sprites/*": [ "src/sprites/*" ],
"$config/*": [ "./config/*" ],
"$styles/*": [ "src/styles/*" ],
"$redux/*": [ "src/redux/*" ],
"$utils/*": [ "src/utils/*" ]
} }
}, },
"include": [ "include": [
"./src/**/*", "./src/**/*",
"./custom.d.ts" "./custom.d.ts"
],
"exclude": [
"./__tests__/**/*"
] ]
} }

View file

@ -25,14 +25,7 @@ const devtool = isDevelopment ? 'cheap-module-eval-source-map' : 'source-map';
const resolve = { const resolve = {
alias: { alias: {
'react-dom': '@hot-loader/react-dom', 'react-dom': '@hot-loader/react-dom',
$components: join(__dirname, 'src/components'), '~': join(__dirname, 'src'),
$containers: join(__dirname, 'src/containers'),
$constants: join(__dirname, 'src/constants'),
$sprites: join(__dirname, 'src/sprites'),
$config: join(__dirname, './config'),
$styles: join(__dirname, 'src/styles'),
$redux: join(__dirname, 'src/redux'),
$utils: join(__dirname, 'src/utils'),
}, },
extensions: ['*', '.ts', '.tsx', '.js', '.jsx', '.json', '.scss'] extensions: ['*', '.ts', '.tsx', '.js', '.jsx', '.json', '.scss']
}; };
@ -171,7 +164,7 @@ module.exports = () => {
}, },
devServer: { devServer: {
historyApiFallback: true, historyApiFallback: true,
port: 8000, port: 4848,
// host: '192.168.88.40', // host: '192.168.88.40',
contentBase: 'dist', contentBase: 'dist',
publicPath: '/', publicPath: '/',