|
1 | 1 | import * as React from 'react';
|
2 | 2 | import Layout from '../components/layout';
|
3 | 3 | import { Content } from '../components/shared/styledHelpers';
|
4 |
| -import { Heading, Text } from '../components/shared/base'; |
| 4 | +import { |
| 5 | + Heading, |
| 6 | + Text, |
| 7 | + Card, |
| 8 | + Flex, |
| 9 | + Image, |
| 10 | + Box, |
| 11 | +} from '../components/shared/base'; |
| 12 | +import { TutorialButton } from '../components/buttons'; |
| 13 | +import { getTutorialOverviewSlug } from '../utils/getTutorialSlug'; |
| 14 | +import ProgressBar from '../components/ProgressBar'; |
5 | 15 |
|
6 |
| -const courses = () => { |
| 16 | +const courses = data => { |
| 17 | + const courseSectionData = [ |
| 18 | + { |
| 19 | + heading: `Frontend`, |
| 20 | + body: `Implement a web frontend for a Hacker News app that talks to a GraphQL |
| 21 | + API. We provide a hosted GraphQL API for you so that you can test your |
| 22 | + app in a real world environment.`, |
| 23 | + data: data.data.frontend.edges, |
| 24 | + }, |
| 25 | + { |
| 26 | + heading: `Backend`, |
| 27 | + body: `Implement a GraphQL API that's backed by a database. The tutorial |
| 28 | + teach schema design and implement features like authentication, |
| 29 | + filtering, pagination and a lot more`, |
| 30 | + data: data.data.backend.edges, |
| 31 | + }, |
| 32 | + ]; |
7 | 33 | return (
|
8 | 34 | <Layout>
|
9 | 35 | <Content>
|
10 | 36 | <Heading> Fullstack Course </Heading>
|
11 |
| - <Text>A general introduction to GraphQL for frontend and backend developers.</Text> |
12 |
| - <Text> Read this tutorial to learn about GraphQL's basic concepts and prepare |
13 |
| - yourself for a hands-on beginner tutorial.</Text> |
| 37 | + <Text> |
| 38 | + A general introduction to GraphQL for frontend and backend developers. |
| 39 | + </Text> |
| 40 | + <Text> |
| 41 | + Read this tutorial to learn about GraphQL's basic concepts and prepare |
| 42 | + yourself for a hands-on beginner tutorial. |
| 43 | + </Text> |
| 44 | + {courseSectionData.map(section => ( |
| 45 | + <div key={section.heading}> |
| 46 | + <CourseSection {...section} /> |
| 47 | + </div> |
| 48 | + ))} |
14 | 49 | </Content>
|
15 | 50 | </Layout>
|
16 | 51 | );
|
17 | 52 | };
|
18 | 53 |
|
| 54 | +type CourseSectionProps = { |
| 55 | + heading: string; |
| 56 | + body: string; |
| 57 | + data: [QueryData]; |
| 58 | +}; |
| 59 | + |
| 60 | +type QueryData = { |
| 61 | + node: Node; |
| 62 | +}; |
| 63 | + |
| 64 | +type Node = { |
| 65 | + id: string; |
| 66 | + fileAbsolutePath: string; |
| 67 | + frontmatter: Frontmatter; |
| 68 | +}; |
| 69 | + |
| 70 | +type Frontmatter = { |
| 71 | + tutorialTitle: string; |
| 72 | + description: string; |
| 73 | +}; |
| 74 | + |
| 75 | +const CourseSection: React.FunctionComponent<CourseSectionProps> = ({ |
| 76 | + heading, |
| 77 | + body, |
| 78 | + data, |
| 79 | +}) => { |
| 80 | + return ( |
| 81 | + <Flex m={[1, 1, 1]}> |
| 82 | + <Box width={[0.2, 0.2, 0.2]}> |
| 83 | + <Heading> {heading} </Heading> |
| 84 | + <Text>{body}</Text> |
| 85 | + </Box> |
| 86 | + <Box width={[0.8, 0.8, 0.8]}> |
| 87 | + <Flex alignItems="top" justifyContent="center" flexWrap="wrap"> |
| 88 | + {data.map(tutorial => ( |
| 89 | + <Box width={[1, 0.8, 0.4]} key={tutorial.node.id}> |
| 90 | + <CourseCard |
| 91 | + tutorialTitle={tutorial.node.frontmatter.tutorialTitle} |
| 92 | + fileAbsolutePath={tutorial.node.fileAbsolutePath} |
| 93 | + /> |
| 94 | + </Box> |
| 95 | + ))} |
| 96 | + </Flex> |
| 97 | + </Box> |
| 98 | + </Flex> |
| 99 | + ); |
| 100 | +}; |
| 101 | + |
| 102 | +type CourseCardProps = { |
| 103 | + tutorialTitle: string; |
| 104 | + fileAbsolutePath: string; |
| 105 | +}; |
| 106 | + |
| 107 | +const CourseCard: React.FunctionComponent<CourseCardProps> = ({ |
| 108 | + tutorialTitle, |
| 109 | + fileAbsolutePath, |
| 110 | +}) => { |
| 111 | + return ( |
| 112 | + <Card m={[1, 1, 1]} p={[2, 2, 2]}> |
| 113 | + <Flex flexDirection="column" alignItems="center" justifyContent="center"> |
| 114 | + <Image |
| 115 | + width={[0.5, 0.5, 0.5]} |
| 116 | + src="https://i.ibb.co/TcKwmwR/Icons.png" |
| 117 | + /> |
| 118 | + <h3>{tutorialTitle}</h3> |
| 119 | + <ProgressBar percentage={Math.floor(Math.random() * 100)} width={80} /> |
| 120 | + <a href={getTutorialOverviewSlug(fileAbsolutePath)}> |
| 121 | + <TutorialButton>Start Tutorial</TutorialButton> |
| 122 | + </a> |
| 123 | + </Flex> |
| 124 | + </Card> |
| 125 | + ); |
| 126 | +}; |
| 127 | + |
| 128 | +export const query = graphql` |
| 129 | + query FullStackCourseQuery { |
| 130 | + frontend: allMdx( |
| 131 | + filter: { |
| 132 | + frontmatter: { tutorialTitle: { ne: null } } |
| 133 | + fileAbsolutePath: { regex: "/courses/frontend/" } |
| 134 | + } |
| 135 | + ) { |
| 136 | + edges { |
| 137 | + node { |
| 138 | + id |
| 139 | + fileAbsolutePath |
| 140 | + frontmatter { |
| 141 | + tutorialTitle |
| 142 | + description |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | + backend: allMdx( |
| 148 | + filter: { |
| 149 | + frontmatter: { tutorialTitle: { ne: null } } |
| 150 | + fileAbsolutePath: { regex: "/courses/backend/" } |
| 151 | + } |
| 152 | + ) { |
| 153 | + edges { |
| 154 | + node { |
| 155 | + id |
| 156 | + fileAbsolutePath |
| 157 | + frontmatter { |
| 158 | + tutorialTitle |
| 159 | + description |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + } |
| 165 | +`; |
| 166 | + |
19 | 167 | export default courses;
|
0 commit comments