-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 비교차트 기능 관련하여 구현여부 테스트 위한 UI 및 로직 초기 세팅 (미완) - 기능 테스트 성공 시 UI 및 로직 보완하여 완성할 예정 Issues #14
- Loading branch information
1 parent
3f27179
commit aa19b02
Showing
10 changed files
with
225 additions
and
79 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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { useState } from "react"; | ||
import { styled } from "styled-components"; | ||
import useCompanyData from "../../hooks/useCompanyData"; | ||
|
||
import CompareList from "./CompareList"; | ||
import IconImg from "../../asset/CentralSectionMenu-compareChart.png"; | ||
|
||
const buttonText: string = "비교차트"; | ||
|
||
const CompareChartBtn = () => { | ||
const { data: companyList } = useCompanyData(1, 14); | ||
const [compare, setCompare] = useState(false); | ||
|
||
const handleCompareChart = () => { | ||
setCompare(!compare); | ||
}; | ||
|
||
// console.log(companyList); | ||
|
||
return ( | ||
<Container> | ||
<div className="compareButtonContainer"> | ||
<Icon src={IconImg} /> | ||
<div className="compareButton" onClick={handleCompareChart}> | ||
{buttonText} | ||
</div> | ||
</div> | ||
{compare && ( | ||
<CompareContainer> | ||
<StockList> | ||
{companyList?.map((company) => { | ||
const corpName = company.korName; | ||
const companyId = company.companyId; | ||
console.log(corpName); | ||
|
||
return <CompareList corpName={corpName} compareCompanyId={companyId} />; | ||
})} | ||
</StockList> | ||
</CompareContainer> | ||
)} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default CompareChartBtn; | ||
|
||
const Container = styled.div` | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: flex-start; | ||
padding-top: 10px; | ||
padding-right: 13px; | ||
.compareButtonContainer { | ||
display: flex; | ||
flex-direction: row; | ||
z-index: 2; | ||
} | ||
.compareButton { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 12px; | ||
padding-top: 2.5px; | ||
cursor: pointer; | ||
} | ||
`; | ||
|
||
const Icon = styled.img` | ||
width: auto; | ||
height: 18px; | ||
padding-top: 0.5px; | ||
padding-right: 3px; | ||
`; | ||
|
||
const CompareContainer = styled.div` | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
`; | ||
|
||
const StockList = styled.div` | ||
position: absolute; | ||
width: 100px; | ||
height: 300px; | ||
z-index: 2; | ||
background-color: white; | ||
`; |
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,34 @@ | ||
import { useSelector, useDispatch } from "react-redux"; | ||
import { setCompareStock } from "../../reducer/CompareChart-Reducer"; | ||
import { StateProps } from "../../models/stateProps"; | ||
import { styled } from "styled-components"; | ||
|
||
const CompareList = (props: OwnProps) => { | ||
const { corpName, compareCompanyId } = props; | ||
|
||
//🔴 확인 직업 | ||
// const compareInfo = useSelector((state: StateProps) => state.compareChart); | ||
// console.log(compareInfo); | ||
// | ||
|
||
const dispatch = useDispatch(); | ||
const currentCompanyid = useSelector((state: StateProps) => state.companyId); | ||
|
||
const handleSelectCompareStock = () => { | ||
if (currentCompanyid === compareCompanyId) { | ||
return; | ||
} | ||
|
||
dispatch(setCompareStock(compareCompanyId)); | ||
}; | ||
|
||
return <Contianer onClick={handleSelectCompareStock}>{corpName}</Contianer>; | ||
}; | ||
export default CompareList; | ||
|
||
interface OwnProps { | ||
corpName: string; | ||
compareCompanyId: number; | ||
} | ||
|
||
const Contianer = styled.div``; |
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
37 changes: 0 additions & 37 deletions
37
client/src/components/CentralChartMenu/CompareChartBtn.tsx
This file was deleted.
Oops, something went wrong.
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
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,17 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
|
||
const initialState = null; | ||
|
||
const compareChartSlice = createSlice({ | ||
name: "compareChart", | ||
initialState: initialState, | ||
reducers: { | ||
setCompareStock: (state, action) => { | ||
state = action.payload; | ||
return state; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { setCompareStock } = compareChartSlice.actions; | ||
export const compareChartReducer = compareChartSlice.reducer; |
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