-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rehowl.stories.tsx
35 lines (31 loc) · 957 Bytes
/
Rehowl.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as React from 'react'
const { useState } = React
import { Rehowl } from '../src/Rehowl.js'
import { Play } from '../src/Play.js'
// @ts-ignore
import sound1 from './static/audio/sound1.mp3'
import type { Meta, StoryFn } from '@storybook/react'
const meta = {
title: 'Components/Rehowl',
component: Rehowl,
tags: ['autodocs'],
} satisfies Meta<typeof Rehowl>
export default meta
type Story = StoryFn<typeof Rehowl>
export const playPause: Story = () => {
const [play, setPlay] = useState(false)
return (
<Rehowl src={sound1} preload={false}>
{({ howl, state, load }) => (
<>
<button onClick={load}>Load source</button>
<button onClick={() => setPlay(!play)}>{play ? 'Pause' : 'Play'}</button>
<p>State: {state}</p>
<Play howl={howl} pause={!play}>
{({ playing }) => <p>Playing: {playing().toString()}</p>}
</Play>
</>
)}
</Rehowl>
)
}