Skip to content
Submitted over 1 year ago

Interactive Pricing Components using NextJS and Typescript

next, tailwind-css, typescript, material-ui
LVL 1
@shreyansh1410
A solution to the Interactive pricing component challenge

Solution retrospective


What are you most proud of, and what would you do differently next time?

I'm happy with how the pricing page's background turned out - the subtle grid pattern and soft glow effects add depth without getting in the way of the pricing information. Looking at the code in PricingComponent.tsx, you can see this in the SimpleAnimatedBackground component that uses basic opacity and masking.

If I did this project again, I would:

  • Make the theme colours easier to change - right now they're all individual variables in globals.css
  • Create separate components for animations instead of putting them all in SimpleAnimatedBackground
  • Use CSS custom properties for animations instead of only Tailwind classes
  • Make the slider work better with keyboards and screen readers (the current CustomSlider needs work)
What challenges did you encounter, and how did you overcome them?

The main problem was making sure the animated background didn't interfere with using the pricing slider and buttons. After some trial and error, I:

  1. Used z-index in the code to put the background behind everything else
  2. Added pointer-events-none to the background div so clicks would go through to the elements underneath
  3. Turned down the opacity and added blur effects to make the background subtle
  4. Made sure everything still looked good on phones and tablets

Another tricky part was getting the light and dark themes to work properly. Looking at globals.css, you can see I had to carefully pick colours that would work in both modes.

The pricing slider also took some work to get right. I had to make sure it updated the prices smoothly and looked consistent with the rest of the design.

What specific areas of your project would you like help with? Accessibility
  • Better keyboard support for the slider (right now it's just mouse/touch)
  • Making sure the color contrast is good enough
  • Adding proper screen reader labels
Performance
  • Reducing the amount of CSS
  • Making the animations smoother
  • Finding better ways to load the code
State Management
  • Whether to keep using local state (useState) or switch to something else
  • How to organize the code if we add user accounts or more pricing plans
Testing
  • Setting up testing tools
  • Writing tests for the pricing calculations
  • Testing that the theme switcher and slider work correctly

Looking at PricingComponent.tsx, there's no testing set up yet, and the accessibility features are pretty basic. These would be the most important areas to improve.

Code
Loading...

Please log in to post a comment

Log in

Community feedback

No feedback yet. Be the first to give feedback on Shreyansh Shukla’s solution.

Join 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