Skip to content

Instantly share code, notes, and snippets.

@marcus-sa
Created February 27, 2018 17:19
Show Gist options
  • Save marcus-sa/914a64aad0162564fc11163863ba039f to your computer and use it in GitHub Desktop.
Save marcus-sa/914a64aad0162564fc11163863ba039f to your computer and use it in GitHub Desktop.
Loading Screen
import React, { Component } from 'react'
import { observer, inject } from 'mobx-react'
import * as utils from '../../../utils'
import Game from '../../Game'
import { Image, Progress, Message, Container } from './styled'
@inject(stores => stores.loadingScreen)
@observer
export default class LoadingScreen extends Component {
constructor() {
super()
this.randomPhoto = utils.getRandomInt(1, 30)
}
render() {
const { active, progress } = this.props
return active ? (
<Container>
<Image.Stack src={`//${Game.config.url}/images/loading/stack.png`}>
<Image.Photo src={`//${Game.config.url}/images/loading/photos/${this.randomPhoto}.png`} />
<Image.Frame src={`//${Game.config.url}/images/loading/frame.png`} />
</Image.Stack>
<Message>
I like your t-shirt, uziboozy
</Message>
<Progress.Container>
<Progress.Bar width={progress} />
</Progress.Container>
<Progress.Count>
{progress}
</Progress.Count>
</Container>
) : null
}
}
import styled from 'styled-components'
export const Image = {
Stack: styled.div`
display: block;
background-image: url(${props => props.src});
width: 490px;
height: 434px;
margin: 0 auto;
margin-bottom: 20px;
position: relative;
`,
Photo: styled.div`
height: 320px;
width: 320px;
position: absolute;
left: 95px;
top: 50px;
background-image: url(${props => props.src});
`,
Frame: styled.div`
background-image: url(${props => props.src});
width: 500px;
height: 434px;
position: absolute;
left: 0;
top: 0;
`
}
export const Progress = {
Container: styled.div`
border: 1px solid #fff;
width: 400px;
display: block;
border-radius: 2px;
margin: 0 auto;
background-color: #000;
box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 1);
padding: 2px;
`,
Bar: styled.div`
background-image: linear-gradient(bottom, #8CA1AD 50%, #BACAD3 50%);
background-image: -o-linear-gradient(bottom, #8CA1AD 50%, #BACAD3 50%);
background-image: -moz-linear-gradient(bottom, #8CA1AD 50%, #BACAD3 50%);
background-image: -webkit-linear-gradient(bottom, #8CA1AD 50%, #BACAD3 50%);
background-image: -ms-linear-gradient(bottom, #8CA1AD 50%, #BACAD3 50%);
display: flex;
height: 20px;
width: ${props => props.width}%; /* 400px is parent width, and with padding of both sides it's 2x2=4*/
transition: width 1s;
-webkit-transition: width 1s;
-moz-transition: width 1s;
`,
Count: styled.p`
font-weight: 600;
text-align: center;
display: block;
padding-top: 5px;
color: #8D8E8E;
`
}
export const Container = styled.div`
top: 0;
left: 0;
position: absolute;
background: #0E151C;/*#2a354c;*/
color: #fff;
width: inherit;
height: inherit;
`
export const Message = styled.p`
font-family: 'Ubuntu Condensed';
font-weight: bold;
font-size: 28px;
text-align: center;
color: #FFF;
padding-bottom: 20px;
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment