Skip to content

Commit 132267c

Browse files
committed
CSS for custom icons
Signed-off-by: Daniel Kastl <[email protected]>
1 parent 5609ca6 commit 132267c

File tree

2 files changed

+48
-32
lines changed

2 files changed

+48
-32
lines changed

src/components/gtt-setting.ts

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ export const gtt_setting = ():void => {
1111
const wrapper = $('<div>', {
1212
text: ''
1313
})
14-
$('<i>', {
15-
class: "ui-icons " + item.optgroup.toLowerCase().split(' ').join('-'),
16-
title: item.label,
17-
text: item.value
18-
}).prependTo(wrapper)
14+
const style = item.optgroup.toLowerCase().split(' ').join('-')
15+
switch (style) {
16+
case 'material-icons':
17+
$('<i>', {
18+
class: "ui-icons " + style,
19+
title: item.label,
20+
text: item.value
21+
}).prependTo(wrapper)
22+
break;
23+
24+
default:
25+
$('<i>', {
26+
class: "ui-icons icon-" + item.value,
27+
title: item.label
28+
}).prependTo(wrapper)
29+
break;
30+
}
1931
return li.append(wrapper).appendTo(ul)
2032
}
2133
});
@@ -39,8 +51,17 @@ export const gtt_setting = ():void => {
3951
}).join(' ')
4052
optgroup.appendChild(new Option(text, i, selected, selected))
4153
if (selected) {
42-
element.nextElementSibling.className = font.toLowerCase().split(' ').join('-')
43-
element.nextElementSibling.textContent = i
54+
const style = font.toLowerCase().split(' ').join('-')
55+
switch (style) {
56+
case 'material-icons':
57+
element.nextElementSibling.className = style
58+
element.nextElementSibling.textContent = i
59+
break;
60+
61+
default:
62+
element.nextElementSibling.className = "icon-" + i
63+
break;
64+
}
4465
}
4566
}
4667
}
@@ -51,8 +72,17 @@ export const gtt_setting = ():void => {
5172
$(element)
5273
.selectmenu({
5374
change: function(event: any, data: any) {
54-
document.querySelector(`#icon_${element.id}`).className = data.item.optgroup.toLowerCase().split(' ').join('-')
55-
document.querySelector(`#icon_${element.id}`).textContent = data.item.value
75+
const style = data.item.optgroup.toLowerCase().split(' ').join('-')
76+
switch (style) {
77+
case 'material-icons':
78+
document.querySelector(`#icon_${element.id}`).className = style
79+
document.querySelector(`#icon_${element.id}`).textContent = data.item.value
80+
break;
81+
82+
default:
83+
document.querySelector(`#icon_${element.id}`).className = 'icon-' + data.item.value
84+
break;
85+
}
5686
}
5787
})
5888
.selectmenu('menuWidget')

src/stylesheets/custom-icons.css

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
@font-face {
2-
font-family: "Custom Icons";
2+
font-family: "custom-icons";
33
font-style: normal;
44
font-weight: 400;
55
font-display: block;
6-
src: url("./custom-icons.woff2") format("woff2");
6+
src: url("./custom-icons.woff2?1109fa2dad74e02707a8301474f34d5d") format("woff2");
77
}
8-
.custom-icons {
9-
font-family: "Custom Icons";
10-
font-weight: normal;
8+
9+
i[class^="icon-"]:before, i[class*=" icon-"]:before {
10+
font-family: custom-icons !important;
1111
font-style: normal;
12+
font-weight: normal !important;
13+
font-variant: normal;
1214
font-size: 24px;
1315
line-height: 1;
1416
letter-spacing: normal;
@@ -23,31 +25,15 @@
2325
font-feature-settings: "liga";
2426
}
2527

26-
/* @font-face {
27-
font-family: "custom-icons";
28-
src: url("./custom-icons.woff2?1109fa2dad74e02707a8301474f34d5d") format("woff2");
29-
}
30-
31-
i[class^="icon-"]:before, i[class*=" icon-"]:before {
32-
font-family: custom-icons !important;
33-
font-style: normal;
34-
font-weight: normal !important;
35-
font-variant: normal;
36-
text-transform: none;
37-
line-height: 1;
38-
-webkit-font-smoothing: antialiased;
39-
-moz-osx-font-smoothing: grayscale;
40-
}
41-
4228
.icon-lobsta:before {
4329
content: "\f101";
4430
}
45-
.icon-park_bench:before {
31+
.icon-park-bench:before {
4632
content: "\f102";
4733
}
4834
.icon-road:before {
4935
content: "\f103";
5036
}
5137
.icon-waste:before {
5238
content: "\f104";
53-
} */
39+
}

0 commit comments

Comments
 (0)