-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ccabo1
committed
Sep 8, 2018
1 parent
cde67fb
commit ceb9fbd
Showing
5 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,10 @@ | |
font-size: 2em; | ||
} | ||
|
||
p { | ||
h4 { | ||
font-size: 2em; | ||
} | ||
|
||
p { | ||
font-size: 1.5em; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,82 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import { Query } from 'react-apollo'; | ||
import gql from 'graphql-tag'; | ||
|
||
import Loading from './shared/Loading'; | ||
import Error from './shared/Error'; | ||
|
||
// Let's build this out some more | ||
// Doesn't do too much at the moment | ||
const Workshop = () => ( | ||
<p>This is the best workshop ever!</p> | ||
); | ||
class Workshop extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
clicked: false, | ||
} | ||
|
||
this.handleClick = this.handleClick.bind(this); | ||
} | ||
|
||
handleClick(event) { | ||
if (this.state.clicked) return; | ||
|
||
this.setState({ | ||
clicked: true, | ||
}); | ||
} | ||
|
||
render() { | ||
const { | ||
title, | ||
author, | ||
id, | ||
} = this.props.workshop; | ||
|
||
const { | ||
clicked, | ||
} = this.state; | ||
|
||
return ( | ||
<div> | ||
<h4>{title}</h4> | ||
<p>{author}</p> | ||
{ | ||
clicked ? ( | ||
<Query query={gql` | ||
{ | ||
workshop(id: ${id}) { | ||
description | ||
url | ||
} | ||
} | ||
`}> | ||
{({ loading, error, data }) => { | ||
if (loading) return (<Loading />); | ||
if (error) return (<Error />); | ||
|
||
const { | ||
description, | ||
url, | ||
} = data.workshop; | ||
|
||
return ( | ||
<div> | ||
<p>{description}</p> | ||
<a href={url}>RSVP</a> | ||
</div> | ||
) | ||
}} | ||
</Query> | ||
) : ( | ||
<div onClick={this.handleClick}> | ||
Learn more | ||
</div> | ||
) | ||
} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Workshop; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
const Error = () => ( | ||
<p>There was an error <span role="img" aria-label="anguish">😩</span></p> | ||
); | ||
|
||
export default Error; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
const Loading = () => ( | ||
<p>Loading... <span role="img" aria-label="confused">😕</span></p> | ||
); | ||
|
||
export default Loading; |