2023-02-05 04:17:51 -08:00
|
|
|
import { useMemo } from 'react'
|
|
|
|
|
2023-02-09 15:35:39 -08:00
|
|
|
const HealthHeart = ({ health, size }: { health: number; size: number }) => {
|
2023-02-05 04:17:51 -08:00
|
|
|
const fillColor = useMemo(() => {
|
|
|
|
if (!health) return 'var(--fgd-4)'
|
|
|
|
if (health <= 25) {
|
|
|
|
return 'var(--down)'
|
|
|
|
}
|
|
|
|
if (health <= 50) {
|
|
|
|
return 'var(--warning)'
|
|
|
|
}
|
|
|
|
if (health <= 75) {
|
|
|
|
return 'var(--up)'
|
|
|
|
}
|
|
|
|
return 'var(--up)'
|
|
|
|
}, [health])
|
|
|
|
|
2022-07-14 20:38:02 -07:00
|
|
|
const styles = {
|
2023-02-05 04:17:51 -08:00
|
|
|
color: fillColor,
|
|
|
|
// filter: `drop-shadow(0px 0px 8px ${fillColor})`,
|
2022-07-14 20:38:02 -07:00
|
|
|
height: `${size}px`,
|
|
|
|
width: `${size}px`,
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<svg
|
2023-02-09 15:35:39 -08:00
|
|
|
className={health && health < 10 ? 'animate-pulse' : ''}
|
2022-09-22 21:00:42 -07:00
|
|
|
id="account-step-eleven"
|
2022-07-14 20:38:02 -07:00
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
style={styles}
|
|
|
|
viewBox="0 0 20 20"
|
|
|
|
fill="currentColor"
|
|
|
|
>
|
|
|
|
<g transform-origin="center">
|
|
|
|
<path
|
|
|
|
fillRule="evenodd"
|
|
|
|
d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z"
|
|
|
|
clipRule="evenodd"
|
|
|
|
/>
|
2023-02-05 04:17:51 -08:00
|
|
|
{/* <animateTransform
|
2022-07-14 20:38:02 -07:00
|
|
|
attributeName="transform"
|
|
|
|
type="scale"
|
|
|
|
keyTimes="0;0.5;1"
|
|
|
|
values="1;1.1;1"
|
2022-08-02 19:15:17 -07:00
|
|
|
dur={
|
2022-09-11 17:22:37 -07:00
|
|
|
health
|
|
|
|
? health > 15 && health < 50
|
|
|
|
? '1s'
|
|
|
|
: health >= 50
|
|
|
|
? '2s'
|
|
|
|
: '0.33s'
|
|
|
|
: '0s'
|
2022-08-02 19:15:17 -07:00
|
|
|
}
|
2022-07-14 20:38:02 -07:00
|
|
|
repeatCount="indefinite"
|
|
|
|
/>
|
|
|
|
<animate
|
|
|
|
attributeName="opacity"
|
|
|
|
values="0.8;1;0.8"
|
2022-08-02 19:15:17 -07:00
|
|
|
dur={
|
2022-09-11 17:22:37 -07:00
|
|
|
health
|
|
|
|
? health > 15 && health < 50
|
|
|
|
? '1s'
|
|
|
|
: health >= 50
|
|
|
|
? '2s'
|
|
|
|
: '0.33s'
|
|
|
|
: '0s'
|
2022-08-02 19:15:17 -07:00
|
|
|
}
|
2022-07-14 20:38:02 -07:00
|
|
|
repeatCount="indefinite"
|
2023-02-05 04:17:51 -08:00
|
|
|
/> */}
|
2022-07-14 20:38:02 -07:00
|
|
|
</g>
|
|
|
|
</svg>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default HealthHeart
|