GithubHelp home page GithubHelp logo

Comments (12)

ian-craig avatar ian-craig commented on June 26, 2024 1

Okay, I've created a branch boilerplate-card which I hope is a working version of master refactored onto the boilerplate-card template.

This is admittedly a pretty huge change, so I'd like you to take a look and poke around with it in your dev environment to give some feedback before I even publish a PR (and the diff won't be useful anyway).

Major conceptual changes:

  1. Adds a lot of tooling: rollup, typescript, prettier, eslint, etc. These are all very standard in the OSS community, are well documented, and I've found them good to work with as I did the refactor so I see this an improvement.
  2. Lit-HTML manages the component lifecycle, and should trigger updates when config or any of the related entities are changed (instead of every time we get a new hass)
  3. Rendering is now functional, and we never directly access DOM elements to modify them (the render() function just runs again with new state, and Lit-HTML takes care of applying necessary updates to the DOM). This means all of the logic for showing the state of entities is in the render() function using html template syntax, and so are references to all the click callbacks.

This is a good video to check out if you're not familiar with any of these patterns. https://www.youtube.com/watch?v=Io6JjgckHbg

And note I've also added a Contributing section in the Readme with instructions on how to start a watch/devserver build and attach that to Home Assistant so you don't need to copy files around.

The built JS is now in the /dist directory (not committed), and is split into separate files for the view and editor. This was just the format set up in boilerplate-card, but we could change it to a single output file if you'd prefer. I don't have much insight into the deployment process so I'll defer to you on that stuff. I did include (and have tested) their GitHub Actions which build these files and attach them to releases.

from lovelace-fan-xiaomi.

ikaruswill avatar ikaruswill commented on June 26, 2024

@ian-craig could I get your help with this?

from lovelace-fan-xiaomi.

ian-craig avatar ian-craig commented on June 26, 2024

I am travelling for the next week and a half, so am unlikely to get much time before then, but I am happy to help after.

It sounds like the best solution may be for us to move to the boilerplate card, as we use other ha-* elements which are officially unsupported and may also break in future updates. That's not a small change though, and comes with a lot more tooling which would be helpful but would also likely take a little time to get used to. What are your thoughts on that?

from lovelace-fan-xiaomi.

ikaruswill avatar ikaruswill commented on June 26, 2024

Sure, it does sound like the way forward. I've been looking at the boilerplate card as well, and it does look like significant change is required, but regardless, I'm down for this change even if it takes some time. I will definitely need your expertise here given my limited knowledge of javascript.

I'm currently refactoring the code to make it more modular and portable which should help with our move to the boilerplate card.

Have a good trip!

from lovelace-fan-xiaomi.

ikaruswill avatar ikaruswill commented on June 26, 2024

@ian-craig Thanks for the work and the resources, I'll go familiarize myself with those patterns tonight. Really appreciate it!

from lovelace-fan-xiaomi.

ikaruswill avatar ikaruswill commented on June 26, 2024

Update: I've been prepping for a trip overseas lately so haven't had the chance to look at it. Will try to take a look at it whenever possible within the next week. ๐Ÿ™

from lovelace-fan-xiaomi.

ian-craig avatar ian-craig commented on June 26, 2024

@ikaruswill I've posted this refactor as PR #95. It'd be good to get that in before doing too many other fixes/refactors as they're certain to conflict. I'll do another pass of testing and make sure recent changes have been included before we complete that PR, but I'm keen to hear your feedback on the overall setup.

from lovelace-fan-xiaomi.

ikaruswill avatar ikaruswill commented on June 26, 2024

@ian-craig Thanks for waiting, I've merged your PR.
I tried your steps as detailed in the Contributing section, but because my HA is on HTTPS, I'm unable to load mixed content since npm run start serves over HTTP.

I think we'll need to come up with a way to develop for people running HA under HTTPS. ๐Ÿค”

from lovelace-fan-xiaomi.

ian-craig avatar ian-craig commented on June 26, 2024

The simplest way would just be to go back to copying manually, and rollup should be outputting the builds still to do that.

If you want a better dev inner loop we can add the devcerts package and pass the cert to rollup-plugin-serve's https config. I can probably take a look at that over the weekend if you want to go that direction.

from lovelace-fan-xiaomi.

ikaruswill avatar ikaruswill commented on June 26, 2024

Sure, having the devcerts would be great.

Out of curiosity how does that work though? It's self-signed right? If so then wouldn't browsers complain and refuse to load the resource again?

from lovelace-fan-xiaomi.

ian-craig avatar ian-craig commented on June 26, 2024

Created PR #96 for easier https inner loop.

I think we can close this issue, unles you wanted to hold off for some more testing?

from lovelace-fan-xiaomi.

ikaruswill avatar ikaruswill commented on June 26, 2024

Back from being away, thanks let's close this one!

from lovelace-fan-xiaomi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.