Last active
May 3, 2017 19:17
-
-
Save dschinkel/94db9bd80a556ff4d0ed7e1385cfe02a to your computer and use it in GitHub Desktop.
A few examples of React components from WeDoTDD.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a "dumb/presentational" React Component | |
import CompanyHeader from './CompanyHeader'; | |
import CompanyProfile from './CompanyProfile'; | |
import InterviewContentMain from './InterviewContentMain'; | |
import Main from '../Main'; | |
import MainLayout from '../MainLayout'; | |
import React, { Component } from 'react'; | |
export default class Interview extends Component{ | |
render(){ | |
const company = this.props.companies; | |
return ( | |
<Main> | |
<MainLayout title={title}> | |
<div> | |
<div id='ft-interview'> | |
<div className="panel vertical-space"> | |
<CompanyHeader company={company}/> | |
<CompanyProfile company={company}/> | |
<InterviewContentMain company={company}/> | |
</div> | |
</div> | |
</div> | |
</MainLayout> | |
</Main> | |
) | |
} | |
} |
RelatedLinks Component (the Related Links section you see in an interview):
import React, { Component } from 'react';
export default class RelatedLinks extends Component {
render(){
const {company} = this.props
return (
<div className="all-100 padding-bottom-200">
{ company.interview.relatedLinks &&
<div id="ft-relatedLinks">
<p id="relatedLinks" className="section-heading bold padding-top-20 font-22">Related Links</p>
<div className="all-100 padding-left-30 align-left">
<div className="all-100">
<Links links={company.interview.relatedLinks}/>
</div>
</div>
</div>
}
</div>
)
}
}
export class Links extends Component {
render(){
const {links} = this.props;
let formattedLink,
formattedLinkGroup,
formattedLinks = [],
formattedLinkGroups = []
for (let [i, link] of links.entries()) {
formattedLink = <li key={i}><a href={link.href} target="_blank"><span className="black small">{link.text}</span></a></li>;
formattedLinkGroup = <div key={i} className="all-40"><ul className="noStyle line-height-1 margin-0">{formattedLinks}</ul></div>;
formattedLinks.push(formattedLink);
if ((++i) % 12 === 0) {
formattedLinkGroups.push(formattedLinkGroup);
formattedLinks = [];
}
}
if(formattedLinkGroups.length === 0){
formattedLinkGroups.push(formattedLinkGroup);
}
return(<div className="ft-links column-group">{formattedLinkGroups}</div>)
}
}
using NGINX
{
"root": "dist/client/",
"routes": {
"/**": "index.html"
},
"proxies": {
"/api/": {
"origin": "https://wedotdd-service.herokuapp.com"
}
}
}
MainLayout component
const DocumentTitle = require('react-document-title');
import React, {Component} from 'react';
import Header from './Header';
import TopNav from './TopNav';
export default class MainLayout extends Component{
render() {
return (
<div className="wrap">
<div className="ink-grid">
<Header />
<DocumentTitle title={this.props.title} />
<div className='ft-homepage'>
<TopNav />
{this.props.children}
</div>
</div>
</div>
)
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
index.html