-
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
Showing
9 changed files
with
241 additions
and
96 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
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,17 @@ | ||
import { gql } from "@apollo/client"; | ||
|
||
export const LOCATIONS_QUERY = gql` | ||
query Query { | ||
countries{ | ||
name | ||
native | ||
capital | ||
emoji | ||
currency | ||
languages { | ||
code | ||
name | ||
} | ||
} | ||
} | ||
`; |
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 |
---|---|---|
@@ -1,26 +1,20 @@ | ||
import { gql, useQuery } from "@apollo/client"; | ||
|
||
const LOCATIONS_QUERY = gql` | ||
query Query { | ||
countries{ | ||
name | ||
native | ||
capital | ||
emoji | ||
currency | ||
languages { | ||
code | ||
name | ||
} | ||
} | ||
} | ||
`; | ||
import { useQuery } from "@apollo/client"; | ||
import { LOCATIONS_QUERY } from "../graphql/queries/getLocations"; | ||
import { Container, Col, Row } from './styles' | ||
|
||
export default function Index() { | ||
const { data } = useQuery(LOCATIONS_QUERY); | ||
const { data } = useQuery(LOCATIONS_QUERY); | ||
return ( | ||
<div> | ||
{JSON.stringify(data)} | ||
</div> | ||
<Container> | ||
{data && data.countries.map((item: any) => ( | ||
<Row key={item.name}> | ||
<Col>{item.name}</Col> | ||
<Col>{item.capital}</Col> | ||
<Col>{item.currency}</Col> | ||
<Col>{item.languages.length > 0 && item.languages[0].name}</Col> | ||
<Col>{item.emoji}</Col> | ||
</Row> | ||
))} | ||
</Container> | ||
); | ||
} | ||
} |
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,23 @@ | ||
import styled from 'styled-components' | ||
|
||
export const Container = styled.div` | ||
` | ||
|
||
export const Row = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
` | ||
|
||
export const Col = styled.div` | ||
width: 15%; | ||
background: #ccc; | ||
margin: 5px; | ||
flex: auto; | ||
text-align: center; | ||
min-height: 20px; | ||
vertical-align: text-bottom; | ||
padding: 10px; | ||
` |
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,4 @@ | ||
import * as React from "react"; | ||
const StylesContext = React.createContext<null | React.ReactNode>(null); | ||
export const StylesProvider = StylesContext.Provider; | ||
export const useStyles = () => React.useContext(StylesContext); |
Oops, something went wrong.