+
Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Conversation

clintcs
Copy link
Collaborator

@clintcs clintcs commented Sep 17, 2024

🚀 Description

  • Added click() and focus() controls to stories. For context: Rework Split Button #361 (comment).

  • Reordered argTypes to match the order of args.

  • Emptied the slot="description" argument in form control stories after some discussion. See CONTRIBUTING.md.

  • Add missing controls to Tab's story and renamed the story to Tab Group.

  • Removed unnecessary instances of control: { type: 'boolean' } and control: { type: 'text' }, both of which are inferred by Storybook.

  • Replaced render: () => {} with render() {} for consistency.

  • Modified various stories whose controls accept markup to use unsafeHTML. This lets Storybook users test out their markup.

    Allowing arbitrary markup is safe because Storybook doesn't push those controls with the URL. And, even if it did, we're not setting cookies or otherwise storing sensitive data vulnerable to an XSS.

  • Added a focus() method to Accordion and a click() method to Icon Button.

  • Removed story and component descriptions.

    Wasn't sure about this. Talked to @ynotdraw about it offline. Many of our descriptions are superfluous (Menu's "A basic menu") and the rest are either implied or include information already present in the controls table.

  • Swapped out styles in stories for top-level decorators property where possible.

  • Added a Mutation Observer to Dropdown's story to account for Dropdown closing when it loses focus or something outside of it is clicked.

📋 Checklist

🔬 How to Test

  1. Spotcheck every story.
  2. Verify Accordion's focus() method.

📸 Images/Videos of Functionality

N/A

Copy link

changeset-bot bot commented Sep 17, 2024

🦋 Changeset detected

Latest commit: 30cdced

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 Minor

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

@clintcs clintcs force-pushed the moar-documentation-improvements branch 2 times, most recently from 0f4c328 to 19deecb Compare September 17, 2024 21:09
'@crowdstrike/glide-core': minor
---

Menu no longer offers a `focus()` method, which focused its target. Simply call `focus()` on your target directly.
Copy link
Collaborator Author

@clintcs clintcs Sep 17, 2024

Choose a reason for hiding this comment

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

No need for a middleman, I figured.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have we checked consumers to see if they're using this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't because it wouldn't affect the outcome for me. Whether they're using it or not, it's superfluous for Menu to offer a method already offered by their target button.

If it were in use, would that change the calculus for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I should have said more: I'm cool with this change either way, we'd just need to be sure to communicate that this is a possible breaking change when it comes time to release. But we're good about doing that anyway, so I probably don't need to say it :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha. Got it. Yeah, that's implied (though not obvious) by minor for us. But, yeah, I trust that @ynotdraw will spread the good word.

Copy link
Collaborator

Choose a reason for hiding this comment

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

🫡 you bet!


export default meta;

export const Tabs: StoryObj = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we need an overflow story? Or can we just show overflow in the primary story?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd vote for a separate overflow story. Because it seems to me the most common case is no overflow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can dig it. I'll revert this.

Copy link
Collaborator Author

@clintcs clintcs Sep 20, 2024

Choose a reason for hiding this comment

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

30cdced

Copy link
Contributor

