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: migrate typography #2677

Merged
merged 20 commits into from
Feb 29, 2024

Conversation

vishvamsinh28
Copy link
Contributor

Desscription : Migration of typography to TS

related #2636

Copy link

netlify bot commented Feb 20, 2024

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ff80aa3
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/65e09730fa31be0008c54926
😎 Deploy Preview https://deploy-preview-2677--asyncapi-website.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.

level?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
textColor?: string;
className?: string;
children: React.ReactNode;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
children: React.ReactNode;
children?: React.ReactNode;

textColor?: string;
fontWeight?: string;
className?: string;
children: React.ReactNode;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
children: React.ReactNode;
children?: React.ReactNode;

href: string;
className?: string;
target?: string;
children: React.ReactNode;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
children: React.ReactNode;
children?: React.ReactNode;

Copy link
Member

@akshatnema akshatnema left a comment

Choose a reason for hiding this comment

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

Hi @vishvamsinh28, kindly use Enums for those values which are constant, instead of comparing it with string. It will be then easier for developers to get those values separately. You can define a separate type declaration file to specify enums for different files of this directory.

Comment on lines 2 to 13
typeStyle?:
| 'heading-xl'
| 'heading-lg'
| 'heading-md'
| 'heading-md-semibold'
| 'heading-sm'
| 'heading-sm-semibold'
| 'heading-xs'
| 'heading-xs-semibold'
| 'body-lg'
| 'body-md'
| 'body-sm';
Copy link
Member

Choose a reason for hiding this comment

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

instead of giving the values in string, you should use the enum property inside typescript.

const classNames = twMerge(`text-secondary-500 underline hover:text-gray-800 font-medium transition ease-in-out duration-300 ${className || ''}`);

return (
<a
Copy link
Member

Choose a reason for hiding this comment

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

We should use link tag also here as previously used in js file

Copy link
Contributor Author

@vishvamsinh28 vishvamsinh28 Feb 22, 2024

Choose a reason for hiding this comment

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

i tried adding that but shows some kind of an error

"Server Error
Error: Invalid with child. Please remove or use .
Learn more: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor"

Copy link
Member

@akshatnema akshatnema Feb 22, 2024

Choose a reason for hiding this comment

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

So, the solution is, replace a with Link tag here and add the same CSS properties inside span as child element.

@vishvamsinh28
Copy link
Contributor Author

@akshatnema @sambhavgupta0705 requested changes have been made

Comment on lines 1 to 22
enum HeadingTypeStyle {
xl = 'heading-xl',
lg = 'heading-lg',
md = 'heading-md',
md_semibold = 'heading-md-semibold',
sm = 'heading-sm',
sm_semibold = 'heading-sm-semibold',
xs = 'heading-xs',
xs_semibold = 'heading-xs-semibold',
body_lg = 'body-lg',
body_md = 'body-md',
body_sm = 'body-sm',
}

enum HeadingLevel {
h1 = 'h1',
h2 = 'h2',
h3 = 'h3',
h4 = 'h4',
h5 = 'h5',
h6 = 'h6',
}
Copy link
Member

Choose a reason for hiding this comment

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

Specify all the enums in different type definition file.

xl = 'heading-xl',
lg = 'heading-lg',
md = 'heading-md',
md_semibold = 'heading-md-semibold',
Copy link
Member

Choose a reason for hiding this comment

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

you should use camelCase naming convention here, because now these are constants and will be used same as variables.

}

return (
<p data-testid="Paragraph-test" className={`${textColor} ${classNames}`}>{children}</p>
Copy link
Member

Choose a reason for hiding this comment

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

Kindly add twMerge in the className here to provide correct classNames.

}

return (
<Tag className={`${textColor} ${classNames}`} id={id}>
Copy link
Member

Choose a reason for hiding this comment

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

Add twMerge here.

@vishvamsinh28
Copy link
Contributor Author

@akshatnema requested changes are made

}

return (
<p data-testid="Paragraph-test" className={twMerge(textColor, classNames)}>{children}</p>
Copy link
Member

Choose a reason for hiding this comment

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

can you please explain this datat-testId

Copy link
Contributor Author

@vishvamsinh28 vishvamsinh28 Feb 27, 2024

Choose a reason for hiding this comment

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

I know it is of no use as of now and I removed it when I created the components. However, once the migration for all components is completed, we will add tests, so I left the data-testid as it. Should I remove it ?

Copy link
Member

Choose a reason for hiding this comment

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

If you are adding data-testid, it's good because later on it will be easier for us to integrate the tests related to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it 😅 let me add it again

@vishvamsinh28
Copy link
Contributor Author

vishvamsinh28 commented Feb 27, 2024

@akshatnema added datatest-id again

Why are tests failing?

@akshatnema
Copy link
Member

Why are tests failing?

Check the logs, you will get your answer 🙂

@vishvamsinh28
Copy link
Contributor Author

vishvamsinh28 commented Feb 29, 2024

@akshatnema , I looked into the logs and tried fixing the errors, but the tests are still failing. I think it's because of some linting issues. can you please have a look at it

@akshatnema
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit b19eab1 into asyncapi:migrate-ts Feb 29, 2024
13 checks passed
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.

4 participants