Skip to content

Commit 4524804

Browse files
authored
Merge pull request #57 from codeacme17/fix
fix(Waveform): fix hight and width style setting
2 parents 9e1ca33 + 06a6b95 commit 4524804

3 files changed

Lines changed: 12 additions & 23 deletions

File tree

example/src/components/visualizaion/EchoWaveform.tsx

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
useWaveform,
77
usePlayer,
88
} from '@echo-ui'
9+
import { useEffect } from 'react'
910
import { Play, Square, Pause, Repeat, VolumeX } from 'lucide-react'
10-
import { useEffect, useState } from 'react'
1111

1212
export const EchoWaveform = () => {
1313
const url = 'https://codeacme17.github.io/1llest-waveform-vue/audios/loop-6.mp3'
@@ -54,27 +54,17 @@ export const EchoWaveform = () => {
5454
setPickTime(e.time)
5555
}
5656

57-
const [tab, setTab] = useState('a')
58-
const swichB = (c: 'a' | 'b') => {
59-
setTab(c)
60-
}
61-
6257
return (
6358
<section className="w-2/3 flex flex-col justify-center items-center">
64-
<button onClick={() => swichB(tab === 'a' ? 'b' : 'a')}>swichB</button>
65-
66-
{tab === 'a' ? (
67-
<Waveform
68-
data={data}
69-
audioDuration={audioDuration.current}
70-
percentage={percentage}
71-
onClick={handleClick}
72-
waveHeight={100}
73-
hideCursorLabel
74-
/>
75-
) : (
76-
<></>
77-
)}
59+
<Waveform
60+
data={data}
61+
audioDuration={audioDuration.current}
62+
percentage={percentage}
63+
onClick={handleClick}
64+
waveHeight={100}
65+
hideCursorLabel
66+
className="w-full"
67+
/>
7868

7969
<Button.Group className="mt-3" disabled={pending || error || !isReady}>
8070
<Button className="p-2" onClick={() => setLoop(!loop)} toggled={loop}>

packages/components/visualization/Waveform/Waveform.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ export const Waveform = forwardRef<WaveformRef, WaveformProps>((props, ref) => {
184184
ref={waveformRef}
185185
className={cn(base(), restProps.className)}
186186
style={{
187-
height: HEIGHT,
188187
...restProps.style,
189188
userSelect: 'none',
190189
}}

packages/components/visualization/Waveform/styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export const useStyle = tv({
44
slots: {
55
base: `text-foreground
66
relative
7-
w-full
8-
h-full
7+
w-96
8+
h-20
99
flex
1010
justify-center
1111
rounded-md

0 commit comments

Comments
 (0)