feat: 添加连锁门店系统首页及核心UI组件
新增首页布局、导航栏、页脚及多个核心UI组件(按钮、卡片、表格等) 添加图片资源、工具函数和样式配置 实现响应式设计和主题支持 包含行业解决方案展示区块
This commit is contained in:
61
components/ui/section-reveal.tsx
Normal file
61
components/ui/section-reveal.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
"use client"
|
||||
|
||||
import { type HTMLAttributes, useEffect, useRef, useState } from "react"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
type SectionRevealProps = HTMLAttributes<HTMLDivElement> & {
|
||||
delay?: number
|
||||
}
|
||||
|
||||
export function SectionReveal({
|
||||
children,
|
||||
className,
|
||||
delay = 0,
|
||||
style,
|
||||
...props
|
||||
}: SectionRevealProps) {
|
||||
const ref = useRef<HTMLDivElement | null>(null)
|
||||
const [visible, setVisible] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const node = ref.current
|
||||
|
||||
if (!node) {
|
||||
return
|
||||
}
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
if (entry.isIntersecting) {
|
||||
setVisible(true)
|
||||
observer.disconnect()
|
||||
}
|
||||
},
|
||||
{
|
||||
threshold: 0.18,
|
||||
rootMargin: "0px 0px -10% 0px",
|
||||
}
|
||||
)
|
||||
|
||||
observer.observe(node)
|
||||
|
||||
return () => observer.disconnect()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
{...props}
|
||||
className={cn(
|
||||
"motion-safe:transition-[opacity,transform,filter] motion-safe:duration-[1200ms] motion-safe:[transition-timing-function:cubic-bezier(0.22,1,0.36,1)] motion-safe:will-change-transform",
|
||||
visible
|
||||
? "opacity-100 translate-y-0 scale-100 blur-0"
|
||||
: "opacity-0 translate-y-10 scale-[0.985] blur-[10px]",
|
||||
className
|
||||
)}
|
||||
style={{ ...style, transitionDelay: `${delay}ms` }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user