├── .gitignore ├── README.md ├── course_logo_udemy.png ├── evens-or-odds ├── .babelrc ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── src │ ├── actions │ │ ├── deck.js │ │ ├── guess.js │ │ ├── settings.js │ │ └── types.js │ ├── assets │ │ ├── economica-bold.ttf │ │ └── roboto-condensed.light.ttf │ ├── components │ │ ├── App.js │ │ ├── Card.js │ │ ├── DrawCard.js │ │ ├── GameState.js │ │ ├── Guess.js │ │ └── Instructions.js │ ├── index.css │ ├── index.html │ ├── index.js │ └── reducers │ │ ├── deck.js │ │ ├── fetchStates.js │ │ ├── gameState.js │ │ ├── index.js │ │ └── settings.js └── yarn.lock ├── music-master ├── .babelrc ├── package-lock.json ├── package.json └── src │ ├── assets │ ├── economica-bold.ttf │ └── roboto-condensed.light.ttf │ ├── components │ ├── App.js │ ├── Artist.js │ ├── Search.js │ └── Tracks.js │ ├── index.css │ ├── index.html │ └── index.js ├── news ├── .babelrc ├── client │ └── src │ │ ├── assets │ │ ├── economica-bold.ttf │ │ └── roboto-condensed.light.ttf │ │ ├── components │ │ └── App.js │ │ ├── index.css │ │ ├── index.html │ │ └── index.js ├── index.js ├── package-lock.json ├── package.json └── stories.json ├── portfolio ├── .babelrc ├── .gitignore ├── README.md ├── package-lock.json ├── package.json └── src │ ├── assets │ ├── economica-bold.ttf │ ├── email_icon.png │ ├── github_icon.png │ ├── linkedin_icon.png │ ├── profile.png │ ├── project1.png │ ├── project2.png │ ├── project3.png │ ├── roboto-condensed.light.ttf │ └── twitter_icon.png │ ├── components │ ├── App.js │ ├── Header.js │ ├── Jokes.js │ ├── Projects.js │ ├── SocialProfiles.js │ └── Title.js │ ├── data │ ├── projects.js │ └── socialProfiles.js │ ├── index.css │ ├── index.html │ ├── index.js │ └── projects │ ├── evens-or-odds │ ├── actions │ │ ├── deck.js │ │ ├── guess.js │ │ ├── settings.js │ │ └── types.js │ ├── assets │ │ ├── economica-bold.ttf │ │ └── roboto-condensed.light.ttf │ ├── components │ │ ├── App.js │ │ ├── Card.js │ │ ├── DrawCard.js │ │ ├── GameState.js │ │ ├── Guess.js │ │ └── Instructions.js │ ├── index.css │ ├── index.js │ └── reducers │ │ ├── deck.js │ │ ├── fetchStates.js │ │ ├── gameState.js │ │ ├── index.js │ │ └── settings.js │ ├── music-master │ ├── assets │ │ ├── economica-bold.ttf │ │ └── roboto-condensed.light.ttf │ ├── components │ │ ├── App.js │ │ ├── Artist.js │ │ ├── Search.js │ │ └── Tracks.js │ ├── index.css │ └── index.js │ └── reaction │ ├── actions │ ├── messages.js │ ├── reactions.js │ ├── types.js │ └── username.js │ ├── assets │ ├── economica-bold.ttf │ └── roboto-condensed.light.ttf │ ├── components │ ├── App.js │ ├── CreateReaction.js │ ├── MessageBoard.js │ ├── PublishMessage.js │ └── SetUsername.js │ ├── index.css │ ├── index.js │ ├── pubnub.config.json │ ├── pubsub.js │ └── reducers │ ├── index.js │ ├── messages.js │ ├── reactions.js │ └── username.js ├── react-app-template ├── .babelrc ├── package-lock.json ├── package.json └── src │ ├── assets │ ├── economica-bold.ttf │ └── roboto-condensed.light.ttf │ ├── components │ └── App.js │ ├── index.css │ ├── index.html │ └── index.js ├── reaction ├── .babelrc ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── src │ ├── actions │ │ ├── messages.js │ │ ├── reactions.js │ │ ├── types.js │ │ └── username.js │ ├── assets │ │ ├── economica-bold.ttf │ │ └── roboto-condensed.light.ttf │ ├── components │ │ ├── App.js │ │ ├── CreateReaction.js │ │ ├── MessageBoard.js │ │ ├── PublishMessage.js │ │ └── SetUsername.js │ ├── index.css │ ├── index.html │ ├── index.js │ ├── pubnub.config.json │ ├── pubsub.js │ └── reducers │ │ ├── index.js │ │ ├── messages.js │ │ ├── reactions.js │ │ └── username.js └── yarn.lock └── starter ├── index.html ├── index.js ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | *node_modules* 2 | *dist* 3 | *.cache* 4 | *DS_Store* 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### React JS and Redux Bootcamp | Master React Web Development 2 | 3 | ![Course Logo](course_logo_udemy.png) 4 | 5 | The official code for the *React JS and Redux Bootcamp | Master React Web Development* course on Udemy by David Katz. 6 | 7 | ## Take the course here: 8 | [http://udemy.com/react-redux-bootcamp](http://udemy.com/react-redux-bootcamp) 9 | 10 | React, by far, has the most opportunity for frontend JavaScript frameworks in the industry today. It's such an elegant technology. learning React is very approachable with its short learning curve. But it has enough depth to keep you long engaged years into your coding journey. 11 | 12 | Here are the main course highlights: 13 | - Dive into React code right away. 14 | - Create a React project from scratch, without helper tools. 15 | - Build five complete React applications. 16 | - Learn Redux the right way. Exploring not only what methods to use, but why to use them, and how they work. 17 | - Create an app that features multi-user functionality, applying the Publish/Subscribe pattern. 18 | - Explore the optimal solution to get over the notorious CORS error. 19 | - Build your own backend APIs - an important layer for web development. 20 | - Deploy your React applications to production. 21 | -------------------------------------------------------------------------------- /course_logo_udemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/course_logo_udemy.png -------------------------------------------------------------------------------- /evens-or-odds/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@babel/plugin-proposal-class-properties"] 3 | } 4 | -------------------------------------------------------------------------------- /evens-or-odds/.gitignore: -------------------------------------------------------------------------------- 1 | *node_modules* 2 | *.cache* 3 | *dist* 4 | -------------------------------------------------------------------------------- /evens-or-odds/README.md: -------------------------------------------------------------------------------- 1 | ## React App Template 2 | 3 | Clone or download this project to bootstrap a React project! 4 | 5 | ### Getting Started 6 | 7 | Install the relevant `node_modules` and fire up the development server: 8 | 9 | ``` 10 | npm i && npm run dev 11 | ``` -------------------------------------------------------------------------------- /evens-or-odds/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "evens-or-odds", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "parcel src/index.html", 8 | "build": "parcel build src/index.html", 9 | "start": "npm run build && live-server dist" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "live-server": "^1.2.1", 16 | "parcel-bundler": "^1.10.3", 17 | "react": "^16.6.3", 18 | "react-dom": "^16.6.3", 19 | "react-redux": "^6.0.0", 20 | "redux": "^4.0.1", 21 | "redux-thunk": "^2.3.0" 22 | }, 23 | "devDependencies": { 24 | "@babel/core": "^7.2.2", 25 | "@babel/plugin-proposal-class-properties": "^7.2.3" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /evens-or-odds/src/actions/deck.js: -------------------------------------------------------------------------------- 1 | import { DECK, DECK_DRAW } from './types'; 2 | 3 | const API_ADDRESS = 'https://deck-of-cards-api-wrapper.appspot.com'; 4 | 5 | export const fetchDeckSuccess = deckJson => { 6 | const { remaining, deck_id } = deckJson; 7 | 8 | return { type: DECK.FETCH_SUCCESS, remaining, deck_id }; 9 | } 10 | 11 | export const fetchDeckError = error => { 12 | return { type: DECK.FETCH_ERROR, message: error.message }; 13 | } 14 | 15 | export const fetchNewDeck = () => dispatch => { 16 | return fetch(`${API_ADDRESS}/deck/new/shuffle`) 17 | .then(response => { 18 | if (response.status !== 200) { 19 | throw new Error('Unsuccessful request to deckofcardsapi.com'); 20 | } 21 | 22 | return response.json(); 23 | }) 24 | .then(json => dispatch(fetchDeckSuccess(json))) 25 | .catch(error => dispatch(fetchDeckError(error))); 26 | } 27 | 28 | export const fetchDrawCard = deck_id => dispatch => { 29 | return fetch(`${API_ADDRESS}/deck/${deck_id}/draw`) 30 | .then(response => { 31 | if (response.status !== 200) { 32 | throw new Error('Unsuccessful request to deckofcardsapi.com'); 33 | } 34 | 35 | return response.json(); 36 | }) 37 | .then(json => { 38 | dispatch({ 39 | type: DECK_DRAW.FETCH_SUCCESS, 40 | cards: json.cards, 41 | remaining: json.remaining 42 | }); 43 | }) 44 | .catch(error => dispatch({ type: DECK_DRAW.FETCH_ERROR, message: error.message })); 45 | } -------------------------------------------------------------------------------- /evens-or-odds/src/actions/guess.js: -------------------------------------------------------------------------------- 1 | import { SET_GUESS } from './types'; 2 | 3 | export const setGuessEven = () => { 4 | return { type: SET_GUESS, guess: 'even' }; 5 | } 6 | 7 | export const setGuessOdd = () => { 8 | return { type: SET_GUESS, guess: 'odd' }; 9 | } -------------------------------------------------------------------------------- /evens-or-odds/src/actions/settings.js: -------------------------------------------------------------------------------- 1 | import { SET_GAME_STARTED, SET_INSTRUCTIONS_EXPANDED } from './types'; 2 | 3 | export const startGame = () => { 4 | return { type: SET_GAME_STARTED, gameStarted: true }; 5 | }; 6 | 7 | export const cancelGame = () => { 8 | return { type: SET_GAME_STARTED, gameStarted: false }; 9 | } 10 | 11 | export const expandInstructions = () => { 12 | return { type: SET_INSTRUCTIONS_EXPANDED, instructionsExpanded: true }; 13 | } 14 | 15 | export const collapseInstructions = () => { 16 | return { type: SET_INSTRUCTIONS_EXPANDED, instructionsExpanded: false }; 17 | } -------------------------------------------------------------------------------- /evens-or-odds/src/actions/types.js: -------------------------------------------------------------------------------- 1 | export const SET_GAME_STARTED = 'SET_GAME_STARTED'; 2 | export const SET_INSTRUCTIONS_EXPANDED = 'SET_INSTRUCTIONS_EXPANDED'; 3 | export const SET_GUESS = 'SET_GUESS'; 4 | 5 | export const DECK = { 6 | FETCH_SUCCESS: 'DECK_FETCH_SUCCESS', 7 | FETCH_ERROR: 'DECK_FETCH_ERROR' 8 | }; 9 | 10 | export const DECK_DRAW = { 11 | FETCH_SUCCESS: 'DECK_DRAW_FETCH_SUCCESS', 12 | FETCH_ERROR: 'DECK_DRAW_FETCH_SUCCESS' 13 | }; 14 | -------------------------------------------------------------------------------- /evens-or-odds/src/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/evens-or-odds/src/assets/economica-bold.ttf -------------------------------------------------------------------------------- /evens-or-odds/src/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/evens-or-odds/src/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /evens-or-odds/src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { startGame, cancelGame } from '../actions/settings'; 4 | import { fetchNewDeck } from '../actions/deck'; 5 | import fetchStates from '../reducers/fetchStates'; 6 | import Instructions from './Instructions'; 7 | import DrawCard from './DrawCard'; 8 | import Card from './Card'; 9 | import Guess from './Guess'; 10 | import GameState from './GameState'; 11 | 12 | class App extends Component { 13 | startGame = () => { 14 | this.props.startGame(); 15 | this.props.fetchNewDeck(); 16 | } 17 | 18 | render() { 19 | console.log('this', this); 20 | 21 | if (this.props.fetchState === fetchStates.error) { 22 | return ( 23 |
24 |

Please try reloading the app. An error occurred.

25 |

{this.props.message}

26 |
27 | ) 28 | } 29 | 30 | return ( 31 |
32 |

♡ ♤ Evens or Odds ♢ ♧

33 | { 34 | this.props.gameStarted ? ( 35 |
36 |

The game is on!

37 | 38 | 39 |
40 | 41 |
42 | 43 |
44 | 45 |
46 | ) : ( 47 |
48 |

A new game awaits

49 |
50 | 51 |
52 | 53 |
54 | ) 55 | } 56 |
57 | ); 58 | } 59 | } 60 | 61 | const mapStateToProps = state => { 62 | const { 63 | settings: { gameStarted }, 64 | deck: { fetchState, message } 65 | } = state; 66 | 67 | return { gameStarted, fetchState, message }; 68 | } 69 | 70 | // const mapDispatchToProps = dispatch => { 71 | // return { 72 | // startGame: () => dispatch(startGame()), 73 | // cancelGame: () => dispatch(cancelGame()), 74 | // fetchNewDeck: () => dispatch(fetchNewDeck()) 75 | // }; 76 | // } 77 | 78 | const componentConnector = connect( 79 | mapStateToProps, 80 | { startGame, cancelGame, fetchNewDeck } 81 | ); 82 | 83 | export default componentConnector(App); 84 | -------------------------------------------------------------------------------- /evens-or-odds/src/components/Card.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | 4 | const Card = ({ cards }) => { 5 | if (!cards[0]) return null; 6 | 7 | const { value, suit, image } = cards[0]; 8 | 9 | return ( 10 |
11 |

{value} of {suit}

12 | card-image 13 |
14 | ) 15 | } 16 | 17 | export default connect(({ deck: { cards } }) => ({ cards }))(Card); 18 | -------------------------------------------------------------------------------- /evens-or-odds/src/components/DrawCard.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { fetchDrawCard } from '../actions/deck'; 4 | 5 | const DrawCard = ({ deck_id, fetchDrawCard }) => { 6 | return ( 7 |
8 | 9 |
10 | ) 11 | } 12 | 13 | const mapDispatchToProps = dispatch => { 14 | return { 15 | fetchDrawCard: deck_id => () => dispatch(fetchDrawCard(deck_id)) 16 | }; 17 | } 18 | 19 | export default connect( 20 | ({ deck: { deck_id } }) => ({ deck_id }), 21 | mapDispatchToProps 22 | )(DrawCard); 23 | -------------------------------------------------------------------------------- /evens-or-odds/src/components/GameState.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | 4 | const correctGuessesRecordKey = 'CORRECT_GUESSES_RECORD_foo123'; 5 | 6 | const checkRecord = correctGuesses => { 7 | const record = Number(localStorage.getItem(correctGuessesRecordKey)); 8 | 9 | if (correctGuesses > record) { 10 | localStorage.setItem(correctGuessesRecordKey, correctGuesses); 11 | 12 | return { record: correctGuesses, isNewRecord: true }; 13 | } 14 | 15 | return { record, isNewRecord: false }; 16 | }; 17 | 18 | const GameState = ({ remaining, correctGuesses }) => { 19 | const guessText = correctGuesses === 1 ? 'guess' : 'guesses'; 20 | const { record, isNewRecord } = checkRecord(correctGuesses); 21 | const recordLabel = isNewRecord ? '🎉 New record' : 'Record'; 22 | 23 | return ( 24 |
25 |

{recordLabel}: {record}

26 |

{remaining} cards remaining

27 |

{correctGuesses} correct {guessText}

28 |
29 | ); 30 | } 31 | 32 | export default connect( 33 | ({ 34 | deck: { remaining }, 35 | gameState: { correctGuesses } 36 | }) => ({ remaining, correctGuesses }) 37 | )(GameState); 38 | -------------------------------------------------------------------------------- /evens-or-odds/src/components/Guess.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { setGuessEven, setGuessOdd } from '../actions/guess'; 4 | 5 | const Guess = ({ guess, setGuessEven, setGuessOdd }) => { 6 | return ( 7 |
8 |

Will it be even or odd?

9 |
10 | 14 | {' '} 15 | 19 |
20 |
21 | ) 22 | } 23 | 24 | export default connect( 25 | ({ gameState: { guess } }) => ({ guess }), 26 | { setGuessEven, setGuessOdd } 27 | )(Guess); 28 | -------------------------------------------------------------------------------- /evens-or-odds/src/components/Instructions.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { expandInstructions, collapseInstructions } from '../actions/settings'; 4 | 5 | const Instructions = props => { 6 | const { instructionsExpanded, expandInstructions, collapseInstructions } = props; 7 | 8 | if (instructionsExpanded) { 9 | return ( 10 |
11 |

Instructions

12 |

Welcome to evens or odds. The game goes like this

13 |

The deck is shuffled. Then choose: will the next card be even or odd?

14 |

Make a choice on every draw, and see how many you get right!

15 |

(Face cards don't count)

16 |
17 | 18 |
19 | ); 20 | } 21 | 22 | return ( 23 |
24 |

Instructions

25 |

Welcome to evens or odds. The game goes like this...

26 | 27 |
28 | ) 29 | } 30 | 31 | export default connect( 32 | state => ({ instructionsExpanded: state.settings.instructionsExpanded }), 33 | { expandInstructions, collapseInstructions } 34 | )(Instructions); 35 | -------------------------------------------------------------------------------- /evens-or-odds/src/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .profile { 24 | width: 200px; 25 | height: 200px; 26 | border-radius: 100px; 27 | } 28 | 29 | .title-fade-out { 30 | opacity: 0; 31 | animation-name: fade-out; 32 | animation-duration: 2s; 33 | } 34 | 35 | .title-fade-in { 36 | opacity: 100; 37 | animation-name: fade-in; 38 | animation-duration: 2s; 39 | } 40 | 41 | @keyframes fade-out { 42 | from {opacity: 100} 43 | to {opacity: 0} 44 | } 45 | 46 | @keyframes fade-in { 47 | from {opacity: 0} 48 | to {opacity: 100} 49 | } 50 | -------------------------------------------------------------------------------- /evens-or-odds/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Evens or Odds 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /evens-or-odds/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { createStore, applyMiddleware } from 'redux'; 4 | import { Provider } from 'react-redux'; 5 | import thunk from 'redux-thunk'; 6 | import App from './components/App'; 7 | import rootReducer from './reducers'; 8 | import './index.css'; 9 | 10 | const store = createStore(rootReducer, applyMiddleware(thunk)); 11 | 12 | console.log('store', store); 13 | console.log('store.getState()', store.getState()); 14 | 15 | store.subscribe(() => console.log('store.getState()', store.getState())); 16 | 17 | ReactDOM.render( 18 | 19 | 20 | , 21 | document.getElementById('root') 22 | ); 23 | -------------------------------------------------------------------------------- /evens-or-odds/src/reducers/deck.js: -------------------------------------------------------------------------------- 1 | import { DECK, DECK_DRAW } from '../actions/types'; 2 | import fetchStates from './fetchStates'; 3 | 4 | const DEFAULT_DECK = { deck_id: '', remaining: 0, fetchState: '', message: '', cards: [] }; 5 | 6 | const deckReducer = (state = DEFAULT_DECK, action) => { 7 | let remaining, deck_id, cards; 8 | 9 | switch(action.type) { 10 | case DECK.FETCH_SUCCESS: 11 | ({ remaining, deck_id } = action); 12 | return { ...state, remaining, deck_id, fetchState: fetchStates.success }; 13 | case DECK.FETCH_ERROR: 14 | return { ...state, message: action.message, fetchState: fetchStates.error }; 15 | case DECK_DRAW.FETCH_SUCCESS: 16 | ({ cards, remaining } = action); 17 | return { ...state, cards, remaining, fetchState: fetchStates.success }; 18 | case DECK_DRAW.FETCH_ERROR: 19 | return { ...state, message: action.message, fetchState: fetchStates.error }; 20 | default: 21 | return state; 22 | } 23 | }; 24 | 25 | export default deckReducer; 26 | -------------------------------------------------------------------------------- /evens-or-odds/src/reducers/fetchStates.js: -------------------------------------------------------------------------------- 1 | export default { 2 | success: 'success', 3 | error: 'error' 4 | }; 5 | -------------------------------------------------------------------------------- /evens-or-odds/src/reducers/gameState.js: -------------------------------------------------------------------------------- 1 | import { SET_GUESS, SET_GAME_STARTED, DECK_DRAW } from '../actions/types'; 2 | 3 | const DEFAULT_GAME_STATE = { guess: '', correctGuesses: 0 }; 4 | 5 | const EVENS = ['2', '4', '6', '8', '0']; 6 | const ODDS = ['ACE', '3', '5', '7', '9']; 7 | 8 | const gameStateReducer = (state = DEFAULT_GAME_STATE, action) => { 9 | switch(action.type) { 10 | case SET_GUESS: 11 | return { ...state, guess: action.guess }; 12 | case SET_GAME_STARTED: 13 | return DEFAULT_GAME_STATE; 14 | case DECK_DRAW.FETCH_SUCCESS: 15 | const { value } = action.cards[0]; 16 | const { guess, correctGuesses } = state; 17 | 18 | if ( 19 | (guess === 'even' && EVENS.includes(value)) || 20 | (guess === 'odd' && ODDS.includes(value)) 21 | ) { 22 | return { ...state, correctGuesses: correctGuesses+1 }; 23 | } 24 | 25 | return state; 26 | default: 27 | return state; 28 | } 29 | }; 30 | 31 | export default gameStateReducer; 32 | -------------------------------------------------------------------------------- /evens-or-odds/src/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from 'redux'; 2 | import settingsReducer from './settings'; 3 | import deckReducer from './deck'; 4 | import gameStateReducer from './gameState'; 5 | 6 | export default combineReducers({ 7 | settings: settingsReducer, 8 | deck: deckReducer, 9 | gameState: gameStateReducer 10 | }); 11 | -------------------------------------------------------------------------------- /evens-or-odds/src/reducers/settings.js: -------------------------------------------------------------------------------- 1 | import { SET_GAME_STARTED, SET_INSTRUCTIONS_EXPANDED } from '../actions/types'; 2 | 3 | const DEFAULT_SETTINGS = { 4 | gameStarted: false, 5 | instructionsExpanded: false 6 | }; 7 | 8 | const settingsReducer = (state = DEFAULT_SETTINGS, action) => { 9 | switch(action.type) { 10 | case SET_GAME_STARTED: 11 | return { ...state, gameStarted: action.gameStarted }; 12 | case SET_INSTRUCTIONS_EXPANDED: 13 | return { ...state, instructionsExpanded: action.instructionsExpanded }; 14 | default: 15 | return state; 16 | } 17 | }; 18 | 19 | export default settingsReducer; 20 | -------------------------------------------------------------------------------- /music-master/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@babel/plugin-proposal-class-properties"] 3 | } -------------------------------------------------------------------------------- /music-master/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "music-master", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "parcel src/index.html", 8 | "build": "parcel build src/index.html", 9 | "start": "npm run build && live-server dist" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "@babel/core": "^7.2.2", 16 | "@babel/plugin-proposal-class-properties": "^7.2.3", 17 | "live-server": "^1.2.1", 18 | "parcel-bundler": "^1.10.3", 19 | "react": "^16.6.3", 20 | "react-dom": "^16.6.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /music-master/src/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/music-master/src/assets/economica-bold.ttf -------------------------------------------------------------------------------- /music-master/src/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/music-master/src/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /music-master/src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import Search from './Search'; 3 | import Artist from './Artist'; 4 | import Tracks from './Tracks'; 5 | 6 | const API_ADDRESS = 'https://spotify-api-wrapper.appspot.com'; 7 | 8 | class App extends Component { 9 | state = { artist: null, tracks: [] }; 10 | 11 | searchArtist = artistQuery => { 12 | fetch(`${API_ADDRESS}/artist/${artistQuery}`) 13 | .then(response => response.json()) 14 | .then(json => { 15 | if (json.artists.total > 0) { 16 | const artist = json.artists.items[0]; 17 | 18 | this.setState({ artist }); 19 | 20 | fetch(`${API_ADDRESS}/artist/${artist.id}/top-tracks`) 21 | .then(response => response.json()) 22 | .then(json => this.setState({ tracks: json.tracks })) 23 | .catch(error => alert(error.message)); 24 | } 25 | }) 26 | .catch(error => alert(error.message)); 27 | } 28 | 29 | render() { 30 | return ( 31 |
32 |

Music Master

33 | 34 | 35 | 36 |
37 | ); 38 | } 39 | } 40 | 41 | export default App; 42 | -------------------------------------------------------------------------------- /music-master/src/components/Artist.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Artist = ({ artist }) => { 4 | if (!artist) return null; 5 | 6 | const { images, name, followers, genres } = artist; 7 | 8 | return ( 9 |
10 |

{name}

11 |

{followers.total} followers

12 |

{genres.join(', ')}

13 | artist-profile 23 |
24 | ) 25 | } 26 | 27 | export default Artist; 28 | -------------------------------------------------------------------------------- /music-master/src/components/Search.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class Search extends Component { 4 | state = { artistQuery: '' }; 5 | 6 | updateArtistQuery = event => { 7 | this.setState({ artistQuery: event.target.value }); 8 | } 9 | 10 | handleKeyPress = event => { 11 | if (event.key === 'Enter') { 12 | this.searchArtist(); 13 | } 14 | } 15 | 16 | searchArtist = () => { 17 | this.props.searchArtist(this.state.artistQuery); 18 | } 19 | 20 | render() { 21 | return ( 22 |
23 | 28 | 29 |
30 | ) 31 | } 32 | } 33 | 34 | export default Search; 35 | -------------------------------------------------------------------------------- /music-master/src/components/Tracks.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class Tracks extends Component { 4 | state = { playing: false, audio: null, playingPreviewUrl: null }; 5 | 6 | playAudio = previewUrl => () => { 7 | const audio = new Audio(previewUrl); 8 | 9 | if (!this.state.playing) { 10 | audio.play(); 11 | this.setState({ playing: true, audio, playingPreviewUrl: previewUrl }); 12 | } else { 13 | this.state.audio.pause(); 14 | 15 | if (this.state.playingPreviewUrl === previewUrl) { 16 | this.setState({ playing: false }); 17 | } else { 18 | audio.play(); 19 | this.setState({ audio, playingPreviewUrl: previewUrl }); 20 | } 21 | } 22 | } 23 | 24 | trackIcon = track => { 25 | if (!track.preview_url) { 26 | return N/A; 27 | } 28 | 29 | if ( 30 | this.state.playing && 31 | this.state.playingPreviewUrl === track.preview_url 32 | ) { 33 | return | |; 34 | } 35 | 36 | return ; 37 | } 38 | 39 | render() { 40 | const { tracks } = this.props; 41 | 42 | return ( 43 |
44 | { 45 | tracks.map(track => { 46 | const { id, name, album, preview_url } = track; 47 | 48 | return ( 49 |
54 | track-image 59 |

{name}

60 |

{this.trackIcon(track)}

61 |
62 | ) 63 | }) 64 | } 65 |
66 | ) 67 | } 68 | } 69 | 70 | export default Tracks; 71 | -------------------------------------------------------------------------------- /music-master/src/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .track { 24 | width: 250px; 25 | height: 250px; 26 | position: relative; 27 | display: inline-block; 28 | margin: 20px; 29 | cursor: pointer; 30 | } 31 | 32 | .track-image { 33 | width: 250px; 34 | height: 250px; 35 | } 36 | 37 | .track-text { 38 | position: absolute; 39 | width: 250px; 40 | bottom: 0px; 41 | background-color: black; 42 | color: white; 43 | padding: 5px; 44 | } 45 | 46 | .track-icon { 47 | position: absolute; 48 | bottom: 100px; 49 | left: 100px; 50 | color: white; 51 | background-color: black; 52 | width: 50px; 53 | height: 50px; 54 | border-radius: 25px; 55 | padding: 10px; 56 | opacity: 0.8; 57 | } -------------------------------------------------------------------------------- /music-master/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Music Master 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /music-master/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './components/App'; 4 | import './index.css'; 5 | 6 | ReactDOM.render(, document.getElementById('root')); 7 | -------------------------------------------------------------------------------- /news/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@babel/plugin-proposal-class-properties"] 3 | } -------------------------------------------------------------------------------- /news/client/src/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/news/client/src/assets/economica-bold.ttf -------------------------------------------------------------------------------- /news/client/src/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/news/client/src/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /news/client/src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class App extends Component { 4 | state = { stories: [] }; 5 | 6 | componentDidMount() { 7 | fetch('http://localhost:3000/topstories') 8 | .then(response => response.json()) 9 | .then(json => this.setState({ stories: json })) 10 | .catch(error => alert(error.message)); 11 | } 12 | 13 | render() { 14 | return ( 15 |
16 |

The Latest Hacker News

17 | { 18 | this.state.stories.map(item => { 19 | const { id, by, score, title, url } = item; 20 | 21 | console.log('item', item); 22 | 23 | return ( 24 |
25 | {title} 26 |

Upvotes: {score}

27 |

{by}}

28 |
29 | ) 30 | }) 31 | } 32 |
33 | ); 34 | } 35 | } 36 | 37 | export default App; 38 | -------------------------------------------------------------------------------- /news/client/src/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .profile { 24 | width: 200px; 25 | height: 200px; 26 | border-radius: 100px; 27 | } 28 | 29 | .title-fade-out { 30 | opacity: 0; 31 | animation-name: fade-out; 32 | animation-duration: 2s; 33 | } 34 | 35 | .title-fade-in { 36 | opacity: 100; 37 | animation-name: fade-in; 38 | animation-duration: 2s; 39 | } 40 | 41 | @keyframes fade-out { 42 | from {opacity: 100} 43 | to {opacity: 0} 44 | } 45 | 46 | @keyframes fade-in { 47 | from {opacity: 0} 48 | to {opacity: 100} 49 | } 50 | -------------------------------------------------------------------------------- /news/client/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | News 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /news/client/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './components/App'; 4 | import './index.css'; 5 | 6 | ReactDOM.render(, document.getElementById('root')); 7 | -------------------------------------------------------------------------------- /news/index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const request = require('request'); 3 | const path = require('path'); 4 | const stories = require('./stories'); 5 | 6 | const app = express(); 7 | 8 | app.use((req, res, next) => { 9 | console.log('Request details. Method:', req.method, 'Original url:', req.originalUrl); 10 | 11 | next(); 12 | }); 13 | 14 | app.use((req, res, next) => { 15 | res.header('Access-Control-Allow-Origin', '*'); 16 | 17 | next(); 18 | }); 19 | 20 | app.use(express.static(path.join(__dirname, 'client/dist'))); 21 | 22 | app.get('/ping', (req, res) => { 23 | res.send('pong!'); 24 | }); 25 | 26 | app.get('/stories', (req, res) => { 27 | res.json(stories); 28 | }); 29 | 30 | app.get('/stories/:title', (req, res) => { 31 | const { title } = req.params; 32 | 33 | res.json(stories.filter(story => story.title.includes(title))); 34 | }); 35 | 36 | app.get('/topstories', (req, res, next) => { 37 | request( 38 | { url: 'https://hacker-news.firebaseio.com/v0/topstories.json' }, 39 | (error, response, body) => { 40 | if (error || response.statusCode !== 200) { 41 | return next(new Error('Error requesting top stories')); 42 | } 43 | 44 | const topStories = JSON.parse(body); 45 | const limit = 10; 46 | 47 | res.json( 48 | topStories.slice(0, limit).map(story => ( 49 | request( 50 | { url: `https://hacker-news.firebaseio.com/v0/item/${story}.json` }, 51 | (error, response, body) => { 52 | if (error || response.statusCode !== 200) { 53 | return next(new Error('Error requesting story item')); 54 | } 55 | 56 | console.log('JSON.parse(body)', JSON.parse(body)); 57 | 58 | return JSON.parse(body); 59 | } 60 | ) 61 | )) 62 | ); 63 | } 64 | ) 65 | }); 66 | 67 | app.use((err, req, res, next) => { 68 | res.status(500).json({ type: 'error', message: err.message }); 69 | }); 70 | 71 | const PORT = 3000; 72 | app.listen(PORT, () => console.log(`listening on ${PORT}`)); 73 | -------------------------------------------------------------------------------- /news/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "news", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "npm run build-client && node ./", 8 | "dev": "nodemon ./", 9 | "dev-client": "parcel client/src/index.html", 10 | "build-client": "parcel build client/src/index.html --out-dir client/dist", 11 | "start-client": "npm run build && live-server client/dist" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "express": "^4.16.4", 18 | "live-server": "^1.2.1", 19 | "parcel-bundler": "^1.10.3", 20 | "react": "^16.6.3", 21 | "react-dom": "^16.6.3", 22 | "request": "^2.88.0", 23 | "@babel/core": "^7.2.2", 24 | "@babel/plugin-proposal-class-properties": "^7.2.3" 25 | }, 26 | "devDependencies": { 27 | "nodemon": "^1.18.9" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /news/stories.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Bye Bye Mongo, Hello Postgres", 5 | "url": "https://www.theguardian.com/info/2018/nov/30/bye-bye-mongo-hello-postgres", 6 | "by": "philliphaydon" 7 | }, 8 | { 9 | "id": 2, 10 | "title": "Glitter bomb tricks parcel thieves", 11 | "url": "https://www.bbc.com/news/technology-46604625", 12 | "by": "tartoran" 13 | }, 14 | { 15 | "id": 3, 16 | "title": "Why parking minimums almost destroyed my town and how we repealed them (2017)", 17 | "url": "https://www.strongtowns.org/journal/2017/11/22/how-parking-minimums-almost-destroyed-my-hometown-and-how-we-repealed-them", 18 | "by": "tartoran" 19 | }, 20 | { 21 | "id": 4, 22 | "title": "The Yoda of Silicon Valley", 23 | "url": "https://www.nytimes.com/2018/12/17/science/donald-knuth-computers-algorithms-programming.html", 24 | "by": "sohkamyung" 25 | }, 26 | { 27 | "id": 5, 28 | "title": "How is NSA breaking so much crypto?", 29 | "url": "https://freedom-to-tinker.com/blog/haldermanheninger/how-is-nsa-breaking-so-much-crypto/", 30 | "by": "sohkamyung" 31 | }, 32 | { 33 | "id": 6, 34 | "title": "NASA’s IMAGE satellite, lost since 2005, is alive", 35 | "url": "https://www.nytimes.com/2018/12/17/science/donald-knuth-computers-algorithms-programming.html", 36 | "by": "sohkamyung" 37 | }, 38 | { 39 | "id": 7, 40 | "title": "MIPS Goes Open Source", 41 | "url": "https://www.eetimes.com/document.asp?doc_id=1334087", 42 | "by": "walterbell" 43 | }, 44 | { 45 | "id": 8, 46 | "title": "Training Your Brain So That You Don’t Need Reading Glasses (2017)", 47 | "url": "https://www.nytimes.com/2017/03/27/upshot/training-your-brain-so-that-you-dont-need-reading-glasses.html", 48 | "by": "walterbell" 49 | }, 50 | { 51 | "id": 9, 52 | "title": "Google Tech Dev Guide", 53 | "url": "https://techdevguide.withgoogle.com/", 54 | "by": "myroon5" 55 | }, 56 | { 57 | "id": 10, 58 | "title": "Bitcoin Mining Now Consuming More Electricity Than Many Countries", 59 | "url": "https://powercompare.co.uk/bitcoin/", 60 | "by": "myroon5" 61 | } 62 | ] 63 | -------------------------------------------------------------------------------- /portfolio/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@babel/plugin-proposal-class-properties"] 3 | } -------------------------------------------------------------------------------- /portfolio/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /portfolio/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /portfolio/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "portfolio", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@babel/plugin-proposal-class-properties": "^7.2.3", 7 | "history": "^4.7.2", 8 | "live-server": "^1.2.1", 9 | "parcel-bundler": "^1.10.3", 10 | "pubnub": "^4.21.7", 11 | "react": "^16.6.3", 12 | "react-dom": "^16.6.3", 13 | "react-redux": "^6.0.0", 14 | "react-router-dom": "^4.3.1", 15 | "redux": "^4.0.1", 16 | "redux-thunk": "^2.3.0", 17 | "uuid": "^3.3.2" 18 | }, 19 | "scripts": { 20 | "dev": "parcel src/index.html", 21 | "build": "parcel build src/index.html", 22 | "start": "npm run build && live-server dist" 23 | }, 24 | "devDependencies": { 25 | "@babel/core": "^7.2.2" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /portfolio/src/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/economica-bold.ttf -------------------------------------------------------------------------------- /portfolio/src/assets/email_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/email_icon.png -------------------------------------------------------------------------------- /portfolio/src/assets/github_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/github_icon.png -------------------------------------------------------------------------------- /portfolio/src/assets/linkedin_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/linkedin_icon.png -------------------------------------------------------------------------------- /portfolio/src/assets/profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/profile.png -------------------------------------------------------------------------------- /portfolio/src/assets/project1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/project1.png -------------------------------------------------------------------------------- /portfolio/src/assets/project2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/project2.png -------------------------------------------------------------------------------- /portfolio/src/assets/project3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/project3.png -------------------------------------------------------------------------------- /portfolio/src/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /portfolio/src/assets/twitter_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/assets/twitter_icon.png -------------------------------------------------------------------------------- /portfolio/src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import Projects from './Projects'; 3 | import SocialProfiles from './SocialProfiles'; 4 | import Title from './Title'; 5 | import profile from '../assets/profile.png'; 6 | 7 | class App extends Component { 8 | state = { displayBio: false }; 9 | 10 | toggleDisplayBio = () => { 11 | this.setState({ displayBio: !this.state.displayBio }); 12 | } 13 | 14 | render() { 15 | return ( 16 |
17 | profile 18 |

Hello!

19 |

My name is David.

20 | 21 | <p>I'm always looking forward to working on meaningful projects.</p> 22 | { 23 | this.state.displayBio ? ( 24 | <div> 25 | <p>I live in San Francisco, and code every day.</p> 26 | <p>My favorite language is JavaScript, and I think React.js is awesome.</p> 27 | <p>Besides coding, I also love music and ramen!</p> 28 | <button onClick={this.toggleDisplayBio}>Show less</button> 29 | </div> 30 | ) : ( 31 | <div> 32 | <button onClick={this.toggleDisplayBio}>Read more</button> 33 | </div> 34 | ) 35 | } 36 | <hr /> 37 | <Projects /> 38 | <hr /> 39 | <SocialProfiles /> 40 | </div> 41 | ) 42 | } 43 | } 44 | 45 | export default App; 46 | -------------------------------------------------------------------------------- /portfolio/src/components/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router-dom'; 3 | 4 | const Header = ({ children }) => { 5 | const style = { 6 | display: 'inline-block', 7 | margin: 10, 8 | marginBottom: 30 9 | }; 10 | 11 | return ( 12 | <div> 13 | <div> 14 | <h3 style={style}><Link to='/'>Home</Link></h3> 15 | <h3 style={style}><Link to='/jokes'>Jokes</Link></h3> 16 | <h3 style={style}><Link to='/music-master'>Music Master</Link></h3> 17 | <h3 style={style}><Link to='/evens-or-odds'>Evens or Odds</Link></h3> 18 | <h3 style={style}><Link to='/reaction'>Reaction</Link></h3> 19 | </div> 20 | {children} 21 | </div> 22 | ) 23 | } 24 | 25 | export default Header; 26 | -------------------------------------------------------------------------------- /portfolio/src/components/Jokes.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | const Joke = ({ joke: { setup, punchline } }) => ( 4 | <p style={{ margin: 20 }}>{setup} <em>{punchline}</em></p> 5 | ) 6 | 7 | class Jokes extends Component { 8 | state = { joke: {}, jokes: [] }; 9 | 10 | componentDidMount() { 11 | fetch('https://official-joke-api.appspot.com/random_joke') 12 | .then(response => response.json()) 13 | .then(json => this.setState({ joke: json })) 14 | .catch(error => alert(error.message)); 15 | } 16 | 17 | fetchJokes = () => { 18 | fetch('https://official-joke-api.appspot.com/random_ten') 19 | .then(response => response.json()) 20 | .then(json => this.setState({ jokes: json })) 21 | .catch(error => alert(error.message)); 22 | } 23 | 24 | render() { 25 | return ( 26 | <div> 27 | <h2>Highlighted Joke</h2> 28 | <Joke joke={this.state.joke} /> 29 | <hr /> 30 | <h3>Want ten new jokes?</h3> 31 | <button onClick={this.fetchJokes}>Click me!</button> 32 | {this.state.jokes.map(joke => (<Joke key={joke.id} joke={joke} />))} 33 | </div> 34 | ) 35 | } 36 | } 37 | 38 | export default Jokes; 39 | -------------------------------------------------------------------------------- /portfolio/src/components/Projects.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PROJECTS from '../data/projects'; 3 | 4 | const Project = props => { 5 | const { title, image, description, link } = props.project; 6 | 7 | return ( 8 | <div style={{ display: 'inline-block', width: 300, margin: 10 }}> 9 | <h3>{title}</h3> 10 | <img src={image} alt='profile' style={{ width: 200, height: 120 }} /> 11 | <p>{description}</p> 12 | <a href={link}>{link}</a> 13 | </div> 14 | ) 15 | } 16 | 17 | const Projects = () => ( 18 | <div> 19 | <h2>Highlighted Projects</h2> 20 | <div> 21 | { 22 | PROJECTS.map(PROJECT => ( 23 | <Project key={PROJECT.id} project={PROJECT} /> 24 | )) 25 | } 26 | </div> 27 | </div> 28 | ) 29 | 30 | export default Projects; 31 | -------------------------------------------------------------------------------- /portfolio/src/components/SocialProfiles.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import SOCIAL_PROFILES from '../data/socialProfiles'; 3 | 4 | const SocialProfile = props => { 5 | const { link, image } = props.socialProfile; 6 | 7 | return ( 8 | <span> 9 | <a href={link}> 10 | <img src={image} alt='social-profile' style={{ width: 35, height: 35, margin: 10 }} /> 11 | </a> 12 | </span> 13 | ) 14 | } 15 | 16 | const SocialProfiles = () => ( 17 | <div> 18 | <h2>Connect with me!</h2> 19 | <div> 20 | { 21 | SOCIAL_PROFILES.map(SOCIAL_PROFILE => { 22 | return <SocialProfile key={SOCIAL_PROFILE.id} socialProfile={SOCIAL_PROFILE} />; 23 | }) 24 | } 25 | </div> 26 | </div> 27 | ) 28 | 29 | export default SocialProfiles; 30 | -------------------------------------------------------------------------------- /portfolio/src/components/Title.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | const TITLES = [ 4 | 'a software engineer', 5 | 'a music lover', 6 | 'an enthusiastic learner', 7 | 'an adventure seeker' 8 | ]; 9 | 10 | class Title extends Component { 11 | state = { titleIndex: 0, fadeIn: true }; 12 | 13 | componentDidMount() { 14 | this.timeout = setTimeout(() => this.setState({ fadeIn: false }), 2000); 15 | 16 | this.animateTitles(); 17 | } 18 | 19 | componentWillUnmount() { 20 | clearInterval(this.titleInterval); 21 | clearTimeout(this.timeout); 22 | } 23 | 24 | animateTitles = () => { 25 | this.titleInterval = setInterval(() => { 26 | const titleIndex = (this.state.titleIndex + 1) % TITLES.length; 27 | 28 | this.setState({ titleIndex, fadeIn: true }); 29 | 30 | this.timeout = setTimeout(() => this.setState({ fadeIn: false }), 2000); 31 | }, 4000); 32 | } 33 | 34 | render() { 35 | const { fadeIn, titleIndex } = this.state; 36 | 37 | const title = TITLES[titleIndex]; 38 | 39 | return ( 40 | <p className={fadeIn ? 'title-fade-in' : 'title-fade-out'}>I am {title}</p> 41 | ) 42 | } 43 | } 44 | 45 | export default Title; 46 | -------------------------------------------------------------------------------- /portfolio/src/data/projects.js: -------------------------------------------------------------------------------- 1 | import project1 from '../assets/project1.png'; 2 | import project2 from '../assets/project2.png'; 3 | import project3 from '../assets/project3.png'; 4 | 5 | const PROJECTS = [ 6 | { 7 | id: 1, 8 | title: 'Example React Application', 9 | description: 'A React App that I built, involving JS and core web dev concepts!', 10 | link: 'https://github.com/15Dkatz/example', 11 | image: project1 12 | }, 13 | { 14 | id: 2, 15 | title: 'My API', 16 | description: 'A REST API that I built from scratch with GET and POST requests!', 17 | link: 'https://github.com/15Dkatz/example', 18 | image: project2 19 | }, 20 | { 21 | id: 3, 22 | title: 'Operating Systems Final Project', 23 | description: 'My unique final project for my university Operating Systems course.', 24 | link: 'https://github.com/15Dkatz/example', 25 | image: project3 26 | } 27 | ]; 28 | 29 | export default PROJECTS; 30 | -------------------------------------------------------------------------------- /portfolio/src/data/socialProfiles.js: -------------------------------------------------------------------------------- 1 | import emailIcon from '../assets/email_icon.png'; 2 | import githubIcon from '../assets/github_icon.png'; 3 | import linkedinIcon from '../assets/linkedin_icon.png'; 4 | import twitterIcon from '../assets/twitter_icon.png'; 5 | 6 | const SOCIAL_PROFILES = [ 7 | { 8 | id: 1, 9 | link: 'mailto:dkcodehelper@gmail.com', 10 | image: emailIcon 11 | }, 12 | { 13 | id: 2, 14 | link: 'https://github.com/15Dkatz', 15 | image: githubIcon 16 | }, 17 | { 18 | id: 3, 19 | link: 'https://www.linkedin.com/in/david-katz-sf', 20 | image: linkedinIcon 21 | }, 22 | { 23 | id: 4, 24 | link: 'https://twitter.com/dkcodehelper', 25 | image: twitterIcon 26 | } 27 | ]; 28 | 29 | export default SOCIAL_PROFILES; 30 | -------------------------------------------------------------------------------- /portfolio/src/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .profile { 24 | width: 200px; 25 | height: 200px; 26 | border-radius: 100px; 27 | } 28 | 29 | .title-fade-out { 30 | opacity: 0; 31 | animation-name: fade-out; 32 | animation-duration: 2s; 33 | } 34 | 35 | .title-fade-in { 36 | opacity: 100; 37 | animation-name: fade-in; 38 | animation-duration: 2s; 39 | } 40 | 41 | @keyframes fade-out { 42 | from {opacity: 100} 43 | to {opacity: 0} 44 | } 45 | 46 | @keyframes fade-in { 47 | from {opacity: 0} 48 | to {opacity: 100} 49 | } -------------------------------------------------------------------------------- /portfolio/src/index.html: -------------------------------------------------------------------------------- 1 | <!DOCTYPE html> 2 | <html lang="en"> 3 | <head> 4 | <title>Portfolio 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /portfolio/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { Router, Switch, Route } from 'react-router-dom'; 4 | import createBrowserHistory from 'history/createBrowserHistory'; 5 | import App from './components/App'; 6 | import Jokes from './components/Jokes'; 7 | import MusicMaster from './projects/music-master'; 8 | import EvensOrOdds from './projects/evens-or-odds'; 9 | import Reaction from './projects/reaction'; 10 | import Header from './components/Header'; 11 | import './index.css'; 12 | 13 | ReactDOM.render( 14 | 15 | 16 |
} /> 17 |
} /> 18 |
} /> 19 |
} /> 20 |
} /> 21 |
22 |
, 23 | document.getElementById('root') 24 | ); 25 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/actions/deck.js: -------------------------------------------------------------------------------- 1 | import { DECK, DECK_DRAW } from './types'; 2 | 3 | const API_ADDRESS = 'https://deck-of-cards-api-wrapper.appspot.com'; 4 | 5 | export const fetchDeckSuccess = deckJson => { 6 | const { remaining, deck_id } = deckJson; 7 | 8 | return { type: DECK.FETCH_SUCCESS, remaining, deck_id }; 9 | } 10 | 11 | export const fetchDeckError = error => { 12 | return { type: DECK.FETCH_ERROR, message: error.message }; 13 | } 14 | 15 | export const fetchNewDeck = () => dispatch => { 16 | return fetch(`${API_ADDRESS}/deck/new/shuffle`) 17 | .then(response => { 18 | if (response.status !== 200) { 19 | throw new Error('Unsuccessful request to deckofcardsapi.com'); 20 | } 21 | 22 | return response.json(); 23 | }) 24 | .then(json => dispatch(fetchDeckSuccess(json))) 25 | .catch(error => dispatch(fetchDeckError(error))); 26 | } 27 | 28 | export const fetchDrawCard = deck_id => dispatch => { 29 | return fetch(`${API_ADDRESS}/deck/${deck_id}/draw`) 30 | .then(response => { 31 | if (response.status !== 200) { 32 | throw new Error('Unsuccessful request to deckofcardsapi.com'); 33 | } 34 | 35 | return response.json(); 36 | }) 37 | .then(json => { 38 | dispatch({ 39 | type: DECK_DRAW.FETCH_SUCCESS, 40 | cards: json.cards, 41 | remaining: json.remaining 42 | }); 43 | }) 44 | .catch(error => dispatch({ type: DECK_DRAW.FETCH_ERROR, message: error.message })); 45 | } -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/actions/guess.js: -------------------------------------------------------------------------------- 1 | import { SET_GUESS } from './types'; 2 | 3 | export const setGuessEven = () => { 4 | return { type: SET_GUESS, guess: 'even' }; 5 | } 6 | 7 | export const setGuessOdd = () => { 8 | return { type: SET_GUESS, guess: 'odd' }; 9 | } -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/actions/settings.js: -------------------------------------------------------------------------------- 1 | import { SET_GAME_STARTED, SET_INSTRUCTIONS_EXPANDED } from './types'; 2 | 3 | export const startGame = () => { 4 | return { type: SET_GAME_STARTED, gameStarted: true }; 5 | }; 6 | 7 | export const cancelGame = () => { 8 | return { type: SET_GAME_STARTED, gameStarted: false }; 9 | } 10 | 11 | export const expandInstructions = () => { 12 | return { type: SET_INSTRUCTIONS_EXPANDED, instructionsExpanded: true }; 13 | } 14 | 15 | export const collapseInstructions = () => { 16 | return { type: SET_INSTRUCTIONS_EXPANDED, instructionsExpanded: false }; 17 | } -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/actions/types.js: -------------------------------------------------------------------------------- 1 | export const SET_GAME_STARTED = 'SET_GAME_STARTED'; 2 | export const SET_INSTRUCTIONS_EXPANDED = 'SET_INSTRUCTIONS_EXPANDED'; 3 | export const SET_GUESS = 'SET_GUESS'; 4 | 5 | export const DECK = { 6 | FETCH_SUCCESS: 'DECK_FETCH_SUCCESS', 7 | FETCH_ERROR: 'DECK_FETCH_ERROR' 8 | }; 9 | 10 | export const DECK_DRAW = { 11 | FETCH_SUCCESS: 'DECK_DRAW_FETCH_SUCCESS', 12 | FETCH_ERROR: 'DECK_DRAW_FETCH_SUCCESS' 13 | }; 14 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/projects/evens-or-odds/assets/economica-bold.ttf -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/projects/evens-or-odds/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { startGame, cancelGame } from '../actions/settings'; 4 | import { fetchNewDeck } from '../actions/deck'; 5 | import fetchStates from '../reducers/fetchStates'; 6 | import Instructions from './Instructions'; 7 | import DrawCard from './DrawCard'; 8 | import Card from './Card'; 9 | import Guess from './Guess'; 10 | import GameState from './GameState'; 11 | 12 | class App extends Component { 13 | startGame = () => { 14 | this.props.startGame(); 15 | this.props.fetchNewDeck(); 16 | } 17 | 18 | render() { 19 | console.log('this', this); 20 | 21 | if (this.props.fetchState === fetchStates.error) { 22 | return ( 23 |
24 |

Please try reloading the app. An error occurred.

25 |

{this.props.message}

26 |
27 | ) 28 | } 29 | 30 | return ( 31 |
32 |

♡ ♤ Evens or Odds ♢ ♧

33 | { 34 | this.props.gameStarted ? ( 35 |
36 |

The game is on!

37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
47 | ) : ( 48 |
49 |

A new game awaits

50 |
51 | 52 |
53 | 54 |
55 | ) 56 | } 57 |
58 | ); 59 | } 60 | } 61 | 62 | const mapStateToProps = state => { 63 | const { 64 | settings: { gameStarted }, 65 | deck: { fetchState, message } 66 | } = state; 67 | 68 | return { gameStarted, fetchState, message }; 69 | } 70 | 71 | // const mapDispatchToProps = dispatch => { 72 | // return { 73 | // startGame: () => dispatch(startGame()), 74 | // cancelGame: () => dispatch(cancelGame()), 75 | // fetchNewDeck: () => dispatch(fetchNewDeck()) 76 | // }; 77 | // } 78 | 79 | const componentConnector = connect( 80 | mapStateToProps, 81 | { startGame, cancelGame, fetchNewDeck } 82 | ); 83 | 84 | export default componentConnector(App); 85 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/components/Card.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | 4 | const Card = ({ cards }) => { 5 | if (!cards[0]) return null; 6 | 7 | const { value, suit, image } = cards[0]; 8 | 9 | return ( 10 |
11 |

{value} of {suit}

12 | card-image 13 |
14 | ) 15 | } 16 | 17 | export default connect(({ deck: { cards } }) => ({ cards }))(Card); 18 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/components/DrawCard.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { fetchDrawCard } from '../actions/deck'; 4 | 5 | const DrawCard = ({ deck_id, fetchDrawCard }) => { 6 | return ( 7 |
8 | 9 |
10 | ) 11 | } 12 | 13 | const mapDispatchToProps = dispatch => { 14 | return { 15 | fetchDrawCard: deck_id => () => dispatch(fetchDrawCard(deck_id)) 16 | }; 17 | } 18 | 19 | export default connect( 20 | ({ deck: { deck_id } }) => ({ deck_id }), 21 | mapDispatchToProps 22 | )(DrawCard); 23 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/components/GameState.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | 4 | const correctGuessesRecordKey = 'CORRECT_GUESSES_RECORD_foo123'; 5 | 6 | const checkRecord = correctGuesses => { 7 | const record = Number(localStorage.getItem(correctGuessesRecordKey)); 8 | 9 | if (correctGuesses > record) { 10 | localStorage.setItem(correctGuessesRecordKey, correctGuesses); 11 | 12 | return { record: correctGuesses, isNewRecord: true }; 13 | } 14 | 15 | return { record, isNewRecord: false }; 16 | }; 17 | 18 | const GameState = ({ remaining, correctGuesses }) => { 19 | const guessText = correctGuesses === 1 ? 'guess' : 'guesses'; 20 | const { record, isNewRecord } = checkRecord(correctGuesses); 21 | const recordLabel = isNewRecord ? '🎉 New record' : 'Record'; 22 | 23 | return ( 24 |
25 |

{recordLabel}: {record}

26 |

{remaining} cards remaining

27 |

{correctGuesses} correct {guessText}

28 |
29 | ); 30 | } 31 | 32 | export default connect( 33 | ({ 34 | deck: { remaining }, 35 | gameState: { correctGuesses } 36 | }) => ({ remaining, correctGuesses }) 37 | )(GameState); 38 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/components/Guess.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { setGuessEven, setGuessOdd } from '../actions/guess'; 4 | 5 | const Guess = ({ guess, setGuessEven, setGuessOdd }) => { 6 | return ( 7 |
8 |

Will it be even or odd?

9 |
10 | 14 | {' '} 15 | 19 |
20 |
21 | ) 22 | } 23 | 24 | export default connect( 25 | ({ gameState: { guess } }) => ({ guess }), 26 | { setGuessEven, setGuessOdd } 27 | )(Guess); 28 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/components/Instructions.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { expandInstructions, collapseInstructions } from '../actions/settings'; 4 | 5 | const Instructions = props => { 6 | const { instructionsExpanded, expandInstructions, collapseInstructions } = props; 7 | 8 | if (instructionsExpanded) { 9 | return ( 10 |
11 |

Instructions

12 |

Welcome to evens or odds. The game goes like this

13 |

The deck is shuffled. Then choose: will the next card be even or odd?

14 |

Make a choice on every draw, and see how many you get right!

15 |

(Face cards don't count)

16 |
17 | 18 |
19 | ); 20 | } 21 | 22 | return ( 23 |
24 |

Instructions

25 |

Welcome to evens or odds. The game goes like this...

26 | 27 |
28 | ) 29 | } 30 | 31 | export default connect( 32 | state => ({ instructionsExpanded: state.settings.instructionsExpanded }), 33 | { expandInstructions, collapseInstructions } 34 | )(Instructions); 35 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .profile { 24 | width: 200px; 25 | height: 200px; 26 | border-radius: 100px; 27 | } 28 | 29 | .title-fade-out { 30 | opacity: 0; 31 | animation-name: fade-out; 32 | animation-duration: 2s; 33 | } 34 | 35 | .title-fade-in { 36 | opacity: 100; 37 | animation-name: fade-in; 38 | animation-duration: 2s; 39 | } 40 | 41 | @keyframes fade-out { 42 | from {opacity: 100} 43 | to {opacity: 0} 44 | } 45 | 46 | @keyframes fade-in { 47 | from {opacity: 0} 48 | to {opacity: 100} 49 | } 50 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { createStore, applyMiddleware } from 'redux'; 3 | import { Provider } from 'react-redux'; 4 | import thunk from 'redux-thunk'; 5 | import App from './components/App'; 6 | import rootReducer from './reducers'; 7 | import './index.css'; 8 | 9 | const store = createStore(rootReducer, applyMiddleware(thunk)); 10 | 11 | const EvensOrOdds = () => { 12 | return ( 13 | 14 | 15 | 16 | ) 17 | } 18 | 19 | export default EvensOrOdds; 20 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/reducers/deck.js: -------------------------------------------------------------------------------- 1 | import { DECK, DECK_DRAW } from '../actions/types'; 2 | import fetchStates from './fetchStates'; 3 | 4 | const DEFAULT_DECK = { deck_id: '', remaining: 0, fetchState: '', message: '', cards: [] }; 5 | 6 | const deckReducer = (state = DEFAULT_DECK, action) => { 7 | let remaining, deck_id, cards; 8 | 9 | switch(action.type) { 10 | case DECK.FETCH_SUCCESS: 11 | ({ remaining, deck_id } = action); 12 | return { ...state, remaining, deck_id, fetchState: fetchStates.success }; 13 | case DECK.FETCH_ERROR: 14 | return { ...state, message: action.message, fetchState: fetchStates.error }; 15 | case DECK_DRAW.FETCH_SUCCESS: 16 | ({ cards, remaining } = action); 17 | return { ...state, cards, remaining, fetchState: fetchStates.success }; 18 | case DECK_DRAW.FETCH_ERROR: 19 | return { ...state, message: action.message, fetchState: fetchStates.error }; 20 | default: 21 | return state; 22 | } 23 | }; 24 | 25 | export default deckReducer; 26 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/reducers/fetchStates.js: -------------------------------------------------------------------------------- 1 | export default { 2 | success: 'success', 3 | error: 'error' 4 | }; 5 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/reducers/gameState.js: -------------------------------------------------------------------------------- 1 | import { SET_GUESS, SET_GAME_STARTED, DECK_DRAW } from '../actions/types'; 2 | 3 | const DEFAULT_GAME_STATE = { guess: '', correctGuesses: 0 }; 4 | 5 | const EVENS = ['2', '4', '6', '8', '0']; 6 | const ODDS = ['ACE', '3', '5', '7', '9']; 7 | 8 | const gameStateReducer = (state = DEFAULT_GAME_STATE, action) => { 9 | switch(action.type) { 10 | case SET_GUESS: 11 | return { ...state, guess: action.guess }; 12 | case SET_GAME_STARTED: 13 | return DEFAULT_GAME_STATE; 14 | case DECK_DRAW.FETCH_SUCCESS: 15 | const { value } = action.cards[0]; 16 | const { guess, correctGuesses } = state; 17 | 18 | if ( 19 | (guess === 'even' && EVENS.includes(value)) || 20 | (guess === 'odd' && ODDS.includes(value)) 21 | ) { 22 | return { ...state, correctGuesses: correctGuesses+1 }; 23 | } 24 | 25 | return state; 26 | default: 27 | return state; 28 | } 29 | }; 30 | 31 | export default gameStateReducer; 32 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from 'redux'; 2 | import settingsReducer from './settings'; 3 | import deckReducer from './deck'; 4 | import gameStateReducer from './gameState'; 5 | 6 | export default combineReducers({ 7 | settings: settingsReducer, 8 | deck: deckReducer, 9 | gameState: gameStateReducer 10 | }); 11 | -------------------------------------------------------------------------------- /portfolio/src/projects/evens-or-odds/reducers/settings.js: -------------------------------------------------------------------------------- 1 | import { SET_GAME_STARTED, SET_INSTRUCTIONS_EXPANDED } from '../actions/types'; 2 | 3 | const DEFAULT_SETTINGS = { 4 | gameStarted: false, 5 | instructionsExpanded: false 6 | }; 7 | 8 | const settingsReducer = (state = DEFAULT_SETTINGS, action) => { 9 | switch(action.type) { 10 | case SET_GAME_STARTED: 11 | return { ...state, gameStarted: action.gameStarted }; 12 | case SET_INSTRUCTIONS_EXPANDED: 13 | return { ...state, instructionsExpanded: action.instructionsExpanded }; 14 | default: 15 | return state; 16 | } 17 | }; 18 | 19 | export default settingsReducer; 20 | -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/projects/music-master/assets/economica-bold.ttf -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/projects/music-master/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import Search from './Search'; 3 | import Artist from './Artist'; 4 | import Tracks from './Tracks'; 5 | 6 | const API_ADDRESS = 'https://spotify-api-wrapper.appspot.com'; 7 | 8 | class App extends Component { 9 | state = { artist: null, tracks: [] }; 10 | 11 | componentDidMount() { 12 | this.searchArtist('pentatonix'); 13 | } 14 | 15 | searchArtist = artistQuery => { 16 | fetch(`${API_ADDRESS}/artist/${artistQuery}`) 17 | .then(response => response.json()) 18 | .then(json => { 19 | if (json.artists.total > 0) { 20 | const artist = json.artists.items[0]; 21 | 22 | this.setState({ artist }); 23 | 24 | fetch(`${API_ADDRESS}/artist/${artist.id}/top-tracks`) 25 | .then(response => response.json()) 26 | .then(json => this.setState({ tracks: json.tracks })) 27 | .catch(error => alert(error.message)); 28 | } 29 | }) 30 | .catch(error => alert(error.message)); 31 | } 32 | 33 | render() { 34 | return ( 35 |
36 |

Music Master

37 | 38 | 39 | 40 |
41 | ); 42 | } 43 | } 44 | 45 | export default App; 46 | -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/components/Artist.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Artist = ({ artist }) => { 4 | if (!artist) return null; 5 | 6 | const { images, name, followers, genres } = artist; 7 | 8 | return ( 9 |
10 |

{name}

11 |

{followers.total} followers

12 |

{genres.join(',')}

13 | artist-profile 23 |
24 | ) 25 | } 26 | 27 | export default Artist; 28 | -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/components/Search.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class Search extends Component { 4 | state = { artistQuery: '' }; 5 | 6 | updateArtistQuery = event => { 7 | this.setState({ artistQuery: event.target.value }); 8 | } 9 | 10 | handleKeyPress = event => { 11 | if (event.key === 'Enter') { 12 | this.searchArtist(); 13 | } 14 | } 15 | 16 | searchArtist = () => { 17 | this.props.searchArtist(this.state.artistQuery); 18 | } 19 | 20 | render() { 21 | return ( 22 |
23 | 28 | 29 |
30 | ) 31 | } 32 | } 33 | 34 | export default Search; 35 | -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/components/Tracks.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class Tracks extends Component { 4 | state = { playing: false, audio: null, playingPreviewUrl: null }; 5 | 6 | playAudio = previewUrl => () => { 7 | const audio = new Audio(previewUrl); 8 | 9 | if (!this.state.playing) { 10 | audio.play(); 11 | this.setState({ playing: true, audio, playingPreviewUrl: previewUrl }); 12 | } else { 13 | this.state.audio.pause(); 14 | 15 | if (this.state.playingPreviewUrl === previewUrl) { 16 | this.setState({ playing: false }); 17 | } else { 18 | audio.play(); 19 | this.setState({ audio, playingPreviewUrl: previewUrl }); 20 | } 21 | } 22 | } 23 | 24 | trackIcon = track => { 25 | if (!track.preview_url) { 26 | return N/A; 27 | } 28 | 29 | if ( 30 | this.state.playing && 31 | this.state.playingPreviewUrl === track.preview_url 32 | ) { 33 | return | |; 34 | } 35 | 36 | return ; 37 | } 38 | 39 | render() { 40 | const { tracks } = this.props; 41 | 42 | return ( 43 |
44 | { 45 | tracks.map(track => { 46 | const { id, name, album, preview_url } = track; 47 | 48 | return ( 49 |
54 | track-image 59 |

{name}

60 |

{this.trackIcon(track)}

61 |
62 | ) 63 | }) 64 | } 65 |
66 | ) 67 | } 68 | } 69 | 70 | export default Tracks; 71 | -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .track { 24 | width: 250px; 25 | height: 250px; 26 | position: relative; 27 | display: inline-block; 28 | margin: 20px; 29 | cursor: pointer; 30 | } 31 | 32 | .track-image { 33 | width: 250px; 34 | height: 250px; 35 | } 36 | 37 | .track-text { 38 | position: absolute; 39 | width: 250px; 40 | bottom: 0px; 41 | background-color: black; 42 | color: white; 43 | padding: 5px; 44 | } 45 | 46 | .track-icon { 47 | position: absolute; 48 | bottom: 100px; 49 | left: 100px; 50 | color: white; 51 | background-color: black; 52 | width: 50px; 53 | height: 50px; 54 | border-radius: 25px; 55 | padding: 10px; 56 | opacity: 0.8; 57 | } -------------------------------------------------------------------------------- /portfolio/src/projects/music-master/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import App from './components/App'; 3 | import './index.css'; 4 | 5 | export default App; 6 | 7 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/actions/messages.js: -------------------------------------------------------------------------------- 1 | import { NEW_MESSAGE } from './types'; 2 | import uuid from 'uuid/v4'; 3 | 4 | export const newMessage = ({ text, username }) => ({ 5 | type: NEW_MESSAGE, 6 | item: { id: uuid(), timestamp: Date.now(), text, username } 7 | }); -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/actions/reactions.js: -------------------------------------------------------------------------------- 1 | import uuid from 'uuid/v4'; 2 | 3 | export const createReaction = ({ type, emoji, username, messageId }) => { 4 | return { 5 | type, 6 | item: { id: uuid(), timestamp: Date.now(), emoji, username, messageId } 7 | }; 8 | }; -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/actions/types.js: -------------------------------------------------------------------------------- 1 | export const NEW_MESSAGE = 'NEW_MESSAGE'; 2 | export const SET_USERNAME = 'SET_USERNAME'; 3 | 4 | export const REACTION_OBJECTS = [ 5 | { 6 | type: 'REACTION_LOVE', 7 | emoji: '❤️' 8 | }, 9 | { 10 | type: 'REACTION_LIKE', 11 | emoji: '👍' 12 | }, 13 | { 14 | type: 'REACTION_DISLIKE', 15 | emoji: '👎' 16 | }, 17 | { 18 | type: 'REACTION_LAUGH', 19 | emoji: '😂' 20 | } 21 | ]; -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/actions/username.js: -------------------------------------------------------------------------------- 1 | import { SET_USERNAME } from './types'; 2 | 3 | export const setUsername = username => ({ type: SET_USERNAME, username }); 4 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/projects/reaction/assets/economica-bold.ttf -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/portfolio/src/projects/reaction/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import PublishMessage from './PublishMessage'; 3 | import MessageBoard from './MessageBoard'; 4 | import SetUsername from './SetUsername'; 5 | 6 | class App extends Component { 7 | render() { 8 | return ( 9 |
10 |

Reaction

11 | 12 |
13 | 14 |
15 | 16 |
17 | ); 18 | } 19 | } 20 | 21 | export default App; 22 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/components/CreateReaction.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { REACTION_OBJECTS } from '../actions/types'; 4 | import { PubSubContext } from '../pubsub'; 5 | import { createReaction } from '../actions/reactions'; 6 | 7 | class CreateReaction extends Component { 8 | publishReaction = ({ type, emoji }) => () => { 9 | const { username, messageId } = this.props; 10 | 11 | this.context.pubsub.publish(createReaction({ type, emoji, username, messageId })); 12 | } 13 | 14 | render() { 15 | return ( 16 |
17 | { 18 | REACTION_OBJECTS.map(REACTION_OBJECT => { 19 | const { type, emoji } = REACTION_OBJECT; 20 | 21 | return ( 22 | 27 | {emoji} 28 | 29 | ) 30 | }) 31 | } 32 |
33 | ) 34 | } 35 | 36 | static contextType = PubSubContext; 37 | } 38 | 39 | export default connect(({ username }) => ({ username }))(CreateReaction); 40 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/components/MessageBoard.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import CreateReaction from './CreateReaction'; 4 | 5 | const MessageReactions = ({ messageReactions }) => { 6 | if (!messageReactions) return null; 7 | 8 | return ( 9 | messageReactions.map((reaction, index) => { 10 | const { id, emoji, username } = reaction; 11 | 12 | return ( 13 | 14 | {username}:{' '} 15 | {emoji} 16 | {index !== messageReactions.length - 1 ? ', ' : null} 17 | 18 | ) 19 | }) 20 | ) 21 | } 22 | 23 | const MessageBoard = ({ messages, reactions }) => { 24 | return ( 25 |
26 | { 27 | messages.items.map(messageItem => { 28 | const { id, text, timestamp, username } = messageItem; 29 | 30 | return ( 31 |
32 |

{new Date(timestamp).toLocaleString()}

33 |

{text}

34 |

- {username}

35 | 36 | 37 |
38 |
39 | ) 40 | }) 41 | } 42 |
43 | ) 44 | } 45 | 46 | export default connect( 47 | ({ messages, reactions }) => ({ messages, reactions }) 48 | )(MessageBoard); -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/components/PublishMessage.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { PubSubContext } from '../pubsub'; 4 | import { newMessage } from '../actions/messages'; 5 | 6 | class PublishMessage extends Component { 7 | state = { text: '' }; 8 | 9 | updateText = event => this.setState({ text: event.target.value }); 10 | 11 | publishMessage = () => { 12 | const { text } = this.state; 13 | const { username } = this.props; 14 | 15 | this.context.pubsub.publish(newMessage({ text, username })); 16 | } 17 | 18 | handleKeyPress = event => { 19 | if (event.key === 'Enter') this.publishMessage(); 20 | } 21 | 22 | render() { 23 | console.log('this', this); 24 | 25 | return ( 26 |
27 |

Got something to say?

28 | 29 | {' '} 30 | 31 |
32 | ) 33 | } 34 | 35 | static contextType = PubSubContext; 36 | } 37 | 38 | export default connect(({ username }) => ({ username }))(PublishMessage); 39 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/components/SetUsername.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { setUsername } from '../actions/username'; 4 | 5 | const SetUsername = ({ setUsername }) => { 6 | return ( 7 |
8 |

username

9 | 10 |
11 | ) 12 | }; 13 | 14 | const mapDispatchToProps = dispatch => { 15 | return { 16 | setUsername: event => dispatch(setUsername(event.target.value)) 17 | } 18 | } 19 | 20 | export default connect(null, mapDispatchToProps)(SetUsername); -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .profile { 24 | width: 200px; 25 | height: 200px; 26 | border-radius: 100px; 27 | } 28 | 29 | .title-fade-out { 30 | opacity: 0; 31 | animation-name: fade-out; 32 | animation-duration: 2s; 33 | } 34 | 35 | .title-fade-in { 36 | opacity: 100; 37 | animation-name: fade-in; 38 | animation-duration: 2s; 39 | } 40 | 41 | @keyframes fade-out { 42 | from {opacity: 100} 43 | to {opacity: 0} 44 | } 45 | 46 | @keyframes fade-in { 47 | from {opacity: 0} 48 | to {opacity: 100} 49 | } 50 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { createStore } from 'redux'; 3 | import { Provider } from 'react-redux'; 4 | import rootReducer from './reducers'; 5 | import PubSub, { PubSubContext } from './pubsub'; 6 | import App from './components/App'; 7 | import { newMessage } from './actions/messages'; 8 | import './index.css'; 9 | 10 | const store = createStore( 11 | rootReducer, 12 | window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() 13 | ); 14 | 15 | console.log('store.getState()', store.getState()); 16 | store.subscribe(() => console.log('store.getState()', store.getState())); 17 | 18 | const pubsub = new PubSub(); 19 | 20 | pubsub.addListener({ 21 | message: messageObject => { 22 | const { message, channel } = messageObject; 23 | 24 | console.log('Received message:', message, 'channel:', channel); 25 | 26 | store.dispatch(message); 27 | } 28 | }); 29 | 30 | setTimeout(() => { 31 | pubsub.publish(newMessage({ text: 'Hello world!', username: 'Bob' })); 32 | }, 1000); 33 | 34 | export default () => ( 35 | 36 | 37 | 38 | 39 | 40 | ); 41 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/pubnub.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "publishKey": "pub-c-0349860e-e28c-4344-a0b6-b6e269ad672e", 3 | "subscribeKey": "sub-c-b56b6750-1798-11e9-a971-425ad67106f3", 4 | "secretKey": "sec-c-MDQxZmQwMjgtMDMyYi00YTFlLThjMGYtMTdjYmFhODNhZTZm" 5 | } -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/pubsub.js: -------------------------------------------------------------------------------- 1 | import PubNub from 'pubnub'; 2 | import { createContext } from 'react'; 3 | import pubnubConfig from './pubnub.config'; 4 | 5 | export const MESSAGE_CHANNEL = 'MESSAGE_CHANNEL'; 6 | 7 | class PubSub { 8 | constructor() { 9 | this.pubnub = new PubNub(pubnubConfig); 10 | 11 | this.pubnub.subscribe({ channels: [MESSAGE_CHANNEL] }); 12 | } 13 | 14 | addListener = listenerConfig => { 15 | this.pubnub.addListener(listenerConfig); 16 | } 17 | 18 | publish = message => { 19 | console.log('publish message', message); 20 | 21 | this.pubnub.publish({ message, channel: MESSAGE_CHANNEL }); 22 | } 23 | } 24 | 25 | export const PubSubContext = createContext(); 26 | 27 | export default PubSub; 28 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from 'redux'; 2 | import messagesReducer from './messages'; 3 | import usernameReducer from './username'; 4 | import reactionsReducer from './reactions'; 5 | 6 | export default combineReducers({ 7 | messages: messagesReducer, 8 | username: usernameReducer, 9 | reactions: reactionsReducer 10 | }); 11 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/reducers/messages.js: -------------------------------------------------------------------------------- 1 | import { NEW_MESSAGE } from '../actions/types'; 2 | 3 | const DEFAULT_MESSAGES = { items: [] }; 4 | 5 | const messagesReducer = (state = DEFAULT_MESSAGES, action) => { 6 | switch(action.type) { 7 | case NEW_MESSAGE: 8 | return { ...state, items: [...state.items, action.item] }; 9 | default: 10 | return state; 11 | } 12 | } 13 | 14 | export default messagesReducer; 15 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/reducers/reactions.js: -------------------------------------------------------------------------------- 1 | import { REACTION_OBJECTS } from '../actions/types'; 2 | 3 | const REACTION_TYPES = REACTION_OBJECTS.map( 4 | REACTION_OBJECT => REACTION_OBJECT.type 5 | ); 6 | 7 | const reactionsReducer = (state = {}, action) => { 8 | if (REACTION_TYPES.includes(action.type)) { 9 | const { messageId } = action.item; 10 | const messageReactions = state[messageId]; 11 | 12 | if (messageReactions) { 13 | return { ...state, [messageId]: [...messageReactions, action.item] } 14 | } 15 | 16 | return { ...state, [messageId]: [action.item] }; 17 | } 18 | 19 | return state; 20 | } 21 | 22 | export default reactionsReducer; 23 | -------------------------------------------------------------------------------- /portfolio/src/projects/reaction/reducers/username.js: -------------------------------------------------------------------------------- 1 | import { SET_USERNAME } from '../actions/types'; 2 | 3 | const DEFAULT_USERNAME = 'anonymous'; 4 | 5 | const usernameReducer = (state = DEFAULT_USERNAME, action) => { 6 | switch(action.type) { 7 | case SET_USERNAME: 8 | return action.username; 9 | default: 10 | return state; 11 | } 12 | } 13 | 14 | export default usernameReducer; 15 | -------------------------------------------------------------------------------- /react-app-template/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@babel/plugin-proposal-class-properties"] 3 | } -------------------------------------------------------------------------------- /react-app-template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "music-master", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "parcel src/index.html", 8 | "build": "parcel build src/index.html", 9 | "start": "npm run build && live-server dist" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "@babel/core": "^7.2.2", 16 | "@babel/plugin-proposal-class-properties": "^7.2.3", 17 | "live-server": "^1.2.1", 18 | "parcel-bundler": "^1.10.3", 19 | "react": "^16.6.3", 20 | "react-dom": "^16.6.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /react-app-template/src/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/react-app-template/src/assets/economica-bold.ttf -------------------------------------------------------------------------------- /react-app-template/src/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/react-app-template/src/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /react-app-template/src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class App extends Component { 4 | render() { 5 | return ( 6 |
React App
7 | ); 8 | } 9 | } 10 | 11 | export default App; 12 | -------------------------------------------------------------------------------- /react-app-template/src/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | -------------------------------------------------------------------------------- /react-app-template/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Music Master 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /react-app-template/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './components/App'; 4 | import './index.css'; 5 | 6 | ReactDOM.render(, document.getElementById('root')); 7 | -------------------------------------------------------------------------------- /reaction/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@babel/plugin-proposal-class-properties"] 3 | } 4 | -------------------------------------------------------------------------------- /reaction/.gitignore: -------------------------------------------------------------------------------- 1 | *node_modules* 2 | *.cache* 3 | *dist* 4 | -------------------------------------------------------------------------------- /reaction/README.md: -------------------------------------------------------------------------------- 1 | ## React App Template 2 | 3 | Clone or download this project to bootstrap a React project! 4 | 5 | ### Getting Started 6 | 7 | Install the relevant `node_modules` and fire up the development server: 8 | 9 | ``` 10 | npm i && npm run dev 11 | ``` -------------------------------------------------------------------------------- /reaction/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reaction", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "parcel src/index.html", 8 | "build": "parcel build src/index.html", 9 | "start": "npm run build && live-server dist" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "live-server": "^1.2.1", 16 | "parcel-bundler": "^1.10.3", 17 | "pubnub": "^4.21.6", 18 | "react": "^16.6.3", 19 | "react-dom": "^16.6.3", 20 | "react-redux": "^6.0.0", 21 | "redux": "^4.0.1", 22 | "uuid": "^3.3.2" 23 | }, 24 | "devDependencies": { 25 | "@babel/core": "^7.2.2", 26 | "@babel/plugin-proposal-class-properties": "^7.2.3" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /reaction/src/actions/messages.js: -------------------------------------------------------------------------------- 1 | import { NEW_MESSAGE } from './types'; 2 | import uuid from 'uuid/v4'; 3 | 4 | export const newMessage = ({ text, username }) => ({ 5 | type: NEW_MESSAGE, 6 | item: { id: uuid(), timestamp: Date.now(), text, username } 7 | }); -------------------------------------------------------------------------------- /reaction/src/actions/reactions.js: -------------------------------------------------------------------------------- 1 | import uuid from 'uuid/v4'; 2 | 3 | export const createReaction = ({ type, emoji, username, messageId }) => { 4 | return { 5 | type, 6 | item: { id: uuid(), timestamp: Date.now(), emoji, username, messageId } 7 | }; 8 | }; -------------------------------------------------------------------------------- /reaction/src/actions/types.js: -------------------------------------------------------------------------------- 1 | export const NEW_MESSAGE = 'NEW_MESSAGE'; 2 | export const SET_USERNAME = 'SET_USERNAME'; 3 | 4 | export const REACTION_OBJECTS = [ 5 | { 6 | type: 'REACTION_LOVE', 7 | emoji: '❤️' 8 | }, 9 | { 10 | type: 'REACTION_LIKE', 11 | emoji: '👍' 12 | }, 13 | { 14 | type: 'REACTION_DISLIKE', 15 | emoji: '👎' 16 | }, 17 | { 18 | type: 'REACTION_LAUGH', 19 | emoji: '😂' 20 | } 21 | ]; -------------------------------------------------------------------------------- /reaction/src/actions/username.js: -------------------------------------------------------------------------------- 1 | import { SET_USERNAME } from './types'; 2 | 3 | export const setUsername = username => ({ type: SET_USERNAME, username }); 4 | -------------------------------------------------------------------------------- /reaction/src/assets/economica-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/reaction/src/assets/economica-bold.ttf -------------------------------------------------------------------------------- /reaction/src/assets/roboto-condensed.light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15Dkatz/react-bootcamp/56cdb06fadad6ed962029aa67a80e976e6e33ff0/reaction/src/assets/roboto-condensed.light.ttf -------------------------------------------------------------------------------- /reaction/src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import PublishMessage from './PublishMessage'; 3 | import MessageBoard from './MessageBoard'; 4 | import SetUsername from './SetUsername'; 5 | 6 | class App extends Component { 7 | render() { 8 | return ( 9 |
10 |

Reaction

11 | 12 |
13 | 14 |
15 | 16 |
17 | ); 18 | } 19 | } 20 | 21 | export default App; 22 | -------------------------------------------------------------------------------- /reaction/src/components/CreateReaction.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { REACTION_OBJECTS } from '../actions/types'; 4 | import { PubSubContext } from '../pubsub'; 5 | import { createReaction } from '../actions/reactions'; 6 | 7 | class CreateReaction extends Component { 8 | publishReaction = ({ type, emoji }) => () => { 9 | const { username, messageId } = this.props; 10 | 11 | this.context.pubsub.publish(createReaction({ type, emoji, username, messageId })); 12 | } 13 | 14 | render() { 15 | return ( 16 |
17 | { 18 | REACTION_OBJECTS.map(REACTION_OBJECT => { 19 | const { type, emoji } = REACTION_OBJECT; 20 | 21 | return ( 22 | 27 | {emoji} 28 | 29 | ) 30 | }) 31 | } 32 |
33 | ) 34 | } 35 | 36 | static contextType = PubSubContext; 37 | } 38 | 39 | export default connect(({ username }) => ({ username }))(CreateReaction); 40 | -------------------------------------------------------------------------------- /reaction/src/components/MessageBoard.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import CreateReaction from './CreateReaction'; 4 | 5 | const MessageReactions = ({ messageReactions }) => { 6 | if (!messageReactions) return null; 7 | 8 | return ( 9 | messageReactions.map((reaction, index) => { 10 | const { id, emoji, username } = reaction; 11 | 12 | return ( 13 | 14 | {username}:{' '} 15 | {emoji} 16 | {index !== messageReactions.length - 1 ? ', ' : null} 17 | 18 | ) 19 | }) 20 | ) 21 | } 22 | 23 | const MessageBoard = ({ messages, reactions }) => { 24 | return ( 25 |
26 | { 27 | messages.items.map(messageItem => { 28 | const { id, text, timestamp, username } = messageItem; 29 | 30 | return ( 31 |
32 |

{new Date(timestamp).toLocaleString()}

33 |

{text}

34 |

- {username}

35 | 36 | 37 |
38 |
39 | ) 40 | }) 41 | } 42 |
43 | ) 44 | } 45 | 46 | export default connect( 47 | ({ messages, reactions }) => ({ messages, reactions }) 48 | )(MessageBoard); -------------------------------------------------------------------------------- /reaction/src/components/PublishMessage.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { PubSubContext } from '../pubsub'; 4 | import { newMessage } from '../actions/messages'; 5 | 6 | class PublishMessage extends Component { 7 | state = { text: '' }; 8 | 9 | updateText = event => this.setState({ text: event.target.value }); 10 | 11 | publishMessage = () => { 12 | const { text } = this.state; 13 | const { username } = this.props; 14 | 15 | this.context.pubsub.publish(newMessage({ text, username })); 16 | } 17 | 18 | handleKeyPress = event => { 19 | if (event.key === 'Enter') this.publishMessage(); 20 | } 21 | 22 | render() { 23 | console.log('this', this); 24 | 25 | return ( 26 |
27 |

Got something to say?

28 | 29 | {' '} 30 | 31 |
32 | ) 33 | } 34 | 35 | static contextType = PubSubContext; 36 | } 37 | 38 | export default connect(({ username }) => ({ username }))(PublishMessage); 39 | -------------------------------------------------------------------------------- /reaction/src/components/SetUsername.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { setUsername } from '../actions/username'; 4 | 5 | const SetUsername = ({ setUsername }) => { 6 | return ( 7 |
8 |

username

9 | 10 |
11 | ) 12 | }; 13 | 14 | const mapDispatchToProps = dispatch => { 15 | return { 16 | setUsername: event => dispatch(setUsername(event.target.value)) 17 | } 18 | } 19 | 20 | export default connect(null, mapDispatchToProps)(SetUsername); -------------------------------------------------------------------------------- /reaction/src/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: RobotoCondensed; 3 | src: url(assets/roboto-condensed.light.ttf); 4 | font-weight: 800; 5 | } 6 | 7 | @font-face { 8 | font-family: EconomicaBold; 9 | src: url(assets/economica-bold.ttf); 10 | } 11 | 12 | body { 13 | text-align: center; 14 | font-size: 20px; 15 | padding: 2.5%; 16 | font-family: 'RobotoCondensed'; 17 | } 18 | 19 | h1, h2, h3, h4, h5 { 20 | font-family: 'EconomicaBold'; 21 | } 22 | 23 | .profile { 24 | width: 200px; 25 | height: 200px; 26 | border-radius: 100px; 27 | } 28 | 29 | .title-fade-out { 30 | opacity: 0; 31 | animation-name: fade-out; 32 | animation-duration: 2s; 33 | } 34 | 35 | .title-fade-in { 36 | opacity: 100; 37 | animation-name: fade-in; 38 | animation-duration: 2s; 39 | } 40 | 41 | @keyframes fade-out { 42 | from {opacity: 100} 43 | to {opacity: 0} 44 | } 45 | 46 | @keyframes fade-in { 47 | from {opacity: 0} 48 | to {opacity: 100} 49 | } 50 | -------------------------------------------------------------------------------- /reaction/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Reaction 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /reaction/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { createStore } from 'redux'; 4 | import { Provider } from 'react-redux'; 5 | import rootReducer from './reducers'; 6 | import PubSub, { PubSubContext } from './pubsub'; 7 | import App from './components/App'; 8 | import { newMessage } from './actions/messages'; 9 | import './index.css'; 10 | 11 | const store = createStore( 12 | rootReducer, 13 | window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() 14 | ); 15 | 16 | console.log('store.getState()', store.getState()); 17 | store.subscribe(() => console.log('store.getState()', store.getState())); 18 | 19 | const pubsub = new PubSub(); 20 | 21 | pubsub.addListener({ 22 | message: messageObject => { 23 | const { message, channel } = messageObject; 24 | 25 | console.log('Received message:', message, 'channel:', channel); 26 | 27 | store.dispatch(message); 28 | } 29 | }); 30 | 31 | setTimeout(() => { 32 | pubsub.publish(newMessage({ text: 'Hello world!', username: 'Bob' })); 33 | }, 1000); 34 | 35 | ReactDOM.render( 36 | 37 | 38 | 39 | 40 | , 41 | document.getElementById('root') 42 | ); 43 | -------------------------------------------------------------------------------- /reaction/src/pubnub.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "publishKey": "copy-your-publishKey", 3 | "subscribeKey": "copy-your-subscribeKey", 4 | "secretKey": "copy-your-secretKey" 5 | } 6 | -------------------------------------------------------------------------------- /reaction/src/pubsub.js: -------------------------------------------------------------------------------- 1 | import PubNub from 'pubnub'; 2 | import { createContext } from 'react'; 3 | import pubnubConfig from './pubnub.config'; 4 | 5 | export const MESSAGE_CHANNEL = 'MESSAGE_CHANNEL'; 6 | 7 | class PubSub { 8 | constructor() { 9 | this.pubnub = new PubNub(pubnubConfig); 10 | 11 | this.pubnub.subscribe({ channels: [MESSAGE_CHANNEL] }); 12 | } 13 | 14 | addListener = listenerConfig => { 15 | this.pubnub.addListener(listenerConfig); 16 | } 17 | 18 | publish = message => { 19 | console.log('publish message', message); 20 | 21 | this.pubnub.publish({ message, channel: MESSAGE_CHANNEL }); 22 | } 23 | } 24 | 25 | export const PubSubContext = createContext(); 26 | 27 | export default PubSub; 28 | -------------------------------------------------------------------------------- /reaction/src/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from 'redux'; 2 | import messagesReducer from './messages'; 3 | import usernameReducer from './username'; 4 | import reactionsReducer from './reactions'; 5 | 6 | export default combineReducers({ 7 | messages: messagesReducer, 8 | username: usernameReducer, 9 | reactions: reactionsReducer 10 | }); 11 | -------------------------------------------------------------------------------- /reaction/src/reducers/messages.js: -------------------------------------------------------------------------------- 1 | import { NEW_MESSAGE } from '../actions/types'; 2 | 3 | const DEFAULT_MESSAGES = { items: [] }; 4 | 5 | const messagesReducer = (state = DEFAULT_MESSAGES, action) => { 6 | switch(action.type) { 7 | case NEW_MESSAGE: 8 | return { ...state, items: [...state.items, action.item] }; 9 | default: 10 | return state; 11 | } 12 | } 13 | 14 | export default messagesReducer; 15 | -------------------------------------------------------------------------------- /reaction/src/reducers/reactions.js: -------------------------------------------------------------------------------- 1 | import { REACTION_OBJECTS } from '../actions/types'; 2 | 3 | const REACTION_TYPES = REACTION_OBJECTS.map( 4 | REACTION_OBJECT => REACTION_OBJECT.type 5 | ); 6 | 7 | const reactionsReducer = (state = {}, action) => { 8 | if (REACTION_TYPES.includes(action.type)) { 9 | const { messageId } = action.item; 10 | const messageReactions = state[messageId]; 11 | 12 | if (messageReactions) { 13 | return { ...state, [messageId]: [...messageReactions, action.item] } 14 | } 15 | 16 | return { ...state, [messageId]: [action.item] }; 17 | } 18 | 19 | return state; 20 | } 21 | 22 | export default reactionsReducer; 23 | -------------------------------------------------------------------------------- /reaction/src/reducers/username.js: -------------------------------------------------------------------------------- 1 | import { SET_USERNAME } from '../actions/types'; 2 | 3 | const DEFAULT_USERNAME = 'anonymous'; 4 | 5 | const usernameReducer = (state = DEFAULT_USERNAME, action) => { 6 | switch(action.type) { 7 | case SET_USERNAME: 8 | return action.username; 9 | default: 10 | return state; 11 | } 12 | } 13 | 14 | export default usernameReducer; 15 | -------------------------------------------------------------------------------- /starter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | -------------------------------------------------------------------------------- /starter/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | 4 | // const element = React.createElement('div', null, 'React element!'); 5 | const element =
React element with JSX!
; 6 | 7 | ReactDOM.render(element, document.getElementById('root')); -------------------------------------------------------------------------------- /starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "starter", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "parcel index.html" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "parcel-bundler": "^1.10.3", 14 | "react": "^16.6.3", 15 | "react-dom": "^16.6.3" 16 | } 17 | } 18 | --------------------------------------------------------------------------------