@clintcs clintcs force-pushed the moar-documentation-improvements branch 2 times, most recently from 2aa29ab to 44d7c85 Compare September 19, 2024 17:24
@clintcs clintcs force-pushed the moar-documentation-improvements branch 2 times, most recently from 70989a5 to a7b75b9 Compare September 19, 2024 18:59
'slot="tooltip"': {
control: { type: 'text' },
table: {
type: { summary: 'HTMLKBDElement | string' },
Copy link
Collaborator Author

@clintcs clintcs Sep 19, 2024

Choose a reason for hiding this comment

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

Slotting a string into a named slot is actually impossible. Derp.

My first thought was to change this to HTMLKBDElement | Element. But Element includes HTMLKBDElement. So I went with Element and thought I'd let the control, which is prominent and easy to read, speak for the <kbd> part.

Similar thinking for the 'slot="description"' changes above and throughout.

@clintcs clintcs force-pushed the moar-documentation-improvements branch from a7b75b9 to f57b44e Compare September 19, 2024 19:04
import '@crowdstrike/glide-core/button-group.js';
import '@crowdstrike/glide-core/button-group.button.js';
</script>
render(arguments_) {
Copy link
Collaborator Author

@clintcs clintcs Sep 19, 2024

Choose a reason for hiding this comment

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

render: () => {}render() {}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably lintable, eh?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Almost certainly. There's a lot I'd like us to lint in stories. The order of top-level is meta properties is another.

Let me get our lint rule guy on the horn 😆. CC: @ynotdraw.

Copy link
Collaborator

Choose a reason for hiding this comment

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

☎️ you rang!?!??!

(I'll add this to my list)

@clintcs clintcs force-pushed the moar-documentation-improvements branch 2 times, most recently from 8399d85 to 6cad939 Compare September 19, 2024 19:25
<glide-core-button-group-button label="Two">
<glide-core-example-icon
slot="prefix"
name="pencil"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Better looking, eh?

Before

image

After

image

},
type: { name: 'string', required: true },
},
open: {
Copy link
Collaborator Author

@clintcs clintcs Sep 19, 2024

Choose a reason for hiding this comment

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

Most other argTypes changes below and throughout are just from reordering to match the order of args.

@clintcs clintcs force-pushed the moar-documentation-improvements branch from 6cad939 to a6572a6 Compare September 19, 2024 19:31
<glide-core-menu-link label="Three" url="/"></glide-core-menu-link>
</glide-core-split-button-container>
`,
<glide-core-menu-button label="One"></glide-core-menu-button>
Copy link
Collaborator Author

@clintcs clintcs Sep 19, 2024

Choose a reason for hiding this comment

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

Two buttons and one link, same as Split Button Container. Most users will probably click the first or second option, which means they won't be suddenly navigated like they would with a link. But a link is still available if they want to click it.

@clintcs clintcs force-pushed the moar-documentation-improvements branch 3 times, most recently from 290d01a to cb8d785 Compare September 19, 2024 20:06
@clintcs clintcs force-pushed the moar-documentation-improvements branch from cb8d785 to dc39940 Compare September 19, 2024 20:12
@clintcs clintcs marked this pull request as ready for review September 19, 2024 20:14
A story showing the use of an optional slot that requires specific markup is one example.
A story showing an error state triggered by a form submission is another.

### Only set required attributes in stories
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

One more of these and we might think about putting Storybook best practices into their own section.

### Only set required attributes in stories

While it's useful to present components in their full form, we think there's more value in providing minimal code examples so consumers don't copy more code than they need.
Only giving required attributes a value also gives us a simple rule to follow when writing stories.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted an example to accompany this but couldn't come up with a clear and simple one.

Copy link
Collaborator

@danwenzel danwenzel left a comment

Choose a reason for hiding this comment

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

🎉 all around

height="16"
stroke="currentColor"
fill="none"
stroke-linecap="round"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Can we ditch any of attributes that aren't necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is copy pasta from another Icon Button test. But 100% we can. Is this the only one that's unnecessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing you could probably remove most of them :). I say if the test passes, it passes 🤷

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah. I see where you're coming from. I was thinking you still wanted the icon to be presentable.

Strictly speaking, it doesn't even need to be an icon. Other components just throw a <div> Icon </div> in there and call it a day.

Icon Button's tests need to be cleaned up in other ways. So I can take both the cleanup and this as a followup if want to go the <div> route.


export default meta;

export const Tabs: StoryObj = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd vote for a separate overflow story. Because it seems to me the most common case is no overflow.

@clintcs clintcs force-pushed the moar-documentation-improvements branch from b15b618 to 30cdced Compare September 20, 2024 18:39
@clintcs clintcs merged commit b3e8efd into main Sep 20, 2024
7 checks passed
@clintcs clintcs deleted the moar-documentation-improvements branch September 20, 2024 18:46
@github-actions github-actions bot mentioned this pull request Sep 20, 2024
@clintcs clintcs mentioned this pull request Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载