浏览代码

Added img loaders hadnling

Maxim 5 年之前
父节点
当前提交
425558a2ec

+ 1 - 1
src/components/common/protectedRoute/config.js

@@ -2,7 +2,7 @@ import React from 'react';
 import * as routes from './../../../constants/routes';
 import { lazy } from 'react';
 
-const DeleteUsers = lazy(()=>import('../../user-components/admin-components/createDeleteUser/index'))
+const DeleteUsers =    lazy(()=>import('../../user-components/admin-components/createDeleteUser/index'))
 const LandingPage =    lazy(() => import('./../../public-components/landingPage'));
 const HomePage =       lazy(() => import('./../../user-components/homePage'));
 const SignInPage =     lazy(() => import('./../../../containers/auth/SignInPage'));

+ 0 - 1
src/components/common/protectedRoute/index.js

@@ -45,7 +45,6 @@ export default ({ component: Component, user: { data }, tokenAuth, access, ...re
 
                 return <PermissionDenied />
             }
-
         }}
     />
 )

+ 34 - 22
src/components/public-components/header/index.js

@@ -5,81 +5,93 @@ import * as routes from './../../../constants/routes';
 import token from './../../../utils/token';
 
 export default class header extends Component {
+    /*
+        TODO: 
+        - add toggler for admin panel
+        - disable marking and background hover effect in the nav panel 
+    */
 
     state = {
-        togglerClosed: true
+        navTogglerClosed: true,
+        adminToggleClosed: true
     }
 
-    handleClick = () => {
+    handleLinkClick = () => {
         this.setState({ togglerClosed: true })
     }
 
-    handleToggle = event => {
-        this.setState((prevState) => ({ togglerClosed: !prevState.togglerClosed }))
+    handleNavToggle = () => {
+        this.setState((prevState) => ({ navTogglerClosed: !prevState.navTogglerClosed }))
+    }
+
+    handleAdminToggle = () => {
+        this.setState({
+
+        })
     }
 
     handleSignOut = () => {
-        console.log("signOut", this.props);
         this.props.signOut();
         localStorage.removeItem(token);
     }
 
     render() {
-        const { togglerClosed } = this.state;
+        const { navTogglerClosed, adminToggleClosed } = this.state;
         const { user: { data } } = this.props;
-        const toggleStatus = togglerClosed ? "toggle-status--closed" : "toggle-status--opened";
+        const navToggleStatus = navTogglerClosed ? "nav-toggle-status--closed" : "nav-toggle-status--opened";
+        const adminToggleStatus = adminToggleClosed ? "admin-toggle-status--closed" : "admin-toggle-status--opened";
 
         return (
             <header className="header">
-                <Link onClick={this.handleClick} to={routes.LANDING}>
+                <Link onClick={this.handleLinkClick} to={routes.LANDING}>
                     <h1 className="header__logo">Test.<span className="header__logo--i-letter">i</span>o</h1>
                 </Link>
                 <hr className="header__logo--divider" />
-                <span className="header__toggle-trigger" onClick={this.handleToggle} >
+                <span className="header__toggle-trigger" onClick={this.handleNavToggle} >
                     <span />
                 </span>
                 <div className="header__flex-wrapper">
-                    <nav className={`header__nav ${toggleStatus}`}>
-                        <ul className="header__nav nav__list"  >
+                    <nav className={`header__nav ${navToggleStatus}`}>
+                        <ul className="header__nav nav__list">
                             <li>
-                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.HOME}>
+                                <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.HOME}>
                                     Home
                                 </Link>
                             </li>
                             <li>
-                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.PROFILE}>
+                                <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.PROFILE}>
                                     Profile
                                 </Link>
                             </li>
                             <li>
-                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.TESTS}>
+                                <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.TESTS}>
                                     Test
                                 </Link>
                             </li>
                             <li>
-                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.CATEGORIES}>
+                                <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.CATEGORIES}>
                                     Categories
                                 </Link>
                             </li>
                             {
                                 data && data.is_admin && (
-                                    <React.Fragment>
+                                    <div className={`header__nav ${adminToggleStatus}`}>
                                         <li>
-                                            <Link onClick={this.handleClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_TEST}>
+                                            <Link onClick={this.handleLinkClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_TEST}>
                                                 Create test
                                             </Link>
                                         </li>
                                         <li>
-                                            <Link onClick={this.handleClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_CATEGORY}>
+                                            <Link onClick={this.handleLinkClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_CATEGORY}>
                                                 Create category
                                             </Link>
                                         </li>
                                         <li>
-                                            <Link onClick={this.handleClick} className="header__nav nav__list-item--admin-only" to={routes.DELETE_USER}>
+                                            <Link onClick={this.handleLinkClick} className="header__nav nav__list-item--admin-only" to={routes.DELETE_USER}>
                                                 Delete data
                                             </Link>
                                         </li>
-                                    </React.Fragment>
+                                    </div>
                                 )
                             }
                         </ul>
@@ -90,8 +102,8 @@ export default class header extends Component {
                             !data
                                 ? (
                                     <React.Fragment>
-                                        <Link onClick={this.handleClick} className="header__links--sign-in link--btn link--btn25" to={routes.SIGN_IN}>Sign in</Link>
-                                        <Link onClick={this.handleClick} className="header__links--sign-up link--btn link--btn25" to={routes.SIGN_UP}>Sign up</Link>
+                                        <Link onClick={this.handleLinkClick} className="header__links--sign-in link--btn link--btn25" to={routes.SIGN_IN}>Sign in</Link>
+                                        <Link onClick={this.handleLinkClick} className="header__links--sign-up link--btn link--btn25" to={routes.SIGN_UP}>Sign up</Link>
                                     </React.Fragment>
                                 )
                                 : (

+ 48 - 24
src/components/public-components/landingPage/index.js

@@ -1,28 +1,52 @@
 import React from 'react';
 import { Link } from 'react-router-dom';
+import Spinner from './../../common/spinner';
 import * as routes from './../../../constants/routes'
 
-export default props => (
-    <div className="page landing-page">
-        <div className="container landing-page__about">
-            <h1 className="description__header">
-                We are the powerfull servise providing you the ability to create and manage
-                your own tests, in any categories, choosing your own marking methods.
-            </h1>
-            <hr className="description__divider" />
-            <p className="description__main">
-                You can <span className="description__inline--pretty">share</span>
-                {" "}your test with anybody you'd like: no matter your friend or college or even subordinates
-                can easily pass them, get marks and <span className="description__inline--pretty">share</span> ones!
-            </p>
-        </div>
-        <div className="container landing-page__links-container">
-            <Link to={routes.SIGN_IN} className="landing-page__links landing-page__links--sign-in">
-                Sign in
-            </Link>
-            <Link to={routes.SIGN_UP} className="landing-page__links landing-page__links--sign-up">
-                Sign up
-            </Link>
-        </div>
-    </div>
-)
+export default class LandingPage extends React.Component {
+    state = {
+        isLoading: true
+    }
+
+    componentDidMount() {
+        const banner = new Image();
+        banner.src = "https://structureofintellect.files.wordpress.com/2017/09/bubble-test.jpg";
+        banner.onload = () => this.setState({
+            isLoading: false
+        })
+    }
+
+    render() {
+        const { isLoading } = this.state;
+
+        return (
+            isLoading
+                ? <Spinner />
+                : (
+
+                    <div className="page landing-page">
+                        <div className="container landing-page__about">
+                            <h1 className="description__header">
+                                We are the powerfull servise providing you the ability to create and manage
+                                your own tests, in any categories, choosing your own marking methods.
+                        </h1>
+                            <hr className="description__divider" />
+                            <p className="description__main">
+                                You can <span className="description__inline--pretty">share</span>
+                                {" "}your test with anybody you'd like: no matter your friend or college or even subordinates
+                            can easily pass them, get marks and <span className="description__inline--pretty">share</span> ones!
+                        </p>
+                        </div>
+                        <div className="container landing-page__links-container">
+                            <Link to={routes.SIGN_IN} className="landing-page__links landing-page__links--sign-in">
+                                Sign in
+                        </Link>
+                            <Link to={routes.SIGN_UP} className="landing-page__links landing-page__links--sign-up">
+                                Sign up
+                        </Link>
+                        </div>
+                    </div>
+                )
+        )
+    }
+}

+ 33 - 10
src/components/public-components/notFound/index.js

@@ -1,12 +1,35 @@
 import React from 'react';
 import { Link } from 'react-router-dom';
-import { HOME } from './../../../constants/routes'
-
-export default props => (
-    <div className="page not-found">
-        <img className="not-found__image" src="http://kiwanismiracleleague.org/wp-content/themes/chillibox/media/images/404.png" alt="404" />
-        <hr className="not-found__divider"/>
-        <h1 className="not-found__message">Sorry, but looks like nobody lives here...</h1>
-        <p><Link className="link--btn link--btn-big not-found__link--home" to={HOME}>Go home</Link></p>
-    </div>
-)
+import { HOME } from './../../../constants/routes';
+import Spinner from './../../common/spinner'
+
+export default class NotFound extends React.Component {
+    state = {
+        isLoading: true
+    }
+
+    componentDidMount() {
+        const image = new Image();
+        image.src = 'http://kiwanismiracleleague.org/wp-content/themes/chillibox/media/images/404.png'
+        image.onload = () => this.setState({
+            isLoading: false
+        })
+    }
+
+    render() {
+        const { isLoading } = this.state;
+
+        return (
+            isLoading
+                ?
+                <Spinner />
+                :
+                <div className="page not-found">
+                    <img className="not-found__image" src="http://kiwanismiracleleague.org/wp-content/themes/chillibox/media/images/404.png" alt="404" />
+                    <hr className="not-found__divider" />
+                    <h1 className="not-found__message">Sorry, but looks like nobody lives here...</h1>
+                    <p><Link className="link--btn link--btn-big not-found__link--home" to={HOME}>Go home</Link></p>
+                </div>
+        )
+    }
+}

+ 1 - 1
src/components/user-components/homePage/index.js

@@ -2,6 +2,6 @@ import React from 'react';
 
 export default props => (
     <div className="page">
-        There should be a home component
+        
     </div>
 )

+ 4 - 4
src/constants/index.js

@@ -1,9 +1,9 @@
-export const SIGN_IN_URL = 'http://quiz.maxcrc.de/api/v1/user?';
+export const SIGN_IN_URL = 'https://quiz.maxcrc.de/api/v1/user?';
 export const SIGN_IN_REQUEST = 'SIGN_IN_REQUEST';
 export const SIGN_IN_REQUEST_SUCCESS = 'SIGN_IN_REQUEST_SUCCESS';
 export const SIGN_IN_REQUEST_FAILURE = 'SIGN_IN_REQUEST_FAILURE';
 
-export const SIGN_UP_URL = 'http://quiz.maxcrc.de/api/v1/user';
+export const SIGN_UP_URL = 'https://quiz.maxcrc.de/api/v1/user';
 export const SIGN_UP_REQUEST = 'SIGN_UP_REQUEST';
 export const SIGN_UP_REQUEST_SUCCESS = 'SIGN_UP_REQUEST_SUCCESS';
 export const SIGN_UP_REQUEST_FAILURE = 'SIGN_UP_REQUEST_FAILURE';
@@ -19,7 +19,7 @@ export const USERS_GET_REQUEST_FAILURE = 'USERS_GET_REQUEST_FAILURE';
 
 export const TOKEN_AUTH = 'TOKEN_AUTH';
 
-export const USERS_CHANGE_URL = 'http://quiz.maxcrc.de/api/v1/user/';
+export const USERS_CHANGE_URL = 'https://quiz.maxcrc.de/api/v1/user/';
 export const USERS_CHANGE_REQUEST = 'USERS_CHANGE_REQUEST';
 export const USERS_CHANGE_REQUEST_SUCCESS = 'USERS_CHANGE_REQUEST_SUCCESS';
 export const USERS_CHANGE_REQUEST_FAILURE = 'USERS_CHANGE_REQUEST_FAILURE';
@@ -34,7 +34,7 @@ export const GET_CARDS = 'GET_CARD';
 export const GET_CARDS_SUCCESS = 'GET_CARDS_SUCCESS';
 export const GET_CARDS_FAILURE = 'GET_CARDS_FAILURE';
 
-export const USER_GET ='http://quiz.maxcrc.de/api/v1/user?'
+export const USER_GET ='https://quiz.maxcrc.de/api/v1/user?'
 export const USER_GET_REQUEST = 'USER_GET_REQUEST';
 export const USER_GET_REQUEST_SUCCESS = 'USER_GET_REQUEST_SUCCESS';
 export const USER_GET_REQUEST_FAILURE = 'USER_GET_REQUEST_FAILURE';

+ 1 - 1
src/styles/base/_base.scss

@@ -35,7 +35,7 @@ code {
 // recheck
 
 @media screen and (max-width: 1200px) {
-    * {
+    *:not(nav) {
         transition: none !important;
     }
 }

+ 6 - 1
src/styles/components/_header.scss

@@ -36,6 +36,10 @@
             display: flex;
             margin-bottom: 25px;
 
+            .header-nav {
+                
+            }
+
             li {
                 a {
                     color: $color-white;
@@ -104,7 +108,8 @@
                 bottom: 7px;
             }
         }
-        .toggle-status {
+
+        .nav-toggle-status {
             &--closed {
                 transform: scale(1, 0);
             }