From 2c8429d01213b15007fe411ef42c57f0d2a4dc48 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Thu, 7 Sep 2023 18:12:33 +0800 Subject: [PATCH] Add slogan to home page --- src/assets/css/common.scss | 11 ++++++- src/assets/css/home.scss | 44 +++++++++++++++++++++++++++ src/assets/svg/down.svg | 1 + src/components/FitCenter.tsx | 11 +++++++ src/components/FitFullScreen.tsx | 12 ++++++-- src/components/Home.tsx | 51 ++++++++++++++++++++++++-------- 6 files changed, 115 insertions(+), 15 deletions(-) create mode 100644 src/assets/svg/down.svg create mode 100644 src/components/FitCenter.tsx diff --git a/src/assets/css/common.scss b/src/assets/css/common.scss index 9747a19..c161ddb 100644 --- a/src/assets/css/common.scss +++ b/src/assets/css/common.scss @@ -116,6 +116,15 @@ $font-secondary-color: #9E9E9E; } #fit-fullscreen { - width: 100vw; + position: relative; + width: 100%; height: 100vh; +} + +#fit-center { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; } \ No newline at end of file diff --git a/src/assets/css/home.scss b/src/assets/css/home.scss index e69de29..5397f58 100644 --- a/src/assets/css/home.scss +++ b/src/assets/css/home.scss @@ -0,0 +1,44 @@ +@use "mixins" as mixins; + +.center-box { + display: flex; + flex-direction: column; +} + +.big-logo { + font: { + size: 5em; + weight: bold; + }; + color: #666; +} + +.slogan { + font: { + size: 1.3em; + style: italic; + }; + color: #666; +} + +.scroll-to-down { + position: absolute; + bottom: 20px; + animation: 1.5s infinite; + @include mixins.unique-keyframes { + 0%, + 100% { + -ms-filter: none; + filter: none; + opacity: 1; + transform: translateY(10px); + } + + 50% { + -ms-filter: alpha(opacity=40); + filter: alpha(opacity=40); + opacity: .4; + transform: translateY(-10px); + } + } +} \ No newline at end of file diff --git a/src/assets/svg/down.svg b/src/assets/svg/down.svg new file mode 100644 index 0000000..872d226 --- /dev/null +++ b/src/assets/svg/down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/FitCenter.tsx b/src/components/FitCenter.tsx new file mode 100644 index 0000000..15bee2c --- /dev/null +++ b/src/components/FitCenter.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const FitCenter: React.FC = (props: PropsWithChildren) => { + return ( + <> +
{props.children}
+ + ) +} + +export default FitCenter diff --git a/src/components/FitFullScreen.tsx b/src/components/FitFullScreen.tsx index fab7cc3..5a6d7bb 100644 --- a/src/components/FitFullScreen.tsx +++ b/src/components/FitFullScreen.tsx @@ -1,9 +1,17 @@ import React from 'react' -const FitFullScreen: React.FC = (props: PropsWithChildren) => { +const FitFullScreen: React.FC = (props: FitFullscreenProps) => { return ( <> -
{props.children}
+
+ {props.children} +
) } diff --git a/src/components/Home.tsx b/src/components/Home.tsx index e73e06a..1eeda90 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -1,22 +1,49 @@ import React from 'react' import '@/assets/css/home.scss' -import { MainFrameworkContext } from '@/pages/MainFramework' +import FitFullScreen from '@/components/FitFullScreen.tsx' +import FitCenter from '@/components/FitCenter.tsx' +import Icon from '@ant-design/icons' const Home: React.FC = () => { - const { - navbarHiddenState: { navbarHidden, setNavbarHidden } - } = useContext(MainFrameworkContext) - const handleButtonClick = () => { - setNavbarHidden(!navbarHidden) + const [slogan, setSlogan] = useState('') + const [sloganType, setSloganType] = useState(true) + const typeText = '/* 因为热爱 所以折腾 */' + if (sloganType) { + setTimeout(() => { + if (slogan.length < typeText.length) { + setSlogan(typeText.substring(0, slogan.length + 1)) + } else { + setSloganType(false) + } + }, 150) + } else { + setTimeout(() => { + if (slogan.length > 0) { + setSlogan(typeText.substring(0, slogan.length - 1)) + } else { + setSloganType(true) + } + }, 50) } + return ( <> -

Home

-
- - {navbarHidden ? '显示' : '隐藏'} - -
+ + +
+
FatWeb
+ + {slogan || <> } + +
+
+ +
+
+
) }