mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-29 22:00:56 +03:00
Refactor segment expanding to use <details>
This commit is contained in:
@@ -79,18 +79,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Individual segments (<button> elements)
|
* <details> wrapper around each segment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.segmentTimeButton {
|
.votingButtons[open] {
|
||||||
background: transparent;
|
padding-bottom: 5px;
|
||||||
border: 0;
|
}
|
||||||
|
|
||||||
|
.votingButtons:hover {
|
||||||
|
background-color: var(--sb-grey-bg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Individual segments summaries (clickable <summary>)
|
||||||
|
*/
|
||||||
|
|
||||||
|
.segmentSummary {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--sb-main-fg-color);
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
outline: none;
|
list-style: none;
|
||||||
width: 100%;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,7 +509,3 @@
|
|||||||
#sponsorBlockPopupBody .hidden {
|
#sponsorBlockPopupBody .hidden {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.voteButtonsContainer--hide {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|||||||
20
src/popup.ts
20
src/popup.ts
@@ -393,8 +393,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
const UUID = segmentTimes[i].UUID;
|
const UUID = segmentTimes[i].UUID;
|
||||||
const locked = segmentTimes[i].locked;
|
const locked = segmentTimes[i].locked;
|
||||||
|
|
||||||
const sponsorTimeButton = document.createElement("button");
|
const segmentSummary = document.createElement("summary");
|
||||||
sponsorTimeButton.className = "segmentTimeButton popupElement";
|
segmentSummary.className = "segmentSummary";
|
||||||
|
|
||||||
const categoryColorCircle = document.createElement("span");
|
const categoryColorCircle = document.createElement("span");
|
||||||
categoryColorCircle.id = "sponsorTimesCategoryColorCircle" + UUID;
|
categoryColorCircle.id = "sponsorTimesCategoryColorCircle" + UUID;
|
||||||
@@ -426,18 +426,17 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
|
|
||||||
segmentTimeFromToNode.style.margin = "5px";
|
segmentTimeFromToNode.style.margin = "5px";
|
||||||
|
|
||||||
sponsorTimeButton.appendChild(categoryColorCircle);
|
segmentSummary.appendChild(categoryColorCircle);
|
||||||
sponsorTimeButton.appendChild(textNode);
|
segmentSummary.appendChild(textNode);
|
||||||
sponsorTimeButton.appendChild(segmentTimeFromToNode);
|
segmentSummary.appendChild(segmentTimeFromToNode);
|
||||||
|
|
||||||
const votingButtons = document.createElement("div");
|
const votingButtons = document.createElement("details");
|
||||||
votingButtons.classList.add("votingButtons");
|
votingButtons.classList.add("votingButtons");
|
||||||
|
|
||||||
//thumbs up and down buttons
|
//thumbs up and down buttons
|
||||||
const voteButtonsContainer = document.createElement("div");
|
const voteButtonsContainer = document.createElement("div");
|
||||||
voteButtonsContainer.id = "sponsorTimesVoteButtonsContainer" + UUID;
|
voteButtonsContainer.id = "sponsorTimesVoteButtonsContainer" + UUID;
|
||||||
voteButtonsContainer.setAttribute("align", "center");
|
voteButtonsContainer.setAttribute("align", "center");
|
||||||
voteButtonsContainer.classList.add('voteButtonsContainer--hide');
|
|
||||||
|
|
||||||
const upvoteButton = document.createElement("img");
|
const upvoteButton = document.createElement("img");
|
||||||
upvoteButton.id = "sponsorTimesUpvoteButtonsContainer" + UUID;
|
upvoteButton.id = "sponsorTimesUpvoteButtonsContainer" + UUID;
|
||||||
@@ -505,11 +504,6 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
voteButtonsContainer.appendChild(hideButton);
|
voteButtonsContainer.appendChild(hideButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
//add click listener to open up vote panel
|
|
||||||
sponsorTimeButton.addEventListener("click", function () {
|
|
||||||
voteButtonsContainer.classList.toggle("voteButtonsContainer--hide");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Will contain request status
|
// Will contain request status
|
||||||
const voteStatusContainer = document.createElement("div");
|
const voteStatusContainer = document.createElement("div");
|
||||||
voteStatusContainer.id = "sponsorTimesVoteStatusContainer" + UUID;
|
voteStatusContainer.id = "sponsorTimesVoteStatusContainer" + UUID;
|
||||||
@@ -521,7 +515,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
thanksForVotingText.classList.add("sponsorTimesThanksForVotingText");
|
thanksForVotingText.classList.add("sponsorTimesThanksForVotingText");
|
||||||
voteStatusContainer.appendChild(thanksForVotingText);
|
voteStatusContainer.appendChild(thanksForVotingText);
|
||||||
|
|
||||||
votingButtons.append(sponsorTimeButton);
|
votingButtons.append(segmentSummary);
|
||||||
votingButtons.append(voteButtonsContainer);
|
votingButtons.append(voteButtonsContainer);
|
||||||
votingButtons.append(voteStatusContainer);
|
votingButtons.append(voteStatusContainer);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user