Skip to content

Commit fd86d82

Browse files
committed
info
1 parent 7694df2 commit fd86d82

6 files changed

Lines changed: 172 additions & 4 deletions

File tree

extras/icons/info.svg

Lines changed: 1 addition & 0 deletions
Loading

extras/icons/warning.svg

Lines changed: 12 additions & 0 deletions
Loading

extras/popup/popup.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,47 @@ input:checked + .slider:before {
375375
span.new-feature-tag.beta {
376376
background-color: #fc8c4f;
377377
cursor: pointer !important;
378+
}
379+
380+
.warning-component {
381+
background-color: #fc8c4f20;
382+
border: 1.5px solid #fc8c4f;
383+
border-radius: .5rem;
384+
padding: .5rem;
385+
font-size: .8rem;
386+
font-weight: 600;
387+
margin-top: .5rem;
388+
display: flex;
389+
align-items: center;
390+
border-bottom-width: 3px;
391+
line-height: 1.2rem;
392+
color: var(--primary-color);
393+
}
394+
395+
.warning-component img {
396+
height: 1rem;
397+
margin-right: 0.5rem;
398+
margin-inline-end: 10px;
399+
transform: scale(1.15);
400+
}
401+
402+
.info-component {
403+
background-color: #fcd44f20;
404+
border: 1.5px solid #fcd44f;
405+
border-radius: .5rem;
406+
padding: .5rem;
407+
font-size: .8rem;
408+
margin-top: .5rem;
409+
display: flex;
410+
align-items: center;
411+
border-bottom-width: 3px;
412+
line-height: 1.2rem;
413+
color: var(--primary-color);
414+
}
415+
416+
.info-component img {
417+
height: 1rem;
418+
margin-right: 0.5rem;
419+
margin-inline-end: 10px;
420+
transform: scale(1.15);
378421
}

extras/popup/popup.js

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,13 +601,13 @@ async function getFeatures() {
601601
span.textContent = "Beta";
602602
span.className = "new-feature-tag beta";
603603
div.appendChild(span);
604-
div.addEventListener("click", function() {
604+
span.addEventListener("click", function () {
605605
ScratchTools.modals.create({
606606
title: "Beta feature",
607607
description:
608608
"This feature is currently in a beta stage, and may have small bugs that weren't noticed during testing. There may also be changes/improvements to come soon.",
609609
});
610-
})
610+
});
611611
}
612612

613613
var label = document.createElement("label");
@@ -801,6 +801,8 @@ async function getFeatures() {
801801
});
802802
div.appendChild(span);
803803

804+
div.appendChild(generateComponents(feature.components || []));
805+
804806
if (
805807
feature.versionAdded?.replace("v", "") ===
806808
chrome.runtime.getManifest().version.toString()
@@ -1252,3 +1254,61 @@ localizationSelectors.forEach(function (item) {
12521254
);
12531255
}
12541256
});
1257+
1258+
function generateComponents(components) {
1259+
let div = document.createElement("div");
1260+
div.classList.add("feature-components");
1261+
1262+
components?.forEach(function (el) {
1263+
let element = document.createElement("div");
1264+
if (el.type === "warning") {
1265+
element.className = "warning-component";
1266+
1267+
let img = document.createElement("img");
1268+
img.src = "/extras/icons/warning.svg";
1269+
1270+
element.textContent = el.content;
1271+
1272+
element.prepend(img);
1273+
}
1274+
1275+
if (el.type === "info") {
1276+
element.className = "info-component";
1277+
1278+
let img = document.createElement("img");
1279+
img.src = "/extras/icons/info.svg";
1280+
1281+
element.textContent = el.content;
1282+
1283+
element.prepend(img);
1284+
}
1285+
1286+
if (el.if) {
1287+
let conditions = [];
1288+
1289+
el.if.conditions?.forEach(function (cond) {
1290+
let value = false;
1291+
if (cond.type === "os") {
1292+
if (navigator.userAgent.includes(cond.value)) {
1293+
value = true;
1294+
}
1295+
}
1296+
conditions.push(value);
1297+
});
1298+
1299+
if (el.if.type === "any") {
1300+
if (!!conditions.find((cond) => cond)) {
1301+
div.appendChild(element);
1302+
}
1303+
} else if (el.if.type === "all") {
1304+
if (conditions.find((cond) => !cond) === undefined) {
1305+
div.appendChild(element);
1306+
}
1307+
}
1308+
} else {
1309+
div.appendChild(element);
1310+
}
1311+
});
1312+
1313+
return div;
1314+
}

extras/style.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,4 +720,47 @@ body[data-filter="Egg"] .feature[data-type*="Egg"] {
720720
span.new-feature-tag.beta {
721721
background-color: #fc8c4f;
722722
cursor: pointer !important;
723+
}
724+
725+
.warning-component {
726+
background-color: #fc8c4f20;
727+
border: 1.5px solid #fc8c4f;
728+
border-radius: .5rem;
729+
padding: .5rem;
730+
font-size: .8rem;
731+
font-weight: 600;
732+
margin-top: .5rem;
733+
display: flex;
734+
align-items: center;
735+
border-bottom-width: 3px;
736+
line-height: 1.2rem;
737+
color: var(--primary-color);
738+
}
739+
740+
.warning-component img {
741+
height: 1rem;
742+
margin-right: 0.5rem;
743+
margin-inline-end: 10px;
744+
transform: scale(1.15);
745+
}
746+
747+
.info-component {
748+
background-color: #fcd44f20;
749+
border: 1.5px solid #fcd44f;
750+
border-radius: .5rem;
751+
padding: .5rem;
752+
font-size: .8rem;
753+
margin-top: .5rem;
754+
display: flex;
755+
align-items: center;
756+
border-bottom-width: 3px;
757+
line-height: 1.2rem;
758+
color: var(--primary-color);
759+
}
760+
761+
.info-component img {
762+
height: 1rem;
763+
margin-right: 0.5rem;
764+
margin-inline-end: 10px;
765+
transform: scale(1.15);
723766
}

features/opacity-slider/data.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
"title": "Opacity Slider",
33
"description": "Change the opacity of objects in the paint editor.",
44
"credits": [
5-
{ "username": "IncognitoOrange", "url": "https://scratch.mit.edu/users/IncognitoOrange/" },
5+
{
6+
"username": "IncognitoOrange",
7+
"url": "https://scratch.mit.edu/users/IncognitoOrange/"
8+
},
69
{ "username": "rgantzos", "url": "https://scratch.mit.edu/users/rgantzos/" }
710
],
811
"type": ["Editor"],
912
"tags": ["New", "Featured", "Beta"],
1013
"dynamic": true,
1114
"scripts": [{ "file": "script.js", "runOn": "/projects/*" }],
12-
"styles": [{ "file": "style.css", "runOn": "/projects/*" }]
15+
"styles": [{ "file": "style.css", "runOn": "/projects/*" }],
16+
"components": [
17+
{
18+
"type": "warning",
19+
"content": "The slider, although located in the fill modal, controls the opacity of the entire shape, including the outline."
20+
}
21+
]
1322
}

0 commit comments

Comments
 (0)