Skip to content

Commit bf88f75

Browse files
authored
Merge pull request #864 from Masaabu/better-popup-options
Better features options
2 parents bbf089b + a97314e commit bf88f75

3 files changed

Lines changed: 51 additions & 50 deletions

File tree

extras/popup/popup.css

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,6 @@ a {
6868

6969
.feature label {
7070
color: var(--primary-color);
71-
position: relative;
72-
top: -0.7rem;
73-
margin-left: 0.5rem;
74-
}
75-
76-
.feature input[type="checkbox"] {
77-
display: inline-block;
78-
width: 1.25rem;
79-
cursor: pointer;
8071
}
8172

8273
.feature > span {
@@ -108,9 +99,10 @@ a {
10899
margin-bottom: 0rem;
109100
}
110101
.feature p {
111-
color: var(--secondary-color);
102+
margin: 5px 0;
112103
opacity: 0.5;
113104
padding-right: 4rem;
105+
color: var(--secondary-color);
114106
}
115107

116108
.feature > input {
@@ -121,19 +113,18 @@ a {
121113
.feature input {
122114
padding: 0.1vw;
123115
height: 2rem;
124-
margin-left: 0.5vw;
125-
background-color: var(--theme);
116+
margin-left: auto;
126117
border-radius: 1rem;
127118
outline: none;
128119
border: 0px;
120+
background-color: var(--theme);
129121
color: white;
130122
}
131123

132124
.feature input {
133125
color: var(--color);
134126
background-color: var(--feature-input-bg);
135127
padding-left: 1rem !important;
136-
margin-bottom: 0.5rem;
137128
}
138129
.feature button {
139130
cursor: pointer;
@@ -238,14 +229,25 @@ a {
238229
.feature input {
239230
padding: 0.1vw;
240231
height: 2rem;
241-
margin-left: 0.5vw;
232+
margin-left: auto;
242233
border-radius: 1rem;
243234
outline: none;
244235
border: 0px;
245236
color: white;
246237
background-color: var(--feature-input-bg);
247238
}
248239

240+
.feature input[type="checkbox"] {
241+
display: inline-block;
242+
width: 1.25rem;
243+
min-width: 55px;
244+
cursor: pointer;
245+
}
246+
.feature input[type="color"] {
247+
padding: 0.1vw !important;
248+
border-radius: 0.4rem;
249+
}
250+
249251
/*Switch*/
250252
.switch {
251253
position: relative;
@@ -431,14 +433,17 @@ span.new-feature-tag.beta {
431433
}
432434

433435
.special-switch {
434-
position: relative;
435436
width: 55px;
436437
height: 28px;
438+
margin-left: auto;
437439
transform: scale(80%);
438-
float: right;
439440
position: relative;
440-
top: -0.25rem;
441-
margin: 0px;
441+
}
442+
443+
.feature .option {
444+
display: flex;
445+
margin: 5px 0;
446+
align-items: center;
442447
}
443448

444449
.feature table,

extras/popup/popup.js

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -686,42 +686,33 @@ async function getFeatures() {
686686
for (var optionPlace in feature.options) {
687687
var option = feature.options[optionPlace];
688688
var input = document.createElement("input");
689+
input.type = ["text", "checkbox", "number", "color"][option.type || 0];
689690
input.dataset.id = option.id;
690691
input.dataset.feature = feature.id;
691-
input.placeholder = option.name;
692-
input.type = ["text", "checkbox", "number", "color"][option.type || 0];
693692
var optionData = (await chrome.storage.sync.get(option.id))[option.id];
694693
input.value = optionData || "";
694+
input.placeholder = `Enter ${input.type}`;
695+
var optionDiv = document.createElement("div")
696+
optionDiv.className = "option";
697+
var label = document.createElement("label");
698+
label.textContent = option.name;
699+
optionDiv.appendChild(label)
700+
695701
if (input.type === "checkbox") {
702+
input.checked = optionData || false;
696703
var specialLabel = document.createElement("label");
697704
specialLabel.className = "special-switch";
698-
input.className = "checkbox"
705+
input.classList.add = "checkbox"
699706
var span = document.createElement("span");
700707
span.className = "slider round";
701708
specialLabel.appendChild(input);
702709
specialLabel.appendChild(span);
710+
optionDiv.appendChild(specialLabel)
703711
} else {
704-
div.appendChild(input);
705-
}
706-
if (input.type === "checkbox") {
707-
let table = document.createElement("table")
708-
let tr = document.createElement("tr")
709-
table.appendChild(tr)
710-
711-
let td1 = document.createElement("td")
712-
tr.appendChild(td1)
713-
let td2 = document.createElement("td")
714-
tr.appendChild(td2)
715-
716-
div.appendChild(table)
717-
718-
var label = document.createElement("label");
719-
label.textContent = option.name;
720-
label.style.marginLeft = "0px"
721-
td1.appendChild(label);
722-
td2.appendChild(specialLabel)
723-
input.checked = optionData || false;
712+
optionDiv.appendChild(input)
724713
}
714+
div.appendChild(optionDiv)
715+
725716
input.dataset.validation = btoa(
726717
JSON.stringify(option.validation || [])
727718
);

extras/style.css

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ a {
122122
}
123123

124124
.feature p {
125+
margin: 5px 0;
125126
opacity: 0.5;
126127
font-size: 0.8rem;
127128
padding-right: 4rem;
@@ -131,11 +132,10 @@ a {
131132
.feature input {
132133
padding: 0.1vw;
133134
height: 2rem;
134-
margin-left: 0.5vw;
135+
margin-left: auto;
135136
border-radius: 1rem;
136137
outline: none;
137138
padding-left: 1rem;
138-
margin-bottom: 0.5rem;
139139
border: 0px;
140140
color: var(--primary-color);
141141
background-color: var(--feature-input-bg);
@@ -144,8 +144,13 @@ a {
144144
.feature input[type="checkbox"] {
145145
display: inline-block;
146146
width: 1.25rem;
147+
min-width: 55px;
147148
cursor: pointer;
148149
}
150+
.feature input[type="color"] {
151+
padding: 0.1vw;
152+
border-radius: 0.4rem;
153+
}
149154

150155
.feature > input {
151156
display: block;
@@ -188,9 +193,6 @@ a {
188193

189194
.feature label {
190195
color: var(--primary-color);
191-
position: relative;
192-
top: -0.7rem;
193-
margin-left: 0.5rem;
194196
}
195197

196198
.feature > span {
@@ -793,14 +795,17 @@ span.new-feature-tag.beta {
793795
}
794796

795797
.special-switch {
796-
position: relative;
797798
width: 55px;
798799
height: 28px;
799-
margin: 0px;
800+
margin-left: auto;
800801
transform: scale(80%);
801-
float: right;
802802
position: relative;
803-
top: -0.25rem;
803+
}
804+
805+
.feature .option {
806+
display: flex;
807+
margin: 5px 0;
808+
align-items: center;
804809
}
805810

806811
.feature table,

0 commit comments

Comments
 (0)