Skip to content

Commit a08d76a

Browse files
committed
Refactor icon font handling to reduce complexity
1 parent c9d7c47 commit a08d76a

File tree

5 files changed

+6
-30
lines changed

5 files changed

+6
-30
lines changed
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
<%= tag.meta(
2-
name: 'gtt-font-custom-icons',
3-
content: asset_path('plugin_assets/redmine_gtt/custom-icons.woff2')) %>
4-
5-
<%= tag.meta(
6-
name: 'gtt-font-mdi-webfont',
7-
content: asset_path('plugin_assets/redmine_gtt/materialdesignicons-webfont.woff2')) %>
1+
<% # Header hook %>

src/styles/icons/custom/custom-icons-def.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,7 @@ const iconMappings: { [key: string]: any } = {
88
'waste': '\uf104'
99
};
1010

11-
// Read the meta tag for custom-icons
12-
const customIconsMeta = document.querySelector('meta[name="gtt-font-custom-icons"]');
13-
const customIconsUrl = customIconsMeta ? customIconsMeta.getAttribute('content') : 'data:application/font-woff2;base64,'; // Provide a data URL for an empty font
14-
15-
// Dynamically create the @font-face rule
16-
const style = document.createElement('style');
17-
style.type = 'text/css';
18-
style.innerHTML = `
19-
@font-face {
20-
font-family: 'custom-icons';
21-
font-style: normal;
22-
font-weight: 400;
23-
font-display: block;
24-
src: url(${customIconsUrl}) format('woff2');
25-
}
26-
`;
27-
document.head.appendChild(style);
11+
const customIconsUrl = 'RAILS_ASSET_URL("custom-icons.woff2")';
2812

2913
// Define the font face
3014
let customFont: FontFace;

src/styles/icons/custom/custom-icons.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$custom-icons-path: unquote('RAILS_ASSET_URL("custom-icons.woff2")');
1+
$custom-icons-path: 'RAILS_ASSET_URL("custom-icons.woff2")';
22

33
@font-face {
44
font-family: "custom-icons";

src/styles/icons/material-design/material-design-def.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7300,13 +7300,11 @@ const iconMappings: { [key: string]: any } = {
73007300
"zodiac-virgo": "\u{F0A88}",
73017301
};
73027302

7303-
// Read the meta tag for MDI webfont
7304-
const mdiWebfontMeta = document.querySelector('meta[name="gtt-font-mdi-webfont"]');
7305-
const mdiWebfontUrl = mdiWebfontMeta ? mdiWebfontMeta.getAttribute('content') : 'data:application/font-woff2;base64,'; // Provide a data URL for an empty font
7303+
const mdiWebfontUrl = 'RAILS_ASSET_URL("materialdesignicons-webfont.woff2")';
73067304

73077305
// Dynamically create the @font-face rule
73087306
const style = document.createElement('style');
7309-
style.type = 'text/css';
7307+
// style.type = 'text/css';
73107308
style.innerHTML = `
73117309
@font-face {
73127310
font-family: 'Material Design Icons';

src/styles/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import './icons/custom/custom-icons-def';
1515

1616
// Import Material Design icons filled style CSS for using a large collection of Google-designed icons
1717
// import '@material-design-icons/font/filled.css';
18-
import '@mdi/font/scss/materialdesignicons.scss';
18+
import '@mdi/font/css/materialdesignicons.css';
1919

2020
// Import Material Design icons definition JS file to define icon names and variations
2121
import './icons/material-design/material-design-def';

0 commit comments

Comments
 (0)