Update, built Contact Page

This commit is contained in:
2018-03-10 21:26:44 +11:00
parent ceb48e104c
commit c24c29c899
33 changed files with 1041 additions and 134 deletions

View File

@ -11,13 +11,14 @@
*/
import React from 'react';
import { Link } from 'react-router-dom';
const FooterLink = function(props) {
return (
<span className="c-footer__link">
<a href={props.to} className="c-footer__link-link">
<Link to={props.to} className="c-footer__link-link">
{props.children}
</a>
</Link>
</span>
)
}
@ -30,16 +31,19 @@ class Footer extends React.Component {
render() {
let year = new Date().getFullYear();
return (
<footer className="c-footer">
<span className="c-footer__copyright">
2012 ~ {year} | Dominic Masters.
</span>
<div className="c-footer__container">
<div className="c-footer__ghost"></div>
<nav className="c-footer__links">
<FooterLink to="/">Privacy Policy</FooterLink>
<FooterLink to="/">Contact Us</FooterLink>
</nav>
</footer>
<footer className="c-footer">
<span className="c-footer__copyright">
2012 ~ {year} | Dominic Masters.
</span>
<nav className="c-footer__links">
<FooterLink to="/">Privacy Policy</FooterLink>
</nav>
</footer>
</div>
)
}
}

View File

@ -0,0 +1,66 @@
/*
* Button
* Button
*
* Dependencies:
* styles/objects/_button.scss
*
* Version:
* 1.0.0 - 2018/03/07
*/
import React from 'react';
import { Link, NavLink } from 'react-router-dom';
class Button extends React.Component {
constructor(props) {
super(props);
}
render() {
let element;
let elementType = "button";
let children = this.props.children;
let type = "button";
let clazz = "o-button";
let props = Object.assign({}, this.props);
//Determine Button type
if(props.submit) {
type = "submit";
delete props.submit;
}
if(props.reset) {
type = "reset";
delete props.reset;
}
props.type = type;//Set onto type
//Link?
if(typeof props.to !== typeof undefined) {
elementType = NavLink;
delete props.type;
}
if(typeof props.href !== typeof undefined) {
elementType = "a";
delete props.type;
}
//Clazzes
if(this.props.style) clazz += " o-button--style-" + this.props.style;
if(this.props.className) clazz += " " + this.props.className;
props.className = clazz;
//Create element
element = React.createElement(
elementType,
props,
children
);
return element;
}
}
export default Button;

View File

@ -0,0 +1,41 @@
/*
* Contact Form
* Contact form.
*
* Version:
* 1.0.0 - 2018/03/06
*/
import React from 'react';
import { Form, InputGroup, TextInput } from './Form';
import Button from './../components/Button';
class ContactForm extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<Form className={this.props.className}>
<InputGroup title="Name">
<TextInput placeholder="Enter your name." />
</InputGroup>
<InputGroup title="Email">
<TextInput type="email" placeholder="Enter your email address." />
</InputGroup>
<InputGroup title="Message">
<TextInput multiline placeholder="Enter your message here." />
</InputGroup>
<Button to="/">Home</Button>
<Button submit>Contact</Button>
</Form>
);
}
}
export default ContactForm;

View File

@ -0,0 +1,84 @@
/*
* Form
* Form.
*
* Version:
* 1.0.0 - 2018/03/06
*/
import React from 'react';
//Form
class Form extends React.Component {
constructor(props) {
super(props);
}
render() {
let clazz = "c-form";
if(this.props.className) clazz += " " + this.props.className;
return (
<form className={clazz}>
{this.props.children}
</form>
)
}
}
//InputGroup
class InputGroup extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="c-form__group">
<label className="c-form__label">{this.props.title}</label>
{ this.props.children }
</div>
);
}
}
//Input
class TextInput extends React.Component {
constructor(props) {
super(props);
}
render() {
let element;
let elementType = "input";
let children;
let props = Object.assign({
}, this.props);
let clazz = "c-form-input ";;
if(this.props.multiline) {
elementType = "textarea";
children = this.props.value;
clazz += "c-form-input--multiline ";
delete props.type;
delete props.multiline;
} else {
props.value = this.props.value;
}
if(this.props.className) clazz += this.props.className;
props.className = clazz;
element = React.createElement(
elementType,
props,
children
);
return element;
}
}
export { Form, InputGroup, TextInput };

