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 remaining design system constants to enums #19133

Merged
merged 1 commit into from
May 17, 2023

Conversation

nazrul7711
Copy link
Contributor

@nazrul7711 nazrul7711 commented May 15, 2023

Explanation

Currently there are some remaining design system constants that need to be migrated to enums. This PR creates enums for the remaining constants. It also deprecates the constants in favour of the enums and points to a good first issue to encourage contributors to replace them.

  • Enums for design system constants DISPLAY, FLEX_DIRECTION, FLEX_WRAP, BLOCK_SIZES, SEVERITIES have been created
  • Box component, documentation and tests updated to favour enums but support constants through unit testing
  • Deprecation JSDoc notices added so strike through appears in VS Code as well as good first issue to replace deprecated constants Replace deprecated constants with enums #18714 (Will add constants in the PR once it's merged)
  • Fixes: Migrate remaning design system consts to enums #19130

Screenshots/Screencaps

Before

before.mov

After

after.mov

Manual Testing Steps

  • Pull this branch
  • Do a search of the code base for any of the deprecated constants DISPLAY, FLEX_DIRECTION, FLEX_WRAP, BLOCK_SIZES, SEVERITIES
  • Ensure you have the correct VS Code settings enabled for deprecation indicators
  • Check that each constant is deprecated according to JSDoc format

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.

@nazrul7711 nazrul7711 requested a review from a team as a code owner May 15, 2023 09:21
@nazrul7711 nazrul7711 requested a review from hmalik88 May 15, 2023 09:21
@github-actions
Copy link
Contributor

github-actions bot commented May 15, 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.

@nazrul7711
Copy link
Contributor Author

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

@socket-security
Copy link

socket-security bot commented May 15, 2023

No dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No dependency changes detected in pull request

Pull request alert summary
Issue Status
Critical CVE ✅ 0 issues
CVE ✅ 0 issues
Mild CVE ✅ 0 issues
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script confusion ✅ 0 issues
Bin script shell injection ✅ 0 issues
Filesystem access ✅ 0 issues
Network access ✅ 0 issues
Shell access ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
GitHub dependency ✅ 0 issues
No bug tracker ✅ 0 issues
No contributors or author data ✅ 0 issues
No README ✅ 0 issues
Deprecated ✅ 0 issues
New author ✅ 0 issues
Unstable ownership ✅ 0 issues
Non-existent author ✅ 0 issues
Unmaintained ✅ 0 issues
Unpublished package ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
AI detected security risk ✅ 0 issues
AI warning ✅ 0 issues

@georgewrmarshall georgewrmarshall added the team-design-system All issues relating to design system in Extension label May 15, 2023
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 @nazrul7711, thanks for your contribution. This is looking really great! I've left a few small suggestions. It would also be great if you could update the PR description according to the template provided. This really helps with review.

I wasn't sure if we would have to update the box.d.ts file with a union type of the Display enum as well as the DISPLAY const? There doesn't seem to be any errors in the TypeScript files I was looking at which I found interesting I suppose because it is just looking for the string or an array of strings.

yarn.lock Outdated Show resolved Hide resolved
ui/helpers/constants/design-system.ts Outdated Show resolved Hide resolved
ui/helpers/constants/design-system.ts Show resolved Hide resolved
ui/components/ui/box/box.js Outdated Show resolved Hide resolved
@georgewrmarshall georgewrmarshall requested review from garrettbear and removed request for hmalik88 May 15, 2023 22:40
@nazrul7711
Copy link
Contributor Author

hi @georgewrmarshall I have made the modifications , kindly review it.

@nazrul7711 nazrul7711 changed the title design systems constants DISPLAY FLEX_DIRECTION FLEX_WRAP BLOCKSIZES … design systems constants DISPLAY FLEX_DIRECTION FLEX_WRAP BLOCKSIZES …. Fixes: #19130 May 16, 2023
yarn.lock Outdated Show resolved Hide resolved
@georgewrmarshall georgewrmarshall changed the title design systems constants DISPLAY FLEX_DIRECTION FLEX_WRAP BLOCKSIZES …. Fixes: #19130 Migrate remaining design system constants to enums May 17, 2023
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 @nazrul7711, I've updated the PR title and description so the PR is a little more clear. Some of it was still commented out. I've also realized that I missed SEVERITIES in the issue(now updated). Could you also create an enum for Severity. I don't think we need one for RESIZE as it's used for a single component that will likely be migrated to TypeScript and have it's own types.

ui/components/component-library/tag-url/tag-url.js Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
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 @nazrul7711, I rebased this PR to remove the yarn.lock changes and made sure that the deprecated constants still work by keeping the unit tests for them. This was kind of blocking some other TS migration work so I really appreciate your timing on this and hope you don't mind my updates. LGMT 🔥

@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Merging #19133 (7ade917) into develop (aa9ee8a) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop   #19133      +/-   ##
===========================================
- Coverage    69.54%   69.53%   -0.01%     
===========================================
  Files          960      960              
  Lines        36583    36583              
  Branches      9493     9493              
===========================================
- Hits         25439    25437       -2     
- Misses       11144    11146       +2     
Impacted Files Coverage Δ
ui/helpers/constants/design-system.ts 100.00% <ø> (ø)
ui/components/ui/box/box.js 98.68% <100.00%> (ø)

... and 2 files with indirect coverage changes

@brad-decker brad-decker merged commit 9ef9327 into MetaMask:develop May 17, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external-contributor 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 remaning design system consts to enums
3 participants