Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates client starter code [Ready to merge] #296

Merged
merged 28 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bfb4ca1
updates client starter code
jpvajda Oct 4, 2022
77e29c5
cleans up index.js file
jpvajda Oct 4, 2022
8d0e0b2
more updates
jpvajda Oct 5, 2022
37c9185
a few more changes
jpvajda Oct 28, 2022
07c86ba
Update final to match starting code
rkoron007 Nov 7, 2022
6c6ec67
Update final code to match starter code
rkoron007 Nov 8, 2022
26d271d
Add comment for useParams
rkoron007 Nov 8, 2022
2668830
Update start/client/src/components/launch-tile.tsx
jpvajda Nov 8, 2022
009b876
Update start/client/src/components/loading.tsx
jpvajda Nov 8, 2022
5de78dd
Update start/client/src/components/login-form.tsx
jpvajda Nov 8, 2022
6a97b5c
Update start/client/src/pages/cart.tsx
jpvajda Nov 8, 2022
f3defe0
Update start/client/src/pages/launch.tsx
jpvajda Nov 8, 2022
b5f4e9c
Update start/client/src/pages/launches.tsx
jpvajda Nov 8, 2022
5e141a2
Update start/client/src/pages/launches.tsx
jpvajda Nov 8, 2022
aac2569
Update start/client/src/pages/profile.tsx
jpvajda Nov 8, 2022
2e5f880
resolves code review
jpvajda Nov 8, 2022
3cc1a1f
Fix tests for the final version
rkoron007 Nov 9, 2022
d967c5a
Update start folder tests to match final tests
rkoron007 Nov 9, 2022
25d150f
Remove changes to cart and launch
rkoron007 Nov 9, 2022
411ff4a
Update start/client/src/pages/launch.tsx
jpvajda Nov 9, 2022
1a80eb0
Update start/client/src/components/menu-item.tsx
jpvajda Nov 9, 2022
cfd9c2e
Update start/client/src/pages/profile.tsx
jpvajda Nov 9, 2022
e8c7e86
Update start/client/src/pages/cart.tsx
jpvajda Nov 9, 2022
f434c46
code review fixes
jpvajda Nov 9, 2022
6c77298
removed pack-lock file
jpvajda Nov 10, 2022
13a9e5c
Merge pull request #305 from apollographql/RK/working-through-client-…
rkoron007 Nov 12, 2022
f0f13a6
Fix small importing issues
rkoron007 Nov 14, 2022
5d786f0
Go through a pass
rkoron007 Nov 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Apollo tutorial

This is the fullstack app for the [Apollo tutorial](http://apollographql.com/docs/tutorial/introduction.html). 🚀
This is the fullstack app for the [Apollo tutorial](https://www.apollographql.com/tutorials/fullstack-quickstart/introduction). 🚀

## File structure

The app is split out into two folders:

- `start`: Starting point for the tutorial
- `final`: Final version

Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions start/client/apollo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//empty
74,460 changes: 41,538 additions & 32,922 deletions start/client/package-lock.json

Large diffs are not rendered by default.

43 changes: 22 additions & 21 deletions start/client/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
jpvajda marked this conversation as resolved.
Show resolved Hide resolved
"name": "client",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"dependencies": {
"@apollo/client": "^3.4.6",
"@reach/router": "^1.2.1",
"@types/node": "^12.12.14",
"@types/reach__router": "^1.2.6",
"@types/react": "^16.9.15",
"@types/react-dom": "^16.9.4",
"emotion": "^9.2.12",
"graphql": "^15.5.1",
"polished": "^3.4.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-emotion": "^9.2.12",
"react-scripts": "^3.4.1",
"typescript": "^3.7.3"
"@apollo/client": "^3.7.0",
"@emotion/css": "^11.10.0",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@types/node": "^18.7.3",
"@types/react-dom": "^18.0.6",
"@types/react-router": "^5.1.19",
"graphql": "^16.5.0",
"polished": "^4.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.4.1",
"react-router-dom": "^6.4.1",
"react-scripts": "^5.0.1",
"typescript": "^4.8.4"
},
"scripts": {
"start": "react-scripts start",
Expand All @@ -36,11 +37,11 @@
"not op_mini all"
],
"devDependencies": {
"@testing-library/jest-dom": "^4.0.0",
"@testing-library/react": "^8.0.7",
"@types/jest": "^24.0.23",
"apollo": "^2.32.5",
"artillery": "^1.6.0-26",
"npm-watch": "^0.6.0"
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.1.1",
"@types/react": "^18.0.21",
"artillery": "^2.0.0-23",
"npm-watch": "^0.11.0"
}
}
2 changes: 1 addition & 1 deletion start/client/src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';
import { lighten } from 'polished';

import { unit, colors } from '../styles';
Expand Down
2 changes: 1 addition & 1 deletion start/client/src/components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import MenuItem from './menu-item';
import LogoutButton from '../containers/logout-button';
Expand Down
2 changes: 1 addition & 1 deletion start/client/src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import { size } from 'polished';

import { unit, colors } from '../styles';
Expand Down
2 changes: 1 addition & 1 deletion start/client/src/components/launch-detail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import { unit } from '../styles';
import { cardClassName, getBackgroundImage } from './launch-tile';
Expand Down
10 changes: 6 additions & 4 deletions start/client/src/components/launch-tile.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import styled, { css } from 'react-emotion';
import { Link } from '@reach/router';
import styled from '@emotion/styled';
import { css } from '@emotion/react';
import { Link } from 'react-router-dom';

import galaxy from '../assets/images/galaxy.jpg';
import iss from '../assets/images/iss.jpg';
Expand All @@ -12,7 +12,7 @@ export function getBackgroundImage(id: string) {
return `url(${backgrounds[Number(id) % backgrounds.length]})`;
}

export default ({ launch }: any) => {
const LaunchTile = ({ launch }: any) => {
const { id, mission, rocket } = launch;
return (
<StyledLink
Expand All @@ -27,6 +27,8 @@ export default ({ launch }: any) => {
);
};

export default LaunchTile

/**
* STYLED COMPONENTS USED IN THIS FILE ARE BELOW HERE
*/
Expand Down
3 changes: 2 additions & 1 deletion start/client/src/components/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled, { keyframes } from 'react-emotion';
import styled from '@emotion/styled';
import { keyframes } from '@emotion/react';
import { size } from 'polished';

import { ReactComponent as Logo } from '../assets/logo.svg';
Expand Down
3 changes: 2 additions & 1 deletion start/client/src/components/login-form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import styled, { css } from 'react-emotion';
import styled from '@emotion/styled';
import { css } from '@emotion/react';
import { size } from 'polished';

import Button from './button';
Expand Down
5 changes: 3 additions & 2 deletions start/client/src/components/menu-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled, { css } from 'react-emotion';
import { Link } from '@reach/router';
import styled from '@emotion/styled';
import { css } from '@emotion/react';
import { Link } from 'react-router-dom';
import { colors, unit } from '../styles';

export const menuItemClassName = css({
Expand Down
2 changes: 1 addition & 1 deletion start/client/src/components/page-container.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import { unit, colors } from '../styles';

Expand Down
20 changes: 20 additions & 0 deletions start/client/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ApolloClient, ApolloProvider } from '@apollo/client';
import { cache } from './cache';
import React from 'react';
import ReactDOM from 'react-dom/client';
import Pages from './pages';
import injectStyles from './styles';

// Initialize ApolloClient


injectStyles();

// Pass the ApolloClient instance to the ApolloProvider component

const root = ReactDOM.createRoot(document.getElementById("root")!);
root.render(
<ApolloProvider client={client}>
<Pages />
</ApolloProvider>,
);
3 changes: 1 addition & 2 deletions start/client/src/pages/cart.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { RouteComponentProps } from '@reach/router';

interface CartProps extends RouteComponentProps {
interface CartProps {

}

Expand Down
19 changes: 9 additions & 10 deletions start/client/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Fragment } from 'react';
import { Router } from '@reach/router';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'

import Launch from './launch';
import Launches from './launches';
Expand All @@ -9,16 +8,16 @@ import { Footer, PageContainer } from '../components';

export default function Pages() {
return (
<Fragment>
<Router>
<PageContainer>
<Router primary={false} component={Fragment}>
<Launches path="/" />
<Launch path="launch/:launchId" />
<Cart path="cart" />
<Profile path="profile" />
</Router>
<Routes>
<Route path="/" element={<Launches />} />
<Route path="launch/:launchId" element={<Launch />} />
<Route path="cart" element={<Cart />} />
<Route path="profile" element={<Profile />} />
</Routes>
</PageContainer>
<Footer />
</Fragment>
</Router>
);
}
5 changes: 2 additions & 3 deletions start/client/src/pages/launch.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { RouteComponentProps } from '@reach/router';

interface LaunchProps extends RouteComponentProps {
import { useParams } from 'react-router-dom';

interface LaunchProps {
}

const Launch: React.FC<LaunchProps> = () => {
Expand Down
5 changes: 2 additions & 3 deletions start/client/src/pages/launches.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Fragment, useState } from 'react';
import { RouteComponentProps } from '@reach/router';
import React, { } from 'react';
import { gql } from '@apollo/client'

export const LAUNCH_TILE_DATA = gql`
Expand All @@ -18,7 +17,7 @@ export const LAUNCH_TILE_DATA = gql`
}
`;

interface LaunchesProps extends RouteComponentProps {}
interface LaunchesProps {}

const Launches: React.FC<LaunchesProps> = () => {
return <div />;
Expand Down
3 changes: 1 addition & 2 deletions start/client/src/pages/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { RouteComponentProps } from '@reach/router';

interface ProfileProps extends RouteComponentProps {}
interface ProfileProps {}

const Profile: React.FC<ProfileProps> = () => {
return <div />;
Expand Down
97 changes: 50 additions & 47 deletions start/client/src/styles.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
import { injectGlobal } from 'react-emotion';
import { injectGlobal } from "@emotion/css";
jpvajda marked this conversation as resolved.
Show resolved Hide resolved

export const unit = 8;
export const colors = {
primary: '#220a82',
secondary: '#14cbc4',
accent: '#e535ab',
background: '#f7f8fa',
grey: '#d8d9e0',
text: '#343c5a',
textSecondary: '#747790'
primary: "#220a82",
secondary: "#14cbc4",
accent: "#e535ab",
background: "#f7f8fa",
grey: "#d8d9e0",
text: "#343c5a",
textSecondary: "#747790",
};

export default () => injectGlobal({
[['html', 'body']]: {
height: '100%',
},
body: {
margin: 0,
padding: 0,
fontFamily: "'Source Sans Pro', sans-serif",
backgroundColor: colors.background,
color: colors.text,
},
'#root': {
display: 'flex',
flexDirection: 'column',
minHeight: '100%',
},
'*': {
boxSizing: 'border-box',
},
[['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]: {
margin: 0,
fontWeight: 600,
},
h1: {
fontSize: 48,
lineHeight: 1,
},
h2: {
fontSize: 40,
},
h3: {
fontSize: 36,
},
h5: {
fontSize: 16,
textTransform: 'uppercase',
letterSpacing: 4,
}
});
const styles = () =>
injectGlobal({
[["html", "body"]]: {
height: "100%",
},
body: {
margin: 0,
padding: 0,
fontFamily: "'Source Sans Pro', sans-serif",
backgroundColor: colors.background,
color: colors.text,
},
"#root": {
display: "flex",
flexDirection: "column",
minHeight: "100%",
},
"*": {
boxSizing: "border-box",
},
[["h1", "h2", "h3", "h4", "h5", "h6"]]: {
margin: 0,
fontWeight: 600,
},
h1: {
fontSize: 48,
lineHeight: 1,
},
h2: {
fontSize: 40,
},
h3: {
fontSize: 36,
},
h5: {
fontSize: 16,
textTransform: "uppercase",
letterSpacing: 4,
},
});

export default styles;
4 changes: 3 additions & 1 deletion start/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react"

},
"include": [
"src"
Expand Down
Loading