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(store-ui): Table Molecule #987

Merged
merged 22 commits into from Oct 18, 2021
Merged

feat(store-ui): Table Molecule #987

merged 22 commits into from Oct 18, 2021

Conversation

victorhmp
Copy link
Member

@victorhmp victorhmp commented Oct 13, 2021

What's the purpose of this pull request?

This PR creates adds a Table molecule to @vtex/store-ui.

Closes #840.

How it works?

The Table component simply takes children and renders them. But to aid in the construction of tables, individual components that should be placed inside of a Table component were also created in this branch:

  • TableBody, renders a <tbody> tag.
  • TableHead, renders a <thead> tag.
  • TableRow, renders a <tr> tag.
  • TableFooter, renders a <tfoot> tag.
  • TableCell, can render a <th> or <td> tag, according to a variation prop that supports values "header" and "data".

All of those components expect to receive children, and render them out.

Here's an example of a table and the JSX markup that generates it:

Screen Shot 2021-10-13 at 12 29 33

    <TableComponent>
      <TableHead>
        <TableRow>
          <TableCell scope="col" variant="header">
            Installments
          </TableCell>
          <TableCell scope="col" variant="header">
            Amount
          </TableCell>
          <TableCell scope="col" variant="header">
            Total
          </TableCell>
        </TableRow>
      </TableHead>
      <TableBody>
        {options.map((option) => (
          <TableRow key={option.numberOfInstallments}>
            <TableCell>{option.numberOfInstallments}x</TableCell>
            <TableCell>
              <Price formatter={priceFormatter} value={option.monthlyPayment} />
            </TableCell>
            <TableCell>
              <Price formatter={priceFormatter} value={option.total} />
            </TableCell>
          </TableRow>
        ))}
      </TableBody>
    </TableComponent>

How to test it?

You can check it out in the Storybook linked below.

Here's also a base.store preview with this table: https://sfj-b961b7e--base.preview.vtex.app/small-messenger-bag-with-double-g-70/p.

References

For inspiration:

References about HTML tables and a11y:

@victorhmp victorhmp self-assigned this Oct 13, 2021
@netlify
Copy link

netlify bot commented Oct 13, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 35a85ac

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/616db5d1a1ea8c0007ddff34

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 13, 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 35a85ac:

Sandbox Source
Store UI Typescript Configuration

@victorhmp victorhmp marked this pull request as ready for review October 13, 2021 17:54
@victorhmp victorhmp requested a review from a team as a code owner October 13, 2021 17:54
@victorhmp victorhmp changed the title Feature/table feat:Table Molecule Oct 13, 2021
@victorhmp victorhmp changed the title feat:Table Molecule feat(store-ui): Table Molecule Oct 13, 2021
@igorbrasileiro
Copy link
Contributor

Also, take a look at this problem on the docs page.
image

@victorhmp
Copy link
Member Author

Also, take a look at this problem on the docs page. image

@igorbrasileiro solved it here: #989 ;)

Copy link
Contributor

@lariciamota lariciamota left a comment

Choose a reason for hiding this comment

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

👏

import React from 'react'

import type { TableProps } from '../Table'
import TableComponent from '../Table'
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for not be calling it "Table"?

Copy link
Member Author

@victorhmp victorhmp Oct 18, 2021

Choose a reason for hiding this comment

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

Just because I wanted the story name to also be Table 😅 And to do so, I have to export a Table variable.

@victorhmp victorhmp merged commit 6ecea2d into master Oct 18, 2021
@victorhmp victorhmp deleted the feature/table branch October 18, 2021 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Installments (price list)
3 participants