-
-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <[email protected]>
- Loading branch information
Showing
9 changed files
with
158 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,8 +61,6 @@ | |
} | ||
|
||
.skeleton { | ||
@apply !cursor-auto; | ||
|
||
& .title, | ||
& .desc { | ||
border-radius: 99px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/components/widgets/comment/CommentBox/SwitchCommentMode.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use client' | ||
|
||
import { useRef } from 'react' | ||
import clsx from 'clsx' | ||
import type { FC } from 'react' | ||
|
||
import { useUser } from '@clerk/nextjs' | ||
|
||
import { MotionButtonBase } from '~/components/ui/button' | ||
import { FloatPopover } from '~/components/ui/float-popover' | ||
|
||
import { | ||
CommentBoxMode, | ||
setCommentMode, | ||
useCommentBoxHasText, | ||
useCommentMode, | ||
} from './hooks' | ||
|
||
export const SwitchCommentMode = () => { | ||
const mode = useCommentMode() | ||
const copy = `转换到${mode === CommentBoxMode.legacy ? '新' : '旧'}版评论` | ||
const TriggerComponent = useRef<FC>(function SwitchCommentModeButton() { | ||
const mode = useCommentMode() | ||
|
||
const hasText = useCommentBoxHasText() | ||
|
||
const notLogged = !!useUser() | ||
|
||
return ( | ||
<MotionButtonBase | ||
className={clsx( | ||
'absolute left-0 top-0 z-10 rounded-full text-sm', | ||
'h-6 w-6 border border-slate-200 dark:border-neutral-800', | ||
'bg-slate-100 dark:bg-neutral-900', | ||
'flex cursor-pointer text-base-100/50 center', | ||
'text-base-content/50', | ||
'opacity-0 transition-opacity duration-200 group-[:hover]:opacity-100', | ||
mode === CommentBoxMode['legacy'] && 'bottom-0 top-auto', | ||
hasText || | ||
(notLogged && | ||
mode === CommentBoxMode['with-auth'] && | ||
'invisible opacity-0'), | ||
)} | ||
onClick={() => { | ||
setCommentMode( | ||
mode === CommentBoxMode.legacy | ||
? CommentBoxMode['with-auth'] | ||
: CommentBoxMode['legacy'], | ||
) | ||
}} | ||
> | ||
<i | ||
className={clsx( | ||
mode === CommentBoxMode.legacy | ||
? 'icon-[mingcute--user-4-line]' | ||
: 'icon-[material-symbols--dynamic-form-outline]', | ||
)} | ||
/> | ||
<span className="sr-only">{copy}</span> | ||
</MotionButtonBase> | ||
) | ||
}).current | ||
return <FloatPopover TriggerComponent={TriggerComponent}>{copy}</FloatPopover> | ||
} |
Oops, something went wrong.
36c3460
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
springtide – ./
springtide.vercel.app
springtide-git-main-innei.vercel.app
springtide-innei.vercel.app
innei.in