Skip to content

Commit

Permalink
Revert "feat: sonner"
Browse files Browse the repository at this point in the history
This reverts commit fb72500.

Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 13, 2023
1 parent d06876d commit 6db88f7
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 198 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
"react-error-boundary": "4.0.10",
"react-intersection-observer": "9.5.2",
"react-tweet": "3.0.3",
"react-toastify": "9.1.3",
"react-wrap-balancer": "1.0.0",
"remove-markdown": "0.5.0",
"shiki": "0.14.3",
"socket.io-client": "4.7.1",
"sonner": "0.6.2",
"tailwind-merge": "1.13.2",
"xss": "1.0.14"
},
Expand Down
43 changes: 43 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions src/app/SonnerContainer.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '../styles/index.css'

import { Analytics } from '@vercel/analytics/react'
import { ToastContainer } from 'react-toastify'
import type { AggregateRoot } from '@mx-space/api-client'
import type { AppThemeConfig } from './config'

Expand All @@ -18,7 +19,6 @@ import { queries } from '~/queries/definition'
import { Providers } from '../providers/root'
import { Analyze } from './analyze'
import { init } from './init'
import { SonnerContainer } from './SonnerContainer'

const { version } = PKG
init()
Expand Down Expand Up @@ -135,8 +135,8 @@ export default async function RootLayout(props: Props) {

<TocAutoScroll />
<Analyze />
<SonnerContainer />
</Providers>
<ToastContainer />
</body>
</html>
<Analytics />
Expand Down
16 changes: 4 additions & 12 deletions src/atoms/owner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const login = async (username?: string, password?: string) => {
if (username && password) {
const user = await apiClient.user.login(username, password).catch((err) => {
console.error(err)
toast.error('再试试哦')
toast('再试试哦', 'error')
throw err
})
if (user) {
Expand All @@ -26,7 +26,7 @@ export const login = async (username?: string, password?: string) => {
jotaiStore.set(isLoggedAtom, true)

await fetchAppUrl()
toast.success(`欢迎回来,${jotaiStore.get(ownerAtom)?.name}`)
toast(`欢迎回来,${jotaiStore.get(ownerAtom)?.name}`, 'success')
}

return true
Expand All @@ -36,15 +36,7 @@ export const login = async (username?: string, password?: string) => {
if (!token) {
return
}
const outdateToast = () =>
toast.message('登录身份过期了,再登录一下吧!', {
action: {
label: '登录',
onClick: () => {
window.location.href = '/login'
},
},
})
const outdateToast = () => toast('登录身份过期了,再登录一下吧!', 'warning')
const validated = await apiClient.user
.checkTokenValid(token)
.then((res) => !!res.ok)
Expand All @@ -63,7 +55,7 @@ export const login = async (username?: string, password?: string) => {

await apiClient.user.proxy.login.put<{ token: string }>().then((res) => {
jotaiStore.set(isLoggedAtom, true)
toast.message(`欢迎回来,${jotaiStore.get(ownerAtom)?.name}`)
toast(`欢迎回来,${jotaiStore.get(ownerAtom)?.name}`, 'success')
setToken(res.token)
})

Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/header/internal/AnimatedLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const TapableLogo = () => {
const adminUrl = getAdminUrl()
if (adminUrl) location.href = adminUrl
else {
toast.error('Admin url not found')
toast('Admin url not found', 'error')
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/code-highlighter/CodeHighlighter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const HighLighter: FC<Props> = (props) => {

const handleCopy = useCallback(() => {
navigator.clipboard.writeText(value)
toast.success('COPIED!')
toast('COPIED!', 'success')
}, [value])

const prevThemeCSS = useRef<ReturnType<typeof loadStyleSheet>>()
Expand Down
1 change: 0 additions & 1 deletion src/components/ui/input/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const TextArea = forwardRef<
'h-full w-full resize-none bg-transparent',
'overflow-auto px-3 py-4',
'text-neutral-900/80 dark:text-slate-100/80',
// 'ring-accent/20 duration-200 focus:border-accent-focus focus:ring-2',
className,
)}
{...rest}
Expand Down
6 changes: 2 additions & 4 deletions src/components/ui/markdown/index.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { useRef } from 'react'
// import { ToastContainer } from 'react-toastify'
import { ToastContainer } from 'react-toastify'
import { ThemeProvider } from 'next-themes'
import type { DocumentComponent } from 'storybook/typings'

import { SonnerContainer } from '~/app/SonnerContainer'

// @ts-expect-error
import customize from './customize.md?raw'
import { Markdown } from './Markdown'
Expand Down Expand Up @@ -33,7 +31,7 @@ export const MarkdownCustomize: DocumentComponent = () => {
/>
</main>

<SonnerContainer />
<ToastContainer />
</ThemeProvider>
</QueryClientProvider>
)
Expand Down
22 changes: 0 additions & 22 deletions src/components/ui/sonner/index.demo.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/widgets/note/NoteActionAside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ const LikeButton = () => {
control.start('tap', {
repeat: 5,
})
toast('谢谢你!', {
icon: (
toast('谢谢你!', undefined, {
iconElement: (
<m.i
className="icon-[mingcute--heart-fill] text-uk-red-light"
initial={{
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/note/NoteHideIfSecret.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const NoteHideIfSecret: Component = ({ children }) => {
const MAX_TIMEOUT = (2 ^ 31) - 1
if (isSecret && timeout && timeout < MAX_TIMEOUT) {
timer = setTimeout(() => {
toast.message('刷新以查看解锁的文章', { duration: Infinity })
toast('刷新以查看解锁的文章', 'info', { autoClose: false })
}, timeout)
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/widgets/post/PostActionAside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const LikeButton = () => {
onClick={() => {
handleLike()
control.start('tap')
toast('捕捉一只大佬!', {
icon: (
toast('捕捉一只大佬!', undefined, {
iconElement: (
<m.i
className="text-uk-orange-light"
initial={{
Expand Down
Loading

0 comments on commit 6db88f7

Please sign in to comment.