Submitted over 2 years ago
Interactive rating component by TailwindCSS and TypeScript
@Md-Raihan-Alam
Design comparison
SolutionDesign
Solution retrospective
This is my first project using typescript and tailwind CSS. Any suggestions is welcom
Community feedback
- @isprutfromuaPosted over 2 years ago
Hi there
Please note the variable declarations. It is better not to use var, it will also be better if you declare the types of these elements.
var intereactiveNumber=document.querySelectorAll(".numbers")!; let mainDiv=document.querySelector('.main')!; var submitBtn=document.querySelector('.sb-btn')!; let updateRatingDiv=document.querySelector('.ratingText')!; let ratingDiv=document.querySelector('.rate')!; var ratingPoint: HTMLInputElement;
It is better not to use any type, especially since you will always have an event target.
element.addEventListener("click",(e: { target: any; })=>{
You don't get an input element here, it's just a number
let targets=e.target.dataset.num as HTMLInputElement;
that would be enough
let targets: number = +e.target.dataset.num
In general, I'll recommend to repeat Javascript Basics Concepts
REgards
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord