Skip to content

Commit

Permalink
新增404页面和文字特效
Browse files Browse the repository at this point in the history
  • Loading branch information
z-9527 committed Aug 2, 2018
1 parent 26039fa commit f9e7f25
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 28 deletions.
59 changes: 31 additions & 28 deletions src/components/ContentMain/index.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
import React from 'react'
import {withRouter,Switch,Redirect} from 'react-router-dom'
import { withRouter, Switch, Redirect } from 'react-router-dom'
import AsyncComponent from '../../utils/AsyncComponent'
import PrivateRoute from '../PrivateRoute'

const Home = AsyncComponent(()=>import('../../routes/Home/index'))
const Home = AsyncComponent(() => import('../../routes/Home/index'))

//基本组件Demo
const ButtonDemo = AsyncComponent(()=>import('../../routes/General/ButtonDemo/index'))
const IconDemo = AsyncComponent(()=>import('../../routes/General/IconDemo/index'))
const ButtonDemo = AsyncComponent(() => import('../../routes/General/ButtonDemo/index'))
const IconDemo = AsyncComponent(() => import('../../routes/General/IconDemo/index'))

//导航组件Demo
const DropdownDemo = AsyncComponent(()=>import('../../routes/Navigation/DropdownDemo/index'))
const MenuDemo = AsyncComponent(()=>import('../../routes/Navigation/MenuDemo/index'))
const StepsDemo = AsyncComponent(()=>import('../../routes/Navigation/StepsDemo/index'))
const DropdownDemo = AsyncComponent(() => import('../../routes/Navigation/DropdownDemo/index'))
const MenuDemo = AsyncComponent(() => import('../../routes/Navigation/MenuDemo/index'))
const StepsDemo = AsyncComponent(() => import('../../routes/Navigation/StepsDemo/index'))

//输入组件Demo
const FormDemo1 = AsyncComponent(()=>import('../../routes/Entry/FormDemo/FormDemo1'))
const FormDemo2 = AsyncComponent(()=>import('../../routes/Entry/FormDemo/FormDemo2'))
const UploadDemo = AsyncComponent(()=>import('../../routes/Entry/UploadDemo/index'))
const FormDemo1 = AsyncComponent(() => import('../../routes/Entry/FormDemo/FormDemo1'))
const FormDemo2 = AsyncComponent(() => import('../../routes/Entry/FormDemo/FormDemo2'))
const UploadDemo = AsyncComponent(() => import('../../routes/Entry/UploadDemo/index'))

//显示组件Demo
const CarouselDemo = AsyncComponent(()=>import('../../routes/Display/CarouselDemo/index'))
const CollapseDemo = AsyncComponent(()=>import('../../routes/Display/CollapseDemo/index'))
const ListDemo = AsyncComponent(()=>import('../../routes/Display/ListDemo/index'))
const TableDemo = AsyncComponent(()=>import('../../routes/Display/TableDemo/index'))
const TabsDemo = AsyncComponent(()=>import('../../routes/Display/TabsDemo/index'))
const CarouselDemo = AsyncComponent(() => import('../../routes/Display/CarouselDemo/index'))
const CollapseDemo = AsyncComponent(() => import('../../routes/Display/CollapseDemo/index'))
const ListDemo = AsyncComponent(() => import('../../routes/Display/ListDemo/index'))
const TableDemo = AsyncComponent(() => import('../../routes/Display/TableDemo/index'))
const TabsDemo = AsyncComponent(() => import('../../routes/Display/TabsDemo/index'))

//反馈组件Demo
const SpinDemo = AsyncComponent(()=>import('../../routes/Feedback/SpinDemo/index'))
const ModalDemo = AsyncComponent(()=>import('../../routes/Feedback/ModalDemo/index'))
const NotificationDemo = AsyncComponent(()=>import('../../routes/Feedback/NotificationDemo/index'))
const SpinDemo = AsyncComponent(() => import('../../routes/Feedback/SpinDemo/index'))
const ModalDemo = AsyncComponent(() => import('../../routes/Feedback/ModalDemo/index'))
const NotificationDemo = AsyncComponent(() => import('../../routes/Feedback/NotificationDemo/index'))

//其它
const AnimationDemo = AsyncComponent(()=>import('../../routes/Other/AnimationDemo/index'))
const GalleryDemo = AsyncComponent(()=>import('../../routes/Other/GalleryDemo/index'))
const DraftDemo = AsyncComponent(()=>import('../../routes/Other/DraftDemo/index'))
const ChartDemo = AsyncComponent(()=>import('../../routes/Other/ChartDemo/index'))
const LoadingDemo = AsyncComponent(()=>import('../../routes/Other/LoadingDemo/index'))
//关于

const AnimationDemo = AsyncComponent(() => import('../../routes/Other/AnimationDemo/index'))
const GalleryDemo = AsyncComponent(() => import('../../routes/Other/GalleryDemo/index'))
const DraftDemo = AsyncComponent(() => import('../../routes/Other/DraftDemo/index'))
const ChartDemo = AsyncComponent(() => import('../../routes/Other/ChartDemo/index'))
const LoadingDemo = AsyncComponent(() => import('../../routes/Other/LoadingDemo/index'))
const ErrorPage = AsyncComponent(() => import('../../routes/Other/ErrorPage/index'))
const SpringText = AsyncComponent(() => import('../../routes/Other/SpringText/index'))

//关于

@withRouter
class ContentMain extends React.Component{
render(){
class ContentMain extends React.Component {
render () {
return (
<div style={{padding:16,position:'relative'}}>
<div style={{padding: 16, position: 'relative'}}>
<Switch>
<PrivateRoute exact path='/home' component={Home}/>

Expand Down Expand Up @@ -75,6 +76,8 @@ class ContentMain extends React.Component{
<PrivateRoute exact path='/home/other/draft' component={DraftDemo}/>
<PrivateRoute exact path='/home/other/chart' component={ChartDemo}/>
<PrivateRoute exact path='/home/other/loading' component={LoadingDemo}/>
<PrivateRoute exact path='/home/other/404' component={ErrorPage}/>
<PrivateRoute exact path='/home/other/springText' component={SpringText}/>

<Redirect exact from='/' to='/home'/>
</Switch>
Expand Down
2 changes: 2 additions & 0 deletions src/components/SiderNav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const menus = [
{key:'/home/other/draft',title:'富文本',icon:''},
{key:'/home/other/chart',title:'图表',icon:''},
{key:'/home/other/loading',title:'加载动画',icon:''},
{key:'/home/other/404',title:'404',icon:''},
{key:'/home/other/springText',title:'弹性文字',icon:''},
]
},
{
Expand Down
71 changes: 71 additions & 0 deletions src/routes/Other/ErrorPage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react'
import './style.css'

class ErrorPage extends React.Component {
componentDidMount(){
this.error404()
}
componentWillUnmount(){
window.cancelAnimationFrame(this.myReq)
}
error404 = ()=>{
const c = document.getElementById("canv");
const $ = c.getContext("2d");
const w = c.width;
const h = c.height;
const id = $.createImageData(w, h);
const _this = this
function draw() {
_this.myReq = window.requestAnimationFrame(draw);
let r;
for (let p = 4 * (w * h - 1); p >= 0; p -= 4) {
r = Math.random();
id.data[p] = id.data[p+1] = id.data[p+2] = 255 * Math.pow(r, 1.6);
id.data[p+3] = 255;
}
$.putImageData(id, 0, 0);
}
draw();
}
render () {
return (
<div style={styles.bg} className='error404'>
<svg className="overlay text" viewBox="0 0 900 400">
<symbol id="main">
<text textAnchor="middle" x="50%" y="50%" dy="0.25em" className="txt">404</text>
<text textAnchor="middle" x="50%" y="90%" dy="0.25em" className="txt2">Not Found</text>
</symbol>
<mask id="msk" maskUnits="userSpaceOnUse" maskContentUnits="userSpaceOnUse">
<rect width="100%" height="100%" className="wrap">
</rect>
<use xlinkHref="#main" className="mtxt"/>
</mask>
</svg>
<section>
<h1 href="#">
<div className="fill">
<canvas id="canv" width="460" height="360" style={{background: 'hsla(0, 0, 0, 1)'}}>
</canvas>
</div>
<svg viewBox="0 0 900 400" className="inv">
<rect width="100%" height="100%" mask="url(#msk)"
className="rect"/>
<use xlinkHref="#main" className="clear"/>
</svg>
</h1>
</section>
</div>
)
}
}

const styles = {
bg: {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: 'calc(100vh - 64px)',
},
}
export default ErrorPage
92 changes: 92 additions & 0 deletions src/routes/Other/ErrorPage/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* latin-ext */
@font-face {
font-family: 'Black Ops One';
font-style: normal;
font-weight: 400;
src: local('Black Ops One Regular'), local('BlackOpsOne-Regular'), url(https://fonts.gstatic.com/s/blackopsone/v9/qWcsB6-ypo7xBdr6Xshe96H3aDXbtxsis4IxXw.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Black Ops One';
font-style: normal;
font-weight: 400;
src: local('Black Ops One Regular'), local('BlackOpsOne-Regular'), url(https://fonts.gstatic.com/s/blackopsone/v9/qWcsB6-ypo7xBdr6Xshe96H3aDvbtxsis4I.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.error404 {
background: #e6e6e6;
font-weight: bold;
font-size: 1em;
display: flex;
justify-content: center;
flex-direction: column;
font-family: 'Black Ops One', cursive;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.error404 canvas {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}

.error404 .text .wrap {
fill: #FFF;
}

.error404 .overlay {
height: 0;
width: 0;
overflow: hidden;
position: absolute;
}
.error404 .overlay .txt {
font-size: 14rem;
text-transform: uppercase;
font-weight: 900;
letter-spacing: -.5rem;
text-shadow: 0 -3px 0 #0d0d0d, 0 6px 8px rgba(13, 13, 13, 0.55), 0 9px 10px rgba(13, 13, 13, 0.25);
}
.error404 .overlay .txt2 {
font-size: 4rem;
}

.error404 section {
align-self: center;
}

.error404 h1 {
position: relative;
font-size: 8em;
font-weight: bold;
line-height: 1;
display: inline-block;
width: 900px;
height: 400px;
}
.error404 h1 .fill {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.error404 h1 .inv {
position: absolute;
width: 900px;
height: 400px;
top: 0;
left: 0;
}
.error404 h1 .rect {
fill: #e6e6e6;
}
.error404 h1 .clear {
fill: transparent;
}
Loading

0 comments on commit f9e7f25

Please sign in to comment.