Skip to content

Commit 5609ca6

Browse files
committed
Make custom icons show up in ol-ext
Signed-off-by: Daniel Kastl <[email protected]>
1 parent dbef075 commit 5609ca6

File tree

7 files changed

+68
-39
lines changed

7 files changed

+68
-39
lines changed

src/components/gtt-setting.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const gtt_setting = ():void => {
1212
text: ''
1313
})
1414
$('<i>', {
15-
class: "ui-icons material-icons",
15+
class: "ui-icons " + item.optgroup.toLowerCase().split(' ').join('-'),
1616
title: item.label,
1717
text: item.value
1818
}).prependTo(wrapper)
@@ -25,21 +25,21 @@ export const gtt_setting = ():void => {
2525
const selectedValue = element.value
2626
if (element.length === 1 && selectedValue !== "") {
2727
element.remove(0)
28-
element.append(new Option("", "", false, false))
28+
// element.append(new Option("", "", false, false))
2929
}
3030
for (let font in FontSymbol.prototype.defs.fonts) {
31-
const optgroup = document.createElement("optgroup")
31+
const optgroup = document.createElement('optgroup')
3232
optgroup.label = font
3333
for (let i in glyph) {
3434
if (glyph[i].font == font) {
3535
const selected = selectedValue === i
3636
const words = i.split('_')
3737
const text = words.map((word) => {
3838
return word[0].toUpperCase() + word.substring(1)
39-
}).join(" ")
39+
}).join(' ')
4040
optgroup.appendChild(new Option(text, i, selected, selected))
4141
if (selected) {
42-
element.nextElementSibling.className = "material-icons"
42+
element.nextElementSibling.className = font.toLowerCase().split(' ').join('-')
4343
element.nextElementSibling.textContent = i
4444
}
4545
}
@@ -51,7 +51,7 @@ export const gtt_setting = ():void => {
5151
$(element)
5252
.selectmenu({
5353
change: function(event: any, data: any) {
54-
document.querySelector(`#icon_${element.id}`).className = "material-icons"
54+
document.querySelector(`#icon_${element.id}`).className = data.item.optgroup.toLowerCase().split(' ').join('-')
5555
document.querySelector(`#icon_${element.id}`).textContent = data.item.value
5656
}
5757
})

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import 'ol-ext/dist/ol-ext.min.css'
33
import './stylesheets/app.scss'
44

55
// Custom Icons
6-
import './stylesheets/icons.css'
7-
import './fonts/IconsDef.js'
6+
import './stylesheets/custom-icons.css'
7+
import './stylesheets/CustomIconsDef.js'
88

99
// Material Design Icons
1010
// https://github.com/marella/material-design-icons/tree/main/font#readme
1111
import '@material-design-icons/font/filled.css'
12-
import './fonts/MaterialDesignDef.js'
12+
import './stylesheets/MaterialDesignDef.js'
1313

1414
import { GttClient } from './components/gtt-client'
1515
import { gtt_setting } from './components/gtt-setting'
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import ol_style_FontSymbol from 'ol-ext/style/FontSymbol'
22

33
ol_style_FontSymbol.addDefs(
4-
{ "font":"General Icons",
5-
"name":"General Icons",
4+
{ "font":"Custom Icons",
5+
"name":"Custom Icons",
66
"copyright":"Apache-2.0",
77
"prefix": "gtt"
88
},
9-
{
10-
9+
{ "lobsta": "\uf101",
10+
"park-bench": "\uf102",
11+
"road": "\uf103",
12+
"waste": "\uf104"
1113
});
1214

1315
export default ol_style_FontSymbol
File renamed without changes.

src/stylesheets/custom-icons.css

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
@font-face {
2+
font-family: "Custom Icons";
3+
font-style: normal;
4+
font-weight: 400;
5+
font-display: block;
6+
src: url("./custom-icons.woff2") format("woff2");
7+
}
8+
.custom-icons {
9+
font-family: "Custom Icons";
10+
font-weight: normal;
11+
font-style: normal;
12+
font-size: 24px;
13+
line-height: 1;
14+
letter-spacing: normal;
15+
text-transform: none;
16+
display: inline-block;
17+
white-space: nowrap;
18+
word-wrap: normal;
19+
direction: ltr;
20+
-webkit-font-smoothing: antialiased;
21+
-moz-osx-font-smoothing: grayscale;
22+
text-rendering: optimizeLegibility;
23+
font-feature-settings: "liga";
24+
}
25+
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+
42+
.icon-lobsta:before {
43+
content: "\f101";
44+
}
45+
.icon-park_bench:before {
46+
content: "\f102";
47+
}
48+
.icon-road:before {
49+
content: "\f103";
50+
}
51+
.icon-waste:before {
52+
content: "\f104";
53+
} */

src/stylesheets/custom-icons.woff2

1.2 KB
Binary file not shown.

src/stylesheets/icons.css

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)