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

feat(chip): add chip component #1981

Merged
merged 5 commits into from
Sep 19, 2023
Merged

feat(chip): add chip component #1981

merged 5 commits into from
Sep 19, 2023

Conversation

LuLaValva
Copy link
Member

Note

Description

  • Add ebay-chip component to ebayui-core

Screenshots

image image image

@LuLaValva LuLaValva self-assigned this Sep 6, 2023
Copy link
Contributor

@agliga agliga left a 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.

<button
type="button"
class="chip__button"
type="button"
Copy link
Contributor

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! :)

Copy link
Member Author

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.

@@ -0,0 +1,19 @@
$ const textId = component.elId("text");
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This is nicer, thanks

@@ -0,0 +1,19 @@
$ const textId = component.elId("text");

<span class="chip">
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

Copy link
Member Author

@LuLaValva LuLaValva left a 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.

@@ -0,0 +1,19 @@
$ const textId = component.elId("text");
Copy link
Member Author

Choose a reason for hiding this comment

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

This is nicer, thanks

@@ -0,0 +1,19 @@
$ const textId = component.elId("text");

<span class="chip">
Copy link
Member Author

Choose a reason for hiding this comment

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

Added

<button
type="button"
class="chip__button"
type="button"
Copy link
Member Author

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.

Copy link
Contributor

@agliga agliga left a 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/chip.stories.js Outdated Show resolved Hide resolved

<span class="chip" ...processHtmlAttributes(htmlAttributes)>
<span class="chip__text" id:scoped="text">
<${input.renderBody}/>
Copy link
Contributor

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

Copy link
Member Author

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.

src/components/ebay-chip/index.marko Outdated Show resolved Hide resolved
Copy link
Member Author

@LuLaValva LuLaValva left a 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/chip.stories.js Outdated Show resolved Hide resolved

<span class="chip" ...processHtmlAttributes(htmlAttributes)>
<span class="chip__text" id:scoped="text">
<${input.renderBody}/>
Copy link
Member Author

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.

src/components/ebay-chip/index.marko Outdated Show resolved Hide resolved
Copy link
Contributor

@ArtBlue ArtBlue left a 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 }",
Copy link
Contributor

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?

Copy link
Member Author

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 () => {
Copy link
Contributor

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?

  1. The default chip is also static, so something like, renders default static chip component
  2. 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

Copy link
Contributor

@agliga agliga Sep 18, 2023

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)

Copy link
Member Author

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.

$ const { renderBody, a11yDeleteButton, ...htmlAttributes } = input;

<span class="chip" ...processHtmlAttributes(htmlAttributes)>
<span class="chip__text" id:scoped="text">
Copy link
Contributor

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.

Copy link
Member Author

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.

@agliga
Copy link
Contributor

agliga commented Sep 18, 2023

I think this PR is fine but need some minor nit cleanup.

Copy link
Member Author

@LuLaValva LuLaValva left a comment

Choose a reason for hiding this comment

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

Thanks for the comments @agliga and @ArtBlue, should look cleaner now.

$ const { renderBody, a11yDeleteButton, ...htmlAttributes } = input;

<span class="chip" ...processHtmlAttributes(htmlAttributes)>
<span class="chip__text" id:scoped="text">
Copy link
Member Author

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 () => {
Copy link
Member Author

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 }",
Copy link
Member Author

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.

@LuLaValva LuLaValva merged commit 2d98582 into 12.6.0 Sep 19, 2023
1 check failed
@LuLaValva LuLaValva deleted the 1973-chip branch September 19, 2023 18:37
Copy link
Contributor

@ArtBlue ArtBlue left a comment

Choose a reason for hiding this comment

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

Looks good.

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.

3 participants