Skip to content

Commit

Permalink
comments + spotify functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanneMadison committed Feb 8, 2024
1 parent 1362438 commit aced71f
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 8 deletions.
18 changes: 16 additions & 2 deletions valentines24/package-lock.json

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

1 change: 1 addition & 0 deletions valentines24/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@iconify/react": "^4.1.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
14 changes: 10 additions & 4 deletions valentines24/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, { useState } from 'react';
import Button from 'react-bootstrap/Button';
import Carousel from './components/carousel.js'
import Spotify from './components/spotify.js';
import Heart from './images/heart.gif';
import Pink from './images/multiple_hearts.gif';
import Love from './images/love_you.gif';
Expand All @@ -28,10 +29,12 @@ function App() {
const [yesPress, setYesPressed] = useState(false);
const yesButtonSize = noCount * 20 + 16;

/* Count "no" clicks */
function handleNoClick() {
setNoCount(noCount + 1);
}

/* Get next phrase from array on each no button click */
function getNoButtonText() {
return phrases[Math.min(noCount, phrases.length - 1)];
}
Expand All @@ -41,25 +44,27 @@ function App() {
<div className="valentine-container">
{yesPress ? (
<>
{/* add a a photo of both of us here.*/}
{/* Handle yes button press */}
<img class="love-you" src={Love} alt="A love you gif" />
<Carousel />
<img class="pink" src={Pink} alt="A pink hearts gif" />
<div className="accept">
<h1>Yay!! Thanks Pookie!! Love you lots!! {"<"}3</h1>
<h1> Enjoy some of my favorite memories of us, Happy Valentines Day!!</h1>
<iframe title="Playa Saturno" style={{borderRadius: '12px', position: 'absolute', right: '20px', bottom: '-50px', }} src="https://open.spotify.com/embed/album/6E7Awtyx6opYTbPXx6ApzB?utm_source=generator" width="20%" height="352" frameBorder="0" allowfullscreen="" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>
<Spotify />
{/*<iframe title="Playa Saturno" style={{borderRadius: '12px', position: 'absolute', right: '20px', bottom: '-50px', }} src="https://open.spotify.com/embed/album/6E7Awtyx6opYTbPXx6ApzB?utm_source=generator" width="20%" height="352" frameBorder="0" allowfullscreen="" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>*/}
</div>
</>
) : (

<>
{/* Add a valentine's day photo here.*/}
{/* Website on arrival */}
<img src={Heart} alt="A heart gif" />
<div className="paragraphText">
<h1>Will you be my valentine?</h1>
</div>
<div className="Buttons">
{/* Pass yes button size */}
<Button
className="yesButton"
style = {{fontSize: yesButtonSize,}}
Expand All @@ -69,7 +74,7 @@ function App() {
>
Yes
</Button>

{/* Handle no button click, increase yes size */}
<Button
className = "noButton"
onClick = {handleNoClick}
Expand All @@ -78,6 +83,7 @@ function App() {


>
{/* Alternate through phrases */}
{getNoButtonText()}
</Button>
</div>
Expand Down
4 changes: 3 additions & 1 deletion valentines24/src/components/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Vgk from '../images/vgk.jpeg';
import HighRoller from '../images/highroller.jpeg';



/* Array of photos to cycle through */
const images = {
cervezas: <img src={Cervezas} alt="Jordan and Madison at a bar in Las Vegas" />,
coaster: <img src={Coaster} alt="Jordan and Madison at Adventureland in Iowa" />,
Expand Down Expand Up @@ -53,6 +53,7 @@ function CarouselImages() {

const [currentIndex, setCurrentIndex] = useState(0);

/* On effect, get a random photo index, change every 5 seconds. */
useEffect (() => {
const intervalId = setInterval(() => {
const randomIndex = Math.floor(Math.random() * Object.keys(images).length);
Expand All @@ -61,6 +62,7 @@ function CarouselImages() {
return () => clearInterval(intervalId);
}, []);

/* Enter, map, and cycle through images */
const carouselItems = Object.entries(images).map(([key, image], index) => (
<Carousel.Item key={key}>
<div className="carousel">
Expand Down
2 changes: 1 addition & 1 deletion valentines24/src/components/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "./navbar.css";

function BasicExample() {
return (

/* Navbar w/ Icon */
<Navbar bg="navbarColor" data-bs-theme="dark" className="navbarText">
<div className="ps-5 pt-3 d-inline-block align-center">
<Icon icon="noto:pink-heart" alt="Heart Logo" width="50" height="50"></Icon>
Expand Down
22 changes: 22 additions & 0 deletions valentines24/src/components/spotify.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#spotify-embed-container{
border-radius: 12px;
position: absolute;
right: 20px;
bottom: -55px;
font-family: "Brush Script MT", cursive;
}

#spotify-controls .spotify-controls-right{
position: absolute;
right: 70px;
bottom: -70px;
color: black;
}

#spotify-controls .spotify-controls-left {
position: absolute;
right: 200px;
bottom: -70px;
color: black;

}
93 changes: 93 additions & 0 deletions valentines24/src/components/spotify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React, { useEffect, useRef, useState } from 'react';
import { Icon } from '@iconify/react';
import './spotify.css';

function SpotifyEmbed() {
const embedRef = useRef(null);
const [currentTrackIndex, setCurrentTrackIndex] = useState(0);

//List of Spotify URIs
const trackURIs = [
//Sunflower by Post Malone and Swae Lee
'spotify:track:3KkXRkHbMCARz0aVfEt68P',

//Yukon (Interlude) by Joji
'spotify:track:5IPl8JpkbtSH1mdyq5ctSx',

//BESO by Rosalía and Rauw Alejandro
'spotify:track:609E1JCInJncactoMmkDon',

//Dial Drunk by Post Malone and Noah Kahan
'spotify:track:22VHOlVYBqytsrAqV8yXBK',

//Sancutary by Joji
'spotify:track:4VQH4VluDUOsOuDxccTeyN',

//Die For You by Joji
'spotify:track:26hOm7dTtBi0TdpDGl141t',

//VAMPIROS by Rosalía and Rauw Alejandro
'spotify:track:3Eax1yebRxj6LSYpxE9Yd3',
];

useEffect(() => {
//Get current reference
const embedElement = embedRef.current;

//Function to update the embed source, and parse the URI
function updateEmbed() {
const currentTrackURI = trackURIs[currentTrackIndex];
const embedSource = `https://open.spotify.com/embed/track/${currentTrackURI.split(':')[2]}`;
embedElement.src = embedSource;

embedElement.contentWindow.postMessage(
{
event: 'command',
func: 'playVideo',
},
'*'
);
}

// Initial update
updateEmbed();


}, [currentTrackIndex]);

//Go forward and backward in the track list and wrap around
const goForward = () => {
setCurrentTrackIndex((currentTrackIndex + 1) % trackURIs.length);

};

const goBackward = () => {
setCurrentTrackIndex((currentTrackIndex - 1 + trackURIs.length) % trackURIs.length);
};

return (
<>
{/* Spotify Embed with Passed Reference */}
<div id="spotify-embed-container">
<h1> Jordan's Playlist! </h1>
<iframe
ref={embedRef}
title="Spotify Embed"
width="300"
height="380"
frameBorder="0"
allowTransparency="true"
allow="encrypted-media"
></iframe>
</div>

{/* Spotify Controls */}
<div id="spotify-controls">
<Icon icon="majesticons:arrow-right" className="spotify-controls-right" width="50" height="50" onClick={goForward} />
<Icon icon="majesticons:arrow-left" className="spotify-controls-left" width="50" height="50" onClick={goBackward} />
</div>
</>
);
}

export default SpotifyEmbed;

0 comments on commit aced71f

Please sign in to comment.