Skip to content

feat(split button): adds split button #207

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

Merged
merged 9 commits into from
Jul 8, 2024
Merged

feat(split button): adds split button #207

merged 9 commits into from
Jul 8, 2024

Conversation

dylankcrwd
Copy link
Contributor

@dylankcrwd dylankcrwd commented Jun 20, 2024

Adds glide-core-split-container, glide-core-split-button, and glide-core-split-link.

Storybook: https://glide-core.crowdstrike-ux.workers.dev/add-split-button?path=/docs/split-button--overview

Copy link

changeset-bot bot commented Jun 20, 2024

🦋 Changeset detected

Latest commit: 9e906ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@crowdstrike/glide-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@dylankcrwd dylankcrwd force-pushed the add-split-button branch 2 times, most recently from f764353 to e33d283 Compare June 26, 2024 20:24
@dylankcrwd dylankcrwd marked this pull request as ready for review June 26, 2024 20:49
Copy link
Collaborator

@ynotdraw ynotdraw 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 @dylankcrwd ! A few questions/comments.


One other thing comes to mind, I imagine design already approved, but with the small variant should the dropdown arrow also change sizing? Without it, the chevron down is larger than the text. Curious what design thinks.

Screenshot 2024-06-27 at 9 02 19 AM

Comment on lines 9 to 10
border-radius: var(--glide-core-spacing-sm) 0 0
var(--glide-core-spacing-sm);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bummer we don't have a --glide-core-border-radius that matches this. I'm a bit hesitant on us using spacing values for border radii. I'd maybe prefer just hardcoding these values instead of using spacing-sm here, because if that value changes for spacing, it would adjust the radii here. What do y'all think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Since this was copied from glide-core-button, should that change as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably say so, yeah. I think it's safer for us. Thanks for looking at glide-core-button too!

Copy link
Contributor Author

@dylankcrwd dylankcrwd Jun 27, 2024

Choose a reason for hiding this comment

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

Updated glide-core-button

}

// Can't disable `glide-core-menu`, so capture the event before it arrives.
// Disabling the trigger button doesn't resolve the issue.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a bug potentially with Menu @clintcs ? I guess maybe not, since the menu doesn't necessarily know if the target it is referencing is disabled or not. And maybe determining that from within menu would be tricky?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I could see it being Menu's responsibility to check if the target is a child of an element with a disabled property and return early if so.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we file a task for this or what do you think? Is it a quick update that we could roll into this PR? Then we could remove some code here and get a nice bonus in Menu with this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to make it a separate task I could do in the next sprint, otherwise I fear this card won't get done in time and since I'm OOO for much of next week, the branch will go quite stale.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I leave it to you two. The work is done on my side. I can push a commit or open a separate PR.

Copy link
Contributor Author

@dylankcrwd dylankcrwd Jun 28, 2024

Choose a reason for hiding this comment

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

@clintcs If you have a commit with the desired change could you please push it to this branch? Thanks!
I can then remove the click interception logic and related test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sweet. I'll push the commit shortly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dylankcrwd: Go ahead and merge as is. Filling test gaps in Menu and accounting for the case where disabled is removed from the target have resulted in a big diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @clintcs

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dylankcrwd: See the comment on my Menu PR for context. I rebased your branch onto main to bring in my changes and then pushed a commit removing your workaround for Menu. You should be good.

In rebasing I amended this branch's history. So locally you'll need to fetch and then git reset --hard origin/add-split-button.

href=${ifDefined(this.url)}
class=${classMap({
component: true,
disabled: this.disabled,
Copy link
Collaborator

Choose a reason for hiding this comment

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

For a11y reasons, when a link should be disabled, we actually render a <span> with some attributes instead. That way the component appears visually disabled, but then we don't have an underlying <a that we have to intercept click handlers for and it also announces to screenreaders as one would expect.

This happened in one of our other private repos (you know the one!) with main-navigation-link.ts if you take a look there. We should probably follow the same pattern here as that was blessed by Noah from an a11y standpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will look into this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

To be consistent with a disabled button, the span is not tabbable when disabled, unlike main-navigation-link.ts. Let me know if this is what you're looking for.

@dylankcrwd
Copy link
Contributor Author

dylankcrwd commented Jun 27, 2024

Looks good @dylankcrwd ! A few questions/comments.

One other thing comes to mind, I imagine design already approved, but with the small variant should the dropdown arrow also change sizing? Without it, the chevron down is larger than the text. Curious what design thinks.

Screenshot 2024-06-27 at 9 02 19 AM

This looks to be consistent with glide-core-button. Maybe this should be a different card?

The split button has been approved, however there is nothing that I've seen in the figma for the small size and was something I added to be consistent with the button.

@ynotdraw
Copy link
Collaborator

The split button has been approved, however there is nothing that I've seen in the figma for the small size and was something I added to be consistent with the button.

Oh. If this is the case, I don't think we want to add sizing for this component. I'd double check with Mary, Joe, or Zheng. We only want to add support for things we know design explicitly calls for. So even though Button supports a size, there may not be needs for a small SplitButton, so we shouldn't add it.

@dylankcrwd
Copy link
Contributor Author

dylankcrwd commented Jun 27, 2024

The split button has been approved, however there is nothing that I've seen in the figma for the small size and was something I added to be consistent with the button.

Oh. If this is the case, I don't think we want to add sizing for this component. I'd double check with Mary, Joe, or Zheng. We only want to add support for things we know design explicitly calls for. So even though Button supports a size, there may not be needs for a small SplitButton, so we shouldn't add it.

I asked the question of Design & awaiting their reply they asked to keep it.

@dylankcrwd dylankcrwd requested a review from ynotdraw June 28, 2024 16:42
border-color: transparent;
color: var(--glide-core-text-selected);

&.disabled {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be good to add a comment on why this uses .disabled versus :disabled (because of the shared usage of buttons and links) for future travelers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment is just above on line 37, but I can move it down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

?.dispatchEvent(event);

await elementUpdated(component);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the test reads "remains closed when clicked", should we verify once again that the menu is in fact closed and not open? Similar to what you have in the next test at the bottom.

Suggested change
expect(
component.shadowRoot?.querySelector('glide-core-menu'),
).to.not.have.attribute('open');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

expect(link?.classList.contains('secondary')).to.be.true;
});

it('becomse a span when the "disabled" attribute exists', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo:

Suggested change
it('becomse a span when the "disabled" attribute exists', async () => {
it('becomes a span when the "disabled" attribute exists', async () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

);
});

it('throws an error when there is something other than text is in the default slot', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A small typo:

Suggested change
it('throws an error when there is something other than text is in the default slot', async () => {
it('throws an error when there is something other than text in the default slot', async () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@dylankcrwd dylankcrwd requested a review from ynotdraw June 28, 2024 19:16
@clintcs clintcs mentioned this pull request Jul 1, 2024
@clintcs clintcs force-pushed the add-split-button branch from 0b7a551 to 9e906ca Compare July 2, 2024 21:26
@dylankcrwd dylankcrwd merged commit b5d9180 into main Jul 8, 2024
7 checks passed
@dylankcrwd dylankcrwd deleted the add-split-button branch July 8, 2024 12:43
@github-actions github-actions bot mentioned this pull request Jul 8, 2024
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