WIP: Allow generating iconset for HASS icons#1100
Conversation
| defs.childNodes = defs.childNodes.filter(icon => icons.has(icon.attrs[0].value)); | ||
|
|
||
| fs.writeFileSync('hass_frontend/hass_icons.html', parse5.serialize(iconDoc)); | ||
| console.log(`Home Assistant has ${icons.size} icons.`); |
There was a problem hiding this comment.
Unexpected console statement no-console
|
|
||
| const ironIconset = iconDoc.childNodes[0]; | ||
| ironIconset.attrs.forEach(attr => { | ||
| if (attr.name == 'name') { |
There was a problem hiding this comment.
Expected '===' and instead saw '==' eqeqeq
| fs.readFileSync('hass_frontend/mdi.html', { encoding: 'utf-8' })); | ||
|
|
||
| const ironIconset = iconDoc.childNodes[0]; | ||
| ironIconset.attrs.forEach(attr => { |
There was a problem hiding this comment.
Expected parentheses around arrow function argument having a body with curly braces arrow-parens
| async function generateHassIcons() { | ||
| const icons = findIcons(); | ||
|
|
||
| const iconDoc = parse5.parseFragment( |
There was a problem hiding this comment.
Unexpected newline after '(' function-paren-newline
| let match; | ||
| while (match = iconRegEx.exec(content)) { | ||
| icons.add(match[0].substr(4)); | ||
| }; |
There was a problem hiding this comment.
Unnecessary semicolon no-extra-semi
| function processFile(filename) { | ||
| const content = fs.readFileSync(filename); | ||
| let match; | ||
| while (match = iconRegEx.exec(content)) { |
There was a problem hiding this comment.
Unexpected assignment within a 'while' statement no-cond-assign
|
Yes, we should also search for python code. However this makes different namespace difficult |
|
We could fork the advantage of loading the full mdi: on-demand under the same namespace would be that while developing (but also users customizing) you don't need to think about the namespace to use. |
|
What if we get rid of all (people can still define icon and it would then load |
|
Probably best approach would be to fork We would patch around here: |
| defs.childNodes = defs.childNodes.filter(icon => icons.has(icon.attrs[0].value)); | ||
|
|
||
| fs.writeFileSync('hass_frontend/hass_icons.html', parse5.serialize(iconDoc)); | ||
| console.log(`Home Assistant has ${icons.size} icons.`); |
There was a problem hiding this comment.
Unexpected console statement no-console
|
So I played a bit more with this. Added a new The dynamic panels still use mdi icons. As you can see, icon for Configuration is missing. I have confirmed in the network panel that Adding some debug statements to |
|
Could this be related? |
|
That's totally it. When I patch |
|
Since I'm already updating the It's not pretty. |
| const downloadMatch = content.match('(/api/download/polymer/v1/([A-Z0-9-]{36}))'); | ||
|
|
||
| if (!downloadMatch) { | ||
| console.error('Unable to find Polymer v1 download link'); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| const parse5 = require('parse5'); | ||
| const getContent = require('../common/http').getContent; | ||
|
|
||
| const outputDir = 'hass_frontend'; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| const downloadMatch = content.match('(/api/download/polymer/v1/([A-Z0-9-]{36}))'); | ||
|
|
||
| if (!downloadMatch) { | ||
| console.error('Unable to find Polymer v1 download link'); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
I've converted the MDI download script to JavaScript, dropping the last Python dependency 🎉 PR on backend to convert built-in panels to use HASS iconset: home-assistant/core#14185 built-in panel icons are hardcoded in the gulp task. Updated service worker to handle fingerprinting of |
|
(didn't look at the code yet) I think we should support icons set by platforms (in Python) |
|
Problem with icon set per platform is the duplication that might occur when we introduce even more namespaces. We currently have overlap between hass and mdi namespace, but we're assuming that the mdi namespace might not be necessary for basic users. I prefer if we first see how far sensor device classes is going to get us before we invest time in making icon sets for Python code. In a perfect world, the Python code should not be aware of icons, although I do realize that it's better for us to break that rule here to make the simple things not overly complicated. |
| const dynamicUrlToDependencies = {}; | ||
|
|
||
| const staticFingerprinted = [ | ||
| 'mdi.html', |
There was a problem hiding this comment.
we still have to fingerprint mdi
There was a problem hiding this comment.
No. It's only going to be loaded from inside ha-icon and that will reference to it without fingerprint.
There was a problem hiding this comment.
When a new service worker is installed, it will check the fingerprint and download a new version if it has changed.
|
This has been fixed in #1214. |



WIP until we migrate to Polymer 3
Included icons will be limited to our official icons (the ones we refer in the frontend code). Size of included icons will be reduced from 747K to 38K.
This new gulp script will:
hassbased on icon setmdiwith only the icons that we useTo do:
hass:and update our search regexWe should add a config option to the frontend component to allow loading the MDI iconsWe should also search the python code for used icons??iron-iconto see if missing iconset ismdiand loadmdiwhen missingNot part of this PR but would help loading time: