Gatsby: How to insert data from frontmatter (Mdx file) into a component - reactjs

I have a series of .mdx files that contain the same information but on different sites (ex: title="aswan"; title="rome" etc). These files are located in a folder called "metadata".
I need to insert mdx information into a component (OurSites.js) that goes to form the HomePage of the site (index.js).
This is the content of the OurSites.js component:
import React from "react";
import styled from "styled-components";
import Card from "react-bootstrap/Card";
import { Container, Row, Col } from "react-bootstrap";
import Button from "react-bootstrap/Button";
import TitleR from "../Title/TitleR";
import Card1 from "../../metadata/1-home-page/images/1-card.jpg";
import Card2 from "../../metadata/1-home-page/images/2-card.jpg";
const Sites = () => {
return (
<Wrapper>
<section className="section bottom-slant-gray">
<Container>
<TitleR title="our sites" />
<Row xs={1} md={2}>
<Col>
<Card>
<Card.Img variant="top" fluid={true} src={Card1} />
<Card.Body>
<Card.Title>First Step</Card.Title>
<Button variant="primary">
<a href="https://docs.paths-erc.eu/data/">
go to paths repository
</a>
</Button>
<Card.Text>
Collection and georeferencing on GIS platform of most of the
historical cartography of Egypt and plans of the main
temple/church/basilica complexes
</Card.Text>
</Card.Body>
</Card>
</Col>
<Col>
<Card>
<Card.Img variant="top" src={Card2} />
<Card.Body>
<Card.Title>Second Step</Card.Title>
<Button variant="primary">
<a href="https://docs.paths-erc.eu/data/svp">
go to spv protocol
</a>
</Button>
<Card.Text>
Vectorization of geo-referenced plants on GIS platform using
a protocol (SPV) developed by PAThs team members
</Card.Text>
</Card.Body>
</Card>
</Col>
</Row>
<Row xs={1} md={2}>
<Col>
<Card>
<Card.Img variant="top" fluid={true} src={Card1} />
<Card.Body>
<Card.Title>First Step</Card.Title>
<Button variant="primary">
<a href="https://docs.paths-erc.eu/data/">
go to paths repository
</a>
</Button>
<Card.Text>
Collection and georeferencing on GIS platform of most of the
historical cartography of Egypt and plans of the main
temple/church/basilica complexes
</Card.Text>
</Card.Body>
</Card>
</Col>
<Col>
<Card>
<Card.Img variant="top" src={Card2} />
<Card.Body>
<Card.Title>Second Step</Card.Title>
<Button variant="primary">
<a href="https://docs.paths-erc.eu/data/svp">
go to spv protocol
</a>
</Button>
<Card.Text>
Vectorization of geo-referenced plants on GIS platform using
a protocol (SPV) developed by PAThs team members
</Card.Text>
</Card.Body>
</Card>
</Col>
</Row>
<Row xs={1} md={2}>
<Col>
<Card>
<Card.Img variant="top" fluid={true} src={Card1} />
<Card.Body>
<Card.Title>First Step</Card.Title>
<Button variant="primary">
<a href="https://docs.paths-erc.eu/data/">
go to paths repository
</a>
</Button>
<Card.Text>
Collection and georeferencing on GIS platform of most of the
historical cartography of Egypt and plans of the main
temple/church/basilica complexes
</Card.Text>
</Card.Body>
</Card>
</Col>
<Col>
<Card>
<Card.Img variant="top" src={Card2} />
<Card.Body>
<Card.Title>Second Step</Card.Title>
<Button variant="primary">
<a href="https://docs.paths-erc.eu/data/svp">
go to spv protocol
</a>
</Button>
<Card.Text>
Vectorization of geo-referenced plants on GIS platform using
a protocol (SPV) developed by PAThs team members
</Card.Text>
</Card.Body>
</Card>
</Col>
</Row>
</Container>
</section>
</Wrapper>
);
};
const Wrapper = styled.section`
a {
color: rgb(130, 36, 51);
font-family: "Raleway", sans-serif;
font-weight: bolder;
font-size: 0.8rem;
line-height: 1rem;
text-transform: uppercase;
display: swap;
text-decoration: none;
}
a:hover {
color: rgb(130, 36, 51);
font-family: "Raleway", sans-serif;
font-weight: bolder;
font-size: 0.8rem;
line-height: 1rem;
text-transform: uppercase;
display: swap;
text-decoration: none;
}
button {
text-align: right;
margin: 3% 0 3% 0;
background: rgb(130, 36, 51, 0.2);
border-color: rgb(130, 36, 51, 0.3);
}
button:hover {
background: none;
border-color: transparent;
}
section {
padding: 4em 5;
position: relative;
z-index: 2;
}
.card {
border: none;
}
.card-body {
text-align: right;
font-family: "Raleway", sans-serif;
font-size: 1rem;
line-height: 1.7rem;
display: swap;
}
.card-title {
font-weight: bolder;
text-transform: uppercase;
}
.container {
padding-bottom: 5%;
}
section {
padding: 0;
position: relative;
z-index: 2;
}
.bottom-slant-gray {
position: relative;
padding-bottom: 10%;
background-color: #f8f9fa;
}
.bottom-slant-gray:before {
content: "";
width: 100%;
height: 240px;
background: #f8f9fa;
z-index: -1;
top: 0px;
background-color: #f8f9fa;
left: 0;
position: absolute;
-webkit-transform: skewY(-6deg);
-ms-transform: skewY(-6deg);
transform: skewY(-6deg);
-webkit-transform-origin: top left;
-ms-transform-origin: top left;
transform-origin: top left;
}
.row {
padding-top: 3%;
}
.sites-img {
border-top-left-radius: var(--radius);
border-top-right-radius: var(--radius);
height: 19rem;
z-index: 1;
}
.sites-img::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom right, var(--clr-primary-5), #222);
opacity: 0.85;
transition: var(--transition);
}
`;
export default Sites;
Where there is text, such as in CardText, I would like to insert the contents of mdx files.
Querying the data on Graphql gave this result:
export const query = graphql`
{
allMdx(limit: 8, sort: { fields: frontmatter___title, order: ASC }) {
nodes {
id
frontmatter {
title
status
typology
image {
childImageSharp {
gatsbyImageData
}
}
}
excerpt
}
}
}
`;
This is the content of the index.js page inside which is present also the OurSite.js component:
import * as React from "react";
import Layout from "../components/Layout";
import Slider from "../components/Slider";
import About from "../components/Home/About";
import Methods from "../components/Home/Methods";
import OurSites from "../components/Home/OurSites";
import { graphql } from "gatsby";
// markup
const IndexPage = () => {
return (
<Layout>
<Slider />
<About />
<Methods />
<OurSites />
</Layout>
);
};
export const query = graphql`
{
allMdx(limit: 8, sort: { fields: frontmatter___title, order: ASC }) {
nodes {
id
frontmatter {
title
status
typology
image {
childImageSharp {
gatsbyImageData
}
}
}
excerpt
}
}
}
`;
export default IndexPage;
This is what the component looks like:

