🚀 **Day 9 – Toasts, Laughs & Custom Magic!** 🍞✨

avatar
(Edited)

Hey Hive Community Members! 🐝

Welcome back to my wild ReactJS learning ride 🎢 — and guess what? We’re already on Day 9! If you've missed previous episodes, don't worry. Grab some popcorn 🍿 and catch up with the epic saga below:


📖 ReactJS Journey So Far


🥳 Today's Adventure: Custom Toast Component

As highlighted in earlier posts, there’s a super cool way to show toast messages with the 'sonner' library (link)... But! I created my own Toast component. It's my first React baby—how could I abandon it? 🤣

So, today we jazz things up and show how to customize our own toast messages and style them like a pro. 🧑‍🎨


🖼️ Toasty Visuals

image for toast


💡 Define Custom Enums for Toasts

// ToastType as a string enum
export enum ToastType {
  Error = "error",
  Warning = "warning",
  Info = "info",
  Success = "success"
}

// ToastStyle as a string enum
export enum ToastStyle {
  Regular = "regular",
  Soft = "soft",
  Outline = "outline",
  Dash = "dash"
}

Because when life hands you errors, turn them into enums! 😂


🎨 SVG Icons for Every Occasion

  function errorPath() {
    return <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />;
  }

  function warningPath() {
    return <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
  }

  function successPath() {
    return <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />;
  }

  function infoPath() {
    return <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />;
  }

Why pick one mood when you can have four? 😉


⚙️ Toast Props Ready for Showbiz

type ToastProps = {
  message: string;
  type: ToastType;
  style: ToastStyle;
  show: boolean;
  setShow: React.Dispatch<React.SetStateAction<boolean>>;
};

const Toast: React.FC<ToastProps> = ({ message, type, style, show, setShow }) => {

Toast gets picky: “I want my message! And my style! And my own show!”


🖌️ SVG Rendering, Like a Boss

<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6 shrink-0 stroke-current" fill="none" viewBox="0 0 24 24">
    {path()}
</svg>

Unleashing the right icon for the right moment⏳

🧩 Path Selector – Icon Power!

function path() {
  switch (type) {
    case ToastType.Error: return errorPath();
    case ToastType.Info: return infoPath();
    case ToastType.Warning: return warningPath();
    case ToastType.Success: return successPath();
    default: return successPath();
  }
}

🌈 Dynamic Class Value: Automatic Styling!

<div role="alert" className={`alert ${classValue()} shadow-lg px-4 py-2 rounded-md`}>
function classValue() {
  switch (type) {
    case ToastType.Error: return "alert-error";
    case ToastType.Info: return "alert-info";
    case ToastType.Warning: return "alert-warning";
    case ToastType.Success: return "alert-success";
    default: return "alert-success";
  }
}

🎩 Supercharged Toast Display Styles

function toastStyle() {
  switch (style) {
    case ToastStyle.Dash: return "alert-dash";
    case ToastStyle.Soft: return "alert-soft";
    case ToastStyle.Outline: return "alert-outline";
    case ToastStyle.Regular: return "";
    default: return "";
  }
}

Update toast-alert-jsx

<div role="alert" className={`alert ${classValue()} ${toastStyle} shadow-lg px-4 py-2 rounded-md`}>

🚀 Implement Your Toast! like a boss

<Toast
    message={errorMessage}
    style={toastStyle}
    type={toastType}
    show={showToast}
    setShow={setShowToast}
/>

Here are the sample screenshots from my project to let you know how it looks.

Screenshot 2025-08-02 at 7.59.42 AM.png

Screenshot 2025-08-02 at 7.57.41 AM.png

Now you can send out all the success, error, or info vibes you want!

🥂 Cheers & Closing

That’s it for this post! I hope you had some laughs, learned how to supercharge your own toast component, and got more confident with customizing ReactJS components. 🍻

🌟 Thank you so much for reading my post. More power to Hive Blockchain. More power to Hive community members! Cheers and high fives to YOU for following along. Have a good one! 🚀🎉


📝 Final Note


🚀 My Contributions to ♦️ Hive Ecosystem

ContributionToHiveEcosystem
Hive Witness NodeHive API Node (in progress)3Speak Video Encoder Node Operator (highest number of nodes)3Speak Mobile App Developer
3Speak Podcast App Developer3Speak Shorts App Developer3Speak Support & Maintenance TeamDistriator Developer
CheckinWithXYZHive InboxHiFindHive Donate App
Contributed to HiveAuth Mobile AppEcency ↔ 3Speak IntegrationEcency ↔ InLeo IntegrationEcency ↔ Actifit Integration
Hive Stats AppVote for Witness AppHiveFlutterKitNew 3Speak App

🙌 Support Back

❤️ Appreciate my work? Consider supporting @threespeak & @sagarkothari88! ❤️

VoteForWitness
sagarkothari88@sagarkothari88
threespeak@threespeak



0
0
0.000
6 comments
avatar

Congratulations @sagarkothari88! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You have been a buzzy bee and published a post every day of the week.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Our Hive Power Delegations to the July PUM Winners
Feedback from the August Hive Power Up Day
Hive Power Up Month Challenge - July 2025 Winners List
0
0
0.000
avatar

In the early 1970s, I discovered programming as a hobby. Then it became a small part of my career. And it remains a hobby to this day.

Throughout, I've learned a few programming languages. I've also read a few books, hundreds of magazines, and thousands upon thousands of online pages.

In all that time, I have never been as entertained as I am by this series. And rarely have I learned so much. So I hope that you will continue for many more days.

It's a rare gift for a programmer to be able to explain techniques using meaningful examples that work in the wild. And to be able to do that with humour is something special indeed.

Thank you @sagarkothari88

!BBH

0
0
0.000
avatar

Wow, @keithtaylor, your message really made me smile—thank you so much!

wow

It feels amazing to hear that you enjoyed my series, especially when you’ve read so much about programming over the years. Your kind words inspire me to keep sharing, not just about ReactJS, but all kinds of tech stuff I’m learning.

share

Recently, I tried setting up my own MongoDB server. It was a mix of “this is awesome!” and “wait, why doesn’t it work?” moments. I can’t wait to share that story next—it should be a fun read!

database-docker-self-hosted

Thanks again for your support. I’ll do my best to keep things both helpful and entertaining!

via Inbox

0
0
0.000
avatar

Hello sagarkothari88!

It's nice to let you know that your article will take 11th place.
Your post is among 15 Best articles voted 7 days ago by the @hive-lu | King Lucoin Curator by keithtaylor

You receive 🎖 0.3 unique LUBEST tokens as a reward. You can support Lu world and your curator, then he and you will receive 10x more of the winning token. There is a buyout offer waiting for him on the stock exchange. All you need to do is reblog Daily Report 746 with your winnings.

2.png


Invest in the Lu token (Lucoin) and get paid. With 50 Lu in your wallet, you also become the curator of the @hive-lu which follows your upvote.
Buy Lu on the Hive-Engine exchange | World of Lu created by szejq

If you no longer want to receive notifications, reply to this comment with the word STOP or to resume write a word START

0
0
0.000