Skip to content

Commit

Permalink
feat: adjust gap
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Jun 19, 2023
1 parent e52bd3f commit 681f3db
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/widgets/note/NoteActionAside.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useQueryClient } from '@tanstack/react-query'
import { motion, useAnimationControls } from 'framer-motion'
import { motion, useAnimationControls, useForceUpdate } from 'framer-motion'
import { produce } from 'immer'
import type { NoteWrappedPayload } from '@mx-space/api-client'

Expand All @@ -12,6 +12,7 @@ import { toast } from '~/lib/toast'
import { urlBuilder } from '~/lib/url-builder'
import { useAggregationData } from '~/providers/root/aggregation-data-provider'
import { queries } from '~/queries/definition'
import { isLikedBefore, setLikeId } from '~/utils/cookie'
import { clsxm } from '~/utils/helper'
import { apiClient } from '~/utils/request'

Expand All @@ -21,7 +22,7 @@ export const NoteActionAside: Component = ({ className }) => {
return (
<div
className={clsxm(
'absolute bottom-0 max-h-[300px] flex-col space-y-4',
'absolute bottom-0 max-h-[300px] flex-col space-y-8',
className,
)}
>
Expand All @@ -37,10 +38,13 @@ const LikeButton = () => {

const queryClient = useQueryClient()
const control = useAnimationControls()
const [update] = useForceUpdate()
if (!note) return null
const id = note.id
const handleLike = () => {
if (isLikedBefore(id)) return
apiClient.note.likeIt(id).then(() => {
setLikeId(id)
queryClient.setQueriesData(
queries.note.byNid(note.nid.toString()),
(old: any) => {
Expand All @@ -49,9 +53,12 @@ const LikeButton = () => {
})
},
)
update()
})
}

const isLiked = isLikedBefore(id)

return (
<MotionButtonBase
className="flex flex-col space-y-2"
Expand Down Expand Up @@ -82,7 +89,11 @@ const LikeButton = () => {
}}
>
<motion.i
className="icon-[mingcute--heart-fill] text-[24px] opacity-80 duration-200 hover:text-uk-red-light hover:opacity-100"
className={clsxm(
'icon-[mingcute--heart-fill] text-[24px] opacity-80 duration-200 hover:text-uk-red-light hover:opacity-100',

isLiked && 'text-uk-red-light',
)}
animate={control}
variants={{
tap: {
Expand Down

0 comments on commit 681f3db

Please sign in to comment.