Skip to content

Commit 6899d7d

Browse files
authored
Merge branch 'Acode-Foundation:main' into codemirror
2 parents e0f7e59 + d3903cd commit 6899d7d

File tree

7 files changed

+52
-25
lines changed

7 files changed

+52
-25
lines changed

src/lib/acode.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,14 +622,37 @@ export default class Acode {
622622
return Url.join(...args);
623623
}
624624

625-
addIcon(className, src) {
625+
/**
626+
* Adds a custom icon class that can be used with the .icon element
627+
* @param {string} className - The class name for the icon (used as .icon.className)
628+
* @param {string} src - URL or data URI of the icon image
629+
* @param {object} [options] - Optional settings
630+
* @param {boolean} [options.monochrome=false] - If true, icon will use currentColor and adapt to theme
631+
*/
632+
addIcon(className, src, options = {}) {
626633
let style = document.head.get(`style[icon="${className}"]`);
627634
if (!style) {
628-
style = (
629-
<style
630-
icon={className}
631-
>{`.icon.${className}{background-image: url(${src})}`}</style>
632-
);
635+
let css;
636+
if (options.monochrome) {
637+
// Monochrome icons: use mask-image (on ::before) for currentColor/theme support
638+
// Using ::before ensures we don't mask the ::after active indicator or the background
639+
css = `.icon.${className}::before {
640+
content: '';
641+
display: inline-block;
642+
width: 24px;
643+
height: 24px;
644+
vertical-align: middle;
645+
-webkit-mask: url(${src}) no-repeat center / contain;
646+
mask: url(${src}) no-repeat center / contain;
647+
background-color: currentColor;
648+
}`;
649+
} else {
650+
// Default: preserve original icon colors
651+
css = `.icon.${className}{
652+
background: url(${src}) no-repeat center / 24px;
653+
}`;
654+
}
655+
style = <style icon={className}>{css}</style>;
633656
document.head.appendChild(style);
634657
}
635658
}

src/res/icons/li-icon.ttf

3.14 KB
Binary file not shown.

src/res/icons/li-icons.ttf

-2.32 KB
Binary file not shown.

src/res/icons/style.css

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@font-face {
1010
font-family: "li-icon";
11-
src: url("li-icons.ttf?6wte0b") format("truetype");
11+
src: url("li-icon.ttf") format("truetype");
1212
font-weight: normal;
1313
font-style: normal;
1414
font-display: block;
@@ -30,9 +30,8 @@
3030
}
3131

3232
.licons {
33-
/* use !important to prevent issues with browser extensions that change fonts */
33+
/* Use !important to prevent extensions from overriding this font. */
3434
font-family: "li-icon" !important;
35-
speak: none;
3635
font-style: normal;
3736
font-weight: normal;
3837
font-variant: normal;
@@ -44,20 +43,28 @@
4443
-moz-osx-font-smoothing: grayscale;
4544
}
4645

47-
.licons.terminal:before {
48-
content: "\e900";
46+
.licons.scale:before {
47+
content: "\f006";
4948
}
49+
5050
.licons.cart:before {
51-
content: "\e901";
51+
content: "\f005";
5252
}
53-
.licons.scale:before {
54-
content: "\e902";
55-
}
56-
.licons.tag:before {
57-
content: "\e903";
53+
54+
.licons.zap:before {
55+
content: "\f000";
5856
}
57+
5958
.licons.verified:before {
60-
content: "\e904";
59+
content: "\f001";
60+
}
61+
62+
.licons.terminal:before {
63+
content: "\f002";
64+
}
65+
66+
.licons.tag:before {
67+
content: "\f003";
6168
}
6269

6370
.icon.acode:before {
@@ -1210,4 +1217,4 @@
12101217

12111218
.icon.all_inclusive:before {
12121219
content: "\ea18";
1213-
}
1220+
}

utils/extra-icons/cart.svg

Lines changed: 1 addition & 5 deletions
Loading

utils/extra-icons/scale.svg

Lines changed: 1 addition & 1 deletion
Loading

utils/extra-icons/zap.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)