diff --git a/src/App.css b/src/App.css index 8ba363b..546191f 100644 --- a/src/App.css +++ b/src/App.css @@ -12,6 +12,10 @@ font-size: 2em; } -p { +h4 { font-size: 2em; } + +p { + font-size: 1.5em; +} diff --git a/src/components/Workshop.js b/src/components/Workshop.js index 8f6e2da..8ecf17a 100644 --- a/src/components/Workshop.js +++ b/src/components/Workshop.js @@ -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 = () => ( -

This is the best workshop ever!

-); +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 ( +
+

{title}

+

{author}

+ { + clicked ? ( + + {({ loading, error, data }) => { + if (loading) return (); + if (error) return (); + + const { + description, + url, + } = data.workshop; + + return ( +
+

{description}

+ RSVP +
+ ) + }} +
+ ) : ( +
+ Learn more +
+ ) + } +
+ ); + } +} export default Workshop; diff --git a/src/components/Workshops.js b/src/components/Workshops.js index 811be4f..530a78b 100644 --- a/src/components/Workshops.js +++ b/src/components/Workshops.js @@ -3,19 +3,31 @@ import React from 'react'; // This is a component we import to make queries with GraphQL import { Query } from 'react-apollo'; +import Workshop from './Workshop'; +import Loading from './shared/Loading'; +import Error from './shared/Error'; + // We use this to actually type and format our query import gql from 'graphql-tag'; const Workshops = () => ( {({ loading, error, data }) => { - if (loading) return (

Loading... 😕

); - if (error) return (

There was an error 😩

); - return (

{data.hello} 🤠

) + if (loading) return (); + if (error) return (); + return ( + data.workshops.map(workshop => ( + + )) + ) }}
); diff --git a/src/components/shared/Error.js b/src/components/shared/Error.js new file mode 100644 index 0000000..8e7dc4b --- /dev/null +++ b/src/components/shared/Error.js @@ -0,0 +1,7 @@ +import React from 'react'; + +const Error = () => ( +

There was an error 😩

+); + +export default Error; diff --git a/src/components/shared/Loading.js b/src/components/shared/Loading.js new file mode 100644 index 0000000..b58f2c3 --- /dev/null +++ b/src/components/shared/Loading.js @@ -0,0 +1,7 @@ +import React from 'react'; + +const Loading = () => ( +

Loading... 😕

+); + +export default Loading;