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

Create 'Bullets' molecule #786

Merged
merged 16 commits into from
Jun 25, 2021
Merged

Create 'Bullets' molecule #786

merged 16 commits into from
Jun 25, 2021

Conversation

victorhmp
Copy link
Member

@victorhmp victorhmp commented Jun 23, 2021

What's the purpose of this pull request?

This PR adds the Bullets molecule to our store-ui library.

How it works?

The Bullets molecule is supposed to be used in scenarios where we have paginated items, which can be navigated through the use of small bullets indicating where the user is and where they can go to. This is commonly used along with Carousels, such as this example:

The Bullets molecule would be used to make those small circles at the bottom of the image. And it supports the following props:

interface BulletsProps {
  /**
   * Number of bullets that should be rendered.
   */
  totalQuantity: number
  /**
   * The currently active bullet (zero-indexed).
   */
  activeBullet: number
  /**
   * Event handler for clicks on each bullet. The handler will be called with
   * the index of the bullet that received the click.
   */
  onClick: (e: MouseEvent, bulletIdx: number) => void
  /**
   * ID to find this component in testing tools (e.g.: cypress,
   * testing-library, and jest).
   */
  testId?: string
  /**
   * Function that should be used to generate the aria-label attribute added
   * to each bullet that is inactive. It receives the bullet index as an
   * argument so that it can be interpolated in the generated string.
   */
  ariaLabelGenerator?: (index: number, isActive: boolean) => string
}

To enable different CSS rules to be applied to the current bullet set as 'active', we render the currently active bullet with a data attribute data-active.

How to test it?

You can check the deploy preview linked below, where you'll find a Bullets section listed under Molecules in our Storybook.
Take a look at the Story section to see the code being used to control the Bullets molecule.

@netlify
Copy link

netlify bot commented Jun 23, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 64b832c

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/60d4eb351b91e000076e2937

😎 Browse the preview: https://deploy-preview-786--storeui.netlify.app/iframe

@victorhmp victorhmp self-assigned this Jun 23, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 23, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 64b832c:

Sandbox Source
Store UI Typescript Configuration

@victorhmp victorhmp marked this pull request as ready for review June 23, 2021 13:47
@victorhmp victorhmp requested a review from a team as a code owner June 23, 2021 13:47
packages/store-ui/src/atoms/Bullets/Bullets.stories.tsx Outdated Show resolved Hide resolved
packages/store-ui/src/atoms/Bullets/Bullets.tsx Outdated Show resolved Hide resolved
packages/store-ui/src/atoms/Bullets/Bullets.tsx Outdated Show resolved Hide resolved
@victorhmp victorhmp changed the title Create 'Bullets' atom Create 'Bullets' molecule Jun 23, 2021
@victorhmp
Copy link
Member Author

victorhmp commented Jun 23, 2021

@Gmantiqueira Check the storybook here 😉

@victorhmp victorhmp requested a review from tlgimenes June 24, 2021 19:43
Copy link
Contributor

@tlgimenes tlgimenes left a comment

Choose a reason for hiding this comment

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

LGTM

@victorhmp victorhmp requested a review from Gmantiqueira June 24, 2021 20:29
@victorhmp victorhmp merged commit 396df0f into master Jun 25, 2021
@victorhmp victorhmp deleted the feature/bullets-atom branch June 25, 2021 14:08
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.

4 participants