Skip to content

Commit

Permalink
feat: play music
Browse files Browse the repository at this point in the history
  • Loading branch information
Renovamen committed May 3, 2021
1 parent 1657d36 commit c54af82
Show file tree
Hide file tree
Showing 56 changed files with 109 additions and 69 deletions.
Binary file removed public/icons/facetime.png
Binary file not shown.
Binary file removed public/icons/github.png
Binary file not shown.
Binary file removed public/icons/launchpad.png
Binary file not shown.
Binary file removed public/icons/mail.png
Binary file not shown.
Binary file removed public/icons/safari.png
Binary file not shown.
Binary file removed public/icons/terminal.png
Binary file not shown.
Binary file removed public/icons/text.png
Binary file not shown.
Binary file removed public/icons/vscode.png
Binary file not shown.
Binary file added public/img/icons/facetime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/launchpad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added public/img/icons/mail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added public/img/icons/notepad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/safari.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/terminal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/icons/vscode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions public/img/sites/bilibili.svg
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions public/img/sites/gmail.svg
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Jost:300,400,500,700" />
<title>Xiaohan Zou's Playground</title>
<title>Xiaohan Zou's Portfolio</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "playground-macos",
"name": "Xiaohan Zou's playground.",
"name": "Xiaohan Zou's Portfolio",
"icons": [
{
"src": "logo/favicon.svg",
Expand Down
Binary file added public/music/sunflower.mp3
Binary file not shown.
21 changes: 0 additions & 21 deletions public/sites/bilibili.svg
Diff not rendered.
7 changes: 4 additions & 3 deletions src/components/apps/Safari.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class NavPage extends Component {
render() {
const grid = this.props.width < 640 ? "grid-cols-4" : "grid-cols-8";
const span = this.props.width < 640 ? "col-span-3" : "col-span-7";
const numTracker = Math.floor(Math.random() * 99 + 1);

return (
<div
Expand Down Expand Up @@ -112,13 +113,13 @@ class NavPage extends Component {
>
<div className="text-black col-start-1 col-span-1 flex flex-row items-center justify-center space-x-2">
<FaShieldAlt size={24} />
<span className="text-xl">1</span>
<span className="text-xl">{numTracker}</span>
</div>
<div
className={`col-start-2 ${span} flex items-center text-black`}
>
In the last sever days, Safari has prevent 2 tracker from
profiling you.
In the last sever days, Safari has prevent {numTracker} tracker
from profiling you.
</div>
</div>
</div>
Expand Down
58 changes: 52 additions & 6 deletions src/components/topbar/ControlCenterMenu.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { Component, useState } from "react";
import React, { Component } from "react";
import nightwind from "nightwind/helper";
import Slider from "react-rangeslider";
import "react-rangeslider/lib/index.css";

// ------- import icons -------
import { FiBluetooth, FiRss } from "react-icons/fi";
import { BsBrightnessAltHigh, BsPlayFill } from "react-icons/bs";
import { BsBrightnessAltHigh, BsPlayFill, BsPauseFill } from "react-icons/bs";
import { IoCopyOutline, IoSunny, IoMoon, IoVolumeHigh } from "react-icons/io5";
import { FaWifi } from "react-icons/fa";

const SliderComponent = ({ icon }) => {
const [value, setValue] = useState(Math.floor(Math.random() * 100));
const SliderComponent = ({ icon, value, setValue }) => {
return (
<div className="slider flex flex-row w-full">
<div className="h-8 p-2 bg-white rounded-l-full">{icon}</div>
Expand All @@ -27,11 +26,50 @@ const SliderComponent = ({ icon }) => {
};

export default class ControlCenterMenu extends Component {
constructor(props) {
super(props);
this.state = {
playing: false,
volume: 100,
brightness: Math.floor(Math.random() * 100)
};
this.toggleAudio = this.toggleAudio.bind(this);
}

componentDidMount() {
this.audio = new Audio("music/sunflower.mp3");
this.audio.load();
this.audio.addEventListener("ended", () => this.audio.play());
this.audio.volume = 1;
}

componentWillUnmount() {
this.audio.removeEventListener("ended", () => this.audio.play());
}

toggleAudio = () => {
this.setState({ playing: !this.state.playing }, () => {
this.state.playing ? this.audio.play() : this.audio.pause();
});
};

toggleMode = () => {
this.props.setDark(!this.props.dark);
nightwind.toggle();
};

setVolume = (value) => {
this.setState({ volume: value }, () => {
this.audio.volume = value / 100;
});
};

setBrightness = (value) => {
this.setState({
brightness: value
});
};

render() {
return (
<div className="fixed w-96 max-w-full top-8 right-0 sm:right-2 z-50 p-2 grid grid-cols-4 grid-rows-5 gap-2 bg-white bg-opacity-25 blur rounded-2xl text-black shadow-2xl">
Expand Down Expand Up @@ -102,25 +140,33 @@ export default class ControlCenterMenu extends Component {
<span className="font-medium">Display</span>
<SliderComponent
icon={<IoSunny size={16} className="text-gray-500" />}
value={this.state.brightness}
setValue={this.setBrightness}
/>
</div>
<div className="col-span-4 bg-white bg-opacity-50 blur rounded-xl p-2 space-y-2 flex flex-col justify-around">
<span className="font-medium">Sound</span>
<SliderComponent
icon={<IoVolumeHigh size={16} className="text-gray-500" />}
value={this.state.volume}
setValue={this.setVolume}
/>
</div>
<div className="col-span-4 bg-white bg-opacity-50 blur rounded-xl p-2 pr-4 flex flex-row justify-between items-center space-x-4">
<img
src="http://p1.music.126.net/z0IO1vEsowL9mD_5yzUjeA==/109951163936068098.jpg"
src="//p1.music.126.net/z0IO1vEsowL9mD_5yzUjeA==/109951163936068098.jpg"
alt="cover art"
className="w-16 rounded-lg"
/>
<div className="flex flex-col flex-grow justify-start">
<span className="font-medium">Sunflower</span>
<span className="font-extralight">Post Malone / Swae Lee</span>
</div>
<BsPlayFill size={24} />
{this.state.playing ? (
<BsPauseFill onClick={this.toggleAudio} size={24} />
) : (
<BsPlayFill onClick={this.toggleAudio} size={24} />
)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/topbar/MenuBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function MenuBar({ title, dark, setDark, setlogon }) {
<MenuItem onClick={() => setShowControlCenter(!showControlCenter)}>
<img
className="w-4 h-4 filter-invert"
src="icons/menu/controlcenter.png"
src="img/icons/menu/controlcenter.png"
alt="control center"
/>
</MenuItem>
Expand Down
18 changes: 9 additions & 9 deletions src/configs/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const apps = [
id: "launchpad",
title: "Launchpad",
desktop: false,
img: "icons/launchpad.png"
img: "img/icons/launchpad.png"
},
{
id: "notepad",
title: "Notepad",
desktop: true,
show: false,
img: "icons/text.png",
img: "img/icons/notepad.png",
content: <Notepad />
},
{
Expand All @@ -27,23 +27,23 @@ const apps = [
width: 1024,
minWidth: 375,
minHeight: 200,
img: "icons/safari.png",
img: "img/icons/safari.png",
content: <Safari />
},
{
id: "vscode",
title: "VSCode",
desktop: true,
show: false,
img: "icons/vscode.png",
img: "img/icons/vscode.png",
content: <VSCode />
},
{
id: "facetime",
title: "FaceTime",
desktop: true,
show: false,
img: "icons/facetime.png",
img: "img/icons/facetime.png",
height: 530,
content: <FaceTime />
},
Expand All @@ -52,22 +52,22 @@ const apps = [
title: "Terminal",
desktop: true,
show: false,
img: "icons/terminal.png",
img: "img/icons/terminal.png",
content: <Terminal />
},
{
id: "email",
title: "Email",
desktop: false,
img: "icons/mail.png",
img: "img/icons/mail.png",
link: "mailto:[email protected]"
},
{
id: "github",
title: "Github",
desktop: false,
img: "icons/github.png",
link: "https://github.com/Renovamen"
img: "img/icons/github.png",
link: "https://github.com/Renovamen/playground-macos"
}
];

Expand Down
16 changes: 8 additions & 8 deletions src/configs/launchpad.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@ const launchpadApps = [
{
id: "flint",
title: "Flint",
img: "icons/launchpad/flint.png",
img: "img/icons/launchpad/flint.png",
link: "https://github.com/Renovamen/flint"
},
{
id: "metallic",
title: "Metallic",
img: "icons/launchpad/meta.png",
img: "img/icons/launchpad/meta.png",
link: "https://github.com/Renovamen/metallic"
},
{
id: "alkaid",
title: "Alkaid",
img: "icons/launchpad/rl.png",
img: "img/icons/launchpad/rl.png",
link: "https://github.com/Renovamen/alkaid"
},
{
id: "oh-vue-icons",
title: "Oh, Vue Icons!",
img: "icons/launchpad/icon.png",
img: "img/icons/launchpad/icon.png",
link: "https://oh-vue-icons.netlify.app/"
},
{
id: "gungnir",
title: "Gungnir",
img: "icons/launchpad/gungnir.png",
img: "img/icons/launchpad/gungnir.png",
link: "https://vuepress-theme-gungnir.vercel.app/"
},
{
id: "what-if",
title: "My Notebook",
img: "icons/launchpad/notebook.png",
img: "img/icons/launchpad/notebook.png",
link: "https://note.zxh.io"
},
{
id: "fishmail",
title: "Fishmail",
img: "icons/launchpad/fishmail.png",
img: "img/icons/launchpad/fishmail.png",
link: "https://fishmail.vercel.app/"
},
{
id: "resume",
title: "Résumé",
img: "icons/launchpad/resume.png",
img: "img/icons/launchpad/resume.png",
link: "https://resume.zxh.io/"
}
];
Expand Down
4 changes: 2 additions & 2 deletions src/configs/wallpapers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const wallpapers = {
day: "img/wallpaper-day.jpg",
night: "img/wallpaper-night.jpg"
day: "img/ui/wallpaper-day.jpg",
night: "img/ui/wallpaper-night.jpg"
};

export default wallpapers;
Loading

0 comments on commit c54af82

Please sign in to comment.