Last active
August 29, 2015 14:27
-
-
Save ernestlv/fb7d196bd9edb24b73ef to your computer and use it in GitHub Desktop.
ReactJS module to compose a page and its different sections and components
This file contains hidden or 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
(function(){ | |
function doComponent(data){ | |
return <div id={data.id}> | |
<h3>{data.title}</h3> | |
<div className="clients">{data.content.clients}</div> | |
<div className="sales"}>{data.content.sales}</div> | |
</div>; | |
} | |
function doContentSet(content){ | |
return <div className="content-set">{content}</div>; | |
} | |
function doSection(id, content){ | |
return <section id={id} className="widget-set">{content}</section>; | |
} | |
function doAsideLogo(){ | |
return <div><img src="company-logo.png" /></div>; | |
} | |
function doAsideOptions(){ | |
var clientsLink = <li><a href="#">Clients</a></li>; | |
var salesLink = <li><a href="#">Sales</a></li>; | |
var locationLink = <li><a href="#">Locations</a></li>; | |
var menu = <ul>{ clientsLink }{ salesLink }{ locationLink }</ul>; | |
return <div>{ menu }</div>; | |
} | |
function doAsideInfo(userName){ | |
var icon = <img src="avatar.png" />; | |
var link = <span>{ userName }</span>; | |
var logout = <a href="#">Logout</a>; | |
var userInfo = <div>{ link }{ logout }</div>; | |
return <div className="sidemenu">{ icon }{ userInfo }</div>; | |
} | |
function doAside(){ | |
return <aside> | |
{ doAsideLogo() } | |
{ doAsideOptions() } | |
{ doAsideInfo('test user') } | |
</aside>; | |
} | |
function doBody(){ | |
return <div class="main"> | |
{ doAside() } | |
<div className="container"> | |
{ doSection("clients", doContentSet([ | |
doComponent(getClients()), | |
])) } | |
{ doSection("sales", doContentSet([ | |
doComponent(getSales()), | |
])) } | |
</div> | |
</div>; | |
} | |
function doHeader(){ | |
return <header>Hello World!</header>; | |
} | |
function doFooter(){ | |
return <footer> | |
<div> | |
<ul> | |
<li><a target="_blank" href="#">Contact Me</a></li> | |
<li><a target="_blank" href="#">About</a></li> | |
</ul> | |
</div> | |
</footer>; | |
} | |
React.render(<div>{ doHeader() }{ doBody() }{ doFooter() }</div>, document.body); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment