Skip to content

Commit

Permalink
refactor: simplify code, add vscode app
Browse files Browse the repository at this point in the history
  • Loading branch information
Renovamen committed Apr 30, 2021
1 parent 8ace737 commit 315a27e
Show file tree
Hide file tree
Showing 15 changed files with 292 additions and 285 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# playround-macos
# playground-macos

Have fun and know more about me in this macOS-like playground: https://zxh.vercel.app
My portfolio website simulating macOS's GUI: https://zxh.vercel.app

Powered by [React](https://reactjs.org/) and [tailwindcss](https://tailwindcss.com/).

Expand All @@ -27,7 +27,6 @@ yarn build
- [macOS Big Sur](https://www.apple.com/in/macos/big-sur/)
- [macOS Icon Gallery](https://www.macosicongallery.com/)
- [sindresorhus/file-icon-cli](https://github.com/sindresorhus/file-icon-cli)
- [tilak30/MacOS-Clone](https://github.com/tilak30/MacOS-Clone)


 
Expand Down
Binary file added public/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.
5 changes: 2 additions & 3 deletions src/components/ControlCenterMenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, { Component, useState } from "react";
import nightwind from "nightwind/helper";
import Slider from "react-rangeslider";
import "react-rangeslider/lib/index.css";
Expand All @@ -10,7 +10,7 @@ import { IoCopyOutline, IoSunny, IoMoon, IoVolumeHigh } from "react-icons/io5";
import { FaWifi } from "react-icons/fa";

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

// export default function ControlCenterMenu()
export default class ControlCenterMenu extends Component {
constructor(props) {
super(props);
Expand Down
58 changes: 17 additions & 41 deletions src/components/Dock.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
import React from "react";
import apps from "../configs/apps";

export default function Dock({ openWindow, showLaunchpad, setShowLaunchpad }) {
const openApp = (title) => {
setShowLaunchpad(false);
openWindow(title);
export default function Dock({ open, toggleLaunchpad, hidde }) {
const openApp = (id) => {
toggleLaunchpad(false);
open(id);
};

return (
<div
className="dock w-full fixed bottom-0"
style={{
zIndex: 99999
zIndex: hidde ? 0 : 99999
}}
>
<ul className="mx-auto w-max p-2 space-x-2 flex flex-row justify-center justify-between bg-white bg-opacity-20 blur rounded-t-lg shadow-2xl">
<li
key="dock-launchpad"
onClick={() => setShowLaunchpad(!showLaunchpad)}
>
<li key="dock-launchpad" onClick={() => toggleLaunchpad()}>
<img
className="w-12"
src="icons/launchpad.png"
alt="Launchpad"
title="Launchpad"
/>
</li>
<li key="dock-text" onClick={() => openApp("Notepad")}>
<img
className="w-12"
src="icons/text.png"
alt="Notepad"
title="Notepad"
/>
</li>
<li key="dock-safari" onClick={() => openApp("Safari")}>
<img
className="w-12"
src="icons/safari.png"
alt="Safari"
title="Safari"
/>
</li>
{apps.map((app) => (
<li key={`dock-${app.id}`} onClick={() => openApp(app.id)}>
<img
className="w-12"
src={app.img}
alt={app.title}
title={app.title}
/>
</li>
))}
<li key="dock-mail">
<a href="mailto:[email protected]">
<img
Expand All @@ -65,22 +57,6 @@ export default function Dock({ openWindow, showLaunchpad, setShowLaunchpad }) {
/>
</a>
</li>
<li key="dock-cmd" onClick={() => openApp("Terminal")}>
<img
className="w-12"
src="icons/terminal.png"
alt="Terminal"
title="Terminal"
/>
</li>
<li key="dock-facetime" onClick={() => openApp("FaceTime")}>
<img
className="w-12"
src="icons/facetime.png"
alt="FaceTime"
title="FaceTime"
/>
</li>
</ul>
</div>
);
Expand Down
48 changes: 3 additions & 45 deletions src/components/Launchpad.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,9 @@
import React, { Component } from "react";
import { BiSearch } from "react-icons/bi";
import launchpadApps from "../configs/launchpad";

const placeholderText = "Search";

const appList = [
{
title: "Flint",
img: "icons/launchpad/flint.png",
link: "https://github.com/Renovamen/flint"
},
{
title: "Metallic",
img: "icons/launchpad/meta.png",
link: "https://github.com/Renovamen/metallic"
},
{
title: "Alkaid",
img: "icons/launchpad/rl.png",
link: "https://github.com/Renovamen/alkaid"
},
{
title: "Oh, Vue Icons!",
img: "icons/launchpad/icon.png",
link: "https://oh-vue-icons.netlify.app/"
},
{
title: "Gungnir",
img: "icons/launchpad/gungnir.png",
link: "https://vuepress-theme-gungnir.vercel.app/"
},
{
title: "My Notebook",
img: "icons/launchpad/notebook.png",
link: "https://vuepress-theme-gungnir.vercel.app/"
},
{
title: "Fishmail",
img: "icons/launchpad/fishmail.png",
link: "https://fishmail.vercel.app/"
},
{
title: "Résumé?",
img: "icons/launchpad/resume.png",
link: "https://midgard.renovamen.ink/"
}
];

export default class Launchpad extends Component {
constructor(props) {
super(props);
Expand All @@ -55,8 +13,8 @@ export default class Launchpad extends Component {
}

search = () => {
if (this.state.searchText === "") return appList;
const list = appList.filter((item) => {
if (this.state.searchText === "") return launchpadApps;
const list = launchpadApps.filter((item) => {
return item.title
.toLowerCase()
.includes(this.state.searchText.toLowerCase());
Expand Down
8 changes: 2 additions & 6 deletions src/components/MenuBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ const MenuItem = ({ children }) => {
);
};

export default function MenuBar({
title,
showControlCenter,
setShowControlCenter
}) {
export default function MenuBar({ title, toggleControlCenter }) {
const [date, setDate] = useState(new Date());

useEffect(() => {
Expand Down Expand Up @@ -48,7 +44,7 @@ export default function MenuBar({
className="w-4 h-4 filter-invert"
src="icons/menu/controlcenter.png"
alt="control center"
onClick={() => setShowControlCenter(!showControlCenter)}
onClick={() => toggleControlCenter()}
/>
</MenuItem>
<span>{format(date, "eee d MMM h:mm aa")}</span>
Expand Down
24 changes: 10 additions & 14 deletions src/components/Window.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { Component } from "react";
import { Rnd } from "react-rnd";

const TrafficLights = ({ setShow, max, setMax }) => {
const TrafficLights = ({ id, close, setMax }) => {
const closeWindow = (e) => {
e.stopPropagation();
setShow(false);
close(id);
};

return (
Expand All @@ -16,13 +16,13 @@ const TrafficLights = ({ setShow, max, setMax }) => {
/>
<button
className="w-3 h-3 rounded-full bg-yellow-500 outline-none focus:outline-none"
onClick={() => setMax(false)}
onTouchEnd={() => setMax(false)}
onClick={() => setMax(id, false)}
onTouchEnd={() => setMax(id, false)}
/>
<button
className="w-3 h-3 rounded-full bg-green-500 outline-none focus:outline-none"
onClick={() => setMax(!max)}
onTouchEnd={() => setMax(!max)}
onClick={() => setMax(id)}
onTouchEnd={() => setMax(id)}
/>
</div>
);
Expand Down Expand Up @@ -71,10 +71,6 @@ export default class Window extends Component {
render() {
const round = this.props.max ? "rounded-none" : "rounded-lg";

if (!this.props.show) {
return <div />;
}

return (
<Rnd
size={{
Expand All @@ -98,16 +94,16 @@ export default class Window extends Component {
dragHandleClassName="window-bar"
disableDragging={this.props.max}
style={{ zIndex: this.props.z }}
onMouseDown={() => this.props.active(this.props.title)}
onMouseDown={() => this.props.focus(this.props.id)}
className={`absolute transition-hw ${round} overflow-hidden bg-transparent w-full h-full shadow-md`}
>
<div
className="window-bar relative h-6 text-center bg-gray-300"
onDoubleClick={() => this.props.setMax(!this.props.max)}
onDoubleClick={() => this.props.setMax(this.props.id)}
>
<TrafficLights
setShow={this.props.setShow}
max={this.props.max}
id={this.props.id}
close={this.props.close}
setMax={this.props.setMax}
/>
<span className="font-semibold text-gray-700">
Expand Down
23 changes: 2 additions & 21 deletions src/components/apps/FaceTime.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { Component, useState } from "react";
import React, { Component } from "react";
import Webcam from "react-webcam";
import Window from "../Window";

const videoConstraints = {
facingMode: "user"
};

class FaceTimeContent extends Component {
export default class FaceTime extends Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -69,21 +68,3 @@ class FaceTimeContent extends Component {
);
}
}

export default function FaceTime({ show, setShow, active, z }) {
const [faceTimeMax, setFaceTimeMax] = useState(false);
return (
<Window
title="FaceTime"
show={show}
setShow={setShow}
max={faceTimeMax}
setMax={setFaceTimeMax}
active={active}
z={z}
height={600}
>
<FaceTimeContent />
</Window>
);
}
22 changes: 2 additions & 20 deletions src/components/apps/Notepad.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from "react";
import Window from "../Window";
import React from "react";

const NotepadContent = () => {
export default function Notepad() {
return (
<div className="w-full h-full bg-gray-100 text-gray-700 overflow-scroll px-8 py-6">
<div className="charapter">
Expand Down Expand Up @@ -187,21 +186,4 @@ const NotepadContent = () => {
</div>
</div>
);
};

export default function Notepad({ show, setShow, active, z }) {
const [textMax, setTextMax] = useState(false);
return (
<Window
title="Notepad"
show={show}
setShow={setShow}
max={textMax}
setMax={setTextMax}
active={active}
z={z}
>
<NotepadContent />
</Window>
);
}
23 changes: 2 additions & 21 deletions src/components/apps/Safari.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, Component } from "react";
import Window from "../Window";
import React, { Component } from "react";

class SafariContent extends Component {
export default class Safari extends Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -37,21 +36,3 @@ class SafariContent extends Component {
);
}
}

export default function Safari({ show, setShow, active, z }) {
const [safariMax, setSafariMax] = useState(false);
return (
<Window
title="Safari"
show={show}
setShow={setShow}
max={safariMax}
setMax={setSafariMax}
active={active}
z={z}
size={"h-3/4 w-3/5"}
>
<SafariContent />
</Window>
);
}
Loading

0 comments on commit 315a27e

Please sign in to comment.