Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sakgoyal committed Jun 27, 2023
1 parent 7ac1d7d commit 8160a9c
Showing 1 changed file with 19 additions and 57 deletions.
76 changes: 19 additions & 57 deletions src/components/Popup/index.jsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
import { render, Fragment } from "preact";
import { useState, useEffect } from "preact/hooks";

// Popup component styling.
import "./popup.scss";
import "./popup.scss"; // Popup component styling.

/**
* The Spotify Friend Activity extension's popup.
*
* @returns {JSX.Element} The popup.
*/
const Popup = () => {
// Keep track of the FriendActivity component's display state.
const [isDisplayed, setIsDisplayed] = useState();
const [isDisplayed, setIsDisplayed] = useState(); // Keep track of the FriendActivity component's display state.

useEffect(() => {
// Get isDisplayed from chrome local storage.
chrome.storage.sync.get("isDisplayed", (store) => {
// If isDisplayed has never been set. (The user hasn't clicked the "Show friend activity" toggle yet)
if (store.isDisplayed === undefined) {
setIsDisplayed(true);
} else {
setIsDisplayed(store.isDisplayed);
}
// If the user hasn't clicked the "Show friend activity" toggle yet...
if (store.isDisplayed === undefined) { setIsDisplayed(true); }
else { setIsDisplayed(store.isDisplayed); }
});
}, []);

// "Show friend activity" toggle handler.
const handleToggleChange = (e) => {
const isDisplayed = e.target.checked;

// Set isDisplayed in chrome local storage.
chrome.storage.sync.set({ isDisplayed });

setIsDisplayed(isDisplayed);
};

Expand All @@ -40,65 +31,36 @@ const Popup = () => {
<h1>Spotify Friend Activity</h1>
{isDisplayed !== undefined && (
<label class="switch">
<input
type="checkbox"
id="friend-activity-toggle"
checked={isDisplayed}
onChange={handleToggleChange}
/>
<span class="slider">
<span class="switch-label">Show friend activity</span>
</span>
<input type="checkbox" id="friend-activity-toggle" checked={isDisplayed} onChange={handleToggleChange} />
<span class="slider"> <span class="switch-label">Show friend activity</span> </span>
</label>
)}
<hr />
<div class="issue-links">
<a
href="https://github.com/jackweatherford/spotify-friend-activity/issues/new?assignees=jackweatherford&labels=bug&template=bug_report.md&title=%5BBUG%5D"
target="_blank"
title="Report a Bug"
>
href="https://github.com/sakgoyal/spotify-friend-activity/issues/new?assignees=sakgoyal&labels=bug&template=bug_report.md&title=%5BBUG%5D"
target="_blank" title="Report a Bug" >
Report a Bug
</a>
<p> | </p>
<a
href="https://github.com/jackweatherford/spotify-friend-activity/issues/new?assignees=jackweatherford&labels=enhancement&template=feature_request.md&title=%5BENHANCEMENT%5D"
target="_blank"
title="Request a Feature"
>
<a href="https://github.com/sakgoyal/spotify-friend-activity/issues/new?assignees=sakgoyal&labels=enhancement&template=feature_request.md&title=%5BENHANCEMENT%5D"
target="_blank" title="Request a Feature" >
Request a Feature
</a>
</div>
<hr />
{/* <hr /> */}
<div class="footer-icons-container">
<a
href="https://github.com/jackweatherford/spotify-friend-activity"
target="_blank"
title="GitHub Repository"
>
<img
width={24}
height={24}
src="../../images/github.png"
alt="GitHub Icon"
/>
</a>
<a
href="https://chrome.google.com/webstore/detail/spotify-friend-activity/amlnlcdighbhfciijpnofbpphfnkmeaa"
target="_blank"
title="Chrome Web Store Page"
>
<img
width={24}
height={21}
src="../../images/chrome-web-store.png"
alt="Chrome Web Store Icon"
/>
<a href="https://github.com/sakgoyal/spotify-friend-activity"
target="_blank" title="GitHub Repository" >
<img width={24} height={24} src="../../images/github.png" alt="GitHub Icon" />
</a>
{/* <a href="https://chrome.google.com/webstore/detail/spotify-friend-activity/amlnlcdighbhfciijpnofbpphfnkmeaa"
target="_blank" title="Chrome Web Store Page" >
<img width={24} height={21} src="../../images/chrome-web-store.png" alt="Chrome Web Store Icon" />
</a> */}
</div>
</Fragment>
);
};

// Inject Popup into popup.html.
render(<Popup />, document.getElementById("popup"));

0 comments on commit 8160a9c

Please sign in to comment.