From f73cab51ec77b5668b8a3f1ab5a8b434b991b057 Mon Sep 17 00:00:00 2001 From: Suhyun Park Date: Wed, 17 Jul 2024 02:30:20 +0900 Subject: [PATCH] feat: gradient header --- src/components/TitleLogo.tsx | 28 +++++++++------- src/components/header/Header.tsx | 41 +++++++++++++++++++++++ src/components/header/HeaderText.tsx | 20 +++++++++++ src/pages/stats/:handle/UserStatsPage.tsx | 28 ++-------------- src/styles/colors.ts | 2 ++ 5 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 src/components/header/Header.tsx create mode 100644 src/components/header/HeaderText.tsx diff --git a/src/components/TitleLogo.tsx b/src/components/TitleLogo.tsx index ebe3bef..9aefcba 100644 --- a/src/components/TitleLogo.tsx +++ b/src/components/TitleLogo.tsx @@ -1,6 +1,7 @@ import styled from "@emotion/styled"; import { Link } from "react-router-dom"; -import logo from "/logo.svg"; +import { Header } from "./header/Header"; +import { useAuth } from "../contexts/AuthContext"; const TotalStatContainer = styled.div` position: relative; @@ -19,14 +20,6 @@ const TotalStatContainer = styled.div` padding: 32px 0; `; -const LogoContainer = styled.img` - position: relative; - min-height: 80px; - max-width: 70vw; - object-fit: contain; - pointer-events: all; -`; - const TotalStatWrapper = styled.div` position: relative; width: 100%; @@ -66,18 +59,29 @@ const TotalStatDetail = styled.div` font-size: 36px; `; +const HeaderLink = styled(Link)` + pointer-events: all; + text-decoration: none; +`; + interface TotalStatProps { useTotalStats?: boolean; } const TitleLogo = (props: TotalStatProps) => { + const { user } = useAuth(); const { useTotalStats } = props; return ( - - - + +
{user?.displayName || "개척단 훈련소"}
+
{useTotalStats && ( diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx new file mode 100644 index 0000000..dc7eab0 --- /dev/null +++ b/src/components/header/Header.tsx @@ -0,0 +1,41 @@ +import styled from "@emotion/styled"; +import { HTMLAttributes, PropsWithChildren } from "react"; +import { color } from "../../styles/colors"; +import { HeaderText } from "./HeaderText"; +import { transparentize } from "polished"; + +const HeaderBackground = styled.div` + max-width: 100vw; + background-image: linear-gradient( + to right, + ${color.silkBlueLight}, + ${transparentize(0.2, color.silkBlueLight)}, + ${transparentize(1, color.silkBlueLight)} + ); + background-clip: padding-box; + border-top: 2px solid transparent; + border-bottom: 2px solid transparent; + border-image: linear-gradient( + to right, + ${color.goldText}, + ${transparentize(0.2, color.goldTextLight)}, + ${transparentize(1, color.goldTextLight)} + ); + border-image-slice: 1; + min-height: 64px; + padding: 8px 160px 8px 24px; + font-size: 2rem; + display: flex; + align-items: center; + justify-content: flex-start; +`; + +interface Props extends HTMLAttributes {} + +export const Header = ({ children, ...rest }: PropsWithChildren) => { + return ( + + {children} + + ); +}; diff --git a/src/components/header/HeaderText.tsx b/src/components/header/HeaderText.tsx new file mode 100644 index 0000000..210df47 --- /dev/null +++ b/src/components/header/HeaderText.tsx @@ -0,0 +1,20 @@ +import styled from "@emotion/styled"; +import { color } from "../../styles/colors"; +import { fontFamilies } from "../../styles/fonts"; + +export const HeaderText = styled.span` + ${fontFamilies.kimDaegon} + background-color: ${color.goldText}; + background-image: linear-gradient( + to bottom, + ${color.goldText}, + ${color.goldTextLight} + ); + background-size: 80%; + background-repeat: repeat; + background-clip: text; + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + -moz-background-clip: text; + -moz-text-fill-color: transparent; +`; diff --git a/src/pages/stats/:handle/UserStatsPage.tsx b/src/pages/stats/:handle/UserStatsPage.tsx index f387d7a..95129e1 100644 --- a/src/pages/stats/:handle/UserStatsPage.tsx +++ b/src/pages/stats/:handle/UserStatsPage.tsx @@ -1,7 +1,7 @@ import styled from "@emotion/styled"; import { useParams } from "react-router-dom"; +import { Header } from "../../../components/header/Header"; import DefaultLayout from "../../../components/layouts/DefaultLayout"; -import { color } from "../../../styles/colors"; import { commons } from "../../../styles/commons"; import { fontFamilies } from "../../../styles/fonts"; import bom from "/bom.png"; @@ -34,29 +34,6 @@ const HandleContainer = styled.div` justify-content: flex-start; `; -const Handle = styled.div` - ${fontFamilies.kimDaegon} - position: absolute; - font-size: 2rem; - bottom: 32px; - left: 16px; - color: #debc80; -`; - -const HandleBackground = styled.div` - position: absolute; - bottom: 16px; - background-image: linear-gradient( - to right, - ${color.silkBlue}, - rgba(33, 36, 67, 0) - ); - height: 64px; - width: 60%; - border-top: 2px solid #debc80; - border-bottom: 2px solid #debc80; -`; - const CardContainer = styled.div` ${commons.card} position: relative; @@ -263,8 +240,7 @@ const UserStatsPage = () => { - - {handle} +
{handle}
diff --git a/src/styles/colors.ts b/src/styles/colors.ts index 53513db..a0df1f5 100644 --- a/src/styles/colors.ts +++ b/src/styles/colors.ts @@ -4,5 +4,7 @@ export const color = { silkBlueDark: "#0b101c", silkBlueSecondaryText: "#8e93bd", goldLight: "#e6b06f", + goldText: "#e6be78", + goldTextLight: "#f9e394", backdropGray: "#1c1c1c", };