You have two options:
Using page queries
Using static queries (useStaticQuery hook)
With the first option, your queries must go on a page (hence the name) and you need to drill down the props containing your data to each desired component. Because of you already have the query set, you just need to:
import * as React from "react";
import Layout from "../components/Layout";
import Slider from "../components/Slider";
import About from "../components/Home/About";
import Methods from "../components/Home/Methods";
import OurSites from "../components/Home/OurSites";
import { graphql } from "gatsby";
// markup
const IndexPage = ({ data }) => {
console.log("your props.data is inside data: " data);
return (
<Layout>
<Slider />
<About />
<Methods />
<OurSites sites={data.allMdx.nodes}/>
</Layout>
);
};
export const query = graphql`
{
allMdx(limit: 8, sort: { fields: frontmatter___title, order: ASC }) {
nodes {
id
frontmatter {
title
status
typology
image {
childImageSharp {
gatsbyImageData
}
}
}
excerpt
}
}
}
`;
export default IndexPage;
Your queried data (via GraphQL) is inside props.data (destructured as data). You can drill down the site's information by data.allMdx.nodes (which is an array). So in your OurSites component, you only need to get the props (props.sites) and loop through them to display dynamically your data.
With the useStaticQuery the approach is exactly the same but the data can be stores somewhere else (in a custom hook or in the inner OurSites component).

