mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-26 13:25:46 +08:00
test(button): add testcase
This commit is contained in:
@@ -2,8 +2,8 @@ import React, { useEffect, useRef } from 'react'
|
||||
import withDefaults from '../utils/with-defaults'
|
||||
|
||||
interface Props {
|
||||
x?: number
|
||||
y?: number
|
||||
x: number
|
||||
y: number
|
||||
color?: string
|
||||
onCompleted?: Function
|
||||
}
|
||||
@@ -20,10 +20,17 @@ const ButtonDrip: React.FC<ButtonDrip> = React.memo(({
|
||||
x, y, color, onCompleted
|
||||
}) => {
|
||||
const dripRef = useRef<HTMLDivElement>(null)
|
||||
/* istanbul ignore next */
|
||||
const top = Number.isNaN(+y) ? 0 : y - 10
|
||||
/* istanbul ignore next */
|
||||
const left = Number.isNaN(+x) ? 0 : x - 10
|
||||
|
||||
useEffect(() => {
|
||||
/* istanbul ignore next */
|
||||
if (!dripRef.current) return
|
||||
dripRef.current.addEventListener('animationend', onCompleted)
|
||||
return () => {
|
||||
/* istanbul ignore next */
|
||||
if (!dripRef.current) return
|
||||
dripRef.current.removeEventListener('animationend', onCompleted)
|
||||
}
|
||||
@@ -32,7 +39,7 @@ const ButtonDrip: React.FC<ButtonDrip> = React.memo(({
|
||||
return (
|
||||
<div ref={dripRef} className="drip">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20"
|
||||
style={{ top: y - 10, left: x - 10 }}>
|
||||
style={{ top, left }}>
|
||||
<g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
|
||||
<g fill={color}><rect width="100%" height="100%" rx="10" /></g>
|
||||
</g>
|
||||
|
||||
Reference in New Issue
Block a user