FastHTML MonsterUI example app that uses Tone.js to make different alarm clock sounds.
The backstory: I've been adjusting my sleep schedule to match up better with my coworkers. This afternoon I found myself quite sleepy at the wrong time. I made this as a little utility for myself.
## Setup
```python
from fasthtml.common import *
from fasthtml.jupyter import *
from monsterui.all import *
```
Click on the first 3 to play their sounds, and "Stop" to stop:
```python
HTMX(index)
```
At this point I have clickable `Li` elements with `onmousedown` handlers. I could call this done if my goal is just to play different alarm clock sounds.
## Better Alarm Display
Let's take it up a level with UI improvements with MonsterUI.
```python
alarms[0]
```
```python
Card?
```
```python
c = Card((Img(alarms[0][1])), header=H2(alarms[0][0]), onmousedown=f"{alarms[0][2]}()")
c
```
```python
show(c)
```
Note: It would be nice if the card looked like a MonsterUI card here, so I could build them up cell by cell. Instead let's look at it by redefining the index handler.
```python
@rt
def index():
return Titled("Alarm Clock Sounds",
*[AlarmCard(a) for a in alarms], Script(sounds_js))
```
```python
HTMX(index)
```
```python
@rt
def index():
return Titled("Alarm Clock Sounds",
*[AlarmCard(a) for a in alarms],
Card("Stop the current alarm", header=H2("STOP"), onmousedown="stopCurrentSound()"),
Script(sounds_js))
```
```python
HTMX(index)
```
```python
@rt
def index():
return Titled("Alarm Clock Sounds",
DivFullySpaced(
*[AlarmCard(a) for a in alarms],
Card("Stop the current alarm", header=H2("STOP"), onmousedown="stopCurrentSound()"),
),
Script(sounds_js))
```
```python
HTMX(index)
```
```python
@rt
def index():
return Titled("Alarm Clock Sounds",
DivFullySpaced(
Div(
*[AlarmCard(a) for a in alarms],
),
Card("Stop the current alarm", header=H2("STOP"), onmousedown="stopCurrentSound()"),
),
Script(sounds_js))
```