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

Refactor into the recommended boilerplate-card #95

Merged
merged 2 commits into from
Jun 13, 2022
Merged

Conversation

ian-craig
Copy link
Collaborator

Fixes issue #72 by doing quite a large refactor to port our code into the boilerplate-card template.

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.

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 (git ignore'd), 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 @ikaruswill I might need your help on that. I did include (and have tested) their GitHub Actions which build these files and attach them to releases.

# Conflicts:
#	fan-xiaomi.js

Overwriting my own work on master for the moment. Will reimplement in the new boilerplate card format.
Copy link
Owner

@ikaruswill ikaruswill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as much as my brain can parse. Let's merge this and patch it along the way if we find any issues. I've decided to overwrite my recent changes after you branched and re-implement them separately.

@ikaruswill ikaruswill merged commit 7a78ee6 into master Jun 13, 2022
@ikaruswill ikaruswill deleted the boilerplate-card branch June 13, 2022 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants