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(dataspreadsheet): optional custom component to row header #5500

Conversation

AustinGitHub
Copy link
Contributor

@AustinGitHub AustinGitHub commented Jun 13, 2024

Closes #5253

What did you change?

Allow users to pass through their own custom component to the data spreadsheet table on column 0. So user can pass through icons, button, menu list, etc.

This component is also directional so user can specify Left or Right to determine which side they want the action to be.

I also created new story for this feature.

How did you test and verify your work?

Storybook

Screen.Recording.2024-06-13.at.11.20.41.AM.mov

The width of the column 0 also scales with the number we put in to render so there shouldn't be any overflow issues.

Screen.Recording.2024-06-13.at.11.22.47.AM.mov

@AustinGitHub AustinGitHub requested a review from a team as a code owner June 13, 2024 18:23
@AustinGitHub AustinGitHub requested review from davidmenendez and annawen1 and removed request for a team June 13, 2024 18:23
Copy link

netlify bot commented Jun 13, 2024

Deploy Preview for carbon-for-ibm-products ready!

Name Link
🔨 Latest commit e898316
🔍 Latest deploy log https://app.netlify.com/sites/carbon-for-ibm-products/deploys/666b39287d0e5a000843d245
😎 Deploy Preview https://deploy-preview-5500--carbon-for-ibm-products.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AustinGitHub
Copy link
Contributor Author

AustinGitHub commented Jun 13, 2024

Please let me know if there is better way to name the variables and descriptions. I was unsure on those, thanks!

Confirmed with my teams UX that this is good for us.

Copy link

netlify bot commented Jun 13, 2024

Deploy Preview for carbon-for-ibm-products ready!

Name Link
🔨 Latest commit 17e0c31
🔍 Latest deploy log https://app.netlify.com/sites/carbon-for-ibm-products/deploys/667a494cc20cfa0008df55fd
😎 Deploy Preview https://deploy-preview-5500--carbon-for-ibm-products.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@davidmenendez
Copy link
Contributor

@AustinGitHub thanks for the submission. i'll need to confirm with design that this enhancement is acceptable.

@davidmenendez
Copy link
Contributor

oh ok i see it under the usage guidelines. i'll go through the code now 👍

data={data}
onDataUpdate={setData}
rowNumberingComponentPosition="Left"
rowNumberingComponent={buildComponent}
Copy link
Contributor

Choose a reason for hiding this comment

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

i think rowNumberingComponent is a tad bit confusing. i think that because the documentation specifies usage of overflow menu that maybe we do an implementation where the API is called rowActions which accepts an array of actions that can be mapped over internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So does the documentation specify it has to be overflow menu? I have it set so user provides custom component so it could be icon, button, or overflow menu.

Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2024-06-17 at 1 02 33 PM

it's a bit hard to find because it's nested under an accordion, but it seems like it's mostly targeted towards overflow usage.

actually looking at this more i think maybe this should be set in the columns API. something like

const columnData = [
  {
    Header: 'Row Index',
    headerActions: [{ label: 'delete', onClick: () => {} }, ...],
    accessor: (row, index) => index,
...

let me pull in @matthewgallo on this since he's much more familiar with this component and i'd like to get his take on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

after talking it over with @matthewgallo we think that a new prop called renderHeaderOverflow would work for this. the only main change we'd like to see is that this overflow is also accessible in the column header as per the usage guidelines. the prop could also provide a callback that distinguishes between a row and column header in case a separate set of actions are required for rows and columns. does that make sense?

Copy link
Contributor Author

@AustinGitHub AustinGitHub Jun 17, 2024

Choose a reason for hiding this comment

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

Result

Screenshot 2024-06-17 at 11 44 27 AM

Edit: I will discuss with Matt to see what should be done. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @davidmenendez I discussed with Matt on this with some back and forth to get understanding.

Currently, with column headers user can already provide custom component to it as with the example I provided above with how we have this in our code right now.

For row headers on the row indexing numbering column there is no user control on this as it is hardcoded in. I explained to Matt how it is easier for Developer to provide their own custom component such as the overflow menu and if that menu has action events, it is easier for us to handle these action events rather than having to try and get them sorted through carbon products.

The changes I will be making is renaming the components to something more understandable like renderRowHeader and renderRowHeaderDirection. I'll also double check with the carbon guidelines, but storybook does have it's own section showing user how to utilize this feature and example is going to be using the overflowmenu.

In future, if this is wanting to be changed around then that is fine but for now since column headers is already customizable, rather than making this not customizable and forcing it to be a pure string and having separate way of adding component. It is easier for now to leave it as is to avoid regressions.

Any thoughts on this?

I will update the PR in a bit with renaming the variables. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

this sounds good to me. if @matthewgallo has any questions or concerns i'll leave it up to him to post them here.

Copy link
Member

@matthewgallo matthewgallo Jun 17, 2024

Choose a reason for hiding this comment

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

Sounds like a plan for now, this way we don't interfere with any existing functionality (ie column headers already being able to be customized). 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks everyone, will leave a comment once I have the PR updated.

@AustinGitHub
Copy link
Contributor Author

Updated the variable names, thanks!

Copy link
Contributor

@davidmenendez davidmenendez left a comment

Choose a reason for hiding this comment

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

looking good! just have one small comment. also, if you could include a unit test for this new feature that would be much appreciated.

@elycheea elycheea added the status: needs design review 🎨 Component is ready for design review label Jun 18, 2024
@elycheea elycheea changed the title feat(dataspreadsheet): optional custom component to column 0 feat(dataspreadsheet): optional custom component to row header Jun 18, 2024
@matthewgallo
Copy link
Member

matthewgallo commented Jun 21, 2024

Hey @AustinGitHub, one of the main pieces of design feedback is that the overflow menu should be square (32x32).

@AustinGitHub
Copy link
Contributor Author

Sure, I will take a look today

@AustinGitHub
Copy link
Contributor Author

Hi @matthewgallo since this is an optional component it is up to user to defined the width and height. I added the change but since this is optional component, it would be up to dev that provides component to add their own stylings to the component. But for storybook I put it to 32x32. Thanks!

Copy link
Contributor

@davidmenendez davidmenendez left a comment

Choose a reason for hiding this comment

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

LGTM

@matthewgallo matthewgallo added this pull request to the merge queue Jun 25, 2024
Merged via the queue into carbon-design-system:main with commit ee749e4 Jun 25, 2024
17 checks passed
@AustinGitHub AustinGitHub deleted the dataspreadsheet_custom_component branch June 25, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs design review 🎨 Component is ready for design review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: DataSpreadsheets: Add way to add custom actions to row index cell
4 participants