Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Your session has expired please log in again.

Submitted

Calculator App - Next13, TypeScript, Zustand & TailwindCSS

frbarbre 660

@frbarbre

Desktop design screenshot for the Calculator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
3intermediate
View challenge

Design comparison


SolutionDesign

Solution retrospective


This was a fun one! A nice break from building conventional websites. Learned alot of logic. However building the themeProvider was a bit tedious because of the enormous amount of colours that changes.

Community feedback

@fazzaamiarso

Posted

Hi @frbarbre! Nice Solution!

I have some suggestion for you:

  • You can reduce nesting when writing logic using Guard Clause.
 function handleEquals() {
    if(secondArg.content === "") return; // ✅ Guard clause
    if(result) calculate(result, secondArg.content, operator, setResult)
    else  calculate(firstArg.content, secondArg.content, operator, setResult);

    softReset();
  }
  • For button component, rather than passing custom style as props to create variation, you can define the styles variation inside the button component. Example:
type Variant = "equal" | "delete" | "reset"';

const variantStyles = {
equal : { bgColorDark : "", bgColorLight: "" , //...},
// ...other styles
}

export default function Button({
  handleClick,
  text,
  gridArea,
  operator,
  type,
  variant, // Receive variant instead👍
  hasSmallFont,
}: Props) {

I hope it helps! Cheers!

Marked as helpful

1

Please log in to post a comment

Log in with GitHub
Discord logo

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