forge42dev / remix-toast

Server side implementation of toast notifications in Remix
MIT License
190 stars 11 forks source link

Add description field to ToastMessage #7

Closed boptom closed 8 months ago

boptom commented 10 months ago

Any chance of getting an optional description field in ToastMessage? This will allow descriptions in Sonner.

See here: https://sonner.emilkowal.ski/toast#api-reference

I believe it would require an additional field here: https://github.com/Code-Forge-Net/remix-toast/blob/main/src/schema.ts#L3

export const toastMessageSchema = z.object({
  message: z.string(),
  type: z.custom<"info" | "success" | "error" | "warning">(),
  description: z.string().optional()
});

Thanks!

houmark commented 9 months ago

Yes, that would be nice, and it would be even better with some specific Sonner functions to cover the Sonner API better. In some cases, it would be nice to be able to control for example the duration of the Sonner toast. Currently, you'd have to handle all that client-side, but that becomes more cumbersome if you adapt a root.tsx approach for the Toast component because you'd have to switch the config for the toast based on the origin or content of the message, which feels hacky.

Or going back, re-using existing methods, an option fourth parameter could be used to pass along an object, that can then be consumed in the loader data and used for configuration. In theory that can be done now using the headers, but this also seems hacky at best. This would enable you to pass along runtime configuration to any client-side toast library. It would be pretty straightforward to add and non-breaking.

What do you think @AlemTuzlak?