Skip to content

Conversation

@blboyle
Copy link
Contributor

@blboyle blboyle commented Mar 29, 2022

As you look at the examples below, you will see examples of this bug, related to the Card component. #5377 I updated this PR to make the border radius of the table match the Card.

WHY are these changes introduced?

  • Visual consistency and alignment with Index table updates.
  • Facilitate data scanning through visual treatment of rows.
    (Ping @mirualves if you have UX questions)

WHAT is this pull request doing?

Density changes

This PR will reduce the padding around the cells to allow for a higher data density. It also aims to align with the visual changes and improvements coming soon to the Index Table component.

Before alt
After alt

Zebra striping

This PR will update the data table to have the zebra striping where the first row is a dark colour and it alternates between that and the white colour for each subsequent row.

The alternating rows (zebra stripes) help users scan data more efficiently, especially for long horizontal datasets. The users may lose their place when parsing large datasets without alternating rows.

Before After
alt alt

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Copy-paste this code in playground/Playground.tsx:
import React from 'react';

import {Page, DataTable, Card, Heading} from '../src';

const rows = [
  [1, 2, 3],
  [1, 2, 3],
  [1, 2, 3],
];
const rowsEven = [
  [1, 2, 3],
  [1, 2, 3],
];

const totals = [4, 5, 6];

const headings = ['one', 'two', 'three'];

const props = {
  increasedTableDensity: true,
  hasZebraStripingOnData: true,
  rows,
  headings,
};

export function Playground() {
  return (
    <Page title="Playground">

      <Heading>Simple</Heading>
      <Card>
        <DataTable
          {...props}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          sortable={[true, false, true]}
        />
      </Card>
      <Card>
        <DataTable
          {...props}
          rows={rowsEven}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          sortable={[true, false, true]}
        />
      </Card>
      <Heading>With footer</Heading>
      <Card>
        <DataTable
          {...props}
          rows={rows}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          footerContent="Hi, this is the footer"
          sortable={[true, false, true]}
        />
      </Card>
      <Card>
        <DataTable
          {...props}
          rows={rowsEven}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          footerContent="Hi, this is the footer"
          sortable={[true, false, true]}
        />
      </Card>
      <Heading>Totals on top, no footer</Heading>
      <Card>
        <DataTable
          {...props}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          sortable={[false, true, true]}
        />
      </Card>
      <Card>
        <DataTable
          {...props}
          rows={rowsEven}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          sortable={[false, true, true]}
        />
      </Card>
      <Heading>Totals at bottom, no footer</Heading>
      <Card>
        <DataTable
          {...props}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          showTotalsInFooter
          sortable={[false, false, true]}
        />
      </Card>
      <Card>
        <DataTable
          {...props}
          rows={rowsEven}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          showTotalsInFooter
          sortable={[false, false, true]}
        />
      </Card>
      <Heading>Totals at bottom, with footer</Heading>
      <Card>
        <DataTable
          {...props}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          showTotalsInFooter
          footerContent="Hi, this is the footer"
          sortable={[true, false, false]}
        />
      </Card>

      <Card>
        <DataTable
          {...props}
          rows={rowsEven}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          showTotalsInFooter
          footerContent="Hi, this is the footer"
          sortable={[true, false, false]}
        />
      </Card>
      <Heading>Totals at top, with footer</Heading>
      <Card>
        <DataTable
          {...props}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          footerContent="Hi, this is the footer"
          sortable={[true, false, false]}
        />
      </Card>
      <Card>
        <DataTable
          {...props}
          rows={rowsEven}
          headings={headings}
          columnContentTypes={['numeric', 'numeric', 'numeric']}
          totals={totals}
          footerContent="Hi, this is the footer"
          sortable={[true, false, false]}
        />
      </Card>
    </Page>
  );
}

🎩 checklist

@ghost
Copy link

ghost commented Mar 29, 2022

👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 29, 2022

size-limit report 📦

Path Size
cjs 157.87 KB (+0.12% 🔺)
esm 89.19 KB (+0.15% 🔺)
esnext 138.66 KB (+0.36% 🔺)
css 36.69 KB (+0.79% 🔺)

@blboyle blboyle force-pushed the data-table-density-stripes branch 4 times, most recently from 2e063fb to 32247c2 Compare March 29, 2022 13:47
@blboyle blboyle changed the title Change density and apply stripes to Data Table [Data Table] Add zebra striping to table and change table density Mar 29, 2022
@blboyle blboyle force-pushed the data-table-density-stripes branch 2 times, most recently from cf3598a to 8dc7b26 Compare March 30, 2022 13:55
@blboyle blboyle marked this pull request as ready for review March 30, 2022 18:45
@blboyle blboyle force-pushed the data-table-density-stripes branch from 8dc7b26 to d239cfb Compare March 30, 2022 19:31
@ghost ghost added the cla-needed Added by a bot. Contributor needs to sign the CLA Agreement. label Mar 30, 2022
@blboyle blboyle marked this pull request as draft March 30, 2022 19:31
@blboyle blboyle force-pushed the data-table-density-stripes branch from d239cfb to 008e1da Compare March 30, 2022 19:33
Copy link
Contributor

@sarahill sarahill left a comment

Choose a reason for hiding this comment

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

Updates visually lgtm 👍 ❇️

@blboyle blboyle force-pushed the data-table-density-stripes branch from 008e1da to f37f48e Compare March 31, 2022 12:46
@ghost ghost removed the cla-needed Added by a bot. Contributor needs to sign the CLA Agreement. label Mar 31, 2022
@blboyle blboyle marked this pull request as ready for review March 31, 2022 13:01
@blboyle blboyle marked this pull request as draft March 31, 2022 13:01
@blboyle blboyle force-pushed the data-table-density-stripes branch from f37f48e to 90ded40 Compare March 31, 2022 13:03
@blboyle blboyle marked this pull request as ready for review March 31, 2022 13:10
@blboyle blboyle marked this pull request as draft April 1, 2022 14:46
@blboyle blboyle force-pushed the data-table-density-stripes branch 4 times, most recently from 53d2849 to 95f63b2 Compare April 4, 2022 17:17
@ghost ghost removed the cla-needed Added by a bot. Contributor needs to sign the CLA Agreement. label Apr 4, 2022
Copy link
Contributor

@philschoefer philschoefer left a comment

Choose a reason for hiding this comment

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

LGTM!

@blboyle blboyle force-pushed the data-table-density-stripes branch from dc20f3b to f640128 Compare April 5, 2022 13:39
@blboyle blboyle force-pushed the data-table-density-stripes branch 4 times, most recently from 84515f8 to c10717b Compare April 5, 2022 16:53
@blboyle blboyle force-pushed the data-table-density-stripes branch from c10717b to 6a42482 Compare April 5, 2022 17:50
@blboyle blboyle force-pushed the data-table-density-stripes branch 3 times, most recently from bbb4dd9 to b6ab89d Compare April 5, 2022 18:40
@blboyle blboyle force-pushed the data-table-density-stripes branch from b6ab89d to de4cb41 Compare April 5, 2022 18:46
@blboyle blboyle merged commit 633d301 into main Apr 5, 2022
@blboyle blboyle deleted the data-table-density-stripes branch April 5, 2022 19:32
@ghost
Copy link

ghost commented Apr 5, 2022

🎉 Thanks for your contribution to Polaris React!

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.

6 participants