Skip to content

Commit b614996

Browse files
committed
better-popup-options
1 parent 83ce51f commit b614996

3 files changed

Lines changed: 49 additions & 50 deletions

File tree

extras/popup/popup.css

Lines changed: 22 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;
@@ -242,14 +233,24 @@ a {
242233
.feature input {
243234
padding: 0.1vw;
244235
height: 2rem;
245-
margin-left: 0.5vw;
236+
margin-left: auto;
246237
border-radius: 1rem;
247238
outline: none;
248239
border: 0px;
249240
color: white;
250241
background-color: var(--feature-input-bg);
251242
}
252243

244+
.feature input[type="checkbox"] {
245+
display: inline-block;
246+
width: 1.25rem;
247+
min-width: 55px;
248+
cursor: pointer;
249+
}
250+
.feature input[type="color"] {
251+
padding-left: 0.1vw !important;
252+
}
253+
253254
/*Switch*/
254255
.switch {
255256
position: relative;
@@ -435,14 +436,17 @@ span.new-feature-tag.beta {
435436
}
436437

437438
.special-switch {
438-
position: relative;
439439
width: 55px;
440440
height: 28px;
441+
margin-left: auto;
441442
transform: scale(80%);
442-
float: right;
443443
position: relative;
444-
top: -0.25rem;
445-
margin: 0px;
444+
}
445+
446+
.feature .option {
447+
display: flex;
448+
margin: 5px 0;
449+
align-items: center;
446450
}
447451

448452
.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: 13 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,12 @@ 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-left: 0.1vw;
152+
}
149153

150154
.feature > input {
151155
display: block;
@@ -188,9 +192,6 @@ a {
188192

189193
.feature label {
190194
color: var(--primary-color);
191-
position: relative;
192-
top: -0.7rem;
193-
margin-left: 0.5rem;
194195
}
195196

196197
.feature > span {
@@ -793,14 +794,17 @@ span.new-feature-tag.beta {
793794
}
794795

795796
.special-switch {
796-
position: relative;
797797
width: 55px;
798798
height: 28px;
799-
margin: 0px;
799+
margin-left: auto;
800800
transform: scale(80%);
801-
float: right;
802801
position: relative;
803-
top: -0.25rem;
802+
}
803+
804+
.feature .option {
805+
display: flex;
806+
margin: 5px 0;
807+
align-items: center;
804808
}
805809

806810
.feature table,

0 commit comments

Comments
 (0)