-
Notifications
You must be signed in to change notification settings - Fork 104
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
feat(chip): add chip component #1981
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.
Some comments to address before merging.
src/components/ebay-chip/index.marko
Outdated
<button | ||
type="button" | ||
class="chip__button" | ||
type="button" |
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.
You have two type=buttons.
You really want this to be a button! :)
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.
Haha, good catch. I removed one of them.
src/components/ebay-chip/index.marko
Outdated
@@ -0,0 +1,19 @@ | |||
$ const textId = component.elId("text"); |
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.
So if we don't allow the user to pass in a custom textid we should not do it this way but rather use :scoped
https://markojs.com/docs/class-components/#scoped
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 is nicer, thanks
src/components/ebay-chip/index.marko
Outdated
@@ -0,0 +1,19 @@ | |||
$ const textId = component.elId("text"); | |||
|
|||
<span class="chip"> |
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.
We should allow spread for probably the root element.
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.
Added
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 Andrew! Should be better now.
src/components/ebay-chip/index.marko
Outdated
@@ -0,0 +1,19 @@ | |||
$ const textId = component.elId("text"); |
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 is nicer, thanks
src/components/ebay-chip/index.marko
Outdated
@@ -0,0 +1,19 @@ | |||
$ const textId = component.elId("text"); | |||
|
|||
<span class="chip"> |
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.
Added
src/components/ebay-chip/index.marko
Outdated
<button | ||
type="button" | ||
class="chip__button" | ||
type="button" |
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.
Haha, good catch. I removed one of them.
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.
Also should add examples in the example
folder. We have a link to examples in readme but no examples.
It should be fine after these changes.
src/components/ebay-chip/index.marko
Outdated
|
||
<span class="chip" ...processHtmlAttributes(htmlAttributes)> | ||
<span class="chip__text" id:scoped="text"> | ||
<${input.renderBody}/> |
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 we have renderBody
defined at the top (so it doesnt get added in spread), why not use it here? At least that way we don't have any unused variables
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.
Whoops! This is what I meant to do, thanks for catching it.
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 @agliga, should be good to go now.
src/components/ebay-chip/index.marko
Outdated
|
||
<span class="chip" ...processHtmlAttributes(htmlAttributes)> | ||
<span class="chip__text" id:scoped="text"> | ||
<${input.renderBody}/> |
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.
Whoops! This is what I meant to do, thanks for catching it.
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.
A couple of minor things...
table: { | ||
category: "Events", | ||
defaultValue: { | ||
summary: "{ el, checked, originalEvent }", |
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.
To what is checked
referring? Should it be deleted
instead?
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.
Good catch, this was actually completely wrong, must've been a copy-paste error. I fixed it.
|
||
use(require("chai-dom")); | ||
|
||
it("renders default chip component", async () => { |
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 rename these tests please?
- The
default
chip is also static, so something like,renders default static chip component
- The second one doesn't refer to chip; I think it should. Maybe something like,
renders interactive chip with close button when close label is provided
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.
Also on this same line, we should group up all these tests in a describe
and say: ebay-chip
or something like that. Then eep the descriptions for each test simple, like renders default
and renders with close icon
https://github.com/eBay/ebayui-core/blob/master/src/components/ebay-icon/test/test.server.js#L11
(I know that its not everywhere but I think we should start to add it in all places)
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.
Sounds good, I updated test names.
src/components/ebay-chip/index.marko
Outdated
$ const { renderBody, a11yDeleteButton, ...htmlAttributes } = input; | ||
|
||
<span class="chip" ...processHtmlAttributes(htmlAttributes)> | ||
<span class="chip__text" id:scoped="text"> |
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.
Just a nit, I would call the id chip
or title
.
Text is pretty ambiguous.
Its fine to leave as is though if there are no other changes.
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.
Sure, I went with title
because I think it's more descriptive of the text node.
I think this PR is fine but need some minor nit cleanup. |
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.
src/components/ebay-chip/index.marko
Outdated
$ const { renderBody, a11yDeleteButton, ...htmlAttributes } = input; | ||
|
||
<span class="chip" ...processHtmlAttributes(htmlAttributes)> | ||
<span class="chip__text" id:scoped="text"> |
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.
Sure, I went with title
because I think it's more descriptive of the text node.
|
||
use(require("chai-dom")); | ||
|
||
it("renders default chip component", async () => { |
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.
Sounds good, I updated test names.
table: { | ||
category: "Events", | ||
defaultValue: { | ||
summary: "{ el, checked, originalEvent }", |
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.
Good catch, this was actually completely wrong, must've been a copy-paste error. I fixed it.
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.
Looks good.
Description
ebay-chip
component to ebayui-coreScreenshots