Skip to content

Commit

Permalink
fix: some ui syles
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Jul 15, 2023
1 parent 4b7b8b1 commit 0ca38b4
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/layout/footer/FooterInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const FooterBottom = async () => {
</>
)}

<Divider />
<Divider className="hidden md:inline" />
<GatewayCount />
{/* {!!lastVisitor && (
<>
Expand Down
45 changes: 45 additions & 0 deletions src/components/layout/footer/GatewayCount.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
'use client'

import { useOnlineCount } from '~/atoms'
import { ImpressionView } from '~/components/common/ImpressionTracker'
import { Divider } from '~/components/ui/divider'
import { FloatPopover } from '~/components/ui/float-popover'
import { NumberSmoothTransition } from '~/components/ui/number-transition/NumberSmoothTransition'
import { TrackerAction } from '~/constants/tracker'
import { usePageIsActive } from '~/hooks/common/use-is-active'
import { useSocketIsConnect } from '~/socket/hooks'

export const GatewayCount = () => {
return (
Expand All @@ -26,10 +30,51 @@ export const GatewayCount = () => {
WebSocket
用于通知站点,站长在站点的实时活动,包括不限于文章的发布和更新。
</p>

<Divider />

<p>
当前 Socket 状态: <ConnectedIndicator />
</p>
</div>
</FloatPopover>
)
}

const ConnectedIndicator = () => {
const connected = useSocketIsConnect()

return (
<div className="inline-flex items-center">
<ImpressionView
trackerMessage="socket_status"
action={TrackerAction.Impression}
/>
{connected ? (
<>
<span className="absolute h-5 w-5">
<span className="absolute inset-0 z-[3] m-auto flex h-3 w-3 rounded-full bg-green-400" />
<span className="absolute inset-0 z-[2] m-auto flex h-4 w-4 rounded-full bg-green-300" />
<span className="relative z-[1] flex h-5 w-5 rounded-full bg-green-200 center" />
</span>

<span className="ml-6">已连接</span>
</>
) : (
<>
<span className="absolute h-5 w-5">
<span className="absolute inset-0 z-[3] m-auto flex h-3 w-3 rounded-full bg-red-400" />
<span className="absolute inset-0 z-[2] m-auto flex h-4 w-4 rounded-full bg-red-300" />
<span className="relative z-[1] flex h-5 w-5 rounded-full bg-red-200 center" />
</span>

<span className="ml-6">未连接</span>
</>
)}
</div>
)
}

const GatewayCountTrigger = () => {
const isActive = usePageIsActive()
const count = useOnlineCount()
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/header/internal/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const Activity = memo(() => {
return (
<>
{!!media && (
<m.div className="absolute bottom-0 left-0 top-0 z-[10] flex items-center md:left-[-30px]">
<m.div className="absolute bottom-0 left-0 top-0 z-[10] flex items-center lg:left-[-30px]">
<div className="absolute inset-0 z-[-1] flex center">
<div className="h-6 w-6 animate-ping rounded-md ring-2 ring-uk-red-dark" />
</div>
Expand All @@ -149,7 +149,7 @@ export const Activity = memo(() => {
{!!appLabels[processName] && (
<m.div
key={processName}
className="pointer-events-auto absolute bottom-0 right-0 top-0 z-[10] flex items-center overflow-hidden md:right-[-25px]"
className="pointer-events-auto absolute bottom-0 right-0 top-0 z-[10] flex items-center overflow-hidden lg:right-[-25px]"
initial={{
opacity: 0.2,
y: 15,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const HeaderDrawerContent = () => {
const { config } = useHeaderConfig()

return (
<div className="mt-12 max-h-screen w-[90vw] space-y-4 overflow-auto pb-8 scrollbar-none">
<div className="mt-12 max-h-screen w-[90vw] space-y-4 overflow-auto pb-24 scrollbar-none">
{config.map((section, index) => {
return (
<m.section
Expand Down
10 changes: 6 additions & 4 deletions src/components/widgets/comment/CommentBox/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ export const CommentBoxActionBar: Component = ({ className }) => {
'flex-1 select-none text-[10px] text-zinc-500 transition-opacity',
)}
>
支持 <b>Markdown</b>{' '}
<MLink href="https://docs.github.com/zh/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax">
GFM
</MLink>
<span className="hidden md:inline">
支持 <b>Markdown</b>{' '}
<MLink href="https://docs.github.com/zh/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax">
GFM
</MLink>
</span>
<CommentBoxSlotProvider />
</span>
<AnimatePresence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const UniversalTextArea = () => {
const EmojiButton = () => {
return (
<button
className="ml-4 inline-flex h-5 w-5 translate-y-1 text-base center"
className="ml-0 inline-flex h-5 w-5 translate-y-1 text-base center md:ml-4"
onClick={preventDefault}
>
<i className="icon-[mingcute--emoji-2-line]" />
Expand Down
3 changes: 2 additions & 1 deletion src/lib/link-parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDev } from './env'
import { isClientSide, isDev } from './env'

export const isTweetUrl = (url: URL) => {
return url.hostname === 'twitter.com' && url.pathname.startsWith('/')
Expand Down Expand Up @@ -63,6 +63,7 @@ export const isCodesandboxUrl = (url: URL) => {
}

export const isSelfArticleUrl = (url: URL) => {
if (!isClientSide) return false
if (isDev && url.hostname === 'innei.in') return true
return (
url.hostname === location.hostname &&
Expand Down
12 changes: 12 additions & 0 deletions src/socket/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { atom, useAtomValue } from 'jotai'

import { jotaiStore } from '~/lib/store'

const socketIsConnectAtom = atom(false)
export const useSocketIsConnect = () => {
return useAtomValue(socketIsConnectAtom)
}

export const setSocketIsConnect = (value: boolean) => {
jotaiStore.set(socketIsConnectAtom, value)
}
14 changes: 13 additions & 1 deletion src/socket/socket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GATEWAY_URL } from '~/constants/env'
import { isDev } from '~/lib/env'

import { eventHandler } from './handler'
import { setSocketIsConnect } from './hooks'

class SocketClient {
public socket!: Socket
Expand All @@ -33,6 +34,15 @@ class SocketClient {
if (!this.socket) {
return
}

this.socket.on('connect', () => {
setSocketIsConnect(true)
})

this.socket.on('disconnect', () => {
setSocketIsConnect(false)
})

this.socket.close()
this.socket.open()
this.socket.on(
Expand Down Expand Up @@ -70,7 +80,9 @@ class SocketClient {
}
})
}

static shared = new SocketClient()
}

export const socketClient = new SocketClient()
export const socketClient = SocketClient.shared
export type TSocketClient = SocketClient

1 comment on commit 0ca38b4

@vercel
Copy link

@vercel vercel bot commented on 0ca38b4 Jul 15, 2023

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:

shiro – ./

springtide.vercel.app
innei.in
shiro-innei.vercel.app
shiro-git-main-innei.vercel.app

Please sign in to comment.