chrisgreg / bloom

The opinionated extension to Phoenix core_components
https://bloom-ui.fly.dev
MIT License
323 stars 16 forks source link

sound effect component #7

Closed C-Sinclair closed 1 week ago

C-Sinclair commented 4 months ago

Changes

This PR implements a component for triggering sound effects in the user's browser

Implementation

The UI component itself SoundEffect.sound_effect/1 is a simple button which toggles the user preference for sound effects. The SoundEffect module also exposes a play_sound/1 function, which can be called from the parent Liveview to trigger sounds to be played in a user's browser purely from Elixir land!

Outside of the scope of Bloom, but I'm imagining this component to be hooked up to the consuming app's PubSub system, so this LiveComponent can ping sound effects for users when backend events take place.

[!Note] Storybook does not allow for custom :live_views, so the triggering of sound effects is somewhat limited. You can see that it works by toggling the button itself - the pop.mp3 file will play/