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

[IndexProvider/Table] Migrate from web - take 2 #3646

Merged
merged 46 commits into from
Feb 5, 2021
Merged

Conversation

AndrewMusgrave
Copy link
Member

@AndrewMusgrave AndrewMusgrave commented Nov 18, 2020

WHY are these changes introduced?

Feature requests: [#390, #3637]

As teams reach AODA they'll need to replace their resource list with headers, with a semantic table. This pull request is bringing the table from orders into Polaris in an unstable state so others can gain from its accessibility improvements and contribute to the stability of its API/name

Major hanges other than C+P

  • Add hook to streamline component usage

Screen Shot 2020-11-18 at 4 46 02 PM

  • Add negative margin while in select mode with bulk actions to remove extra white space at the bottom of the list
  • Add tests
  • Change loading bar colors to meet contrast requirements

Notes

Accessibility tests are failing from the filter's component - going to address them in another pull request

WHAT is this pull request doing?

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

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

export function Playground() {
  return (
    <Page title="Playground">
      {/* Add the code you want to test in here */}
    </Page>
  );
}

Screenies

Simple index table

Screen Shot 2020-11-18 at 4 53 16 PM

Simple small screen index table

Screen Shot 2020-11-18 at 4 48 58 PM

Index table with empty state

Screen Shot 2020-11-18 at 4 49 05 PM

Index table with bulk actions

Screen Shot 2020-11-18 at 4 49 15 PM

Index table with bulk actions across pages

Screen Shot 2020-11-18 at 4 49 24 PM

Index table with loading state

Screen Shot 2020-11-18 at 4 49 28 PM

IndexTable with filtering

Screen Shot 2020-11-18 at 4 49 49 PM

IndexTable with all of its elements

Screen Shot 2020-11-18 at 4 49 55 PM

Small screen IndexTablr with all of its elements

Screen Shot 2020-11-18 at 4 50 05 PM

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2020

🟢 This pull request modifies 30 files and might impact 1 other files.

Details:
All files potentially affected (total: 1)
📄 .storybook/polaris-readme-loader.js (total: 0)

Files potentially affected (total: 0)

📄 locales/cs.json (total: 0)

Files potentially affected (total: 0)

📄 locales/da.json (total: 0)

Files potentially affected (total: 0)

📄 locales/de.json (total: 0)

Files potentially affected (total: 0)

📄 locales/en.json (total: 0)

Files potentially affected (total: 0)

📄 locales/es.json (total: 0)

Files potentially affected (total: 0)

📄 locales/fi.json (total: 0)

Files potentially affected (total: 0)

📄 locales/fr.json (total: 0)

Files potentially affected (total: 0)

📄 locales/it.json (total: 0)

Files potentially affected (total: 0)

📄 locales/ja.json (total: 0)

Files potentially affected (total: 0)

📄 locales/ko.json (total: 0)

Files potentially affected (total: 0)

📄 locales/nb.json (total: 0)

Files potentially affected (total: 0)

📄 locales/nl.json (total: 0)

Files potentially affected (total: 0)

📄 locales/pl.json (total: 0)

Files potentially affected (total: 0)

📄 locales/pt-BR.json (total: 0)

Files potentially affected (total: 0)

📄 locales/pt-PT.json (total: 0)

Files potentially affected (total: 0)

📄 locales/sv.json (total: 0)

Files potentially affected (total: 0)

📄 locales/th.json (total: 0)

Files potentially affected (total: 0)

📄 locales/tr.json (total: 0)

Files potentially affected (total: 0)

📄 locales/vi.json (total: 0)

Files potentially affected (total: 0)

📄 locales/zh-CN.json (total: 0)

Files potentially affected (total: 0)

📄 locales/zh-TW.json (total: 0)

Files potentially affected (total: 0)

🧩 src/components/IndexProvider/IndexProvider.tsx (total: 1)

Files potentially affected (total: 1)

🧩 src/components/IndexProvider/index.ts (total: 1)

Files potentially affected (total: 1)

🧩 src/components/IndexProvider/tests/IndexProvider.test.tsx (total: 0)

Files potentially affected (total: 0)

🎨 src/components/IndexTable/IndexTable.scss (total: 1)

Files potentially affected (total: 1)

🧩 src/components/IndexTable/IndexTable.tsx (total: 0)

Files potentially affected (total: 0)

📄 src/components/IndexTable/README.md (total: 0)

Files potentially affected (total: 0)

🧩 src/components/IndexTable/components/Cell/Cell.tsx (total: 1)

Files potentially affected (total: 1)

🧩 src/components/IndexTable/components/Cell/index.ts (total: 1)

Files potentially affected (total: 1)

@@ -72,7 +72,7 @@ $loading-panel-height: rem(53px);

.LoadingPanelText {
margin-left: rem(12px);
color: var(--p-text-highlight, color('teal', 'dark'));
color: var(--p-text, color('teal', 'darker'));
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to adjust colors to meet contrast requirements. We'll want to take a look at making --p-text-highlight accessible.

@AndrewMusgrave
Copy link
Member Author

Other accessibility tests are fixed in : #3651

@AndrewMusgrave AndrewMusgrave added the 🤖Skip Changelog Causes CI to ignore changelog update check. label Nov 20, 2020
@@ -138,8 +138,8 @@ import {
Heading,
Icon,
Image,
IndexProvider,
IndexTable,
UnstableIndexProvider as IndexProvider,
Copy link
Member Author

Choose a reason for hiding this comment

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

Commit adding unstable prefix

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about this being marked "unstable" again. What would it take for us to consider this stable and be confident in this being a v1 of the component? We have been running this in production now for quite some time, it seems like from a stability perspective we should be confident at this point.

Copy link
Member Author

Choose a reason for hiding this comment

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

The instability is regarding the API since we've never revisited it. I was hoping to take a look at it this week but didn't have the chance. I'm going on vacation but ill take a look when I'm back and see if we can resolve the API

@@ -194,7 +194,7 @@ import {
UnstyledLink,
VisuallyHidden,
VideoThumbnail,
useIndexResourceState,
useIndexResourceStateUnstable as useIndexResourceState,
Copy link
Member Author

Choose a reason for hiding this comment

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

Used suffix for the hook - since hooks always start with use as per convention

@AndrewMusgrave AndrewMusgrave changed the title [WIP][Index] Migrate #2 [IndexProvider/Table] Migrate from web - take 2 Nov 20, 2020
@AndrewMusgrave AndrewMusgrave marked this pull request as ready for review November 20, 2020 16:38
@@ -117,6 +117,28 @@
"Icon": {
"backdropWarning": "The {color} icon doesn’t accept backdrops. The icon colors that have backdrops are: {colorsWithBackDrops}"
},
"IndexProvider": {
"defaultItemSingular": "Item",
Copy link
Contributor

Choose a reason for hiding this comment

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

Poorly localized source string detected

List of problems detected:

  • Key Polaris.IndexProvider.defaultItemSingular contains the word singular. While this in itself is not an issue, it is a good indicator that you should be making use of the pluralization subkeys one and other instead (see String Externalization Guide).

Questions about these messages? Hop in the #help-i18n-and-translation Slack channel.

@@ -117,6 +117,28 @@
"Icon": {
"backdropWarning": "The {color} icon doesn’t accept backdrops. The icon colors that have backdrops are: {colorsWithBackDrops}"
},
"IndexProvider": {
"defaultItemSingular": "Item",
"defaultItemPlural": "Items",
Copy link
Contributor

Choose a reason for hiding this comment

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

Poorly localized source string detected

List of problems detected:

  • Key Polaris.IndexProvider.defaultItemPlural contains the word plural. While this in itself is not an issue, it is a good indicator that you should be making use of the pluralization subkeys one and other instead (see String Externalization Guide).

Questions about these messages? Hop in the #help-i18n-and-translation Slack channel.

@@ -138,8 +138,8 @@ import {
Heading,
Icon,
Image,
IndexProvider,
IndexTable,
UnstableIndexProvider as IndexProvider,
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about this being marked "unstable" again. What would it take for us to consider this stable and be confident in this being a v1 of the component? We have been running this in production now for quite some time, it seems like from a stability perspective we should be confident at this point.

src/components/IndexProvider/IndexProvider.tsx Outdated Show resolved Hide resolved
src/components/IndexTable/IndexTable.tsx Outdated Show resolved Hide resolved
src/components/IndexTable/README.md Outdated Show resolved Hide resolved
src/components/IndexTable/README.md Show resolved Hide resolved

### Simple small screen index table

A small screen index table with simple items and no bulk actions, sorting, or filtering.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if rather than having a separate example like this that looks strange when viewed on larger screens, we instead have one example that actually does the responsive switch between the views. I think that would be more helpful to consumers who are trying to wire this up.

Copy link
Member Author

Choose a reason for hiding this comment

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

@umar-k Is adding responsive examples here 🎉

@Alexzanderk
Copy link

@alex-page @dfmcphee @translation-platform Hi guys! How is it going with this PR?

@@ -7,6 +7,13 @@ configure({adapter: new Adapter()});
// Mocks for scrolling
window.scroll = () => {};

window.open = (
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding a mock for window.open

);
}

const mockRenderRow = (item: any) => {
return <Component {...item} key={item.id} />;
};

const mockRenderCondensedRow = (item: any) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding a second renderer to remove the console errors

@@ -41,13 +41,9 @@ describe('<Row />', () => {

it('renders a RowHoveredContext provider', () => {
const row = mountWithTable(
<table>
Copy link
Member Author

Choose a reason for hiding this comment

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

We're already using mountWithTable

@AndrewMusgrave
Copy link
Member Author

@dfmcphee I took a look at Checkbox, Row & Cell.

Row didn't need any changes.

For Cell & Checkbox, I removed the last & sub props since they're not used in production. I changed noPadding to flush to match Modal's API. first has also been removed. The styles are being applied through a selector rather than a second class. Row now renders a checkbox by default, allowing us to remove IndexTable.Checkbox from the API assisting in small screen view creation.

I briefly looked at IndexTable & IndexProvider. I removed onMoreActionPopoverToggle for now till we're more confident about it. On Friday I'm hoping to finish reworking these. I want to take a look changing the sort prop on IndexTable and see if we have a better way of handling it. We can also remove resolveItemId from 'IndexProvider` & I'm thinking we'll be able to combine the components since we don't get a lot of value from having them separate.

What do you think?

@dfmcphee
Copy link
Contributor

That all sounds great to me. I think combining makes sense, at least for consumers right now. It still would be nice to be able to have some of the index logic abstracted from the view for other types in the future (index grid for example). Could we keep the provider but have it automatically included in the table?

@lsit
Copy link
Contributor

lsit commented Jan 20, 2021

Hi! Love this PR! We (Merchandising) have converted Products and Collections to use the IndexTable as well and we've collected some improvements here. If you need help testing or reviewing, I'm sure @xie or I could help out. Thanks for doing this! 🎉

Base automatically changed from master to main January 21, 2021 15:38
@GhostApps
Copy link

Is this going to be in v6?

@AndrewMusgrave
Copy link
Member Author

Hi @GhostApps, this will not be bundled with v6. V6 primarily revolves around design language and accessibility standards (AODA). This change would possibly delay the v6 rollout. Ideally, we'll have this ready shortly after and ship it out in a minor version!

Copy link
Contributor

@umar-k umar-k left a comment

Choose a reason for hiding this comment

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

Component looks really good 👍

I noticed one issue with the horizontal scrollbar during 🎩
It looks like the scrollBarContentStyles doesn't get an updated width when the window is resized. It causes a scrollbar even when it's not needed.

indexTableScrollBar.mov

tableElement.current && tableInitialized
? {
height: '1px',
width: tableElement.current.offsetWidth - SCROLL_BAR_PADDING,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is tableElement.current.offsetWidth supposed to change with every render when the browser is being resized?
It seems to stay the same and might be whats causing the scrollbar issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lhoffbeck Sounds like this might be what you noticed this morning

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that looks exactly like what I was seeing!

Copy link
Member Author

Choose a reason for hiding this comment

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

@umar-k Should be fixed now - here's the commit

@AndrewMusgrave
Copy link
Member Author

We still need 3 required languages to 🚢 however the estimate is that they'll come in over the weekend.

Copy link
Contributor

@umar-k umar-k left a comment

Choose a reason for hiding this comment

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

🎩 'd and looks good to me! 🎉

@AndrewMusgrave AndrewMusgrave merged commit a040dea into main Feb 5, 2021
@AndrewMusgrave AndrewMusgrave deleted the add-unstable-view branch February 5, 2021 20:30
@GhostApps
Copy link

@AndrewMusgrave any chance you know when this will be released? I tried to play with it by pulling latest but couldn't get the playground or building for a consuming project to work so am having to wait for the next official Polaris release

@AndrewMusgrave
Copy link
Member Author

AndrewMusgrave commented Feb 9, 2021

@GhostApps The Polaris team will have more context, but they usually draft a release ~2 weeks. The last one was 11 days ago so it shouldn't be to long until a release

What error were you getting in the playground? Maybe we could sort that out.

@AndrewMusgrave
Copy link
Member Author

If you wanted to create an issue and ping me there I would have happy to answer (so everyone in this pull request doesn't get pinged 😄 )

sylvhama pushed a commit that referenced this pull request Mar 26, 2021
* Initial migration

* Fix differences between web & polaris

* Remove local translations

* Fix styles & add useIndexResourceSelection

* Added more tests

* Docs & fixes & polish

* Fix errors

* Improve loading constrast

* Add unstable prefix

* Rework Checkbox, Row & Cell API

* Remove onMoreActionPopoverToggle

* Change imports to remove circular deps & delete subrow

* Convert indexprovider internals to hooks

* Removed index provider export

* Update docs to exclude indextable

* Apply feedback

* Fix errors & tighten types

* Rebase with main & remove NDL

* Add new known custom property

* Add useIndexResourceSelection tests

* Add more tests

* More tests

* Add tests and remove unused code

* Finish adding test for all reachable code

* Update locales/fi.json

* Update locales/fr.json

* Update locales/zh-TW.json

* Update locales/pt-PT.json

* Update locales/th.json

* Update locales/ja.json

* Update locales/da.json

* Update locales/ko.json

* Update locales/pl.json

* Update locales/it.json

* Update locales/zh-CN.json

* Update locales/sv.json

* Update locales/nb.json

* Update locales/nl.json

* Fix scrollbar issue

* Add known custom property

* Update locales/vi.json

* Update locales/es.json

* Update locales/pt-BR.json

* Update locales/tr.json

* Update locales/de.json

* Update locales/cs.json

Co-authored-by: translation-platform <35075727+translation-platform@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖Skip Changelog Causes CI to ignore changelog update check.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants