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

refactor(typescript): Convert TableHead, TableHeader to tsx #13367

Merged
merged 11 commits into from
Mar 23, 2023

Conversation

pratikkarad
Copy link
Contributor

Closes #12527, #12528

Converts TableHead and TableHeader to tsx in preparation for the main Table conversion

Changelog

Changed

  • Converted TableHead.js -> TableHead.tsx
  • Converted TableHeader.js -> TableHeader.tsx

Testing / Reviewing

To verify these changes are working, we can check to see if the existing storybook behavior is still working correctly. Should be able to properly import converted components in a TS environment

@pratikkarad pratikkarad requested a review from a team as a code owner March 17, 2023 08:51
@netlify
Copy link

netlify bot commented Mar 17, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 1914fb7
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/641b9cec4f4716000808a92b
😎 Deploy Preview https://deploy-preview-13367--carbon-elements.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 settings.

Copy link
Collaborator

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together @pratikkarad! Just one change request regarding the thead interface. also looks like some of the CI checks are failing

packages/react/src/components/DataTable/TableHead.tsx Outdated Show resolved Hide resolved
@@ -91,7 +158,7 @@ const TableHeader = React.forwardRef(function TableHeader(
[`${prefix}--table-sort--descending`]:
isSortHeader && sortDirection === sortStates.DESC,
});
const ariaSort = !isSortHeader ? 'none' : sortDirections[sortDirection];
const ariaSort = !isSortHeader ? 'none' : sortDirection ? sortDirections[sortDirection] : sortDirections[sortStates.NONE];
Copy link
Contributor Author

@pratikkarad pratikkarad Mar 17, 2023

Choose a reason for hiding this comment

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

I observed It is still failing here. I tried debugging but got no luck. Any help or suggestion is appreciated. 😃

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's change this line to const ariaSort = (!isSortHeader || !sortDirection) ? 'none' : sortDirections[sortDirection];

and change the type of sortDirections in the top to

const sortDirections: {[key: string]: 'none' | 'ascending' | 'descending'} = {
  [sortStates.NONE]: 'none',
  [sortStates.ASC]: 'ascending',
  [sortStates.DESC]: 'descending',
};

That should fix this issue

Copy link
Contributor Author

@pratikkarad pratikkarad left a comment

Choose a reason for hiding this comment

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

Hi @francinelucca, I'm facing a problem with declaring the static properties on the functional component in typescript.
For eg.
TableHeader.translationKeys = Object.values(translationKeys);
In TableHeader, translationKeys is giving the compilation error.
I tried creating a separate type as suggested on StackOverflow/blogs, but still got no luck.

@francinelucca
Copy link
Collaborator

Hi @francinelucca, I'm facing a problem with declaring the static properties on the functional component in typescript. For eg. TableHeader.translationKeys = Object.values(translationKeys); In TableHeader, translationKeys is giving the compilation error. I tried creating a separate type as suggested on StackOverflow/blogs, but still got no luck.

can you try doing (TableHeader as any).translationKeys = Object.values(translationKeys);

@netlify
Copy link

netlify bot commented Mar 22, 2023

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f6dd2a6
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/641b2e2dc64cf40007db778c
😎 Deploy Preview https://deploy-preview-13367--carbon-components-react.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 settings.

@netlify
Copy link

netlify bot commented Mar 22, 2023

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1914fb7
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/641b9ceca6a1e50008e6dbde
😎 Deploy Preview https://deploy-preview-13367--carbon-components-react.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 settings.

@kodiakhq kodiakhq bot merged commit 9cc6a01 into carbon-design-system:main Mar 23, 2023
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.

Add TypeScript types to TableHead
3 participants