-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Update component docs to use angle bracket syntax #292
Update component docs to use angle bracket syntax #292
Conversation
I tried use ember-angle-brackets-codemod, but it didn't seem to work on .js files. So I edited the doc comments manually.
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 a lot for updating. Seems we missed it on the last PRs.
I think you need to rebase after #291 has been merged.
I fear we missed some work to fully support angle bracket invocation. I see two ways to address it:
- Do not pass HTML attributes but arguments on component invocation or
- fix missing attributes forwarding before merging this one.
onfileadd=(action "uploadImage")}} | ||
<FileUpload name="photos" | ||
accept="image/*" | ||
multiple=true |
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.
multiple=true
is not valid HTML, is it? I think it should be <FileUpload multiple />
.
multiple=true | ||
onfileadd=(action "uploadImage")}} | ||
<FileUpload name="photos" | ||
accept="image/*" |
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.
I fear we don't support passing HTML attributes to <FileUpload>
yet. It doesn't seem to pass them to <input>
. At least I don't see a ...attributes
in the template.
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.
...attributes are applied to the parent element unless tagName is set to a empty string.
<FileUpload name="photos" | ||
accept="image/*" | ||
multiple=true | ||
@onfileadd={{action "uploadImage"}}> |
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.
The coding style looks different than what I would expect. I'm used to this one:
<FileUpload
@onfileadd={{action "uploadImage"}}
name="photos"
accept="image/*"
/>
So it's basically about this rules:
- If there are multiple lines, each attribute or property should be on a new line
- It should be intended by two spaces.
- Arguments should be before HTML attributes.
I thought that's also what's used in Ember docs but noticed that Ember docs aren't consistent on these ones.
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.
I usually do html attributes first and then args, usually actions last
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.
Hmm I wonder if there is any ember-template-lint rule about this...
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.
@mcfiredrill I am glad you asked 😄
ember-template-lint/ember-template-lint#871
I requested this a while ago :)
ember-template-lint/ember-template-lint#684
Although it isn't exactly what @knownasilya mentioned
Sounds good, I'm using this addon with angle brackets in my app now so I will make another PR with those fixes before getting this merged. |
See file-upload-test.js for the angle-bracket API that is currently covered by integration tests. It's not an absolutely ideal API (no html attribute support) but it does allow us to support a wide range of ember versions. |
@Turbo87 gave me a few tips on this:
|
@Alonski Very good points! I didn't think about the basically becoming public API. It seems like I got really hung up on getting the component to work with normal HTML attributes without really thinking about the tradeoffs or alternatives.
Maybe @jelhan 's initial suggestion 1 here was a better idea after all. 🤔 |
@gilest Thank you, I didn't even realize that was in the tests! 😅 |
@Alonski I'm not sure if I agree. Designing this component from scratch using an outer-html approach, would we really end up with this as best API? <label ...attributes>
<input>
</label> I've the feeling that we would have done something like: {{#if (has-block)}}
{{yield
(hash
fileChanged=(action "change")
)
}}
{{else}}
<label
for={{inputId}}
>
<input
id={{inputId}}
type="file"
onchange={{action "change" value="target.files"}}
...attributes
>
{{(/if}} |
@jelhan if you implement it that way you would have no way of controlling the margins around the component from the outside without adding another unnecessary wrapper component. I would consider the fact that the component is using a native input element inside an implementation detail that should not be relied upon. |
Using So I think if I just change all the arguments in the docs to be
I think we could leave the templates as is without I renamed my related PR to "Support html attributes in angle bracket components", since angle bracket components technically already work. |
Done in aa98e71 Hmm build is failing...I haven't changed any code in this PR however. Someone want to try running it again for me? 🛠 |
bump...anyone know why my build failed? :) |
@mcfiredrill Restarted. Ping me on Discord if it fails again please 🙂 |
@mcfiredrill 👋 Hello from the future. Care to rebase this so the CI can run again? |
Hi there, it's been awhile! I just merged master into this branch. |
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.
@jelhan Your requested changes had been addressed – yes?
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.
Since (#476) onfileadd
has been deprecated in favour of onFileAdd
.
Also found a >
was missing.
Also suggest we:
- Drop
action
helper from examples - Use
fn
helper to pass arguments to callbacks
Please rebase 😅
Co-authored-by: Giles Thompson <[email protected]>
Co-authored-by: Giles Thompson <[email protected]>
…-file-upload into angle-brackets-codemod
Sorry for the delay, I have merged master.
I could try to address these here, or that could be another PR? |
Looks like you addressed these in 71d3298 |
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. Believe this syntax is correct for the current version.
@jelhan I think this can be merged now. Let me know if you still need changes |
I tried use ember-angle-brackets-codemod, but it didn't seem to work on
.js files. So I edited the doc comments manually.