From ff7fc88e36bb66a47327fa2c7e8513b222e539ef Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Wed, 27 Jun 2018 13:02:25 -0400 Subject: Video 21 --- stepped-solutions/17/frontend/components/Items.js | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 stepped-solutions/17/frontend/components/Items.js (limited to 'stepped-solutions/17/frontend/components/Items.js') diff --git a/stepped-solutions/17/frontend/components/Items.js b/stepped-solutions/17/frontend/components/Items.js new file mode 100755 index 0000000..1a30dd5 --- /dev/null +++ b/stepped-solutions/17/frontend/components/Items.js @@ -0,0 +1,50 @@ +import React, { Component } from 'react'; +import { Query } from 'react-apollo'; +import gql from 'graphql-tag'; +import styled from 'styled-components'; +import Item from './Item'; + +const ALL_ITEMS_QUERY = gql` + query ALL_ITEMS_QUERY { + items { + id + title + price + description + image + largeImage + } + } +`; + +const Center = styled.div` + text-align: center; +`; + +const ItemsList = styled.div` + display: grid; + grid-template-columns: 1fr 1fr; + grid-gap: 60px; + max-width: ${props => props.theme.maxWidth}; + margin: 0 auto; +`; + +class Items extends Component { + render() { + return ( +
+ + {({ data, error, loading }) => { + if (loading) return

Loading...

; + if (error) return

Error: {error.message}

; + return ( + {data.items.map(item => )} + ); + }} +
+
+ ); + } +} + +export default Items; -- cgit v1.3