From 86823dcb15b6bdf02fbad43dcc705ce36fd563f3 Mon Sep 17 00:00:00 2001
From: mackt <1033530438@qq.com>
Date: Sat, 27 Apr 2024 11:31:54 +0800
Subject: [PATCH] update(CollectButton): Add color prop
---
src/components/AudioPlayer/PlayerControl.tsx | 4 ++-
src/components/Button/CollectButton.tsx | 32 ++++---------------
src/components/Icon/Heart.tsx | 30 +++++++++++++++++
.../heart.module.css} | 28 ++++++++++------
src/components/index.ts | 1 +
5 files changed, 58 insertions(+), 37 deletions(-)
create mode 100644 src/components/Icon/Heart.tsx
rename src/components/{Button/collect.module.css => Icon/heart.module.css} (73%)
diff --git a/src/components/AudioPlayer/PlayerControl.tsx b/src/components/AudioPlayer/PlayerControl.tsx
index ba27b6c..67e6f05 100644
--- a/src/components/AudioPlayer/PlayerControl.tsx
+++ b/src/components/AudioPlayer/PlayerControl.tsx
@@ -105,7 +105,9 @@ export default function AudioPlayer({
{/* control */}
{/* 收藏歌曲 */}
- {!!audio?.id &&
}
+ {!!audio?.id && (
+
+ )}
{/* 播放顺序 */}
{showOrder &&
orderList.map((item) => (
diff --git a/src/components/Button/CollectButton.tsx b/src/components/Button/CollectButton.tsx
index 79f4fb8..3073c46 100644
--- a/src/components/Button/CollectButton.tsx
+++ b/src/components/Button/CollectButton.tsx
@@ -6,8 +6,7 @@ import { useEffect, useState } from 'react';
import { useShallow } from 'zustand/react/shallow';
-import styles from './collect.module.css';
-
+import { IconHeart } from '@/components';
import { apiCollect } from '@/services';
import { useAudioStore } from '@/store';
@@ -26,6 +25,7 @@ interface Props {
textClassName?: string;
/** 文字跟图标之间的间隔 单位px */
gap?: number;
+ color?: string;
}
export default function CollectButton({
@@ -39,6 +39,7 @@ export default function CollectButton({
className = '',
textClassName = '',
showText = false,
+ color,
}: Props) {
const { playList, playQueue, updatePlayList, setPlayQueue } = useAudioStore(
useShallow((state) => {
@@ -122,38 +123,17 @@ export default function CollectButton({
className={`flex flex-row items-center gap-[${gap}px] w-fit h-fit cursor-pointer group ${className}`}
onClick={handleCollect}
>
- {iconPosition === 'left' &&
}
+ {iconPosition === 'left' &&
}
{/* 文案 */}
{!!(showText && currentCount > 0) && (
{`${currentCount || ''}${text || ''}`}
)}
{/* 图标 */}
- {iconPosition === 'right' &&
}
-
- );
-}
-
-function Icon({ haveCollect, animate }: { haveCollect: boolean; animate: boolean }) {
- return (
-