New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New-HTMLStatusItem customization #111
Conversation
[string]$Percentage = '100%', | ||
|
||
[ValidatePattern('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')] | ||
[Parameter(ParameterSetName = 'Hex')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For colors you should use what other commands are using. Register-ArgumentCompleter. It allows for pick from 800 colors but also takes '#COLOR' if typed in.
Public/New-HTMLStatusItem.ps1
Outdated
} elseif ($Icon -eq 'Good') { | ||
#$IconType = 'performance' | ||
if ($IconHex) { | ||
$IconType = $IconHex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For icons you should allow a choice from Font Awesome like other commands are doing.
I believe we should leave the old option as one ParameterSet, and create fully customizable one with another set. Not sure if it's worth going with limiting it the way it was limited. It was created for Statusimo but Statusimo is very limited and I believe we should let people pick whatever they want for colors/percentage/icons. |
I was able to update the colors to utilize the $Script:RGBColors and add the FontAwesome functionality for icons. Unfortunately, I am unable to reach FontAwesome from work where I am generating and using these reports. Are you alright with me keeping the $IconHex as a different parameter set? With the updates there are currently 4 parameter sets:
If you are looking to deprecate the original parameters once this is implemented, we could write a warning inside the 'Satusimo' parameter set. I will upload changes when I get home tonight. |
Yes, we're looking to depreciate old original parameters as long as we update Statusimo to new ones. Yes you can use iconHex - how does that work anyway? |
… names, deprecation warning of parameter set.
Changes have all been uploaded in the latest commit.
The $IconHex works with UTF-8 Unicode character hex codes. All the main browsers support translation of these codes by default and a reference sheet of codes can be found at https://www.w3schools.com/charsets/ref_html_utf8.asp. |
That is a cool feature. Probably others would have use of it instead of FontAwesome - with the same problem as yours. It might be worth adding it to other places where font awesome is used. |
I guess we should also convert Font Awesome to use Register-ArgumentCompleter the same way colors do. But this needs fixing all over the place. |
It is something that may be beneficial to others. From what I read, Font Awesome does have the capability to be used locally if you wanted to do that instead. I believe you would download the latest CSS from them at build time, pushing to the PSGallery, and then in the head of your HTML instead of linking their site you link "the path to your module\resources\css\css.all". That reference would probably have to be built dynamically on install of the module or something since there are a few locations it could be. I am not sure how it would react to a source that does not exist if you just added all the locations. The ArgumentCompleter seemed to work fine for me on the Font Awesome parameters. If you were to look into changing all of those autocomplete to standardize I would recommend dynamic parameters instead. I think the autocomplete functionality on them works better than the Register-ArgumentCompleter. If you would like, I could send you an example of how something like that would be implemented. |
I do know how to build DynamicParams as I use it in PSWinReportingV2. But as far as I know, it's recommended to go for Register-ArgumentCompleter as it's an easier and cleaner way to work. It also allows to build one "source" and register it in multiple functions. As for CSS, we are already doing that for other code/libraries. But we're not doing linking to CSS local files but instead, we push it inline. New-Html -UseJavaScrriptLinks -UseCssLinks {
} If you don't use code like above all CSS/JS code is added inline. It's controlled by: It's as simple as defining CssLink/CSS or/and JSlink/Js to have offline support. I was just not aware you can download https://use.fontawesome.com/releases/v5.11.2/css/all.css and use it offline. If you can then that is a trivial fix... PSWriteHTML/Private/Parameters.Configuration.ps1 Lines 228 to 236 in cd1b01d
Just create all.css in resources, add CSS entry in that file and you've got offline support. |
Modifications leave all original functionality and syntax in working order.