help w/ mantine notifications
i've got mantine modals working in content.tsx but notifications don't seem to work, probably not mounting them correctly. can anyone provide some help (or code) on how to use mantine notifications in content.tsx [https://mantine.dev/others/notifications/]
here's the modal:
25 Replies
@cooper has reached level 2. GG!
@louis can you please reply with some ideas
@cooper what's the code you're using for notification?
Notifications system
Mantine notifications system
i tried different permutations and combinations, from a simple one liner onclick notification.show
to complex stuff
nothing worked
im probably missing something basic
You're probably not nesting your notification.show within the provider
Basically, try making a component with the notification.show, then insert it as child inside MantineProvider
target _something right?
Do not use the notification.show inside the same component as the provider
_plasmo i think
yeah
_plasmo
or you can prob use the doc root as welli tried that but i am unable to figure it out
can you please send an example?
feel free to base it base it off the modals code
Send me the code you have right now that's attemping to call notifcation.show
i deleted it all and reverted back to modals
i thought that I'll start from scratch sometime later
Is the above your CSUI?
one of the simplest things that i tried:
return (
<>
<button onClick={() => notifications.show({ message: 'Hello' })}>Open notif</button>
</> ); i was like if this didn't work there's something basic that I'm missing this was my content.tsx after imports and defining the function @louis no i am not using mantine provider 😦 is it necessary
</> ); i was like if this didn't work there's something basic that I'm missing this was my content.tsx after imports and defining the function @louis no i am not using mantine provider 😦 is it necessary
I think so - their notification.show function is probably using the provider context to trigger the notification
i also didn't add
<Notifications />
component anywhere
can this be the basic mistake
do i just call it in content.tsx
like just in the first line of return
could this return work?
<MantineProvider withNormalizeCSS withGlobalStyles>
<Notifications />
<button onClick={() => notifications.show({ message: 'Hello' })}>Open notif</button>
</MantineProvider>
<button onClick={() => notifications.show({ message: 'Hello' })}>Open notif</button>
</MantineProvider>
@cooper has reached level 3. GG!
Prob not, try it and see if it works, but I doubt
you need to move the button into another component
what could be better
oh
so a new file -> new components then mount on content tsx?
@louis
You can declare a separate comp in the same file too:
yeah i agree
comps look better in different files though haha,
just semantics i guess
The idea is to test it out
Note that I don't use mantine - the example was contributed by the community
wow thanks!
I'll test this out.
Want to bump this up, as I have a similar issue - and curious if someone has found a fix.
I have a wrapper around my content script that looks like this:
In my content script I have the equivalent of:
The mantine styles have been working flawlessly with the method described in the example / on github.
But for the notifications, not so much. I can see what I assume to be the <Notification /> component in the top left corner of my screen, but triggering notifications does nothing.
The notifications/styles.css file looks like this:
So wouldn't guess there was a need for a overwrite or anything.
I can make a reproducible minimal repo if someone wants to make a go at getting it working!