├── .gitignore ├── README.md ├── firebase.json ├── firestore.indexes.json ├── firestore.rules ├── package-lock.json ├── package.json ├── public ├── assets │ ├── audio │ │ ├── Anuel AA - Keii.mp3 │ │ ├── Elephante - Glass Mansion.mp3 │ │ ├── Galantis & Yellow Claw - We Can Get High.mp3 │ │ ├── Lauv & LANY - Mean It.mp3 │ │ ├── Midnight Kids - Run It.mp3 │ │ ├── Post Malone - Circles.mp3 │ │ ├── Ráptame - Reik.mp3 │ │ ├── SHY Martin - Good Together.mp3 │ │ ├── Selena Gomez - Hands To Myself.mp3 │ │ └── Shawn Mendes, Zedd - Lost In Japan (Remix).mp3 │ └── images │ │ ├── Anuel AA - Keii.jpg │ │ ├── Elephante - Glass Mansion.jpeg │ │ ├── Flow.jpg │ │ ├── Galantis - Church.jpg │ │ ├── House.jpg │ │ ├── Lauv - in my feelings.jpg │ │ ├── Midnight Kids - Run It.jpg │ │ ├── Placeholder.jpg │ │ ├── Post Malone - Hollywoods Bleeding.jpg │ │ ├── Reik - Ahora.jpg │ │ ├── SHY Martin - Overthinking.jpg │ │ ├── Selena Gomez - Revival.jpg │ │ └── Shawn Mendes - Lost in Japan.jpg ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── src ├── App.js ├── App.test.js ├── Components │ ├── ListItem.js │ ├── Miniplayer.js │ ├── PlaylistPicker.js │ ├── ProgressBar.js │ └── ProgressSlider.js ├── Contexts │ ├── DisplayContext.js │ ├── MusicContext.js │ └── ThemeContext.js ├── Example.js ├── Hooks │ ├── useAudio.js │ ├── useCloud.js │ └── useDisplay.js ├── Main.js ├── Styles │ ├── App.css │ ├── MusicPlayer.css │ └── MusicPlayerM.css ├── Views │ ├── ListMenu.js │ ├── MainScreen.js │ ├── MusicPlayer-Backup.js │ └── MusicPlayer.js ├── assets │ └── icons │ │ ├── PlusSquareBtn.jpg │ │ ├── back.svg │ │ ├── dots.svg │ │ ├── pause.svg │ │ ├── play.svg │ │ ├── plus.svg │ │ ├── repeat.svg │ │ ├── shuffle.svg │ │ ├── skipbackward.svg │ │ └── skipforward.svg ├── data │ ├── Playlist.js │ └── Songs.js ├── fonts │ ├── Futura_PT_Book.ttf │ ├── Futura_PT_ExtraBold.ttf │ ├── Futura_PT_Heavy.ttf │ ├── Futura_PT_Light.ttf │ └── Futura_PT_Medium.ttf ├── index.css ├── index.js ├── logo.svg ├── serviceWorker.js └── setupTests.js └── storage.rules /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "firestore": { 3 | "rules": "firestore.rules", 4 | "indexes": "firestore.indexes.json" 5 | }, 6 | "hosting": { 7 | "public": "build", 8 | "ignore": [ 9 | "firebase.json", 10 | "**/.*", 11 | "**/node_modules/**" 12 | ], 13 | "rewrites": [ 14 | { 15 | "source": "**", 16 | "destination": "/index.html" 17 | } 18 | ] 19 | }, 20 | "storage": { 21 | "rules": "storage.rules" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /firestore.indexes.json: -------------------------------------------------------------------------------- 1 | { 2 | "indexes": [], 3 | "fieldOverrides": [] 4 | } 5 | -------------------------------------------------------------------------------- /firestore.rules: -------------------------------------------------------------------------------- 1 | rules_version = '2'; 2 | service cloud.firestore { 3 | match /databases/{database}/documents { 4 | 5 | // This rule allows anyone on the internet to view, edit, and delete 6 | // all data in your Firestore database. It is useful for getting 7 | // started, but it is configured to expire after 30 days because it 8 | // leaves your app open to attackers. At that time, all client 9 | // requests to your Firestore database will be denied. 10 | // 11 | // Make sure to write security rules for your app before that time, or else 12 | // your app will lose access to your Firestore database 13 | match /{document=**} { 14 | allow read, write: if request.time < timestamp.date(2020, 4, 9); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "musicplayer", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.4.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "feather-icons": "^4.26.0", 10 | "firebase": "^7.10.0", 11 | "neumorphic-ui": "^1.1.0", 12 | "nouislider": "^14.1.1", 13 | "react": "^16.12.0", 14 | "react-addons-css-transition-group": "^15.6.2", 15 | "react-audio-player": "^0.11.1", 16 | "react-dom": "^16.12.0", 17 | "react-filter-search": "^1.0.9", 18 | "react-icons": "^3.9.0", 19 | "react-palette": "^1.0.1", 20 | "react-router": "^5.1.2", 21 | "react-router-dom": "^5.1.2", 22 | "react-router-transition": "^2.0.0", 23 | "react-scripts": "3.4.0", 24 | "react-sound": "^1.2.0", 25 | "react-transition-group": "^4.3.0", 26 | "shards-react": "^1.0.3" 27 | }, 28 | "scripts": { 29 | "start": "react-scripts start", 30 | "build": "react-scripts build", 31 | "test": "react-scripts test", 32 | "eject": "react-scripts eject" 33 | }, 34 | "eslintConfig": { 35 | "extends": "react-app" 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /public/assets/audio/Anuel AA - Keii.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Anuel AA - Keii.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Elephante - Glass Mansion.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Elephante - Glass Mansion.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Galantis & Yellow Claw - We Can Get High.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Galantis & Yellow Claw - We Can Get High.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Lauv & LANY - Mean It.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Lauv & LANY - Mean It.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Midnight Kids - Run It.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Midnight Kids - Run It.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Post Malone - Circles.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Post Malone - Circles.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Ráptame - Reik.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Ráptame - Reik.mp3 -------------------------------------------------------------------------------- /public/assets/audio/SHY Martin - Good Together.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/SHY Martin - Good Together.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Selena Gomez - Hands To Myself.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Selena Gomez - Hands To Myself.mp3 -------------------------------------------------------------------------------- /public/assets/audio/Shawn Mendes, Zedd - Lost In Japan (Remix).mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/audio/Shawn Mendes, Zedd - Lost In Japan (Remix).mp3 -------------------------------------------------------------------------------- /public/assets/images/Anuel AA - Keii.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Anuel AA - Keii.jpg -------------------------------------------------------------------------------- /public/assets/images/Elephante - Glass Mansion.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Elephante - Glass Mansion.jpeg -------------------------------------------------------------------------------- /public/assets/images/Flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Flow.jpg -------------------------------------------------------------------------------- /public/assets/images/Galantis - Church.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Galantis - Church.jpg -------------------------------------------------------------------------------- /public/assets/images/House.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/House.jpg -------------------------------------------------------------------------------- /public/assets/images/Lauv - in my feelings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Lauv - in my feelings.jpg -------------------------------------------------------------------------------- /public/assets/images/Midnight Kids - Run It.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Midnight Kids - Run It.jpg -------------------------------------------------------------------------------- /public/assets/images/Placeholder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Placeholder.jpg -------------------------------------------------------------------------------- /public/assets/images/Post Malone - Hollywoods Bleeding.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Post Malone - Hollywoods Bleeding.jpg -------------------------------------------------------------------------------- /public/assets/images/Reik - Ahora.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Reik - Ahora.jpg -------------------------------------------------------------------------------- /public/assets/images/SHY Martin - Overthinking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/SHY Martin - Overthinking.jpg -------------------------------------------------------------------------------- /public/assets/images/Selena Gomez - Revival.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Selena Gomez - Revival.jpg -------------------------------------------------------------------------------- /public/assets/images/Shawn Mendes - Lost in Japan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/assets/images/Shawn Mendes - Lost in Japan.jpg -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | Wave 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Wave", 3 | "name": "Wave Music", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { BrowserRouter } from 'react-router-dom'; 3 | 4 | import { MusicProvider } from "./Contexts/MusicContext"; 5 | import { ThemeProvider } from "./Contexts/ThemeContext"; 6 | import { DisplayProvider } from "./Contexts/DisplayContext"; 7 | 8 | import Main from "./Main"; 9 | 10 | import './Styles/App.css'; 11 | import "bootstrap/dist/css/bootstrap.min.css"; 12 | import "shards-ui/dist/css/shards.min.css"; 13 | 14 | function App() { 15 | return ( 16 |
17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 |
27 | ); 28 | } 29 | 30 | export default App; 31 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/Components/ListItem.js: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | import { useHistory } from 'react-router-dom'; 3 | 4 | import { MusicContext } from '../Contexts/MusicContext'; 5 | import { DisplayContext } from '../Contexts/DisplayContext'; 6 | 7 | import useAudio from '../Hooks/useAudio'; 8 | import useDisplay from '../Hooks/useDisplay'; 9 | 10 | import DotsIcon from '../assets/icons/dots.svg'; 11 | import AddPlaylistIcon from '../assets/icons/PlusSquareBtn.jpg'; 12 | 13 | const PlaylistListItem = ({ id, playlist, data }) => { 14 | const [state] = useContext(MusicContext); 15 | const [display] = useContext(DisplayContext) 16 | let history = useHistory(); 17 | const { 18 | addToPlaylist 19 | } = useAudio(); 20 | const { 21 | closeModal, 22 | closePlaylistPicker 23 | } = useDisplay(); 24 | 25 | return ( 26 |
27 | 49 |
50 | ); 51 | } 52 | 53 | const AddPlaylistListItem = () => { 54 | const [state] = useContext(MusicContext); 55 | const { 56 | createPlaylist 57 | } = useAudio(); 58 | 59 | return ( 60 |
61 | 73 |
74 | ); 75 | } 76 | 77 | const SongListItem = ({ 78 | i, 79 | track, 80 | data, 81 | playlistid, 82 | }) => { 83 | const [state] = useContext(MusicContext); 84 | const { 85 | changeTrack 86 | } = useAudio(); 87 | const { 88 | openModal, 89 | closeModal, 90 | setDisplaySong 91 | } = useDisplay(); 92 | 93 | return ( 94 |
95 | 115 | dots button { 119 | openModal(track); 120 | setDisplaySong(track); 121 | }} 122 | /> 123 |
124 | ); 125 | } 126 | 127 | export { PlaylistListItem, AddPlaylistListItem, SongListItem }; 128 | -------------------------------------------------------------------------------- /src/Components/Miniplayer.js: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | import { useHistory } from 'react-router-dom'; 3 | import { usePalette } from 'react-palette'; 4 | 5 | import { MusicContext } from '../Contexts/MusicContext'; 6 | 7 | import ProgressBar from '../Components/ProgressBar'; 8 | 9 | import useAudio from "../Hooks/useAudio"; 10 | 11 | import PlusIcon from '../assets/icons/plus.svg'; 12 | import PauseIcon from '../assets/icons/pause.svg'; 13 | import PlayIcon from '../assets/icons/play.svg'; 14 | 15 | import '../Styles/App.css'; 16 | 17 | const Miniplayer = () => { 18 | const [state] = useContext(MusicContext); 19 | const { 20 | togglePlay, 21 | play 22 | } = useAudio(); 23 | const { data } = usePalette(state.activeSong.thumbs[0]) 24 | let history = useHistory(); 25 | 26 | return ( 27 |
30 |
31 |
32 | 51 |
52 |
history.push('/player')} 54 | > 55 |
56 |
57 |
{state.activeSong.artist.join(', ')}
58 |
{state.activeSong.title}
59 |
60 | 68 |
69 | 70 |
71 |
72 |
73 | ); 74 | } 75 | 76 | export default Miniplayer; -------------------------------------------------------------------------------- /src/Components/PlaylistPicker.js: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | 3 | import { MusicContext } from '../Contexts/MusicContext'; 4 | import { DisplayContext } from '../Contexts/DisplayContext'; 5 | 6 | import { PlaylistListItem, AddPlaylistListItem } from './ListItem'; 7 | 8 | import useDisplay from '../Hooks/useDisplay'; 9 | 10 | import BackIcon from '../assets/icons/back.svg'; 11 | 12 | export const PlaylistPicker = () => { 13 | const [state] = useContext(MusicContext); 14 | const [display] = useContext(DisplayContext); 15 | const { 16 | closePlaylistPicker 17 | } = useDisplay(); 18 | 19 | return ( 20 |
23 |
24 | 29 | Add to Playlist 30 |
31 |
32 | 33 | {Object.keys(state.playlists).map((pl, i) => 34 | 40 | )} 41 |
42 |
43 | ); 44 | } -------------------------------------------------------------------------------- /src/Components/ProgressBar.js: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | 3 | import { MusicContext } from '../Contexts/MusicContext'; 4 | 5 | import '../Styles/App.css'; 6 | 7 | const ProgressBar = ({ color }) => { 8 | const [state] = useContext(MusicContext); 9 | 10 | return ( 11 |
12 |
17 |
18 | ); 19 | } 20 | 21 | export default ProgressBar; -------------------------------------------------------------------------------- /src/Components/ProgressSlider.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useContext } from 'react'; 2 | 3 | import { MusicContext } from '../Contexts/MusicContext'; 4 | 5 | import useAudio from "../Hooks/useAudio"; 6 | 7 | import '../Styles/App.css'; 8 | 9 | const ProgressSlider = ({ color, accent }) => { 10 | const [state] = useContext(MusicContext); 11 | const { 12 | adjustProgress, 13 | formatTime 14 | } = useAudio(); 15 | const [scrubProgress, setScrubProgress] = useState(state.progress); 16 | const [scrubbing, setScrubbing] = useState(false); 17 | 18 | function scrub(e) { 19 | if (!scrubbing) setScrubbing(true); 20 | setScrubProgress(e.target.value); 21 | if (e.type !== "change") { 22 | setScrubbing(false); 23 | adjustProgress(scrubProgress); 24 | } 25 | } 26 | 27 | return ( 28 |
29 |
30 |
37 | 43 |
44 |
47 | {scrubbing ? formatTime(scrubProgress / 100 * state.audio.duration) : state.starttime} 48 |
49 |
{formatTime(state.audio.duration)}
50 |
51 |
52 |
53 | ); 54 | } 55 | 56 | export default ProgressSlider; -------------------------------------------------------------------------------- /src/Contexts/DisplayContext.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useContext } from 'react'; 2 | 3 | import { MusicContext } from '../Contexts/MusicContext'; 4 | 5 | const DisplayContext = React.createContext([{}, () => { }]); 6 | 7 | const DisplayProvider = (props) => { 8 | const [state] = useContext(MusicContext); 9 | 10 | const [display, setDisplay] = useState({ 11 | inModal: false, 12 | inPlaylistPicker: false, 13 | displaySong: state.tracks[0] 14 | }); 15 | 16 | return ( 17 | 18 | {props.children} 19 | 20 | ); 21 | } 22 | 23 | export { DisplayContext, DisplayProvider }; -------------------------------------------------------------------------------- /src/Contexts/MusicContext.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { playlists as plist } from "../data/Playlist"; 3 | 4 | import * as firebase from "firebase/app" 5 | import "firebase/firestore" 6 | import "firebase/storage" 7 | 8 | const firebaseConfig = { 9 | apiKey: "AIzaSyDqeeErNO_5d6uk0xUEooRiiMOGRQra6z0", 10 | authDomain: "reactmusicapp-sylee2k.firebaseapp.com", 11 | databaseURL: "https://reactmusicapp-sylee2k.firebaseio.com", 12 | projectId: "reactmusicapp-sylee2k", 13 | storageBucket: "reactmusicapp-sylee2k.appspot.com", 14 | messagingSenderId: "133469247508", 15 | appId: "1:133469247508:web:660a0e1399b3f236fbef01" 16 | }; 17 | 18 | firebase.initializeApp(firebaseConfig) 19 | 20 | const MusicContext = React.createContext([{}, () => { }]); 21 | 22 | const MusicProvider = (props) => { 23 | const [state, setState] = useState({ 24 | playlistplaceholder: plist["default"], 25 | playlists: plist, 26 | tracks: plist["default"].tracks, 27 | index: -1, 28 | audioSrc: plist["default"].tracks[0].src, 29 | audio: new Audio(plist["default"].tracks[0]), 30 | play: false, 31 | progress: 0.0, 32 | activeSong: { 33 | id: 'placeholder', 34 | src: '', 35 | cover: '', 36 | thumbs: [], 37 | title: 'Title', 38 | artist: ['Artist'], 39 | album: 'Album' 40 | }, 41 | starttime: '0:00', 42 | color: "#ffffff", 43 | playlist: plist["default"], 44 | displayinfo: plist["default"], 45 | displaylist: plist["default"].tracks, 46 | shuffle: false, 47 | repeat: 'none', 48 | pthumb: '../assets/images/Placeholder.jpg' 49 | }); 50 | 51 | return ( 52 | 53 | {props.children} 54 | 55 | ); 56 | } 57 | 58 | export { MusicContext, MusicProvider }; -------------------------------------------------------------------------------- /src/Contexts/ThemeContext.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | 3 | const ThemeContext = React.createContext([{}, () => {}]); 4 | 5 | const ThemeProvider = (props) => { 6 | const [state, setState] = useState({ 7 | theme: "light" 8 | }); 9 | 10 | return ( 11 | 12 | {props.children} 13 | 14 | ) 15 | } 16 | 17 | export { ThemeContext, ThemeProvider }; -------------------------------------------------------------------------------- /src/Example.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import classNames from 'classnames'; 4 | import Progress from './components/Progress'; 5 | import './MusicPlayer.scss'; 6 | 7 | const formatTime = time => { 8 | /* eslint no-restricted-globals: off */ 9 | if (isNaN(time) || time === 0) { 10 | return ''; 11 | } 12 | const mins = Math.floor(time / 60); 13 | const secs = (time % 60).toFixed(); 14 | return `${mins < 10 ? '0' : ''}${mins}:${secs < 10 ? '0' : ''}${secs}`; 15 | }; 16 | 17 | const processArtistName = artistList => artistList.join(' / '); 18 | 19 | const getPlayModeClass = playMode => { 20 | if (playMode === 'loop') return 'refresh'; 21 | if (playMode === 'random') return 'random'; 22 | return 'repeat'; 23 | }; 24 | 25 | export default class MusicPlayer extends Component { 26 | static propTypes = { 27 | playlist: PropTypes.arrayOf( 28 | PropTypes.shape({ 29 | url: PropTypes.string, 30 | cover: PropTypes.string, 31 | title: PropTypes.string, 32 | artist: PropTypes.arrayOf(PropTypes.string) 33 | }) 34 | ).isRequired, 35 | mode: PropTypes.oneOf(['horizontal', 'vertical']), 36 | width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), 37 | autoplay: PropTypes.bool, 38 | progressColor: PropTypes.string, 39 | btnColor: PropTypes.string, 40 | style: PropTypes.object 41 | }; 42 | 43 | static defaultProps = { 44 | mode: 'horizontal', 45 | width: '100%', 46 | autoplay: false, 47 | progressColor: '#66cccc', 48 | btnColor: '#4a4a4a', 49 | style: {} 50 | }; 51 | 52 | constructor(props) { 53 | super(props); 54 | this.state = { 55 | activeMusicIndex: 0, 56 | leftTime: 0, 57 | play: props.autoplay || false, 58 | playMode: 'loop', 59 | progress: 0, 60 | volume: 1 61 | }; 62 | this.modeList = ['loop', 'random', 'repeat']; 63 | this.audioContainer = React.createRef(); 64 | } 65 | 66 | componentDidMount() { 67 | this.audioContainer.current.addEventListener('timeupdate', this.updateProgress); 68 | this.audioContainer.current.addEventListener('ended', this.end); 69 | } 70 | 71 | componentWillUnmount() { 72 | this.audioContainer.current.removeEventListener('timeupdate', this.updateProgress); 73 | this.audioContainer.current.removeEventListener('ended', this.end); 74 | } 75 | 76 | updateProgress = () => { 77 | const { duration, currentTime } = this.audioContainer.current; 78 | const progress = currentTime / duration || 0; 79 | this.setState({ progress, leftTime: duration - currentTime }); 80 | }; 81 | 82 | end = () => { 83 | this.handleNext(); 84 | }; 85 | 86 | handleAdjustProgress = value => { 87 | const currentTime = this.audioContainer.current.duration * value; 88 | this.audioContainer.current.currentTime = currentTime; 89 | this.setState({ play: true, progress: value }, () => this.audioContainer.current.play()); 90 | }; 91 | 92 | handleAdjustVolume = value => { 93 | const volume = value < 0 ? 0 : value; 94 | this.audioContainer.current.volume = volume; 95 | this.setState({ volume }); 96 | }; 97 | 98 | handleToggle = () => { 99 | const { play } = this.state; 100 | if (play) { 101 | this.audioContainer.current.pause(); 102 | } else { 103 | this.audioContainer.current.play(); 104 | } 105 | this.setState(({ play }) => ({ play: !play })); 106 | }; 107 | 108 | handlePrev = () => { 109 | const { playlist } = this.props; 110 | const { playMode, activeMusicIndex } = this.state; 111 | if (playMode === 'repeat') { 112 | this.playMusic(activeMusicIndex); 113 | } else if (playMode === 'loop') { 114 | const total = playlist.length; 115 | const index = activeMusicIndex > 0 ? activeMusicIndex - 1 : total - 1; 116 | this.playMusic(index); 117 | } else if (playMode === 'random') { 118 | let randomIndex = Math.floor(Math.random() * playlist.length); 119 | while (randomIndex === activeMusicIndex) { 120 | randomIndex = Math.floor(Math.random() * playlist.length); 121 | } 122 | this.playMusic(randomIndex); 123 | } else { 124 | this.setState({ play: false }); 125 | } 126 | }; 127 | 128 | handleNext = () => { 129 | const { playlist } = this.props; 130 | const { playMode, activeMusicIndex } = this.state; 131 | if (playMode === 'repeat') { 132 | this.playMusic(activeMusicIndex); 133 | } else if (playMode === 'loop') { 134 | const total = playlist.length; 135 | const index = activeMusicIndex < total - 1 ? activeMusicIndex + 1 : 0; 136 | this.playMusic(index); 137 | } else if (playMode === 'random') { 138 | let randomIndex = Math.floor(Math.random() * playlist.length); 139 | while (randomIndex === activeMusicIndex) { 140 | randomIndex = Math.floor(Math.random() * playlist.length); 141 | } 142 | this.playMusic(randomIndex); 143 | } else { 144 | this.setState({ play: false }); 145 | } 146 | }; 147 | 148 | handleChangePlayMode = () => { 149 | const { playMode } = this.state; 150 | let index = this.modeList.indexOf(playMode); 151 | index = (index + 1) % this.modeList.length; 152 | this.setState({ playMode: this.modeList[index] }); 153 | }; 154 | 155 | playMusic = index => { 156 | this.setState({ activeMusicIndex: index, leftTime: 0, play: true, progress: 0 }, () => { 157 | this.audioContainer.current.currentTime = 0; 158 | this.audioContainer.current.play(); 159 | }); 160 | }; 161 | 162 | render() { 163 | const { playlist, mode, width, progressColor, btnColor, style } = this.props; 164 | const { play, progress, leftTime, volume, activeMusicIndex, playMode } = this.state; 165 | const activeMusic = playlist[activeMusicIndex]; 166 | const playModeClass = getPlayModeClass(playMode); 167 | const btnStyle = { color: btnColor }; 168 | 169 | return ( 170 |
174 | 177 |
178 |
179 |

{activeMusic.title}

180 |

{processArtistName(activeMusic.artist)}

181 |
182 |
183 |
-{formatTime(leftTime)}
184 |
185 | 186 |
187 | 188 |
189 |
190 |
191 | 192 |
193 |
208 |
209 |
210 |
211 | ); 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /src/Hooks/useAudio.js: -------------------------------------------------------------------------------- 1 | import { useContext, useEffect, useState } from 'react'; 2 | 3 | import { MusicContext } from '../Contexts/MusicContext'; 4 | 5 | import * as firebase from "firebase/app" 6 | import "firebase/firestore" 7 | import "firebase/storage" 8 | 9 | import { playlists as plist } from "../data/Playlist"; 10 | 11 | const store = firebase.firestore(); 12 | const storageref = firebase.storage().ref(); 13 | 14 | const useAudio = () => { 15 | const [id, setId] = useState("default"); 16 | const [state, setState] = useContext(MusicContext); 17 | const cloudPlaylists = store.collection("playlists"); 18 | const cloudSongs = store.collection("songs"); 19 | 20 | // on load, creates listener to populate list of playlists from firestore 21 | useEffect(() => { 22 | if (state.playlists === plist) { 23 | setState(state => ({ ...state, playlists: {} })); 24 | cloudPlaylists.onSnapshot((e) => e.docChanges().forEach((c) => { 25 | const { doc } = c 26 | const id = doc.id; 27 | setState((state) => { 28 | const temp = state.playlists; 29 | const pl = { ...temp, [id]: doc.data() }; 30 | return ({ ...state, playlists: pl }); 31 | }); 32 | console.log("FETCHED DATA: ", doc.data()); 33 | })); 34 | } 35 | }, []); 36 | 37 | // passes ID of current display playlist 38 | function passID(newid) { 39 | console.log("PASS ID ", newid, state.playlists); 40 | if (newid !== id && state.playlists[newid] !== undefined) { 41 | setId(newid) 42 | setDisplayFromId(newid); 43 | } 44 | } 45 | 46 | // sets display playlist to id 47 | function setDisplayFromId(id) { 48 | console.log("SETTING DISPLAY FROM ID:", id); 49 | setState(state => ({ 50 | ...state, 51 | displayinfo: state.playlists[id], 52 | displaylist: [] 53 | })) 54 | state.playlists[id].tracks.map((track, i) => { 55 | track.get().then((doc) => { 56 | console.log("ADDING TRACK:", doc.data()); 57 | setState(state => ({ 58 | ...state, 59 | displaylist: [...state.displaylist, doc.data()] 60 | })); 61 | }); 62 | }); 63 | } 64 | 65 | // handle skip forward button 66 | function nextSong() { 67 | console.log(state.repeat); 68 | if (state.repeat === 'repeatsong') { 69 | console.log("repeat song"); 70 | changeTrack(state.playlist.id, state.index); 71 | } else if (state.index < state.tracks.length - 1) { 72 | console.log("next song"); 73 | changeTrack(state.playlist.id, state.index + 1); 74 | } else if (state.repeat === 'repeat') { 75 | console.log("play first song"); 76 | changeTrack(state.playlist.id, 0); 77 | } else { 78 | console.log("stop playing"); 79 | setState(state => ({ 80 | ...state, 81 | index: 0, 82 | activeSong: state.tracks[0], 83 | audioSrc: state.tracks[0].src, 84 | play: false 85 | })); 86 | state.audio.src = state.tracks[0].src; 87 | state.audio.currentTime = 0; 88 | } 89 | } 90 | 91 | // handle skip backward button 92 | function prevSong() { 93 | console.log("prev song"); 94 | if (state.progress > 10 || state.index === 0) { 95 | state.audio.currentTime = 0; 96 | } else if (state.index > 0) { 97 | changeTrack(state.playlist.id, state.index - 1); 98 | } 99 | setState(state => ({ ...state, play: true })); 100 | } 101 | 102 | // when index is updated, change the active song and 103 | // attach new event listeners 104 | useEffect(() => { 105 | state.audio.addEventListener('timeupdate', updateProgress); 106 | state.audio.addEventListener('ended', nextSong); 107 | return () => { 108 | state.audio.removeEventListener('timeupdate', updateProgress); 109 | state.audio.removeEventListener('ended', nextSong); 110 | }; 111 | }, [state.index]) 112 | 113 | // when audioSrc is updated, update the audio src and play 114 | function changeTrack(n, i) { 115 | if (state.playlist.id !== n) { 116 | console.log('change to playlist ' + n); 117 | setState(state => ({ 118 | ...state, 119 | tracks: state.displaylist, 120 | playlist: state.playlists[n], 121 | index: i, 122 | activeSong: state.displaylist[i], 123 | audioSrc: state.displaylist[i].src, 124 | play: true 125 | })); 126 | state.audio.src = state.displaylist[i].src; 127 | state.audio.currentTime = 0; 128 | state.audio.play(); 129 | } else { 130 | console.log('same playlist'); 131 | setState(state => ({ 132 | ...state, 133 | index: i, 134 | activeSong: state.tracks[i], 135 | audioSrc: state.tracks[i].src, 136 | play: true 137 | })); 138 | state.audio.src = state.tracks[i].src; 139 | state.audio.currentTime = 0; 140 | state.audio.play(); 141 | } 142 | } 143 | 144 | // create new playlist 145 | function createPlaylist(name) { 146 | const index = Object.keys(state.playlists).length; 147 | cloudPlaylists.add({ 148 | author: "Shawn Lee", 149 | name: name, 150 | index: index, 151 | tracks: [] 152 | }).then(function(docRef) { 153 | console.log("NEW PLAYLIST ID: ", docRef.id); 154 | }) 155 | } 156 | 157 | // add song s to playlist p in firestore 158 | function addToPlaylist(p, s) { 159 | var pref = cloudPlaylists.doc(p); 160 | console.log("ADDING TO PLAYLIST:", p, s); 161 | pref.update({ 162 | tracks: firebase.firestore.FieldValue.arrayUnion(cloudSongs.doc(s)) 163 | }); 164 | } 165 | 166 | // remove song s from playlist p, both in state and firestore 167 | function removeFromPlaylist(p, s) { 168 | var pref = cloudPlaylists.doc(p); 169 | console.log("REMOVING FROM PLAYLIST:", p, s.id); 170 | pref.update({ 171 | tracks: firebase.firestore.FieldValue.arrayRemove(cloudSongs.doc(s.id)) 172 | }); 173 | const templist = state.displaylist; 174 | var index = state.displaylist.indexOf(s); 175 | templist.splice(index, 1); 176 | setState(state => ({ ...state, displaylist: templist })) 177 | } 178 | 179 | // when play is updated, play/pause music accordingly 180 | useEffect(() => { 181 | state.play ? state.audio.play() : state.audio.pause(); 182 | }, [state.play]) 183 | 184 | // toggle play true/false 185 | function togglePlay() { 186 | setState(state => ({ ...state, play: !state.play })); 187 | } 188 | 189 | // toggle shuffle mode on/off 190 | function toggleShuffle() { 191 | if (state.shuffle) { 192 | console.log('shuffle OFF'); 193 | setState(state => ({ ...state, shuffle: false })); 194 | } else { 195 | console.log('shuffle ON'); 196 | setState(state => ({ ...state, shuffle: true })); 197 | } 198 | } 199 | 200 | // cycle repeat from off / repeat / repeat song 201 | function setRepeat(mode) { 202 | console.log('repeat: ' + mode); 203 | setState(state => ({ ...state, repeat: mode })); 204 | } 205 | 206 | // update progress in accordance to audio's currentTime 207 | function updateProgress() { 208 | const duration = state.audio.duration; 209 | const currentTime = state.audio.currentTime; 210 | setState(state => ({ 211 | ...state, 212 | progress: (currentTime / duration) * 100 || 0, 213 | starttime: formatTime(currentTime) 214 | })); 215 | } 216 | 217 | // handle progress slider input 218 | function adjustProgress(newProgress) { 219 | const newTime = state.audio.duration * (newProgress / 100); 220 | state.audio.currentTime = newTime; 221 | setState(state => ({ ...state, progress: newProgress / 100 })); 222 | } 223 | 224 | // format time to m:ss 225 | function formatTime(time) { 226 | if (isNaN(time) || time === 0) { 227 | return '0:00'; 228 | } 229 | const mins = Math.floor(time / 60); 230 | const secs = (time % 60).toFixed(); 231 | return `${mins}:${secs < 10 ? '0' : ''}${secs}`; 232 | } 233 | 234 | return { 235 | passID, 236 | nextSong, 237 | prevSong, 238 | togglePlay, 239 | changeTrack, 240 | adjustProgress, 241 | toggleShuffle, 242 | formatTime, 243 | setRepeat, 244 | setDisplayFromId, 245 | addToPlaylist, 246 | removeFromPlaylist, 247 | createPlaylist 248 | } 249 | }; 250 | 251 | export default useAudio; -------------------------------------------------------------------------------- /src/Hooks/useCloud.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import * as firebase from "firebase/app" 3 | import "firebase/firestore" 4 | import "firebase/storage" 5 | 6 | const useCloud = () => { 7 | const [audioFile, setAudioFile] = useState(null); 8 | const [artFile, setArtFile] = useState(null); 9 | const [title, setTitle] = useState("title"); 10 | const [artist, setArtist] = useState("artist"); 11 | const [album, setAlbum] = useState("album"); 12 | 13 | 14 | 15 | 16 | 17 | // const derp = cloudPlaylists.get(); 18 | // derp.then((snap) => { 19 | // // console.log(snap); 20 | // const der = snap.docs[0].data(); 21 | // // console.log(der); 22 | // }); 23 | 24 | function handleUpload(e) { 25 | const file = e.target.files[0]; 26 | console.log(file); 27 | 28 | const musicRef = firebase.storage().ref('music/' + file.name); 29 | 30 | musicRef.put(file).then(() => { 31 | const storageRef = firebase.storage().ref('/music'); 32 | 33 | storageRef.child(file.name).getMetadata().then(metadata => { 34 | const url = metadata.downloadURLs[0]; 35 | const messageRef = firebase.database().ref('message'); 36 | messageRef.push({ 37 | song: url, 38 | songName: file.name 39 | }) 40 | }) 41 | }) 42 | } 43 | 44 | return { 45 | handleUpload, 46 | audioFile, setAudioFile, 47 | artFile, setArtFile, 48 | title, setTitle, 49 | artist, setArtist, 50 | album, setAlbum, 51 | } 52 | } 53 | 54 | export { useCloud }; 55 | 56 | -------------------------------------------------------------------------------- /src/Hooks/useDisplay.js: -------------------------------------------------------------------------------- 1 | import { useContext, useEffect, useState } from 'react'; 2 | 3 | import { DisplayContext } from '../Contexts/DisplayContext'; 4 | 5 | const useDisplay = () => { 6 | const [display, setDisplay] = useContext(DisplayContext); 7 | 8 | function openModal() { 9 | setDisplay(display => ({ ...display, inModal: true })) 10 | } 11 | 12 | function closeModal() { 13 | setDisplay(display => ({ ...display, inModal: false })) 14 | } 15 | 16 | function openPlaylistPicker() { 17 | setDisplay(display => ({ ...display, inPlaylistPicker: true })) 18 | } 19 | 20 | function closePlaylistPicker() { 21 | setDisplay(display => ({ ...display, inPlaylistPicker: false })) 22 | } 23 | 24 | function setDisplaySong(song) { 25 | setDisplay(display => ({ 26 | ...display, 27 | inModal: true, 28 | displaySong: song 29 | })) 30 | } 31 | 32 | return { 33 | openModal, 34 | closeModal, 35 | openPlaylistPicker, 36 | closePlaylistPicker, 37 | setDisplaySong 38 | } 39 | }; 40 | 41 | export default useDisplay; -------------------------------------------------------------------------------- /src/Main.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Switch, Route } from 'react-router-dom'; 3 | import MusicPlayer from './Views/MusicPlayer'; 4 | import ListMenu from './Views/ListMenu'; 5 | import MainScreen from './Views/MainScreen'; 6 | 7 | const Main = () => { 8 | return ( 9 | 10 | 11 | 12 | 13 | 14 | 15 | ); 16 | } 17 | 18 | export default Main; 19 | -------------------------------------------------------------------------------- /src/Styles/App.css: -------------------------------------------------------------------------------- 1 | button:focus { 2 | outline: none !important; 3 | outline-offset: none !important; 4 | } 5 | 6 | .App { 7 | text-align: center; 8 | font-family: Futura PT; 9 | } 10 | 11 | .TouchBlocker { 12 | position: absolute; 13 | background-color: rgba(0, 0, 0, 0.1); 14 | height: 100%; 15 | width: 100%; 16 | z-index: 1999; 17 | } 18 | 19 | /* Text Styles */ 20 | 21 | .txt-label { 22 | padding: 5px 0px 5px 3px; 23 | font-size: 1.5rem; 24 | font-weight: 900; 25 | } 26 | 27 | .txt-biglabel { 28 | padding: 5px 0px 5px 3px; 29 | font-size: 2.5rem; 30 | font-weight: 900; 31 | } 32 | 33 | 34 | 35 | /* Button/Icon Styles */ 36 | 37 | .btn-control { 38 | margin: 20px; 39 | background-color: white; 40 | width: 2.5rem; 41 | height: 2.5rem; 42 | border: none; 43 | border-radius: 100%; 44 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 45 | } 46 | 47 | .btn-play { 48 | /* background-color: rgb(251, 210, 204); */ 49 | width: 4.5rem; 50 | height: 4.5rem; 51 | border: none; 52 | border-radius: 100%; 53 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 54 | } 55 | 56 | .btn-topicon { 57 | background-color: rgba(0,0,0,0); 58 | border: none; 59 | height: 1.5rem; 60 | width: 1.5rem; 61 | } 62 | 63 | .btn-icon { 64 | background-color: rgba(0,0,0,0); 65 | border: none; 66 | width: 3.3rem; 67 | height: 3.3rem; 68 | } 69 | 70 | .icon { 71 | font-size: 1.5rem; 72 | color: rgb(116, 116, 116); 73 | transition: transform 0.5s; 74 | } 75 | 76 | .largeicon { 77 | font-size: 2rem; 78 | color: white; 79 | } 80 | 81 | .playicon { 82 | font-size: 2.2rem; 83 | color: white; 84 | margin-left: 4px; 85 | } 86 | 87 | /* Header Styles */ 88 | 89 | .MainScreenHeader { 90 | top: 0; 91 | width: 100%; 92 | padding: 30px 30px 0px 30px; 93 | display: flex; 94 | flex-direction: row; 95 | align-items: center; 96 | justify-content: flex-start; 97 | height: 6rem; 98 | } 99 | 100 | .Header { 101 | top: 0; 102 | width: 100%; 103 | padding: 15px 30px 0px 30px; 104 | display: flex; 105 | flex-direction: row; 106 | align-items: center; 107 | justify-content: flex-start; 108 | height: 6rem; 109 | } 110 | 111 | .btn-righticon { 112 | margin-left: auto; 113 | margin-right: 5px; 114 | background-color: rgba(0,0,0,0); 115 | border: none; 116 | padding: 0px; 117 | width: 1.2rem; 118 | height: 1.2rem; 119 | z-index: 2001; 120 | } 121 | 122 | @keyframes dropdown { 123 | from {height: 0px;} 124 | to {height: 200px;} 125 | } 126 | 127 | @keyframes dropdown-large { 128 | from {height: 0px;} 129 | to {height: 450px;} 130 | } 131 | 132 | .droptest { 133 | animation-name: dropdown; 134 | animation-duration: 0.5s; 135 | position: absolute; 136 | top: 30px; 137 | right: 18px; 138 | z-index: 2000; 139 | height: 200px; 140 | width: 200px; 141 | border-radius: 25px; 142 | background-color: rgba(255, 255, 255, 0.3); 143 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1); 144 | backdrop-filter: blur(15px); 145 | display: flex; 146 | flex-direction: column; 147 | justify-content: flex-end; 148 | padding: 45px 20px 15px 20px; 149 | overflow: hidden; 150 | } 151 | 152 | .droptest-banner { 153 | animation-name: dropdown-large; 154 | animation-duration: 0.5s; 155 | position: absolute; 156 | bottom: 0px; 157 | z-index: 2000; 158 | height: 450px; 159 | width: 100%; 160 | /* padding: 40px; */ 161 | border-radius: 25px 25px 0px 0px; 162 | background-color: rgba(255, 255, 255, 0.3); 163 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1); 164 | backdrop-filter: blur(15px); 165 | display: flex; 166 | flex-direction: column; 167 | justify-content: flex-end; 168 | padding: 45px 20px 15px 20px; 169 | overflow: hidden; 170 | } 171 | 172 | .drop-button-container { 173 | display: flex; 174 | flex-direction: column; 175 | border-top: 1px solid rgb(65, 65, 65); 176 | padding: 5px 0px 0px 0px; 177 | } 178 | 179 | .drop-bannerbutton-container { 180 | margin-top: auto; 181 | display: flex; 182 | flex-direction: column; 183 | border-top: 1px solid rgb(65, 65, 65); 184 | padding: 5px 0px 0px 0px; 185 | } 186 | 187 | .drop-songinfo { 188 | 189 | } 190 | 191 | .drop-songimage { 192 | width: 20vh; 193 | height: 20vh; 194 | } 195 | 196 | .drop-button { 197 | text-align: left; 198 | font-size: 1.1rem; 199 | font-weight: 600; 200 | color: rgb(51, 51, 51); 201 | padding: 5px; 202 | border: none; 203 | background-color: rgba(0, 0, 0, 0); 204 | } 205 | 206 | /* Miniplayer Styles */ 207 | 208 | .miniplayer-container { 209 | position: absolute; 210 | bottom: 0; 211 | width: 100%; 212 | padding: 40px 30px; 213 | display: flex; 214 | flex-direction: row; 215 | justify-content: center; 216 | height: 9.5rem; 217 | background-image: linear-gradient( rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.7), white); 218 | overflow: hidden; 219 | } 220 | 221 | .miniplayer { 222 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1); 223 | background-color: white; 224 | border-radius: 15px; 225 | width: 100%; 226 | display: flex; 227 | flex-direction: row; 228 | justify-content: flex-end; 229 | height: Calc(45px + 1.8rem); 230 | } 231 | 232 | .img-minicoverart { 233 | height: 100%; 234 | 235 | } 236 | 237 | .miniplaybutton { 238 | height: 100%; 239 | width: Calc(45px + 1.8rem); 240 | border-radius: 15px 0px 0px 15px; 241 | border: none; 242 | } 243 | 244 | .wrapper-stack { 245 | width: 100%; 246 | display: flex; 247 | flex-direction: column; 248 | justify-content: flex-end; 249 | overflow: hidden; 250 | } 251 | 252 | .container-row { 253 | display: flex; 254 | flex-direction: row; 255 | } 256 | 257 | .container-stack { 258 | display: flex; 259 | flex-direction: column; 260 | align-items: flex-start; 261 | width: 100%; 262 | background-color: rgba(0,0,0,0); 263 | border: none; 264 | } 265 | 266 | .txt-minititle { 267 | padding-left: 10px; 268 | font-size: 1.2rem; 269 | font-weight: bold; 270 | margin-bottom: 0px; 271 | } 272 | 273 | .txt-minisubtitle { 274 | padding-left: 10px; 275 | margin-top: 10px; 276 | font-size: 0.8rem; 277 | font-weight: 400; 278 | } 279 | 280 | .btn-miniplayericon { 281 | background-color: rgba(0,0,0,0); 282 | border: none; 283 | width: 2rem; 284 | height: 4rem; 285 | margin-left: auto; 286 | margin-right: 10px; 287 | } 288 | 289 | /* ListMenu Styles */ 290 | 291 | .playlisttop-wrapper { 292 | height: 26vh; 293 | width: 100%; 294 | display: flex; 295 | flex-direction: column; 296 | } 297 | 298 | .playlistinfo-container { 299 | display: flex; 300 | flex-direction: row; 301 | padding: 0px 30px; 302 | } 303 | 304 | .playlist-search-container { 305 | padding: 20px 30px 15px 30px; 306 | height: 4rem; 307 | display: flex; 308 | flex-direction: column; 309 | justify-content: center; 310 | } 311 | 312 | .playlist-cover { 313 | width: Calc(26vh - 4rem); 314 | height: Calc(26vh - 4rem);; 315 | /* max-height: 200px; 316 | max-width: 200px; */ 317 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1); 318 | } 319 | 320 | .playlist-info { 321 | padding: 15px; 322 | display: flex; 323 | flex-direction: column; 324 | justify-content: flex-end; 325 | } 326 | 327 | .txt-playlistinfo { 328 | text-align: left; 329 | } 330 | 331 | .txt-playlisttitle { 332 | font-size: 1.4rem; 333 | font-weight: bold; 334 | 335 | text-align: left; 336 | } 337 | 338 | .search-bar { 339 | background-color: rgb(240, 240, 240); 340 | border-radius: 15px; 341 | font-weight: 500; 342 | font-size: 0.7rem; 343 | height: 100%; 344 | display: flex; 345 | flex-direction: column; 346 | justify-content: center; 347 | align-items: flex-start; 348 | padding: 5px 15px; 349 | } 350 | 351 | /* Track Styles */ 352 | 353 | .track-container { 354 | padding: 10px 40px; 355 | width: 100%; 356 | display: flex; 357 | flex-direction: row; 358 | align-items: center; 359 | } 360 | 361 | .track-button { 362 | background: none; 363 | border: none; 364 | width: 100%; 365 | display: flex; 366 | flex-direction: row; 367 | align-items: center; 368 | } 369 | 370 | .track-img { 371 | height: 7vh; 372 | width: 7vh; 373 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1); 374 | } 375 | 376 | .track-dots { 377 | margin-left: auto; 378 | height: 4vh; 379 | width: 4vh; 380 | z-index: 100; 381 | } 382 | 383 | .track-textwrapper { 384 | height: 7vh; 385 | padding: 0px 15px; 386 | display: flex; 387 | flex-direction: column; 388 | justify-content: center; 389 | } 390 | 391 | .curtrack-container { 392 | padding: 10px 40px; 393 | width: 100%; 394 | background-color: rgba(0,0,0,0); 395 | border: none; 396 | color: red; 397 | } 398 | 399 | .txt-tracktitle { 400 | text-align: left; 401 | font-size: 1.2rem; 402 | font-weight: 500; 403 | color: rgb(80, 80, 80); 404 | } 405 | 406 | .txt-trackinfo { 407 | text-align: left; 408 | font-weight: 500; 409 | font-size: 0.8rem; 410 | color: rgb(200, 200, 200); 411 | } 412 | 413 | .track-list { 414 | width: 100%; 415 | height: Calc(74vh - 6rem); 416 | display: flex; 417 | flex-direction: column; 418 | overflow-y: auto; 419 | } 420 | 421 | .playlist-list { 422 | width: 100%; 423 | height: Calc(100vh - 14rem); 424 | display: flex; 425 | flex-direction: column; 426 | overflow-y: auto; 427 | } 428 | 429 | /* Playlist Picker Styles */ 430 | 431 | .playlist-picker-page { 432 | position: absolute; 433 | width: 100%; 434 | z-index: 2010; 435 | background-color: rgba(255, 255, 255, 0.7); 436 | backdrop-filter: blur(15px); 437 | } 438 | 439 | .playlist-picker { 440 | width: 100%; 441 | height: Calc(100vh - 6rem); 442 | display: flex; 443 | flex-direction: column; 444 | overflow-y: auto; 445 | } 446 | 447 | /* ProgressBar Styles */ 448 | 449 | .progressbar-container { 450 | height: 15px; 451 | width: 100%; 452 | background-color: white; 453 | border-bottom-right-radius: 15px; 454 | overflow: hidden; 455 | display: flex; 456 | flex-direction: column; 457 | justify-content: flex-end; 458 | } 459 | 460 | .progressbar-bar { 461 | background-color: rgb(200, 200, 200); 462 | height: 20%; 463 | } 464 | 465 | /* ProgressSlider Styles */ 466 | 467 | .progressslider-wrapper { 468 | padding: 20px 20px; 469 | } 470 | 471 | .progressslider-container { 472 | width: 100%; 473 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1); 474 | height: 30px; 475 | background-color: rgb(224, 224, 224); 476 | border-radius: 15px; 477 | display: flex; 478 | flex-direction: column; 479 | justify-content: center; 480 | overflow: hidden; 481 | position: relative; 482 | } 483 | 484 | .progressslider-bar { 485 | transition: background-color 0.1s ease; 486 | height: 40px; 487 | /* inline: backgroundImage: 'linear-gradient(to right, ' + color + ', ' + accent + ')' */ 488 | } 489 | 490 | .progressslider { 491 | appearance: none; 492 | background: none; 493 | height: 0px; 494 | } 495 | 496 | .progressslider::-webkit-slider-thumb { 497 | appearance: none; 498 | width: 10px; 499 | height: 80px; 500 | background-color: rgba(0,0,0,0); 501 | } 502 | 503 | .time-row { 504 | position: absolute; 505 | width: 100%; 506 | pointer-events: none; 507 | display: flex; 508 | flex-direction: row; 509 | align-items: center; 510 | justify-content: flex-start; 511 | padding: 0px 13px; 512 | font-weight: 500; 513 | } 514 | 515 | .right-time { 516 | margin-left: auto; 517 | } 518 | 519 | /* Playlist Styles */ 520 | 521 | .playlistlist-container { 522 | padding: 20px 40px 0px; 523 | width: 100%; 524 | background-color: rgba(0,0,0,0); 525 | border: none; 526 | display: flex; 527 | flex-direction: row; 528 | align-items: center; 529 | } 530 | 531 | .img-playlistlistcover { 532 | height: 8vh; 533 | width: 8vh; 534 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1); 535 | } 536 | 537 | .playlistlist-textcontainer { 538 | padding: 12px 15px; 539 | } 540 | 541 | .mainscreen-tabs { 542 | padding: 0px 30px; 543 | height: 4rem; 544 | display: flex; 545 | flex-direction: row; 546 | justify-content: flex-start; 547 | align-items: flex-end; 548 | } -------------------------------------------------------------------------------- /src/Styles/MusicPlayer.css: -------------------------------------------------------------------------------- 1 | .txt-title { 2 | font-size: 1.8rem; 3 | font-weight: bold; 4 | margin-bottom: 10px; 5 | } 6 | 7 | .txt-subtitle { 8 | margin-top: 10px; 9 | font-size: 1rem; 10 | font-weight: bold; 11 | } 12 | 13 | /* MusicInfo Styles */ 14 | 15 | .AlbumContainer { 16 | height: Calc(100vh - 22.5rem); 17 | padding: 15px 18px; 18 | position: relative; 19 | } 20 | 21 | .img-coverart { 22 | z-index: 1000; 23 | max-width: 90%; 24 | max-height: 100%; 25 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 26 | position: absolute; 27 | top: 50%; 28 | left: 50%; 29 | transform: translate(-50%, -50%); 30 | object-fit: contain; 31 | } 32 | 33 | /* MusicPlayer Styles */ 34 | 35 | .Controller { 36 | height: 16.5rem; 37 | padding: 0px 20px 20px; 38 | position: absolute; 39 | width: 100%; 40 | bottom: 0; 41 | } 42 | 43 | .control-row { 44 | display: flex; 45 | flex-direction: row; 46 | justify-content: center; 47 | align-items: center; 48 | } 49 | 50 | .MusicPlayerHeader { 51 | top: 0; 52 | width: 100%; 53 | padding: 15px 30px 0px 30px; 54 | display: flex; 55 | flex-direction: row; 56 | align-items: center; 57 | justify-content: flex-start; 58 | height: 6rem; 59 | } -------------------------------------------------------------------------------- /src/Styles/MusicPlayerM.css: -------------------------------------------------------------------------------- 1 | .txt-title { 2 | color: white; 3 | font-size: 1.8rem; 4 | font-weight: 500; 5 | margin-bottom: 10px; 6 | } 7 | 8 | .txt-subtitle { 9 | color: white; 10 | margin-top: 10px; 11 | font-size: 1rem; 12 | font-weight: 500; 13 | } 14 | 15 | /* MusicInfo Styles */ 16 | 17 | .AlbumContainer { 18 | z-index: -1; 19 | height: 100vh; 20 | width: 100vw; 21 | position: absolute; 22 | top: 0; 23 | display: flex; 24 | flex-direction: row; 25 | justify-content: center; 26 | overflow: hidden; 27 | } 28 | 29 | .img-coverart { 30 | z-index: -1; 31 | height: 100vh; 32 | box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 33 | object-fit: contain; 34 | } 35 | 36 | /* MusicPlayer Styles */ 37 | 38 | .Controller { 39 | height: 16.5rem; 40 | padding: 0px 20px 20px; 41 | position: absolute; 42 | width: 100%; 43 | bottom: 0; 44 | } 45 | 46 | .control-row { 47 | display: flex; 48 | flex-direction: row; 49 | justify-content: center; 50 | align-items: center; 51 | } 52 | 53 | .MusicPlayerHeader { 54 | top: 0; 55 | width: 100%; 56 | padding: 15px 30px 0px 30px; 57 | display: flex; 58 | flex-direction: row; 59 | align-items: center; 60 | justify-content: flex-start; 61 | height: 6rem; 62 | background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); 63 | color: white; 64 | } -------------------------------------------------------------------------------- /src/Views/ListMenu.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useContext } from 'react'; 2 | import { usePalette } from 'react-palette'; 3 | import { Link, useLocation } from 'react-router-dom'; 4 | // import FilterResults from 'react-filter-search'; 5 | 6 | import { MusicContext } from '../Contexts/MusicContext'; 7 | import { DisplayContext } from '../Contexts/DisplayContext'; 8 | 9 | import Miniplayer from '../Components/Miniplayer'; 10 | import { SongListItem } from '../Components/ListItem'; 11 | import { PlaylistPicker } from '../Components/PlaylistPicker'; 12 | 13 | import useAudio from "../Hooks/useAudio"; 14 | import useDisplay from "../Hooks/useDisplay"; 15 | 16 | import BackIcon from '../assets/icons/back.svg'; 17 | 18 | import '../Styles/App.css'; 19 | 20 | const ListMenu = () => { 21 | const [state] = useContext(MusicContext); 22 | const [display] = useContext(DisplayContext); 23 | const { 24 | passID, 25 | removeFromPlaylist, 26 | } = useAudio(); 27 | const { 28 | closeModal, 29 | openPlaylistPicker 30 | } = useDisplay(); 31 | 32 | const { data } = usePalette(state.activeSong.thumbs[0]); 33 | const { pathname } = useLocation(); 34 | 35 | useEffect(() => { 36 | passID(pathname.substring(10)); 37 | }, [state.playlists]); 38 | 39 | return ( 40 | <> 41 | 42 | 43 | {/* BANNER MODAL */} 44 |
50 |
51 | album art 55 |
56 |
57 | 62 | 63 | 64 | 65 | 66 | 74 |
75 |
76 | 77 | {/* MODAL TOUCH BLOCKER */} 78 |
closeModal()} 81 | /> 82 | 83 | {/* HEADER NAVIGATION */} 84 |
85 | 86 | 92 | 93 | Playlist 94 |
95 | 96 | {/* PLAYLIST INFO BOX */} 97 |
98 |
99 | Playlist Cover 103 |
104 |
By {state.displayinfo.author}
105 |
{state.displayinfo.name}
106 |
{state.displayinfo.tracks.length} Songs
107 |
108 |
109 |
110 |
Search
111 |
112 |
113 | 114 | {/* PLAYLIST TRACK LIST */} 115 |
116 | 117 | {state.displaylist.map((track, i) => 118 | 125 | )} 126 |
127 |
128 | 129 | {/* MINI PLAYER */} 130 | 131 | 132 | ); 133 | } 134 | 135 | export default ListMenu; -------------------------------------------------------------------------------- /src/Views/MainScreen.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useRef, useContext } from 'react'; 2 | import { usePalette } from 'react-palette'; 3 | 4 | import { MusicContext } from '../Contexts/MusicContext'; 5 | 6 | import Miniplayer from '../Components/Miniplayer'; 7 | import { PlaylistListItem, AddPlaylistListItem } from '../Components/ListItem'; 8 | 9 | import useAudio from "../Hooks/useAudio"; 10 | import { useCloud } from "../Hooks/useCloud"; 11 | 12 | import '../Styles/App.css'; 13 | 14 | const MainScreen = () => { 15 | const [state] = useContext(MusicContext); 16 | useAudio(); 17 | const { data } = usePalette(state.playlist.thumbs[0]); 18 | const [mode, setMode] = useState("playlists"); 19 | 20 | return ( 21 | <> 22 | {/* HEADER LABEL */} 23 |
24 | Music 25 |
26 | 27 | {/* TAB NAVIGATION & SEARCH BAR */} 28 |
29 | setMode("playlists")} 31 | style={{ color: mode === "playlists" ? 'rgb(80, 80, 80)' : 'rgb(200, 200, 200)' }} 32 | > 33 | Playlists 34 | 35 | setMode("songs")} 37 | style={{ 38 | paddingLeft: '8px', 39 | color: mode === "songs" ? 'rgb(80, 80, 80)' : 'rgb(200, 200, 200)' 40 | }} 41 | > 42 | Songs 43 | 44 |
45 |
46 |
Search
47 |
48 | 49 | {/* PLAYLIST LIST */} 50 |
53 | 54 | {Object.keys(state.playlists).map((pl, i) => 55 | 62 | )} 63 |
64 |
65 | 66 | {/* UPLOAD FORM */} 67 |
70 | 71 |
72 | 73 | {/* MINI PLAYER */} 74 | 75 | 76 | ); 77 | } 78 | 79 | const UploadForm = () => { 80 | const inputFile = useRef(null); 81 | const { 82 | handleUpload, 83 | audioFile, setAudioFile, 84 | artFile, setArtFile, 85 | title, setTitle, 86 | artist, setArtist, 87 | album, setAlbum 88 | } = useCloud(); 89 | 90 | return ( 91 | <> 92 |
93 | 94 | setAudioFile(e)} ref={inputFile} accept="audio/mp3, audio/wav" /> 95 |
96 |
97 | 98 | setArtFile(e)} accept="image/png, image/jpeg" /> 99 |
100 |
101 | 102 | setTitle(e)} /> 103 |
104 |
105 | 106 | setArtist(e)} /> 107 |
108 |
109 | 110 | setAlbum(e)} /> 111 |
112 | 113 | 114 | ); 115 | } 116 | 117 | export default MainScreen; -------------------------------------------------------------------------------- /src/Views/MusicPlayer-Backup.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useRef, useEffect } from 'react'; 2 | import './Styles/App.css'; 3 | import "bootstrap/dist/css/bootstrap.min.css"; 4 | import "shards-ui/dist/css/shards.min.css"; 5 | import { 6 | Button, 7 | Dropdown, 8 | DropdownToggle, 9 | DropdownMenu, 10 | DropdownItem, 11 | Slider 12 | } from "shards-react"; 13 | import { 14 | FiChevronLeft, 15 | FiPlus, 16 | FiPlay, 17 | FiPause, 18 | FiSkipBack, 19 | FiSkipForward, 20 | FiShuffle, 21 | FiRepeat 22 | } from "react-icons/fi"; 23 | import Playlist from "../data/Playlist"; 24 | import { MusicContext } from "../MusicContext" 25 | 26 | // Backup of MusicPlayer without using a custom hook. 27 | 28 | const Header = () => { 29 | const [open, setOpen] = useState(false) 30 | 31 | function toggle() { 32 | setOpen(!open); 33 | } 34 | 35 | return ( 36 |
37 | 40 | Player 41 | 42 | 43 | 44 | 45 | 46 | 47 | Add to Playlist 48 | Add to Queue 49 | View Album 50 | View Artist 51 | 52 | 53 |
54 | ); 55 | } 56 | 57 | const MusicPlayer = () => { 58 | const [index, setIndex] = useState(0); 59 | const [audioSrc, setAudioSrc] = useState(Playlist[index].src); 60 | const [audio] = useState(new Audio(audioSrc)); 61 | const [play, setPlay] = useState(false); 62 | const [progress, setProgress] = useState(0.0); 63 | const [activeSong, setActiveSong] = useState(0); 64 | const [starttime, setStarttime] = useState('0:00'); 65 | 66 | // handle skip forward button 67 | function nextSong() { 68 | console.log("next song"); 69 | if (index < Playlist.length - 1) { 70 | setIndex(index + 1); 71 | setPlay(true); 72 | } else { 73 | setPlay(false); 74 | setIndex(0); 75 | } 76 | } 77 | 78 | // handle skip backward button 79 | function prevSong() { 80 | console.log("prev song"); 81 | if (progress > 10 || index == 0) { 82 | audio.currentTime = 0; 83 | } else if (index > 0) { 84 | setIndex(index - 1); 85 | } 86 | setPlay(true); 87 | } 88 | 89 | // when index is updated, change the active song and 90 | // attach new event listeners 91 | useEffect(() => { 92 | setActiveSong(Playlist[index]); 93 | setAudioSrc(Playlist[index].src); 94 | audio.addEventListener('timeupdate', updateProgress); 95 | audio.addEventListener('ended', nextSong); 96 | return () => { 97 | audio.removeEventListener('timeupdate', updateProgress); 98 | audio.removeEventListener('ended', nextSong); 99 | }; 100 | }, [index]) 101 | 102 | // when audioSrc is updated, update the audio src and play 103 | useEffect(() => { 104 | audio.src = audioSrc; 105 | audio.currentTime = 0; 106 | if (play) audio.play(); 107 | }, [audioSrc]) 108 | 109 | // when play is updated, play/pause music accordingly 110 | useEffect(() => { 111 | play ? audio.play() : audio.pause(); 112 | }, [play]) 113 | 114 | // toggle play true/false 115 | function togglePlay() { 116 | setPlay(!play); 117 | } 118 | 119 | // update progress in accordance to audio's currentTime 120 | function updateProgress() { 121 | const duration = audio.duration; 122 | const currentTime = audio.currentTime; 123 | setProgress((currentTime / duration) * 100 || 0); 124 | setStarttime(formatTime(currentTime)); 125 | } 126 | 127 | // handle progress slider input 128 | function adjustProgress(e) { 129 | const newTime = audio.duration * (parseFloat(e[0]) / 100); 130 | audio.currentTime = newTime; 131 | setProgress(parseFloat(e[0]) / 100); 132 | } 133 | 134 | function formatTime(time) { 135 | if (isNaN(time) || time === 0) { 136 | return '0:00'; 137 | } 138 | const mins = Math.floor(time / 60); 139 | const secs = (time % 60).toFixed(); 140 | return `${mins}:${secs < 10 ? '0' : ''}${secs}`; 141 | } 142 | 143 | return ( 144 | <> 145 |
146 |
147 |
148 | cover art 149 |
{activeSong.artist}
150 |
{activeSong.title}
151 |
152 |
153 | 154 | 158 | 164 | 168 | 169 |
170 | 176 |
177 |
{starttime}
178 |
{formatTime(audio.duration)}
179 |
180 |
181 | 182 | ); 183 | } 184 | 185 | export default MusicPlayer; 186 | -------------------------------------------------------------------------------- /src/Views/MusicPlayer.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useContext } from 'react'; 2 | import { usePalette } from 'react-palette'; 3 | import { useHistory } from 'react-router-dom'; 4 | 5 | import { MusicContext } from '../Contexts/MusicContext'; 6 | import { DisplayContext } from '../Contexts/DisplayContext'; 7 | import { ThemeContext } from '../Contexts/ThemeContext'; 8 | 9 | import ProgressSlider from "../Components/ProgressSlider" 10 | import { PlaylistPicker } from '../Components/PlaylistPicker'; 11 | 12 | import useAudio from "../Hooks/useAudio"; 13 | import useDisplay from "../Hooks/useDisplay"; 14 | 15 | import PlayIcon from '../assets/icons/play.svg'; 16 | import SkipForwardIcon from '../assets/icons/skipforward.svg'; 17 | import SkipBackwardIcon from '../assets/icons/skipbackward.svg'; 18 | import ShuffleIcon from '../assets/icons/shuffle.svg'; 19 | import RepeatIcon from '../assets/icons/repeat.svg'; 20 | import BackIcon from '../assets/icons/back.svg'; 21 | import PlusIcon from '../assets/icons/plus.svg'; 22 | import PauseIcon from '../assets/icons/pause.svg'; 23 | 24 | import '../Styles/App.css'; 25 | // import '../Styles/MusicPlayerM.css'; 26 | import '../Styles/MusicPlayer.css'; 27 | 28 | const MusicPlayer = () => { 29 | const [state] = useContext(MusicContext); 30 | const [display] = useContext(DisplayContext); 31 | const [theme] = useContext(ThemeContext); 32 | const { 33 | nextSong, 34 | prevSong, 35 | togglePlay, 36 | toggleShuffle, 37 | setRepeat, 38 | play, 39 | shuffle, 40 | repeat 41 | } = useAudio(); 42 | const { 43 | openModal, 44 | closeModal, 45 | openPlaylistPicker 46 | } = useDisplay(); 47 | const { data } = usePalette(state.activeSong.thumbs[0]); 48 | let history = useHistory(); 49 | 50 | function handleRepeatButton() { 51 | switch (repeat) { 52 | case 'none': 53 | setRepeat('repeat'); 54 | break; 55 | case 'repeat': 56 | setRepeat('repeatsong'); 57 | break; 58 | case 'repeatsong': 59 | setRepeat('none'); 60 | break; 61 | } 62 | } 63 | 64 | function handleNextButton() { 65 | if (repeat === 'repeatsong') { 66 | setRepeat('repeat'); 67 | } 68 | nextSong(); 69 | } 70 | 71 | return ( 72 | <> 73 | 74 | 75 | {/* DROPDOWN MODAL */} 76 |
82 |
83 | 88 | 89 | 90 | 91 |
92 |
93 | 94 | {/* MODAL TOUCH BLOCKER */} 95 |
99 | 100 | {/* HEADER NAVIGATION */} 101 |
102 | 110 | Player 111 | 120 |
121 | 122 | {/* ALBUM ART */} 123 |
124 | cover art 128 |
129 | 130 | {/* ALBUM INFO AND CONTROLLER */} 131 |
136 |
{state.activeSong.artist.join(', ')}
137 |
{state.activeSong.title}
138 | 139 |
140 | 150 | 159 | 172 | 181 | 190 |
191 | 192 | 196 |
197 | 198 | ); 199 | } 200 | 201 | export default MusicPlayer; 202 | -------------------------------------------------------------------------------- /src/assets/icons/PlusSquareBtn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/src/assets/icons/PlusSquareBtn.jpg -------------------------------------------------------------------------------- /src/assets/icons/back.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/assets/icons/dots.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/assets/icons/pause.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/assets/icons/play.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/assets/icons/plus.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/assets/icons/repeat.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/assets/icons/shuffle.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/assets/icons/skipbackward.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/assets/icons/skipforward.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/data/Playlist.js: -------------------------------------------------------------------------------- 1 | import { songs } from './Songs'; 2 | const imagedir = '../assets/images/'; 3 | 4 | export const info = { 5 | name: 'Liked Songs', 6 | cover: imagedir + 'Flow.jpg', 7 | author: 'Shawn Lee' 8 | }; 9 | 10 | export const tracks = [ 11 | songs["shy_martin-good_together"], 12 | songs["reik-raptame"], 13 | songs["selena_gomez-hands_to_myself"], 14 | songs["post_malone-circles"], 15 | songs["anuel_aa-keii"], 16 | songs["galantis-we_can_get_high"], 17 | songs["elephante-glass_mansion"], 18 | songs["lauv-mean_it"], 19 | songs["shawn_mendes-lost_in_japan_remix"], 20 | songs["midnight_kids-run_it"] 21 | ]; 22 | 23 | export const playlists = { 24 | 'default': { 25 | id: 'default', 26 | name: 'default', 27 | cover: imagedir + 'Placeholder.jpg', 28 | thumbs: [imagedir + 'Placeholder.jpg', imagedir + 'Placeholder.jpg', imagedir + 'Placeholder.jpg'], 29 | author: 'default', 30 | tracks: [ 31 | songs["default"] 32 | ] 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /src/data/Songs.js: -------------------------------------------------------------------------------- 1 | const audiodir = '../assets/audio/'; 2 | const imagedir = '../assets/images/'; 3 | 4 | export const songs = { 5 | 'default': { 6 | id: 'default', 7 | src: audiodir + 'SHY Martin - Good Together.mp3', 8 | cover: imagedir + 'Placeholder.jpg', 9 | thumbs: [imagedir + 'Placeholder.jpg',imagedir + 'Placeholder.jpg',imagedir + 'Placeholder.jpg'], 10 | title: 'default', 11 | artist: ['default'], 12 | album: 'default' 13 | }, 14 | // 'shy_martin-good_together': { 15 | // id: 'shy_martin-good_together', 16 | // src: audiodir + 'SHY Martin - Good Together.mp3', 17 | // cover: imagedir + 'SHY Martin - Overthinking.jpg', 18 | // title: 'Good Together', 19 | // artist: ['SHY Martin'], 20 | // album: 'Overthinking' 21 | // }, 22 | // 'reik-raptame': { 23 | // id: 'reik-raptame', 24 | // src: audiodir + 'Ráptame - Reik.mp3', 25 | // cover: imagedir + 'Reik - Ahora.jpg', 26 | // title: 'Ráptame', 27 | // artist: ['Reik'], 28 | // album: 'Ahora' 29 | // }, 30 | // 'selena_gomez-hands_to_myself': { 31 | // id: 'selena_gomez-hands_to_myself', 32 | // src: audiodir + 'Selena Gomez - Hands To Myself.mp3', 33 | // cover: imagedir + 'Selena Gomez - Revival.jpg', 34 | // title: 'Hands to Myself', 35 | // artist: ['Selena Gomez'], 36 | // album: 'Revival' 37 | // }, 38 | // 'post_malone-circles': { 39 | // id: 'post_malone-circles', 40 | // src: audiodir + 'Post Malone - Circles.mp3', 41 | // cover: imagedir + 'Post Malone - Hollywoods Bleeding.jpg', 42 | // title: 'Circles', 43 | // artist: ['Post Malone'], 44 | // album: 'Hollywood\'s Bleeding' 45 | // }, 46 | // 'anuel_aa-keii': { 47 | // id: 'anuel_aa-keii', 48 | // src: audiodir + 'Anuel AA - Keii.mp3', 49 | // cover: imagedir + 'Anuel AA - Keii.jpg', 50 | // title: 'Keii', 51 | // artist: ['Anuel AA'], 52 | // album: 'Keii' 53 | // }, 54 | // 'galantis-we_can_get_high': { 55 | // id: 'galantis-we_can_get_high', 56 | // src: audiodir + 'Galantis & Yellow Claw - We Can Get High.mp3', 57 | // cover: imagedir + 'Galantis - Church.jpg', 58 | // title: 'We Can Get High', 59 | // artist: ['Galantis', 'Yellow Claw'], 60 | // album: 'Church' 61 | // }, 62 | // 'elephante-glass_mansion': { 63 | // id: 'elephante-glass_mansion', 64 | // src: audiodir + 'Elephante - Glass Mansion.mp3', 65 | // cover: imagedir + 'Elephante - Glass Mansion.jpeg', 66 | // title: 'Glass Mansion', 67 | // artist: ['Elephante'], 68 | // album: 'Glass Mansion' 69 | // }, 70 | // 'lauv-mean_it': { 71 | // id: 'lauv-mean_it', 72 | // src: audiodir + 'Lauv & LANY - Mean It.mp3', 73 | // cover: imagedir + 'Lauv - in my feelings.jpg', 74 | // title: 'Mean It', 75 | // artist: ['Lauv', 'LANY'], 76 | // album: '~in my feelings~' 77 | // }, 78 | // 'shawn_mendes-lost_in_japan_remix': { 79 | // id: 'shawn_mendes-lost_in_japan_remix', 80 | // src: audiodir + 'Shawn Mendes, Zedd - Lost In Japan (Remix).mp3', 81 | // cover: imagedir + 'Shawn Mendes - Lost in Japan.jpg', 82 | // title: 'Lost in Japan - Remix', 83 | // artist: ['Shawn Mendes', 'Zedd'], 84 | // album: 'Lost in Japan' 85 | // }, 86 | // 'midnight_kids-run_it': { 87 | // id: 'midnight_kids-run_it', 88 | // src: audiodir + 'Midnight Kids - Run It.mp3', 89 | // cover: imagedir + 'Midnight Kids - Run It.jpg', 90 | // title: 'Run It', 91 | // artist: ['Midnight Kids', 'Annika Wells'], 92 | // album: 'Run It' 93 | // } 94 | }; -------------------------------------------------------------------------------- /src/fonts/Futura_PT_Book.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/src/fonts/Futura_PT_Book.ttf -------------------------------------------------------------------------------- /src/fonts/Futura_PT_ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/src/fonts/Futura_PT_ExtraBold.ttf -------------------------------------------------------------------------------- /src/fonts/Futura_PT_Heavy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/src/fonts/Futura_PT_Heavy.ttf -------------------------------------------------------------------------------- /src/fonts/Futura_PT_Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/src/fonts/Futura_PT_Light.ttf -------------------------------------------------------------------------------- /src/fonts/Futura_PT_Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnSYLee/react-music-player/4912ed9d6c3ae4b2b9c51819bf1d7e95f78118c9/src/fonts/Futura_PT_Medium.ttf -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Futura PT'; 3 | src: local('Futura'), url('./fonts/Futura_PT_Medium.ttf') format('truetype'); 4 | } 5 | 6 | body { 7 | margin: 0; 8 | font-family: Futura PT, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 9 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 10 | sans-serif; 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | } 14 | 15 | code { 16 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 17 | monospace; 18 | } 19 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | import './fonts/Futura_PT_Light.ttf'; 7 | import './fonts/Futura_PT_Book.ttf'; 8 | import './fonts/Futura_PT_Medium.ttf'; 9 | import './fonts/Futura_PT_Heavy.ttf'; 10 | import './fonts/Futura_PT_ExtraBold.ttf'; 11 | 12 | ReactDOM.render(( 13 | 14 | ), document.getElementById('root') 15 | ); 16 | 17 | // If you want your app to work offline and load faster, you can change 18 | // unregister() to register() below. Note this comes with some pitfalls. 19 | // Learn more about service workers: https://bit.ly/CRA-PWA 20 | serviceWorker.unregister(); 21 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' } 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready 134 | .then(registration => { 135 | registration.unregister(); 136 | }) 137 | .catch(error => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /storage.rules: -------------------------------------------------------------------------------- 1 | service firebase.storage { 2 | match /b/{bucket}/o { 3 | match /{allPaths=**} { 4 | allow read, write: if request.auth!=null; 5 | } 6 | } 7 | } 8 | --------------------------------------------------------------------------------