Skip to content

Commit

Permalink
change into React Metronome Button
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazingRockStorm committed Aug 16, 2024
1 parent 0b2f6e2 commit ade215a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
13 changes: 13 additions & 0 deletions app/javascript/components/MetronomeButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";

const MetronomeButton = () => {
return (
<div>
<button className='btn btn-primary'>
Start metronome for the song
</button>
</div>
);
}

export default MetronomeButton
3 changes: 2 additions & 1 deletion app/javascript/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { createRoot } from "react-dom/client";
import MetronomeButton from "./MetronomeButton";

const metronome_container = document.getElementById("metronome-button");

Expand All @@ -12,7 +13,7 @@ const metronome_root = createRoot(metronome_container);
document.addEventListener("DOMContentLoaded", () => {
metronome_root.render(
<>
<p className="font-bold">Yay! You're on Rails!</p>
<MetronomeButton />
</>
);
});
7 changes: 1 addition & 6 deletions app/views/songs/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
p
strong Tempo:
= @song.tempo.to_s + ' BPM'
#metronome-button
= tag.div id: 'metronome-button', data: {tempo: @song.tempo}

div[data-controller='metronome']
input[type="hidden" data-metronome-target="bpm" value="#{@song.tempo}"]
input[type="hidden" data-metronome-target="sound" value="#{audio_path('drumsticks.mp3')}"]
= button_tag '', type: 'button', data: { action: 'metronome#handleClick' }, class: 'btn btn-primary'
span[data-metronome-target='tempoButton'] Start metronome for the song
div
strong Lyric:
=< simple_format(@song.lyric)
Expand Down

0 comments on commit ade215a

Please sign in to comment.