-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: TopBarText import 절대경로, styled-component 분리
- Loading branch information
1 parent
be78770
commit e55d026
Showing
4 changed files
with
109 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,80 @@ | ||
import { FC } from "react" | ||
import logo from "../assets/logo_space.svg" | ||
import back from "../assets/icon_back.svg" | ||
import * as sty from "../styles/TopBarTextStyles" | ||
import '../index.css' | ||
import { FC } from "react"; | ||
import logo from "@/assets/logo_space.svg"; | ||
import back from "@/assets/icon_back.svg"; | ||
import * as sty from "@/styles/TopBarText.styled"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
|
||
|
||
|
||
export enum LeftEnum { | ||
Logo = "logo", | ||
Back = "back", | ||
None = "none" | ||
}; | ||
Logo = "logo", | ||
Back = "back", | ||
None = "none", | ||
} | ||
|
||
interface topbarProps { | ||
left: LeftEnum; | ||
center: string; | ||
right: string; | ||
left: LeftEnum; | ||
center: string; | ||
right: string; | ||
} | ||
|
||
const TopBarText: FC<topbarProps> = ({ left, center, right }) => { | ||
const navigate = useNavigate(); | ||
switch (left) { | ||
case "logo": | ||
return ( | ||
<div> | ||
<sty.StyledTopBarDiv> | ||
<nav> | ||
<sty.StyledLeftDiv onClick={() => { navigate('/') }} style={{ cursor: "pointer" }}> | ||
<img src={logo} width="120px"></img> | ||
</sty.StyledLeftDiv> | ||
</nav> | ||
<nav> | ||
<sty.StyledCenterDiv> | ||
<sty.StyledCenterP>{center}</sty.StyledCenterP> | ||
</sty.StyledCenterDiv> | ||
</nav> | ||
<nav> | ||
<sty.StyledRightDiv> | ||
<sty.StyledRightP>{right}</sty.StyledRightP> | ||
</sty.StyledRightDiv> | ||
</nav> | ||
</sty.StyledTopBarDiv> | ||
</div > | ||
); | ||
case "back": | ||
return ( | ||
<div> | ||
<sty.StyledTopBarDiv> | ||
<sty.StyledLeftDiv onClick={() => { navigate(-1) }} style={{ cursor: "pointer" }} > | ||
<img src={back} width="120px"></img> | ||
</sty.StyledLeftDiv> | ||
<sty.StyledCenterDiv> | ||
<sty.StyledCenterP>{center}</sty.StyledCenterP> | ||
</sty.StyledCenterDiv> | ||
<sty.StyledRightDiv> | ||
<sty.StyledRightP>{right}</sty.StyledRightP> | ||
</sty.StyledRightDiv> | ||
</sty.StyledTopBarDiv> | ||
</div> | ||
); | ||
case "none": | ||
return ( | ||
<div> | ||
<sty.StyledTopBarDiv> | ||
<sty.StyledLeftDiv> | ||
</sty.StyledLeftDiv> | ||
<sty.StyledCenterDiv> | ||
<sty.StyledCenterP>{center}</sty.StyledCenterP> | ||
</sty.StyledCenterDiv> | ||
<sty.StyledRightDiv> | ||
<sty.StyledRightP>{right}</sty.StyledRightP> | ||
</sty.StyledRightDiv> | ||
</sty.StyledTopBarDiv> | ||
</div> | ||
) | ||
} | ||
const navigate = useNavigate(); | ||
switch (left) { | ||
case "logo": | ||
return ( | ||
<div> | ||
<sty.StyledTopBarDiv> | ||
<sty.StyledLeftDiv | ||
onClick={() => { | ||
navigate("/"); | ||
}} | ||
> | ||
<img src={logo}></img> | ||
</sty.StyledLeftDiv> | ||
<sty.StyledCenterDiv> | ||
<sty.StyledCenterP>{center}</sty.StyledCenterP> | ||
</sty.StyledCenterDiv> | ||
<sty.StyledRightDiv> | ||
<sty.StyledRightP>{right}</sty.StyledRightP> | ||
</sty.StyledRightDiv> | ||
</sty.StyledTopBarDiv> | ||
</div> | ||
); | ||
|
||
case "back": | ||
return ( | ||
<div> | ||
<sty.StyledTopBarDiv> | ||
<sty.StyledLeftDiv | ||
onClick={() => { | ||
navigate(-1); | ||
}} | ||
> | ||
<img src={back}></img> | ||
</sty.StyledLeftDiv> | ||
<sty.StyledCenterDiv> | ||
<sty.StyledCenterP>{center}</sty.StyledCenterP> | ||
</sty.StyledCenterDiv> | ||
<sty.StyledRightDiv> | ||
<sty.StyledRightP>{right}</sty.StyledRightP> | ||
</sty.StyledRightDiv> | ||
</sty.StyledTopBarDiv> | ||
</div> | ||
); | ||
|
||
case "none": | ||
return ( | ||
<div> | ||
<sty.StyledTopBarDiv> | ||
<sty.StyledLeftDiv></sty.StyledLeftDiv> | ||
<sty.StyledCenterDiv> | ||
<sty.StyledCenterP>{center}</sty.StyledCenterP> | ||
</sty.StyledCenterDiv> | ||
<sty.StyledRightDiv> | ||
<sty.StyledRightP>{right}</sty.StyledRightP> | ||
</sty.StyledRightDiv> | ||
</sty.StyledTopBarDiv> | ||
</div> | ||
); | ||
} | ||
}; | ||
export default TopBarText; | ||
export default TopBarText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import styled from "styled-components"; | ||
|
||
export const StyledTopBarDiv = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
`; | ||
|
||
export const StyledLeftDiv = styled.div` | ||
${(props) => props.onClick && "cursor: pointer;"} | ||
img { | ||
width: 120px; | ||
} | ||
`; | ||
|
||
export const StyledCenterDiv = styled.div` | ||
width: 160px; | ||
text-align: center; | ||
`; | ||
|
||
export const StyledRightDiv = styled.div` | ||
width: 160px; | ||
`; | ||
|
||
export const StyledCenterP = styled.p` | ||
font-family: "Freesentation M"; | ||
font-size: 20px; | ||
color: white; | ||
`; | ||
|
||
export const StyledRightP = styled.p` | ||
font-family: "Freesentation M"; | ||
font-size: 16px; | ||
color: white; | ||
margin-right: 22px; | ||
`; |
This file was deleted.
Oops, something went wrong.