-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add a Lit TodoMVC app #251
Conversation
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.
This looks good to me, but I have a few comments and questions still.
I'm excited to see this in tree!
@rictic - lint check is failing. A good way to catch things is by running |
Huh, I think something is wrong with my prettier setup, as |
I was definitely doing something wrong. This should now be properly formatted and passing eslint |
@rictic - I noticed that you are defining the styles inside js, which is more idiomatic to lit, but doesn't let us manage consistency in the styles across todomvc apps. This workload also looks slightly different compared to the other ones. I added an alternate approach with css-modules here (if approved): these could be installed as a local package and that could potentially work? Just posting here for thoughts. |
I had to `rm -rf ./node_modules/ ./package-lock.json` to get it to regen
This isn't part of the other todomvcs in Speedometer
This was formatted by a different prettier config, and I forgot to reformat every file when importing into Speedometer
Instead of firing events, we add methods onto the root app element to get the relevant parts of the private shadow DOM so that the test code can interact with them directly. Added the callElementMethod method onto the Page class from WebKit#249
Currently, editing a todo (toggling it or changing its text) creates a new Todo object and splices it into the array. This is unnecessary work, if we instead make the `<todo-item>` take each field of the todo separately (common in Lit for leaf elements) then we can update it in place. This exercises more idiomatic Lit code (more template bindings) and less copying and splicing of the array of todos.
This build looks great and it's pretty easy to follow along and parsing the code 🚀 . The only thing that threw me off was that the Todos class also handles route changes. I'd expect the app to listen for those and notify or set the filter in the Todos class., but that's maybe subjective. Besides that, the only other difference I noticed was here the todos id is a simple int that increments, vs other implementations where we use uuid / nanoid. |
This required some changes to the querySelectorAll implementation because the DOM is set up like: * todo-app * todo-list * todo-item - .toggle - .destroy * todo-item - .toggle - .destroy * ... The current implementation does the "selectAll" logic only at the final lowest level. I implemented this as a generator function so that we don't do array allocation and copying at every level.
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.
LGTM - potential alignment with a11y related updates could happen in a follow up pr.
Because this wasn't super clear for everybody, the lit code already uses socalled "constructable css" with its |
Yeah, expanding on that, the |
resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts
Outdated
Show resolved
Hide resolved
Yes, this sounds good to me! I just wanted other folks to know that this uses |
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.
Thanks, this looks good to me!
Just a few comments (including the one I left earlier about running npm i
) and then we're good to go!
resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts
Outdated
Show resolved
Hide resolved
These weren't triggering, but they may save eslint time
To match the vanilla webcomponents suite at WebKit#251
@@ -0,0 +1,53 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> |
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.
Can we use spaces instead of tabs like all other files?
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.
+1, done
It's hand authored, so it should be formatted and linted.
This aims to fix #52