From b18c085afea8ac5ec03048d5d51a09f51ba70e41 Mon Sep 17 00:00:00 2001 From: Chris Zieba Date: Tue, 3 Oct 2017 23:57:41 -0700 Subject: [PATCH] Add youtube lib --- src/App.css | 7 ++--- src/App.js | 6 ++++ src/components/Form/Form.css | 53 ++++++++++++++++++++++++++++++------ src/components/Form/Form.js | 18 +++++++++--- src/index.css | 3 +- src/lib/youtube.js | 48 ++++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 src/lib/youtube.js diff --git a/src/App.css b/src/App.css index 0ebad88..c5ce3a4 100644 --- a/src/App.css +++ b/src/App.css @@ -3,16 +3,13 @@ .app { padding-top: 25px; text-align: center; - background-color: #B9461A; - border: 8px solid black; color: white; - min-height: 800px; } .social { position: absolute; - top: 25px; - left: 25px; + top: 15px; + left: 15px; } .social iframe { diff --git a/src/App.js b/src/App.js index 994a888..cfcd775 100644 --- a/src/App.js +++ b/src/App.js @@ -1,10 +1,16 @@ import React, { Component } from 'react'; import './App.css'; import logo from './logo.png'; +import youtube from './lib/youtube'; import Container from './components/Container/Container'; class App extends Component { + componentWillMount() { + // Load the youtube player asap + youtube.init(); + } + render() { return (
diff --git a/src/components/Form/Form.css b/src/components/Form/Form.css index 7590519..c319262 100644 --- a/src/components/Form/Form.css +++ b/src/components/Form/Form.css @@ -2,17 +2,52 @@ } -#form select { - margin: 0 12px 10px 0; - outline: none; +#form select.genre { + margin: 0 12px 10px 0; + outline: none; + color: #B9461A; + font-weight: bold; + text-overflow: ellipsis; + text-overflow: ""; +} + +#form .slider { + -webkit-appearance: none; /* Override default CSS styles */ + appearance: none; + width: 200px; /* Full-width */ + height: 25px; /* Specified height */ + background: #d3d3d3; /* Grey background */ + outline: none; /* Remove outline */ + opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */ + -webkit-transition: .2s; /* 0.2 seconds transition on hover */ + transition: opacity .2s; +} - color: #B9461A; - padding:6px 10px; +/* Mouse-over effects */ +#form .slider:hover { + opacity: 1; /* Fully shown on mouse-over */ +} - font-weight: bold; - text-overflow: ellipsis; +/* The slider handle (use webkit (Chrome, Opera, Safari, Edge) and moz (Firefox) to override default look) */ +#form .slider::-webkit-slider-thumb { + -webkit-appearance: none; /* Override default look */ + appearance: none; + width: 25px; /* Set a specific slider handle width */ + height: 25px; /* Slider handle height */ + background: #4CAF50; /* Green background */ + cursor: pointer; /* Cursor on hover */ +} +#form .slider::-moz-range-thumb { + width: 25px; /* Set a specific slider handle width */ + height: 25px; /* Slider handle height */ + background: #4CAF50; /* Green background */ + cursor: pointer; /* Cursor on hover */ +} - text-indent: 0.01px; - text-overflow: ""; +#form label { + width: 200px; + color: #e3e3e3; + font-weight: bold; + text-align: right; } \ No newline at end of file diff --git a/src/components/Form/Form.js b/src/components/Form/Form.js index 0287f07..582d28e 100644 --- a/src/components/Form/Form.js +++ b/src/components/Form/Form.js @@ -2,29 +2,39 @@ import React, { Component } from 'react'; import './Form.css'; class Form extends Component { + submit() { + // Clear out the player view + // Get token to use with the spotify api if time has passed + // Get recomendations + // Find videos on youtube + } + render() { return (
-
- +
- +
- +
+ +
); } diff --git a/src/index.css b/src/index.css index 11f51cd..9e5e552 100644 --- a/src/index.css +++ b/src/index.css @@ -1,6 +1,5 @@ body { margin: 0; - padding: 12px; font-family: sans-serif; - background-color: #F28333; + background-color: #B9461A; } \ No newline at end of file diff --git a/src/lib/youtube.js b/src/lib/youtube.js new file mode 100644 index 0000000..675b8ae --- /dev/null +++ b/src/lib/youtube.js @@ -0,0 +1,48 @@ +'use strict'; + +let player; + +const youtube = { + init: () => { + console.log(234); + // This code loads the IFrame Player API code asynchronously. + const tag = document.createElement('script'); + + tag.src = "https://www.youtube.com/iframe_api"; + const firstScriptTag = document.getElementsByTagName('script')[0]; + firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); + + // Youtube api needs to use the global space + window.onYouTubeIframeAPIReady = () => { + player = new YT.Player('player', { + height: '279', + width: '372', + videoId: '', + playerVars: { + 'wmode': 'opaque', + 'rel': 0, + 'showinfo': 1, + 'controls': 2 + }, + events: { + 'onReady': function () { + ytf.init(); + }, + 'onStateChange': function (event) { + + ytf.setPageTitle(event.data); + + if (event.data == YT.PlayerState.ENDED) { + ytf.next(); + } + } + } + }); + } + }, + getPlayer: () => { + return player; + } +}; + +export default youtube; \ No newline at end of file