Related

I’m building a portfolio but the sidebar component is not showing on any of the pages?

The sidebar is not showing on the home page of my portfolio or on any other pages like it’s supposed to be. Im wondering if it’s the CSS or something deeper. I assume the relevant code to this issue is of course the Sidebar component, App.js, and maybe Layout component and the scss file for the sidebar. Does anyone have any advice on how to narrow down as to which few files are likely the problem as it feels like it could be any of the components or their scss is not working together. Anyone know how to fix the sidebar not showing?
Sidebare index.js --->
import './index.scss'
import LogoS from '../../assets/images/logo-s.png'
import LogoSubtitle from '../../assets/images/logo_sub.png'
import { FontAwesomeIcon } from '#fortawesome/react-fontawesome'
import {
faLinkedin,
faGithub,
faYoutube,
faSkype,
} from '#fortawesome/free-brands-svg-icons'
import { faHome, faUser, faEnvelope, faSuitcase } from '#fortawesome/free-solid-svg-icons'
import { Link, NavLink } from 'react-router-dom'
const Sidebar = () => {
return (
<div className="nav-bar">
<Link className="logo" to="/">
<img src={LogoS} alt="Logo" />
<img className="sub-logo" src={LogoSubtitle} alt="slobodan" />
</Link>
<nav>
<NavLink exact="true" activeclassname="active" to="/">
<FontAwesomeIcon icon={faHome} color="#4d4d4e" />
</NavLink>
<NavLink activeclassname="active" className="about-link" to="/about">
<FontAwesomeIcon icon={faUser} color="#4d4d4e" />
</NavLink>
<NavLink activeclassname="active" className="portfolio-link" to="/portfolio">
<FontAwesomeIcon icon={faSuitcase} color="#4d4d4e" />
</NavLink>
<NavLink
activeclassname="active"
className="contact-link"
to="/contact"
>
<FontAwesomeIcon icon={faEnvelope} color="#4d4d4e" />
</NavLink>
</nav>
<ul>
<li>
<a
href="https://www.linkedin.com/in/slobodan-gaji%C4%87-006bb8b8/"
target="_blank"
rel="noreferrer"
>
<FontAwesomeIcon icon={faLinkedin} color="#4d4d4e" />
</a>
</li>
<li>
<a
href="https://github.com/bobangajicsm"
target="_blank"
rel="noreferrer"
>
<FontAwesomeIcon icon={faGithub} color="#4d4d4e" />
</a>
</li>
<li>
<a
href="https://www.youtube.com/channel/UCBu5ulO4d-d47lAVybpRTkw"
rel="noreferrer"
target="_blank"
>
<FontAwesomeIcon icon={faYoutube} color="#4d4d4e" />
</a>
</li>
<li>
<a href="skype:live:bobangajicsm" rel="noreferrer" target="_blank">
<FontAwesomeIcon icon={faSkype} color="#4d4d4e" />
</a>
</li>
</ul>
</div>
)
}
export default Sidebar
Sidebare scss -->
.nav-bar {
background: #181818;
width: 60px;
height: 100%;
position: absolute;
top: 0;
z-index: 3;
min-height: 500px;
.logo {
display: block;
padding: 8px 0;
img {
display: block;
margin: 8px auto;
width: 24px;
height: auto;
&.sub-logo {
width: 50px;
}
}
}
nav {
display: block;
text-align: center;
position: absolute;
height: 210px;
top: 50%;
margin-top: -120px;
width: 100%;
a {
font-size: 22px;
color: #4d4d4e;
display: block;
line-height: 51px;
height: 51px;
position: relative;
text-decoration: none;
i {
transition: all 0.3s ease-out;
}
&:hover {
color: #ffd700;
svg {
opacity: 0;
}
&:after {
opacity: 1;
}
}
&:after {
content: '';
font-size: 9px;
letter-spacing: 2px;
position: absolute;
bottom: 0;
display: block;
width: 100%;
text-align: center;
opacity: 0;
-webkit-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
&:first-child {
&:after {
content: 'HOME';
}
}
}
a.about-link {
&:after {
content: 'ABOUT';
}
}
a.contact-link {
&:after {
content: 'CONTACT';
}
}
a.portfolio-link {
&:after {
content: 'PORTFOLIO';
}
}
a.active {
svg {
color: #ffd700;
}
}
}
ul {
position: absolute;
bottom: 20px;
width: 100%;
display: block;
padding: 0;
list-style: none;
text-align: center;
margin: 0;
li {
a {
padding: 7px 0;
display: block;
font-size: 15px;
line-height: 16px;
color: #4d4d4e;
&:hover {
color: #ffd700;
}
}
}
}
}
App.js --->
import { Route, Routes } from 'react-router-dom'
import Home from './components/Home'
import About from './components/About'
import Contact from './components/Contact'
import Layout from './components/Layout'
import Portfolio from './components/Portfolio'
import Dashboard from './components/Dashboard'
import './App.scss'
function App() {
return (
<>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route path="/contact" element={<Contact />} />
<Route path="/portfolio" element={<Portfolio />} />
<Route path="/dashboard" element={<Dashboard />} />
</Route>
</Routes>
</>
)
}
export default App
Layout index.js -->
import { Outlet } from 'react-router-dom'
import Sidebar from '../Sidebar/'
import './index.scss'
const Layout = () => {
return (
<div className="App">
<Sidebar />
<div className="page">
<span className="tags top-tags"><body></span>
<Outlet />
<span className="tags bottom-tags">
</body>
<br />
<span className="bottom-tag-html"></html></span>
</span>
</div>
</div>
)
}
export default Layout
Thank you in advance any help is greatly appreciated!!

Converting regular bootstrap code into React Bootstrap styled component

I am following a tutorial where a person is teaching me how to write Bootstrap code. They created a top bar that goes across the entire browser width with the following code
CSS
.top-bar {
background: #7aaec4;
height: 2.8rem;
padding: .5rem 0;
}
.topbar a {
color: #fff;
text-decoration: none;
font-size: 1.1rem;
}
HTML Code
<div class="top-bar">
<div class="container">
<div class="col-12 text-right">
<p>
Call us at +1 (888) 555-5555
</p>
</div>
</div>
</div>
The code above created the top bar which runs across the browser width and has a specific height as well.
Now I am trying to get the same behavior but with react-bootstrap and styled-components. So I wrote this code
import React from 'react';
import {Container, Row, Col} from 'react-bootstrap';
import styled from 'styled-components';
const Styles = styled.div`
background: #7aaec4;
height: 2.8rem;
padding: .5rem 0;
text-align: right;
a {
color: #fff;
text-decoration: none;
font-size: 1.1rem;
};
`;
export const TopBar = () => {return (
<Container>
<Styles>
<Row>
<Col xs={12} sm={12} md={12} lg={12} xl={12}>
Call us at +1 (888) 555-5555
</Col>
</Row>
</Styles>
</Container>
)}
And then finally use my component as
<React.Fragment>
<GlobalStyles />
<TopBar />
<div>Hello World</div>
</React.Fragment>
I see that the topbar is not running across the browser screen. it looks like this

Component with an email field that will POST back to a server when a user clicks a button and I need to validate the email address

I have a component with an email input and I need to figure out a way to check the email address to see if it's valid like 'name#email.com' whenever a user clicks the next button on a form. I also need to send the value of that input back along with other data on the page and I'm not sure how to do either.
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import {
Col, Row, Icon, Input, Tooltip
} from 'antd'
import Checkbox from '../elements/Checkbox'
import Markup from '../core/Markup'
const CustomerDetails = ({ customer }) => {
const { contact = {}, account = {}, site = {} } = customer || {}
const [disableInput, setDisableInput] = React.useState(false)
const [inputValue, setInputValue] = React.useState(contact.email)
function clearInput() {
setInputValue(' ')
}
function handleInputChange(event) {
setInputValue(event.target.value)
}
function CheckboxClick() {
if (!disableInput) {
clearInput()
}
setDisableInput(prevValue => !prevValue)
}
return (
<Container>
<h2>{account.name}</h2>
<Row>
<Col span={8}>
<H3>
<strong>Primary Contact:</strong>
</H3>
<P>{contact.name}</P>
<P>{contact.phone}</P>
</Col>
<Col span={8}>
<H3>
<strong>Service Address:</strong>
</H3>
<P>{site.address1}</P>
<P>{site.address2}</P>
<P>
{site.city}, {site.state}
{site.postalCode}
</P>
</Col>
<Col span={8}>
<H3>
<strong>Billing Address:</strong>
</H3>
<StyledMarkup>{account.billingStreet}</StyledMarkup>
<P>
{account.billingCity}, {account.billingState}
{account.billingPostalCode}
</P>
</Col>
</Row>
<br />
<Row>
<Col span={10}>
<h4>
PRIMARY CONTACT EMAIL
<Tooltip
placement="right"
title={primaryContact}
>
<StyledTooltipIcon
type="question-circle"
theme="filled"
/>
</Tooltip>
</h4>
</Col>
</Row>
<Row>
<Col span={8}>
<StyledInput
value={inputValue}
onChange={handleInputChange}
disabled={disableInput}
/>
</Col>
<Col span={2} />
<Col span={8}>
<StyledCheckbox
value={disableInput}
onChange={CheckboxClick}
/> EMAIL
OPT OUT{' '}
<Tooltip
placement="right"
title={emailText}
>
<StyledTooltipIcon
type="question-circle"
theme="filled"
/>
</Tooltip>
</Col>
</Row>
<br />
<Row>
<Col>
<StyledCheckbox /> EXEMPT
</Col>
</Row>
<br />
<Row>
<Col>
<H4>BUILDER</H4>
</Col>
</Row>
</Container>
)
}
CustomerDetails.propTypes = {
customer: PropTypes.object
}
CustomerDetails.defaultProps = {
customer: {}
}
const Container = styled.div`
text-align: left;
`
const StyledCheckbox = styled(Checkbox)`
&&& {
background: white;
input + span {
width: 35px;
height: 35px;
border: 2px solid ${({ theme }) => theme.colors.black};
}
input + span:after {
width: 12.5px;
height: 20px;
}
input:focus + span {
width: 35px;
height: 35px;
}
}
`
const StyledInput = styled(Input)`
max-width: 100%;
background: white;
&&& {
border: 2px solid ${({ theme }) => theme.colors.black};
border-radius: 0px;
height: 35px;
}
`
const ErrorContainer = styled.div`
span {
text-align: center;
}
`
const StyledTooltipIcon = styled(Icon)`
color: #1571da;
`
const H3 = styled.h3`
white-space: nowrap;
margin-top: 0;
margin-bottom: 0;
line-height: 1.5;
`
const H4 = styled.h4`
text-decoration: underline;
color: #1590ff;
`
const P = styled.p`
margin-top: 0;
margin-bottom: 0;
font-size: 1rem;
`
const StyledMarkup = styled(Markup)`
margin-top: 0;
margin-bottom: 0;
font-size: 1rem;
`
export default CustomerDetails

How to create Accordion using Card Component

I am using react-bootstrap 1.0.0-beta.3, which is build for supporting bootstrap 4 update.
Before this I was using react-bootstrap 0.32.1 and created Accordion using Panels and Panel group.
But after bootstrap upgrade it was suggested to Card component. I tried to achieve the same behavior like this:
<CardGroup>
<Card eventKey={this.state.eventKey} className="border-0">
<Card.Header>
<div className="row">
<div className="col-xs-9 col-sm-9 col-md-9 col-lg-9">
<Card.Title>
This is test
</Card.Title>
</div>
<div className="col-xs-3 col-sm-3 col-md-3 col-lg-3">
Test Text 123
</div>
</div>
</Card.Header>
<Card.Body>
Test Text 456
</Card.Body>
</Card>
</CardGroup>
I am facing couple of issues here:
How to make one card to take the full width.
How to make this structure behave like accordion.
Something like this:
You'll need to create custom components and css classNames.
Working example: https://codesandbox.io/s/8zkrw9jw50
components/Accordian.js
import React from "react";
import Card from "../../components/Card";
const panels = [
"Add Edit Menus",
"Resource Management",
"Asset Management",
"User Management",
"Account Management"
];
export default () => (
<div className="app-container">
<div className="accordion-container">
{panels.map(title => (
<Card key={title} title={title} />
))}
</div>
</div>
);
components/Card.js
import React, { Component } from "react";
import PropTypes from "prop-types";
import { Row, Col, Card } from "react-bootstrap";
import Collapse from "../Collapse";
import Button from "../Button";
const { Body, Header, Title } = Card;
class CardComponent extends Component {
state = { isActive: false };
toggleVisibility = () =>
this.setState(prevState => ({ isActive: !this.state.isActive }));
render = () => (
<div className={`${this.state.isActive ? "active" : "inactive"}`}>
<Card>
<Header style={{ padding: 0 }}>
<Row>
<Col xs={9}>
<Button onClick={this.toggleVisibility}>
{!this.state.isActive ? "+" : "-"}
</Button>
<Title style={{ display: "inline-block" }}>
{this.props.title}
</Title>
</Col>
<Col style={{ paddingTop: 7 }} xs={3}>
Test Text 123
</Col>
</Row>
</Header>
<Collapse>
<Body style={{ padding: 10 }}>Test Text 456</Body>
</Collapse>
</Card>
</div>
);
}
export default CardComponent;
CardComponent.propTypes = {
title: PropTypes.string.isRequired
};
components/Button.js
import styled from "styled-components";
const StyledButton = styled.button`
color: #909090;
background-color: transparent;
font-weight: bold;
outline: none;
border: 0;
cursor: pointer;
font-size: 22px;
transition: all 0.3s ease-in-out;
margin: 0 15px;
width: 25px;
&:hover {
color: #333333;
}
&:focus {
outline: none;
}
`;
export default StyledButton;
components/Collapse.js
import React from "react";
import PropTypes from "prop-types";
const Collapse = ({ children }) => (
<span className="folding-pannel">{children}</span>
);
export default Collapse;
Collapse.propTypes = {
children: PropTypes.node.isRequired
};
styles.css
.accordion-container {
width: 100%;
}
.app-container {
margin: 20px;
}
.active,
.inactive {
margin-bottom: 5px;
}
.active .folding-pannel {
transition: all 0.3s ease-in-out;
height: 42px;
}
.inactive .folding-pannel {
transform: perspective(0px) rotateX(90deg);
transition: all 0.3s ease-in-out;
height: 0;
}

Material-UI drawer persistent state

I'm new to Material-ui and react. What I'm trying to do is have my drawer stay in a persistent open state when the user clicks the hamburger menu on the AppBar. I want my main content 'pushed' to the right when the drawer opens, not the drawer laying on top of it. I'm stuck and don't know how to get this to work. Here's my code thus far. Thanks in advance for any tips or tricks! :)
Application.js
import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import {ClassificationBanner} from './ClassificationBanner'
import TitleBar from './TitleBar'
import styles from './Application.css'
import injectTapEventPlugin from 'react-tap-event-plugin'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
injectTapEventPlugin();
class Application extends Component {
render() {
return (
<MuiThemeProvider>
<div className={styles.root}>
<ClassificationBanner />
<TitleBar />
{this.props.children}
</div>
</MuiThemeProvider>
)
}
}
Application.propTypes = {
children: PropTypes.object.isRequired,
bbox: React.PropTypes.arrayOf(React.PropTypes.number),
};
export default Application
TitleBar.js
import React, {Component} from 'react'
import logo from '../../images/logo.1.png'
import AppBar from 'material-ui/AppBar'
import Drawer from 'material-ui/Drawer'
import Subheader from 'material-ui/Subheader'
import baseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import MenuItem from 'material-ui/MenuItem'
import { Link, IndexLink } from 'react-router';
import css from './TitleBar.css'
class TitleBar extends Component {
constructor(props){
super(props);
this.state = {drawerOpen:false};
}
getChildContext() {
return {muiTheme: getMuiTheme(baseTheme)};
}
handleToggle() {
this.setState({drawerOpen: !this.state.drawerOpen});
}
handleClose() { this.setState({drawerOpen: false}); }
render() {
const styles = {
appBar: {
backgroundColor: 'black',
height: '70px',
top: '25px'
},
img: {
position: 'absolute',
left: '50%',
marginLeft: '-127px',
marginTop: '10px',
height: '50px'
},
drawer: {
width: '200px',
marginTop: '95px',
backgroundColor: '#010101',
marginLeft: '0px',
padding: '0px'
},
mainMenu: {
color: '#3e3f3f',
display: 'inline-block',
marginRight: '40px',
fontSize: '20px',
align: 'left',
},
};
const img = <img style={styles.img} src={logo}/>
return (
<header className="header">
<AppBar style={styles.appBar} title={img} onLeftIconButtonTouchTap={this.handleToggle.bind(this)} />
<Drawer containerStyle={styles.drawer}
overlayStyle={styles.drawer}
docked={false}
open={this.state.drawerOpen}
onRequestChange={(open) => this.setState({open})}>
<Subheader inset={false}><span style={{width:'100%'}}><div style={styles.mainMenu}>MAIN MENU</div><div style={{display:'inline-block'}}><i className="fa fa-long-arrow-left fa-lg" style={{color: '#4498c0'}} onTouchTap={this.handleClose.bind(this)} aria-hidden="true"></i></div></span></Subheader>
<MenuItem className={css.menuItem} onTouchTap={this.handleClose.bind(this)}><IndexLink className={css.link} activeClassName={css.active} onlyActiveOnIndex={true} to="/exports"><i className="fa fa-book" aria-hidden="true"></i> DataPack Library</IndexLink></MenuItem>
<MenuItem className={css.menuItem} onTouchTap={this.handleClose.bind(this)}><Link className={css.link} activeClassName={css.active} to="/create" ><i className="fa fa-plus-square" aria-hidden="true"></i> Create Datapack</Link></MenuItem>
<MenuItem className={css.menuItem} onTouchTap={this.handleClose.bind(this)}><Link className={css.link} activeClassName={css.active} to="/about" ><i className="fa fa-info-circle" aria-hidden="true"></i> About EventKit</Link></MenuItem>
<MenuItem className={css.menuItem} onTouchTap={this.handleClose.bind(this)}><Link className={css.link} activeClassName={css.active} to="/account" ><i className="fa fa-user" aria-hidden="true"></i> Account Settings</Link></MenuItem>
<MenuItem className={css.menuItem} onTouchTap={this.handleClose.bind(this)}><Link className={css.link} activeClassName={css.active} to="/logout" ><i className="fa fa-sign-out" aria-hidden="true"></i> Log Out</Link></MenuItem>
</Drawer>
</header>
)
}
}
TitleBar.childContextTypes = {
muiTheme: React.PropTypes.object.isRequired,
};
export default TitleBar
TitleBar.css
.menuItem > div > div{
margin-left: 0px !important;
padding: 0px !important;
}
.img {
width: 205px;
height: 40px;
}
/* =========================================================================
Link
========================================================================= */
.link {
position: relative;
display: block;
padding: 5px;
text-align: left;
text-decoration: none;
color: #4498c0;
}
.link:visited {
text-decoration:none;
}
.atHome .link {
line-height: 150px;
}
.link:hover {
background-color: #161e2e;
text-decoration: none;
}
.link:active {
text-decoration: none;
}
a:link {
text-decoration: none;
}
/* Link: State
========================================================================= */
.active,
.active:hover {
box-shadow: 0 2px rgba(0,0,0,.1);
background-color: #161e2e;
text-decoration: none;
}
.active:visited {
text-decoration: none;
}
.active .icon {
fill: #1675aa;
filter: none;
-webkit-filter: none;
box-shadow: 0 2px rgba(0,0,0,.1);
text-decoration: none;
}
Application.css
.root {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.body {
font-family: 'Roboto', sans-serif;
}

Resources