Skip to content

Commit

Permalink
Tags showing preprocessors
Browse files Browse the repository at this point in the history
  • Loading branch information
PRO-2684 committed Sep 25, 2024
1 parent 0dd35ad commit 677a54f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const log = isDebug ? simpleLog : dummyLog;
let devMode = false;
let watcher = null;

const supportedPreprocessors = ["transitio", "stylus"];
const supportedPreprocessors = ["none", "transitio", "stylus"];
const dataPath = LiteLoader.plugins.transitio.path.data;
const stylePath = path.join(dataPath, "styles");
const debouncedSet = debounce(LiteLoader.api.config.set, updateInterval);
Expand Down
1 change: 1 addition & 0 deletions modules/main/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ function extractUserStyleMetadata(css) {
} else { // Fall back to the old method
const comment = getDesc(css) || "";
result["description"] = comment;
result["preprocessor"] = "none"; // No preprocessor
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/renderer/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function searchAndHighlight(highlight, el, keyword) {
*/
function searchAllAndHighlight(highlight, detail, keywords) {
const settingItem = detail.querySelector("summary > setting-item");
const nameEl = settingItem.querySelector("setting-text");
const nameEl = settingItem.querySelector("setting-text[data-type='primary']");
const descEl = settingItem.querySelector("setting-text[data-type='secondary']");
let matches = 0;
for (const keyword of keywords) {
Expand Down
3 changes: 3 additions & 0 deletions modules/renderer/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ function addItem(path, container) {
item.setAttribute("data-direction", "row");
const left = item.appendChild(document.createElement("div"));
const itemName = left.appendChild(document.createElement("setting-text"));
itemName.setAttribute("data-type", "primary");
itemName.setAttribute("data-preprocessor", "Unknown");
const itemDesc = document.createElement("setting-text");
itemDesc.setAttribute("data-type", "secondary");
left.appendChild(itemDesc);
Expand Down Expand Up @@ -405,6 +407,7 @@ function transitioSettingsUpdateStyle(container, args) {
const optionalVersion = meta.version ? ` (v${meta.version})` : "";
itemName.textContent = meta.name + optionalVersion;
itemName.title = path;
itemName.setAttribute("data-preprocessor", meta.preprocessor);
const itemDesc = item.querySelector("setting-text[data-type='secondary']");
itemDesc.textContent = meta.description || "此文件没有描述";
itemDesc.title = itemDesc.textContent;
Expand Down
20 changes: 20 additions & 0 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@
background-color: yellow;
color: black;
}
> setting-item > div > setting-text[data-type="primary"] {
&::after {
content: "@" attr(data-preprocessor);
text-transform: capitalize;
font-size: smaller;
border-radius: 4px;
margin-left: 0.1em;
padding: 2px;
opacity: 0.8;
}
&[data-preprocessor="none"]::after {
background: #808080aa;
}
&[data-preprocessor="transitio"]::after {
background: #74a9f6aa;
}
&[data-preprocessor="stylus"]::after {
background: #6da13faa;
}
}
}
> setting-item {
padding-left: 1em;
Expand Down

0 comments on commit 677a54f

Please sign in to comment.