View File

@ -11,14 +11,76 @@
import React from 'react';
import FontAwesomeIcon from '@fortawesome/react-fontawesome'
import { NavLink } from 'react-router-dom';
import { faBars } from '@fortawesome/fontawesome-free-solid'
const MenuGroup = function(props) {
return (
<nav className="c-menu__group">
<h1 className="c-menu__group-title">{props.title}</h1>
{props.children}
</nav>
)
}
const MenuItem = function(props) {
return (
<NavLink className="c-menu__item" to={props.to}>
{props.children}
</NavLink>
)
}
class Menu extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false
}
}
toggleMenu() {
this.setState({
open: !this.state.open
});
}
render() {
if(this.state.open) {
document.body.classList.add('is-menu-open');
} else {
document.body.classList.remove('is-menu-open');
}
return (
<nav className="c-menu">
<nav className="c-menu__wrapper open">
<div className="c-menu">
<div className="c-menu__fix">
<div className={"c-menu__container" + (this.state.open === true ? " open": "")}>
<div className="c-menu__body">
<div className="c-menu__fix c-menu__groups">
<MenuGroup title="Get in touch">
<MenuItem to="/contact">Contact Me</MenuItem>
</MenuGroup>
<MenuGroup title="Legal Stuff">
<MenuItem to="/privacy-policy">Privacy Policy</MenuItem>
</MenuGroup>
</div>
</div>
</div>
</div>
</div>
<button type="button" className="c-menu__button" onClick={this.toggleMenu.bind(this)}>
<FontAwesomeIcon icon={faBars} />
</button>
</nav>
)
}

View File

@ -11,15 +11,14 @@
*/
import React from 'react';
import { Link, NavLink } from 'react-router-dom';
import Menu from './Menu';
import FontAwesomeIcon from '@fortawesome/react-fontawesome'
import { faBars } from '@fortawesome/fontawesome-free-solid'
const NavLink = function(props) {
const NavbarLink = function(props) {
return (
<a href={props.to} className="c-navbar__link">
<NavLink exact to={props.to} className="c-navbar__link" activeClassName="active">
<span className="c-navbar__link-text">{props.children}</span>
</a>
</NavLink>
)
}
@ -31,17 +30,15 @@ class Navbar extends React.Component {
render() {
return (
<nav className="c-navbar">
<button type="button" className="c-navbar__menu-button">
<FontAwesomeIcon icon={faBars} />
</button>
<Menu open />
<a href="#" className="c-navbar__logo-container">
<Link to="/" className="c-navbar__logo-container">
<img src={ require('./../../images/logo.svg') } className="c-navbar__logo" alt="domsPlace" />
</a>
</Link>
<div className="c-navbar__links">
<NavLink to="/">Home</NavLink>
<NavLink to="/contact">Contact</NavLink>
<NavbarLink exact to="/">Home</NavbarLink>
<NavbarLink to="/contact">Contact</NavbarLink>
</div>
</nav>
)

View File

@ -0,0 +1,43 @@
/*
* Contact Page
* Not the Homepage.
*
* Dependencies:
* styles/components/_page--style-contact.scss
*
* Version:
* 1.0.0 - 2018/03/03
*/
import React from 'react';
import Page from './../Page';
import PhoneSection from './../sections/PhoneSection';
import BodySection from './../sections/BodySection';
import ContactForm from './../forms/ContactForm';
class ContactPage extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<Page>
<PhoneSection />
<BodySection>
<h1>Contact</h1>
<div className="c-page--style-container__split">
<p className="c-page--style-container__split-part">
Want to get ahold of me and other lorem ipsum dolor?
</p>
<ContactForm className="c-page--style-container__split-part" />
</div>
</BodySection>
</Page>
)
}
}
export default ContactPage;

View File

@ -0,0 +1,28 @@
/*
* BlankPromo
* Blank Promo section.
*
* Dependencies:
* styles/components/_section--style-blank-promo.scss
*
* Version:
* 1.0.0 - 2018/02/24
*/
import React from 'react';
import Section from './../Section';
class BlankPromo extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<Section section="blank-promo" full>
</Section>
)
}
}
export default BlankPromo;

View File

@ -0,0 +1,62 @@
/*
* Poly
* Poly styled section.
*
* Dependencies:
* styles/components/_section--style-phone.scss
*
* Version:
* 1.1.0 - 2018/03/10
*/
import React from 'react';
import ThreeSection from './ThreeSection';
import * as THREE from 'three';
import * as Easing from './../../animation/Easing';
import PhoneModel from './../../3d/phone.json';
class PhoneSection extends React.Component {
constructor(props) {
super(props);
}
onSetup(scene) {
this.loader = new THREE.JSONLoader();
this.data = this.loader.parse(PhoneModel);
this.material = new THREE.MeshLambertMaterial({
color: 0xff66ab
});
this.mesh = new THREE.Mesh(this.data.geometry, this.material);
this.mesh.position.z = 2;
scene.add(this.mesh);
}
getV(j) {
var x = new Date().getTime() % j;
var h = x;
if(x > (j/2)) h = (j/2) - (x - (j/2));
h *= 2;
return Easing.easeInOutQuart(h, 0, 1, j);
}
onRender(diff) {
this.mesh.rotation.set(
THREE.Math.degToRad(this.getV(25000)*5),
THREE.Math.degToRad(this.getV(15000)*10),
THREE.Math.degToRad(this.getV(40000)*20)
);
}
render() {
return (
<ThreeSection
onRender={this.onRender.bind(this)}
onSetup={this.onSetup.bind(this)}
/>
)
}
}
export default PhoneSection;

View File

@ -8,9 +8,8 @@
* Version:
* 1.0.0 - 2018/02/24
*/
import React from 'react';
import Section from './../Section';
import ThreeSection from './ThreeSection';
import * as THREE from 'three';
const CUBES = [
@ -57,24 +56,17 @@ class Poly extends React.Component {
super(props);
}
componentDidMount() {
if(typeof this.scene !== typeof undefined) return;
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(17, window.innerWidth / window.innerHeight, 0.1, 1000 );
this.isAlive = true;
this.render = new THREE.WebGLRenderer({canvas: this.refs.canvas, alpha: true});
this.render.setSize(window.innerWidth, window.innerHeight);
onSetup(scene) {
this.cubes = [];
this.outlines = [];
for(var i = 0; i < CUBES.length; i++) {
let c = CUBES[i];
let geometry = new THREE.BoxGeometry(c.size[0],c.size[1],c.size[2]);
let material = new THREE.MeshLambertMaterial( { color: c.color } );
let cube = new THREE.Mesh(geometry, material);
cube.position.x = c.pos[0];
cube.position.y = c.pos[1];
cube.position.z = c.pos[2];
@ -82,7 +74,8 @@ class Poly extends React.Component {
cube.rotation.y = Math.random()*360;
cube.rotation.z = Math.random()*360;
cube.velocity = c.velocity;
this.scene.add(cube);
scene.add(cube);
this.cubes.push(cube);
if(typeof c.outline !== typeof undefined) {
@ -94,50 +87,13 @@ class Poly extends React.Component {
outlineMesh.scale.multiplyScalar(1.05);
this.outlines[i] = outlineMesh;
this.scene.add( outlineMesh );
scene.add( outlineMesh );
}
}
this.camera.position.z = 5;
this.ambient1 = new THREE.AmbientLight(0xFFCCFF, 0.2);
this.scene.add(this.ambient1);
this.ambient2 = new THREE.AmbientLight(0xFFFFFF, 0.5);
this.scene.add(this.ambient2);
this.light = new THREE.DirectionalLight(0x22BBFF, 0.5);
this.light.position.x = this.camera.position.x;
this.light.position.y = this.camera.position.y;
this.light.position.z = this.camera.position.z + 8;
this.scene.add(this.light);
this.onFrame();
}
componentWillUnmount() {
this.isAlive = false;
}
onFrame() {
if(!this.isAlive) return;
let now = new Date();
let width = this.refs.canvasSpace.clientWidth;
let height = this.refs.canvasSpace.clientHeight;
let diff = now.getTime() - (this.lastTime || new Date()).getTime();
diff = diff / 1000;
let hfov = 95;
let hfovRad = hfov * Math.PI / 180;
let vfovRad = 2*Math.atan(Math.tan(hfovRad/2)*height/width);
this.render.setSize(width, height);
this.camera.aspect = width / height;
this.camera.fov = vfovRad * 180 / Math.PI;
this.camera.updateProjectionMatrix();
requestAnimationFrame(this.onFrame.bind(this));
this.render.render(this.scene, this.camera);
onRender(diff) {
for(var i = 0; i < this.cubes.length; i++) {
let e = this.cubes[i];
let o = this.outlines[i];
@ -153,16 +109,14 @@ class Poly extends React.Component {
o.rotation.z = e.rotation.z;
}
}
this.lastTime = now;
}
render() {
return (
<Section section="poly" full>
<div className="c-section--style-poly__canvas" ref="canvasSpace"></div>
<canvas ref="canvas" className="c-section--style-poly__canvas">
</canvas>
</Section>
<ThreeSection
onRender={this.onRender.bind(this)}
onSetup={this.onSetup.bind(this)}
/>
)
}
}

View File

@ -0,0 +1,91 @@
/*
* ThreeJS Section
* Section for Three JS.
*
* Version:
* 1.0.0 - 2018/03/10
*/
import React from 'react';
import Section from './../Section';
import * as THREE from 'three';
class ThreeSection extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
if(typeof this.scene !== typeof undefined) return;
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(17, window.innerWidth / window.innerHeight, 0.1, 1000 );
this.isAlive = true;
this.render = new THREE.WebGLRenderer({canvas: this.refs.canvas, alpha: true});
this.render.setSize(window.innerWidth, window.innerHeight);
this.camera.position.z = 5;
this.ambient1 = new THREE.AmbientLight(0xFFCCFF, 0.2);
this.scene.add(this.ambient1);
this.ambient2 = new THREE.AmbientLight(0xFFFFFF, 0.5);
this.scene.add(this.ambient2);
this.light = new THREE.DirectionalLight(0x22BBFF, 0.5);
this.light.position.x = this.camera.position.x;
this.light.position.y = this.camera.position.y;
this.light.position.z = this.camera.position.z + 8;
this.scene.add(this.light);
if(typeof this.props.onSetup !== typeof undefined) {
this.props.onSetup(this.scene, this.camera, this.renderer);
}
this.onFrame();
}
componentWillUnmount() {
this.isAlive = false;
}
onFrame() {
if(!this.isAlive) return;
let now = new Date();
let width = this.refs.canvasSpace.clientWidth;
let height = this.refs.canvasSpace.clientHeight;
let diff = now.getTime() - (this.lastTime || new Date()).getTime();
diff = diff / 1000;
let hfov = 95;
let hfovRad = hfov * Math.PI / 180;
let vfovRad = 2*Math.atan(Math.tan(hfovRad/2)*height/width);
this.render.setSize(width, height);
this.render.setPixelRatio(window.devicePixelRatio);
this.camera.aspect = width / height;
this.camera.fov = vfovRad * 180 / Math.PI;
this.camera.updateProjectionMatrix();
requestAnimationFrame(this.onFrame.bind(this));
if(typeof this.props.onRender !== typeof undefined) {
this.props.onRender(diff);
}
this.render.render(this.scene, this.camera);
this.lastTime = now;
}
render() {
return (
<Section section="three" full>
<div className="c-section--style-three__canvas" ref="canvasSpace"></div>
<canvas ref="canvas" className="c-section--style-three__canvas">
</canvas>
</Section>
)
}
}
export default ThreeSection;