-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from MatheusR42/feature/toggle-switch
feat: toggle swith to turn off and on
- Loading branch information
Showing
6 changed files
with
242 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
body { | ||
width: 10rem; | ||
display: flex; | ||
justify-items: center; | ||
align-items: center; | ||
flex-direction: column; | ||
padding: 0.5rem; | ||
} | ||
|
||
.logo { | ||
display: flex; | ||
justify-items: center; | ||
align-items: center; | ||
flex-direction: column; | ||
} | ||
|
||
.switch { | ||
position: relative; | ||
display: inline-block; | ||
width: 45px; | ||
height: 25.5px; | ||
} | ||
|
||
.switch input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
|
||
.slider { | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: #ccc; | ||
-webkit-transition: 0.4s; | ||
transition: 0.4s; | ||
} | ||
|
||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 19.5px; | ||
width: 19.5px; | ||
left: 3px; | ||
bottom: 3px; | ||
background-color: white; | ||
-webkit-transition: 0.4s; | ||
transition: 0.4s; | ||
} | ||
|
||
input:checked + .slider { | ||
background-color: #2196f3; | ||
} | ||
|
||
input:checked + .slider:before { | ||
-webkit-transform: translateX(19.5px); | ||
-ms-transform: translateX(19.5px); | ||
transform: translateX(19.5px); | ||
} | ||
|
||
/* Rounded sliders */ | ||
.slider.round { | ||
border-radius: 25.5px; | ||
} | ||
|
||
.slider.round:before { | ||
border-radius: 50%; | ||
} | ||
|
||
.disabled-toggle { | ||
opacity: 0.5; | ||
cursor: default; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<html> | ||
<head> | ||
<title>Minimal Youtube Popup</title> | ||
<link rel="stylesheet" href="popup.css" /> | ||
</head> | ||
|
||
<body class=""> | ||
<div class="logo"> | ||
<img src="./assets/128x128.png" width="70" /> | ||
<h2>Minimal Youtube</h2> | ||
</div> | ||
<div> | ||
<label class="switch"> | ||
<input id="toggle" checked type="checkbox" /> | ||
<span class="slider round"></span> | ||
</label> | ||
</div> | ||
<script src="popup.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
let enabled = true; | ||
const toggleSwitch = document.getElementById("toggle"); | ||
|
||
chrome.storage.local.get("enabled", (data) => { | ||
enabled = typeof data.enabled === "undefined" ? true : !!data.enabled; | ||
setToggleState(); | ||
}); | ||
|
||
toggleSwitch.addEventListener("change", () => { | ||
enabled = toggleSwitch.checked; | ||
chrome.storage.local.set({ enabled: enabled }); | ||
}); | ||
|
||
function setToggleState() { | ||
toggleSwitch.checked = enabled; | ||
} |
Oops, something went wrong.