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

ActionList Composable API #1517

Merged
merged 117 commits into from
Nov 11, 2021
Merged

ActionList Composable API #1517

merged 117 commits into from
Nov 11, 2021

Conversation

siddharthkp
Copy link
Member

@siddharthkp siddharthkp commented Oct 15, 2021

Ready for review :)


Closes https://github.com/github/primer/issues/307 | Interface guidelines | Figma
Next: https://github.com/github/primer/issues/447 + https://github.com/github/primer/issues/448


See Docs for API surface area for ActionList

 


See Storybook for use cases as standalone and as List inside Menu/Select

 

API opinions worth noting:

Watch video instead

  1. Prefer composition over config: See https://github.com/github/primer/issues/307 for long version

  2. selectionVariant for ActionList is null by default. Item makes no assumptions about what kind of selection to render if it is not set on the List root or Group

  3. showDividers is on ActionList root, not each ActionList.Item. Loosely held opinion, will test with memex. The Dividers are meant to add a separator between Items of the list and should be consistent in a given List and not customisable at the Item level.

    • Should it also be on Group level? Can 2 groups inside a List have different divider settings?
    • Does the name showDividers cause confusion/conflict with ActionList.Divider?
  4. Added ActionList.LinkItem which uses an internal API with Item to make sure we can give the semantics for free.


Progressive improvements:

  • Try out rc version in memex https://github.com/github/memex/pull/5862
  • Play well with AnchoredOverlay for "build your own ActionMenu" mode in memex
  • replace custom item themes when Release Tracking primitives#263 is released
  • help wanted: typescript unhappy with polymorphic + forwardRef
  • ActionList.LinkItem
    • Polymorphic Link component
    • Padding at the container not root
  • Test suite for create-slots (it's where all the complex logic sits)

Questions:

Design

Bundling

  • Bundle ActionList2 in @primer/components/unreleased

While I'm confident about the API in this PR, I'd like to "release" these changes along with their composable counterparts ActionMenu and SelectPanel, so that the memex team can catch up with breaking API for Menus together. This also gives us a change to tweak and polish the underlying ActionList to be accessible. The change is not code aesthetics, it's a more mature group of components ✨

Accessibility questions moved to ActionList beta audit

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2021

🦋 Changeset detected

Latest commit: 3cfc4f7

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

This PR includes changesets to release 1 package
Name Type
@primer/components 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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 15, 2021

size-limit report 📦

Path Size
dist/browser.esm.js 54.44 KB (+0.4% 🔺)
dist/browser.umd.js 54.83 KB (+0.39% 🔺)

Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Love where this is going ❤️ Amazing work, @siddharthkp!

Happy to move forward with what you have here. Left a few minor comments.

@@ -1,5 +1,6 @@
// @preval
// This file needs to be a JavaScript file using CommonJS to be compatiable with preval
// Cache bust: 2021-11-04 12:00:00 GMT (This file is cached by our deployment tooling, update this timestamp to rebuild this file)
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL

Copy link
Member Author

@siddharthkp siddharthkp Nov 10, 2021

Choose a reason for hiding this comment

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

There has to be a better way of doing this, but I did not spend more than 5 minutes researching vercel's caching mechanism. So, this date will probably live here until we find a different way 😇

src/utils/create-slots.tsx Show resolved Hide resolved
@@ -0,0 +1,2 @@
// Components
export * from './ActionList2'
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of keeping experiments out of the main bundle. A couple of questions:

  • If we want to build experimental components in primer, should we update the definition of "experimental" in this document? https://primer.style/contribute/component-lifecycle#experimental (defines "experimental" as built outside of Primer)
  • Should we rename this file experimental to align with that document? ☝️
  • When we release breaking changes to experimental components, which semver number should we bump?

Copy link
Member Author

@siddharthkp siddharthkp Nov 10, 2021

Choose a reason for hiding this comment

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

Hmm, there's a name conflict here for sure.

In our component lifecycle maturity, components with experimental maturity can still be in the main bundle.

What I want to signal here is - this is a "unreleased" component that is not part of the public api yet (not in main bundle). We don't recommend using it in production yet. You can still import it with explicitly for experimentation/feedback.

alternate names: unreleased, next, future, private, internal

When we release breaking changes to experimental components, which semver number should we bump?

As these are outside the public API, they don't get a major/minor version bump with the assumption that only prototypes/experiments are using them and not continuously maintained applications. (mostly safe because prototypes/sandboxes have a locked version in time)

Copy link
Member Author

Choose a reason for hiding this comment

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

Update: changed to unreleased.

(next was a close second, but that might get confused with npm tag primer/components@next. future is romantic, but i'd like to put long running things in this scope that might not make it to main bundle at all)

@pksjce thoughts for new Button?

Copy link
Member Author

@siddharthkp siddharthkp Nov 10, 2021

Choose a reason for hiding this comment

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

(Useful to add, also added to PR description)

Why is ActionList2 in unreleased instead of replacing the current ActionList with a breaking change?

While I'm confident about the API in this PR (by testing it A LOT 😇), I'd like to "release" these changes along with their composable counterparts ActionMenu and SelectPanel, so that the memex team can catch up with breaking API for Menus together.

This also gives us a change to tweak and polish the underlying ActionList to be accessible. The change is not code aesthetics, it's a more mature group of components ✨

src/ActionList2/Visuals.tsx Outdated Show resolved Hide resolved
src/ActionList2/Visuals.tsx Show resolved Hide resolved
src/ActionList2/Visuals.tsx Show resolved Hide resolved
src/ActionList2/List.tsx Show resolved Hide resolved
src/ActionList2/List.tsx Outdated Show resolved Hide resolved
src/ActionList2/Item.tsx Show resolved Hide resolved
Co-authored-by: Cole Bemis <colebemis@github.com>
/**
* Primary content for an Item
*/
children?: React.ReactNode
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to specifically define React.ReactNode?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so 🤔 Added this here because that's what we say in the docs

@siddharthkp siddharthkp merged commit 561c0bd into main Nov 11, 2021
@siddharthkp siddharthkp deleted the action-list-2 branch November 11, 2021 13:32
@primer-css primer-css mentioned this pull request Nov 11, 2021
pksjce pushed a commit that referenced this pull request Nov 15, 2021
New ActionList component, bundled in @primer/components/unreleased

Co-authored-by: Jonathan Fuchs <jfuchs@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants