Skip to content
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

Allow basic formatting for templates of UI elements #123

Closed
kellerza opened this issue Oct 9, 2016 · 13 comments
Closed

Allow basic formatting for templates of UI elements #123

kellerza opened this issue Oct 9, 2016 · 13 comments

Comments

@kellerza
Copy link
Member

kellerza commented Oct 9, 2016

Basic formatting for UI elements like persistent_notifications and device attributes could improve the information significantly.

This could include: linebreaks as a minimum, links, and lastly bold or italics.

Examples of current UI displays that could be improved:

  • persistent_notifications for invalid config [see PR HA #3738]
    20161009-000448-home assistant
  • Device attributes could benefit from having links (e.g. pointing at source data / attribution)
    20161009-000449-home assistant
@balloob
Copy link
Member

balloob commented Oct 11, 2016

The best way to do this would be to add Markdown support (same formatting as we use on GitHub). The smallest library that supports this comes in at 5kb: https://github.com/SimonWaldherr/micromarkdown.js

That's small but still quite big for a feature that might not be used by 95% of the users.

I would be open for including this if we can conditionally load this on demand.

@kellerza
Copy link
Member Author

What if we support only our current use cases?

  • honor linebreaks \n --> <br>, and
  • support links (url)[http://xyx] --> <a href='http://xyx'>url</a>

It will cover the startup messages and attribution cases, and will allow the following message:


Invalid config

The following platforms contain invalid config: sensor

Please check your configuration files and see logs for more information. For fault finding tips see here


@justweb1
Copy link
Contributor

We could create an element for markdown. This way it will only load the js if the element is loaded.
<ha-markdown>(url)[http://xyx]</ha-markdown>

@balloob
Copy link
Member

balloob commented Oct 13, 2016

All elements for cards in the UI are included in the initial load so they would be included in the initial load.

@justweb1
Copy link
Contributor

ah... that's right it will flatten it.

@justweb1
Copy link
Contributor

I'm not seeing a good way to do this.

@balloob
Copy link
Member

balloob commented Oct 14, 2016

One way I can think of is having a web component that includes the markdown be included in the static folder. We'll load it on demand when the card with a notification is shown. ( Using this.importHref in a web component or Polymer.Base.importHref outside). HTML imports have the nice side effect that they will never be resolved twice.

@justweb1
Copy link
Contributor

justweb1 commented Oct 14, 2016

I like it. I'll have to dig it to see if I can figure out how to implement it.

@justweb1
Copy link
Contributor

@kellerza I have added markdown to persistent notifications for now. Should be merged soon. I don't know that we are adding it anywhere else at this point.

@kellerza
Copy link
Member Author

Thanks, persistent notification will be a great improvement!

Not sure if there is an easy way to enable this for platform attributes? (like links)

@justweb1
Copy link
Contributor

probably just a concatenated string.

@justweb1
Copy link
Contributor

@kellerza Do we want to close this for now?

@kellerza
Copy link
Member Author

Thanks @justweb1!

tkdrob pushed a commit to tkdrob/frontend that referenced this issue Apr 20, 2021
…pdate

SSID/BSSID errors and internal URL
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants