refactor: enhance icon transition handling and improve Zustand store proxy functionality

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2024-12-13 13:23:25 +08:00
parent 3365d7afa0
commit 3e2603c3ea
2 changed files with 20 additions and 15 deletions
@@ -44,13 +44,11 @@ const createIconTransition =
exit={exit}
/>
) : (
cloneElement(icon1, {
className: cn(icon1ClassName, className),
key: "1",
initial,
animate,
exit,
})
<m.span key="1" initial={initial} animate={animate} exit={exit}>
{cloneElement(icon1, {
className: cn(icon1ClassName, className),
})}
</m.span>
)
) : typeof icon2 === "string" ? (
<m.i
@@ -61,13 +59,11 @@ const createIconTransition =
exit={exit}
/>
) : (
cloneElement(icon2, {
className: cn(icon2ClassName, className),
key: "2",
initial,
animate,
exit,
})
<m.span key="2" initial={initial} animate={animate} exit={exit}>
{cloneElement(icon2, {
className: cn(icon2ClassName, className),
})}
</m.span>
)}
</AnimatePresence>
)
+10 -1
View File
@@ -60,7 +60,16 @@ export const createZustandStore =
{
get(_, prop) {
if (prop in storeMap) {
return storeMap[prop as string].getState()
return new Proxy(() => {}, {
get() {
return storeMap[prop as string].getState()
},
apply(target, thisArg, argumentsList) {
return storeMap[prop as string].setState(
produce(storeMap[prop as string].getState(), ...argumentsList),
)
},
})
}
return
},