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

Migrate ButtonBase component to TypeScript #18950

Closed
wants to merge 0 commits into from

Conversation

thebinij
Copy link
Contributor

@thebinij thebinij commented May 2, 2023

Explanation

Closes #18886

Manual Testing Steps

No functional changes

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@thebinij thebinij requested a review from a team as a code owner May 2, 2023 13:17
@github-actions
Copy link
Contributor

github-actions bot commented May 2, 2023

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@thebinij
Copy link
Contributor Author

thebinij commented May 2, 2023

I have read the CLA Document and I hereby sign the CLA

@georgewrmarshall georgewrmarshall added the team-design-system All issues relating to design system in Extension label May 4, 2023
@georgewrmarshall georgewrmarshall self-requested a review May 5, 2023 00:44
Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Hey @makoto, thanks for your contribution. This is looking really great! I've made some suggestions that weren't outlined in the original issue so my apologies. I'll make sure other issues have been updated with the enum conventions.

/**
* The polymorphic `as` prop allows you to change the root HTML element of the Button component between `button` and `a` tag
*/
as?: ValidTag;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should just limit this to button and a link element cc @garrettbear

type ButtonOrAnchorTag = 'button' | 'a';

ui/components/ui/box/box.d.ts Outdated Show resolved Hide resolved
@thebinij
Copy link
Contributor Author

thebinij commented May 5, 2023

Hi @georgewrmarshall, thanks for the all suggestions! I think I've implemented them correctly. Let me know if there is anything else.

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Hey @thebinij, Looking really good. I left a couple more suggestions thanks!

Comment on lines 12 to 14
SM = 'sm',
MD = 'md',
LG = 'lg',
Copy link
Contributor

Choose a reason for hiding this comment

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

Our enum conventions should use PascalCase for keys too! Sorry some are a little mixed.

Suggested change
SM = 'sm',
MD = 'md',
LG = 'lg',
Sm = 'sm',
Md = 'md',
Lg = 'lg',

@@ -290,7 +290,7 @@ export interface BoxProps extends React.HTMLAttributes<HTMLElement> {
* Use TEXT_ALIGN const from '../../../helpers/constants/design-system';
* Accepts responsive props in the form of an array.
*/
textAlign?: BoxTextAlign | BoxTextAlignArray;
textAlign?: BoxTextAlign | BoxTextAlignArray | TextAlign;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh I think Box still uses the deprecated version of TextAlign. Would you be able to update it to use the TextAlign enum and remove instances of TEXT_ALIGN Similar to other enums in the file

Create new type

export type TextAlignArray = [
  TextAlign,
  TextAlign?,
  TextAlign?,
  TextAlign?,
];

Then you should be able to remove the old types

export type BoxTextAlign = (typeof TEXT_ALIGN)[keyof typeof TEXT_ALIGN] | null;
export type BoxTextAlignArray = [
  BoxTextAlign,
  BoxTextAlign?,
  BoxTextAlign?,
  BoxTextAlign?,
];
Suggested change
textAlign?: BoxTextAlign | BoxTextAlignArray | TextAlign;
textAlign?: TextAlign | TextAlignArray;

yarn.lock Outdated
checksum: bc8ab55cd194e240152946b54bfaff7456180cc018674fc7ed134f4f502192405f6643f422feaa0a5e7cc02b5bac564cfac7771ac6d29f5d129482fcfe335ba1
version: 1.0.30001482
resolution: "caniuse-lite@npm:1.0.30001482"
checksum: a5f7681c860a29736f29350ebd81041c40b6aa7b2f94c50ed27284a0507e46dc79536dcfc05432504cfc80a0bf2070e4ad6fa704a9c0f3f32d47bed9059e98c2
languageName: node
linkType: hard

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm shouldn't be any changes to this file can you please revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I didn't know . Okay sure.

@thebinij thebinij closed this May 9, 2023
@thebinij thebinij force-pushed the #18886-Migrate-ButtonBase branch from 3e6362e to 124678e Compare May 9, 2023 09:52
@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external-contributor stability team-design-system All issues relating to design system in Extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate components to TS: ButtonBase
2 participants