mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
added back to top component
This commit is contained in:
1 parent
080e1f36fb
commit
eefd479108
9 files changed
+106
-2
No files matched your search
File renamed without changes.
@@ -0,0 +1,13 @@
|
||||
services:
|
||||
dong-site:
|
||||
image: nginx:alpine
|
||||
container_name: dong-site
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./dist:/usr/share/nginx/html:ro
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
networks:
|
||||
- docker-network
|
||||
networks:
|
||||
docker-network:
|
||||
external: true
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# React/Vue/Vite SPA routing
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Do not aggressively cache index.html.
|
||||
# It references the latest hashed JS/CSS files.
|
||||
location = /index.html {
|
||||
try_files $uri =404;
|
||||
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
}
|
||||
|
||||
# Vite-generated assets normally contain content hashes.
|
||||
# They can safely be cached for a long time.
|
||||
location ~* \.(?:css|js|mjs|map|png|jpg|jpeg|gif|svg|ico|webp|avif|woff|woff2|ttf|otf)$ {
|
||||
try_files $uri =404;
|
||||
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, max-age=2592000, immutable";
|
||||
}
|
||||
|
||||
location = /favicon.ico {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
+1
-1
@@ -427,7 +427,7 @@
|
||||
}
|
||||
|
||||
.hero-photo {
|
||||
width: 100%;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center top;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Navigation } from './Navigation'
|
||||
import { BackToTop } from '@/components/ui/BackToTop'
|
||||
import { Footer } from './Footer'
|
||||
|
||||
interface LayoutProps {
|
||||
@@ -16,6 +17,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
{children}
|
||||
</main>
|
||||
<Footer />
|
||||
<BackToTop />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import { motion, AnimatePresence } from "motion/react"
|
||||
|
||||
const SCROLL_THRESHOLD = 300
|
||||
|
||||
export function BackToTop() {
|
||||
const [visible, setVisible] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
setVisible(window.scrollY > SCROLL_THRESHOLD)
|
||||
}
|
||||
|
||||
window.addEventListener("scroll", handleScroll, { passive: true })
|
||||
return () => window.removeEventListener("scroll", handleScroll)
|
||||
}, [])
|
||||
|
||||
const scrollToTop = () => {
|
||||
window.scrollTo({ top: 0, behavior: "smooth" })
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{visible && (
|
||||
<motion.button
|
||||
className="back-to-top"
|
||||
aria-label="Scroll to top"
|
||||
onClick={scrollToTop}
|
||||
initial={{ opacity: 0, y: 10 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: 10 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
>
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
width="20"
|
||||
height="20"
|
||||
>
|
||||
<path d="M18 15l-6-6-6 6" />
|
||||
</svg>
|
||||
</motion.button>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
'@': path.resolve(import.meta.dirname, './src'),
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user