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

Update Text to use TS version of Box #19572

Closed
wants to merge 1 commit into from

Conversation

georgewrmarshall
Copy link
Contributor

@georgewrmarshall georgewrmarshall commented Jun 12, 2023

Explanation

Currently the Text component still uses the JS version of the Box component and blocks TypeScript migration. This PR updates the Text component to use the TS version of the Box component. I've also added a few Before/After screenshots in the code comments to ensure no visual regression

Screenshots/Screencaps

Before

Showing original Text component in storybook to show no visual regressions

before.mov

After

Showing updated Text component in storybook using the TS version of the Box component. Showing no visual regressions and all stories and controls are working as expected. I have made some small updates to more easily find the replace Typography with Text section and linked the issue

after.mov

Manual Testing Steps

  • I've added a few screenshots in the code comments to show no visual regressions between develop and the updates in this PR

To check storybook

  • Go to the latest build of storybook in this PR
  • Search Text in the search panel
  • Check the controls, stories and docs are working as expected.

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.

@github-actions
Copy link
Contributor

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.

@@ -91,15 +91,15 @@ BannerBase.propTypes = {
/**
* Additional props to pass to the `Text` component used for the `title` text
*/
titleProps: PropTypes.shape(Text.PropTypes),
titleProps: PropTypes.object,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately using Text.propTypes breaks so need to update proptypes to use generic object while during our migration process

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a task captured for returning to PropTypes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a particular issues addressing the propTypes but is it possible to use types from a TypeScript component with PropTypes. The issue that would fix this in future ins the migration of the component to TypeScript

@@ -33,6 +33,7 @@ $text-variants: (
color: var(--color-text-default);
font-family: var(--font-family-sans);

&:is(strong),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating so it's based on CSS not a prop

@georgewrmarshall georgewrmarshall self-assigned this Jun 12, 2023
@georgewrmarshall georgewrmarshall added the team-design-system All issues relating to design system in Extension label Jun 12, 2023
@@ -6,7 +6,7 @@ exports[`Beta Header should match snapshot 1`] = `
class="box beta-header box--padding-2 box--display-flex box--flex-direction-row box--align-items-center box--width-full box--background-color-warning-default"
>
<h6
class="box mm-text beta-header__message mm-text--body-sm box--flex-direction-row box--color-warning-inverse"
class="mm-box mm-text beta-header__message mm-text--body-sm mm-box--color-warning-inverse"
>
<span>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-06-12 at 1 19 38 PM Screenshot 2023-06-12 at 1 35 23 PM

@georgewrmarshall georgewrmarshall force-pushed the fix/19569/update-text-with-ts-box branch from f99f22f to 66a9dc5 Compare June 13, 2023 15:14
@georgewrmarshall georgewrmarshall added the DO-NOT-MERGE Pull requests that should not be merged label Jun 13, 2023
@georgewrmarshall georgewrmarshall force-pushed the fix/19569/update-text-with-ts-box branch from 66a9dc5 to 0339946 Compare June 13, 2023 20:56
>
<span>

This allows the third party to spend
<h6
class="box mm-text custom-spending-cap__input-value-and-token-name mm-text--body-sm-bold box--flex-direction-row box--color-text-default"
class="mm-box mm-text custom-spending-cap__input-value-and-token-name mm-text--body-sm-bold"
>
10

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-06-13 at 2 01 29 PM Screenshot 2023-06-13 at 2 02 12 PM

>
<span>
<button
class="box mm-text mm-button-base mm-button-link mm-button-link--size-auto mm-text--body-md mm-text--text-align-left box--display-inline-flex box--flex-direction-row box--justify-content-center box--align-items-center box--color-primary-default box--background-color-transparent"
class="mm-box mm-text mm-button-base mm-button-link mm-button-link--size-auto mm-text--body-md mm-text--text-align-left mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
>
Go to full screen to connect your Ledger.
</button>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-06-13 at 2 03 33 PM Screenshot 2023-06-13 at 2 03 49 PM

@@ -54,7 +54,7 @@ exports[`Customize Nonce should match snapshot 1`] = `
>
<h6
boxprops="[object Object]"
class="box mm-text mm-text--body-sm mm-text--font-weight-bold box--flex-direction-row box--color-text-default"
class="mm-box mm-text mm-text--body-sm mm-text--font-weight-bold"
>
Edit nonce
</h6>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-06-13 at 2 04 44 PM Screenshot 2023-06-13 at 2 04 57 PM

>
Cancel
</button>
<button
class="box mm-text mm-button-base mm-button-base--size-lg mm-button-base--disabled mm-button-base--block mm-button-primary mm-button-primary--disabled mm-text--body-md box--padding-right-4 box--padding-left-4 box--display-inline-flex box--flex-direction-row box--justify-content-center box--align-items-center box--color-primary-inverse box--background-color-primary-default box--rounded-pill"
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-base--disabled mm-button-base--block mm-button-primary mm-button-primary--disabled mm-text--body-md mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-inverse mm-box--background-color-primary-default mm-box--rounded-pill"
disabled=""
>
Continue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-06-13 at 2 05 53 PM Screenshot 2023-06-13 at 2 06 08 PM

type="secondary"
>
Cancel
</button>
<button
class="box mm-text mm-button-base mm-button-base--size-lg mm-button-base--disabled mm-button-primary mm-button-primary--disabled mm-text--body-md box--padding-right-4 box--padding-left-4 box--display-inline-flex box--flex-direction-row box--justify-content-center box--align-items-center box--width-1/2 box--color-primary-inverse box--background-color-primary-default box--rounded-pill"
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-base--disabled mm-button-primary mm-button-primary--disabled mm-text--body-md mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--width-1/2 mm-box--color-primary-inverse mm-box--background-color-primary-default mm-box--rounded-pill"
disabled=""
type="primary"
>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-06-13 at 2 07 02 PM Screenshot 2023-06-13 at 2 07 17 PM

/>
</div>
<p
class="box mm-text mm-text--body-md box--flex-direction-row box--color-text-alternative"
class="mm-box mm-text mm-text--body-md mm-box--color-text-alternative"
data-testid="multichain-token-list-item-value"
>
5.000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-06-13 at 2 08 09 PM Screenshot 2023-06-13 at 2 08 23 PM

@georgewrmarshall georgewrmarshall force-pushed the fix/19569/update-text-with-ts-box branch 2 times, most recently from 762ccd7 to c348964 Compare June 13, 2023 21:46
.mm-text {
// Set default styles
color: var(--color-text-default);
Copy link
Contributor Author

@georgewrmarshall georgewrmarshall Jun 13, 2023

Choose a reason for hiding this comment

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

Now that the CSS specificity of the Box has been fixed i.e the order of stylesheets has been updated. We should set the default by the utility prop so it this style doesn't override it

dir={textDirection}
ref={ref}
color={TextColor.textDefault}
{...props} // TODO: Need to fix Box types to allow for spreading props
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still dealing with a TypeScript issue that complains about spreading props. This doesn't effect the functionality of the component and doesn't block the build so I'll create a ticket to look into it. Need some more time to look into it. I think as this doesn't effect anything else we move forward to unblock migration and I'll look into it in a separate issue.

Screenshot 2023-06-13 at 3 02 10 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm why isn't it blocking the build 🤔 type errors should

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible your editor's typescript process was just... slow on reading updates? I don't see the error on my end when I view this file

Comment on lines -63 to +67
* HelpText also accepts all Text and Box props
* HelpText also accepts all Box props
*/
...Text.propTypes,
...Box.propTypes,
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fine and not that someone should be changing the variant but what happens if they do? Would the variant prop error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yes I think this should cause a temporary prop error while this component is still in JS. There is an open contributor PR to migrate it though so once this is merged I can assist with that.

@georgewrmarshall georgewrmarshall force-pushed the fix/19569/update-text-with-ts-box branch 2 times, most recently from 727b6bd to 837b5d2 Compare June 15, 2023 16:03
@georgewrmarshall georgewrmarshall force-pushed the fix/19569/update-text-with-ts-box branch from 80b0251 to f7ce1cf Compare July 10, 2023 21:36
@github-actions github-actions bot locked and limited conversation to collaborators Jul 12, 2023
@DDDDDanica DDDDDanica deleted the fix/19569/update-text-with-ts-box branch December 5, 2023 14:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team-design-system All issues relating to design system in Extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Text component to use TS version of Box
3 participants