Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_VERSION=3.0.5
1 change: 0 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"styled-components": "^6.1.0",
"wavesurfer.js": "^7.4.12",
"web-vitals": "^2.1.4",
"wavesurfer-react": "../../wavesurfer-react-artifacts/demo_dist"
Expand Down
6,476 changes: 3,202 additions & 3,274 deletions demo/pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion demo/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
/>
<meta
name="description"
content="Web site created using create-react-app"
Expand All @@ -24,7 +28,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Wavesurfer React - Demo</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file added demo/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions demo/src/App.css

This file was deleted.

121 changes: 80 additions & 41 deletions demo/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ import React, {
useState,
useMemo
} from "react";
import styled from "styled-components";
import { WaveSurfer, WaveForm, Region, Marker } from "wavesurfer-react";
import "./App.css";
import styles from "./App.module.css";
import RegionsPlugin from "wavesurfer.js/dist/plugins/regions";
import TimelinePlugin from "wavesurfer.js/dist/plugins/timeline";

const Buttons = styled.div`
display: inline-block;
`;

const Button = styled.button``;
const APP_LOGO_URL = "/logo.png";
const APP_VERSION = process.env.REACT_APP_VERSION || "3.0.5";

/**
* @param min
Expand Down Expand Up @@ -287,40 +283,83 @@ function App() {
};

return (
<div className="App">
<WaveSurfer plugins={plugins} onMount={handleWSMount} cursorColor="transparent" container="#waveform">
<WaveForm>
{isLoaded && regions.map((regionProps) => (
<Region
onUpdateEnd={handleRegionUpdate}
key={regionProps.id}
{...regionProps}
/>
))}
{isLoaded && markers.map(markerProps => (
<Marker
key={markerProps.id}
onUpdateEnd={handleMarkerUpdate}
start={markerProps.time}
color={markerProps.color}
content={markerProps.label}
drag={markerProps.draggable}
/>
))}
</WaveForm>
<div id="timeline" />
</WaveSurfer>
<Buttons>
<Button onClick={generateRegion}>Generate region</Button>
<Button onClick={generateMarker}>Generte Marker</Button>
<Button onClick={play}>Play / Pause</Button>
<Button onClick={removeLastRegion}>Remove last region</Button>
<Button onClick={removeLastMarker}>Remove last marker</Button>
<Button onClick={shuffleLastMarker}>Shuffle last marker</Button>
<Button onClick={toggleTimeline}>Toggle timeline</Button>
<Button onClick={setZoom50}>zoom 50%</Button>
</Buttons>
</div>
<main className={styles.app}>
<header className={styles.header}>
<div className={styles.brand}>
<img
src={APP_LOGO_URL}
alt="Wavesurfer React logo"
className={styles.logo}
width={56}
height={56}
/>
<div>
<h1 className={styles.title}>Wavesurfer React</h1>
<p className={styles.subtitle}>Interactive regions and markers demo</p>
</div>
</div>
<span className={styles.badge}>v{APP_VERSION}</span>
</header>

<section className={styles.waveformCard}>
<WaveSurfer
plugins={plugins}
onMount={handleWSMount}
cursorColor="transparent"
container="#waveform"
>
<WaveForm className={styles.waveform}>
{isLoaded && regions.map((regionProps) => (
<Region
onUpdateEnd={handleRegionUpdate}
key={regionProps.id}
{...regionProps}
/>
))}
{isLoaded && markers.map((markerProps, index) => (
<Marker
key={`${markerProps.label}-${index}`}
onUpdateEnd={handleMarkerUpdate}
start={markerProps.time}
color={markerProps.color}
content={markerProps.label}
drag={markerProps.draggable}
/>
))}
</WaveForm>
<div id="timeline" />
</WaveSurfer>
</section>

<section className={styles.controls}>
<div className={styles.buttons}>
<button type="button" className={styles.button} onClick={generateRegion}>
Generate region
</button>
<button type="button" className={styles.button} onClick={generateMarker}>
Generate marker
</button>
<button type="button" className={styles.button} onClick={play}>
Play / Pause
</button>
<button type="button" className={styles.button} onClick={removeLastRegion}>
Remove last region
</button>
<button type="button" className={styles.button} onClick={removeLastMarker}>
Remove last marker
</button>
<button type="button" className={styles.button} onClick={shuffleLastMarker}>
Shuffle last marker
</button>
<button type="button" className={styles.button} onClick={toggleTimeline}>
Toggle timeline
</button>
<button type="button" className={styles.button} onClick={setZoom50}>
Zoom 50%
</button>
</div>
</section>
</main>
);
}

Expand Down
79 changes: 79 additions & 0 deletions demo/src/App.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.app {
max-width: 980px;
margin: 0 auto;
padding: 2.5rem 1rem 3rem;
}

.header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
flex-wrap: wrap;
margin-bottom: 1.5rem;
}

.brand {
display: flex;
align-items: center;
gap: 0.85rem;
}

.logo {
width: 56px;
height: 56px;
border-radius: 12px;
object-fit: contain;
background: transparent;
}

.title {
margin: 0;
font-size: 1.8rem;
line-height: 1.2;
}

.subtitle {
margin: 0.2rem 0 0;
color: var(--pico-muted-color);
font-size: 0.95rem;
}

.badge {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.35rem 0.75rem;
border-radius: 999px;
background: var(--pico-secondary-background);
color: var(--pico-secondary-inverse);
font-size: 0.85rem;
font-weight: 600;
white-space: nowrap;
}

.waveformCard {
padding: 1rem;
border-radius: 14px;
background: var(--pico-card-background-color);
box-shadow: 0 16px 30px rgba(16, 24, 40, 0.12);
}

.waveform {
min-height: 170px;
}

.controls {
margin-top: 1rem;
}

.buttons {
display: flex;
flex-wrap: wrap;
gap: 0.65rem;
}

.button {
margin: 0;
min-width: 160px;
}
2 changes: 2 additions & 0 deletions demo/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ body {
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background: radial-gradient(circle at top, #edf4ff 0%, #f8fafc 45%, #f4f7fb 100%);
min-height: 100vh;
}

code {
Expand Down