From 91de25acaf5048971a23c4b7eddcf6175e0aa87f Mon Sep 17 00:00:00 2001 From: Marie Holen Danielson Date: Mon, 7 Sep 2026 12:02:07 +0200 Subject: [PATCH 1/3] Implementert bla frem og tilbake --- src/App.tsx | 14 +++++++++++--- src/components/Navigation.tsx | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index c68e3e9..5faf4d3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,11 +5,14 @@ import { SongList } from './components/SongList' import { FilterSortBar } from './components/FilterSortBar' import { songs } from './data/songs' import './App.css' +import { useState } from "react"; function App() { const handleSelectSong = (song: (typeof songs)[number]) => { console.log('Valgt sang:', song) } + const [currentSongIndex, setCurrentSongIndex] = useState(0) + const currentSong = songs[currentSongIndex] return (
@@ -26,9 +29,14 @@ function App() {
- - - + + + setCurrentSongIndex(currentSongIndex - 1)} + onNext={() => setCurrentSongIndex(currentSongIndex + 1)} + />
diff --git a/src/components/Navigation.tsx b/src/components/Navigation.tsx index e5d001b..dd70e01 100644 --- a/src/components/Navigation.tsx +++ b/src/components/Navigation.tsx @@ -1,15 +1,18 @@ type NavigationProps = { isFirst: boolean isLast: boolean + onPrevious: () => void + onNext: () => void } -export function Navigation({isFirst, isLast}: NavigationProps) { +export function Navigation({isFirst, isLast, onPrevious, onNext}: NavigationProps) { return (