-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
165 additions
and
85 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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { type StockMetricsPanelProps } from '@/types/metrics'; | ||
|
||
export const METRIC_DETAILS = { | ||
price: { | ||
currentPrice: { | ||
name: '현재가', | ||
message: '현재 주식의 거래 가격이에요.', | ||
}, | ||
tradingVolume: { | ||
name: '거래량', | ||
message: '해당 기간 동안 거래된 주식의 수량이에요.', | ||
}, | ||
fluctuationRate: { | ||
name: '변동률', | ||
message: '전일 대비 주가 변동 비율이에요.', | ||
}, | ||
fiftyTwoWeekRange: { | ||
name: '52주 최고/최저가', | ||
message: '최근 52주 동안의 최고/최저 주가예요.', | ||
}, | ||
}, | ||
enterpriseValue: { | ||
marketCap: { | ||
name: '시가총액', | ||
message: '발행 주식 수와 현재 가격을 곱한 값으로, 기업가치를 나타내요.', | ||
}, | ||
per: { | ||
name: 'PER', | ||
message: '주가/주당순이익으로, 주식의 투자 매력도를 나타내요.', | ||
}, | ||
eps: { | ||
name: 'EPS', | ||
message: '주당순이익으로, 기업의 수익성을 보여줘요.', | ||
}, | ||
}, | ||
}; | ||
|
||
export const METRICS_DATA = ({ | ||
price, | ||
volume, | ||
change, | ||
high52w, | ||
low52w, | ||
marketCap, | ||
per, | ||
eps, | ||
}: StockMetricsPanelProps) => { | ||
return { | ||
price: { | ||
title: '가격', | ||
metrics: [ | ||
{ | ||
...METRIC_DETAILS.price.currentPrice, | ||
value: price?.toLocaleString(), | ||
}, | ||
{ | ||
...METRIC_DETAILS.price.tradingVolume, | ||
value: volume?.toLocaleString(), | ||
}, | ||
{ | ||
...METRIC_DETAILS.price.fluctuationRate, | ||
value: change?.toLocaleString(), | ||
}, | ||
{ | ||
...METRIC_DETAILS.price.fiftyTwoWeekRange, | ||
value: `${high52w?.toLocaleString()}/${low52w?.toLocaleString()}`, | ||
}, | ||
], | ||
}, | ||
enterpriseValue: { | ||
title: '기업가치', | ||
metrics: [ | ||
{ | ||
...METRIC_DETAILS.enterpriseValue.marketCap, | ||
value: marketCap?.toLocaleString(), | ||
}, | ||
{ | ||
...METRIC_DETAILS.enterpriseValue.per, | ||
value: per?.toLocaleString(), | ||
}, | ||
{ | ||
...METRIC_DETAILS.enterpriseValue.eps, | ||
value: eps?.toLocaleString(), | ||
}, | ||
], | ||
}, | ||
}; | ||
}; |
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
50 changes: 39 additions & 11 deletions
50
packages/frontend/src/pages/stock-detail/StockMetricsPanel.tsx
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,17 +1,45 @@ | ||
import { MetricSection } from './components'; | ||
import { METRIC_DETAILS } from '@/constants/METRIC_DETAILS'; | ||
import { MetricItem, Title } from './components'; | ||
import { METRICS_DATA } from '@/constants/metricDetail'; | ||
import { type StockMetricsPanelProps } from '@/types/metrics'; | ||
|
||
export const StockMetricsPanel = ({ | ||
eps, | ||
high52w, | ||
low52w, | ||
marketCap, | ||
per, | ||
price, | ||
change, | ||
volume, | ||
}: StockMetricsPanelProps) => { | ||
const metricsData = METRICS_DATA({ | ||
eps, | ||
high52w, | ||
low52w, | ||
marketCap, | ||
per, | ||
price, | ||
change, | ||
volume, | ||
}); | ||
|
||
export const StockMetricsPanel = () => { | ||
return ( | ||
<article className="flex flex-col gap-10 rounded-md bg-white p-6 shadow"> | ||
<MetricSection | ||
title="가격" | ||
metricInfo={Object.values(METRIC_DETAILS.price)} | ||
/> | ||
<MetricSection | ||
title="기업가치" | ||
metricInfo={Object.values(METRIC_DETAILS.enterpriseValue)} | ||
/> | ||
{Object.values(metricsData).map((section) => ( | ||
<section className="flex flex-col"> | ||
<Title>{section.title}</Title> | ||
<section className="grid grid-cols-[repeat(4,100px)] items-center"> | ||
{section.metrics.map((metric) => ( | ||
<MetricItem | ||
key={metric.name} | ||
label={metric.name} | ||
value={metric.value} | ||
tooltip={metric.message} | ||
/> | ||
))} | ||
</section> | ||
</section> | ||
))} | ||
</article> | ||
); | ||
}; |
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
13 changes: 7 additions & 6 deletions
13
packages/frontend/src/pages/stock-detail/components/MetricItem.tsx
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,20 +1,21 @@ | ||
import { Tooltip } from '@/components/ui/tooltip'; | ||
|
||
export interface MetricItemProps { | ||
name: string; | ||
message: string; | ||
label: string; | ||
tooltip: string; | ||
value?: string | number; | ||
} | ||
|
||
export const MetricItem = ({ name, message }: MetricItemProps) => { | ||
export const MetricItem = ({ label, tooltip, value }: MetricItemProps) => { | ||
return ( | ||
<> | ||
<div className="group relative"> | ||
<Tooltip className="absolute bottom-full mb-6">{message}</Tooltip> | ||
<Tooltip className="absolute bottom-full mb-6">{tooltip}</Tooltip> | ||
<span className="display-medium14 text-gray cursor-pointer font-bold"> | ||
{name} | ||
{label} | ||
</span> | ||
</div> | ||
<span className="display-medium14 text-dark-gray">00.000</span> | ||
<span className="display-medium14 text-dark-gray">{value}</span> | ||
</> | ||
); | ||
}; |
19 changes: 0 additions & 19 deletions
19
packages/frontend/src/pages/stock-detail/components/MetricSection.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
export * from './TextArea'; | ||
export * from './MetricItem'; | ||
export * from './MetricSection'; | ||
export * from './Title'; | ||
export * from './StockDetailHeader'; |
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,10 @@ | ||
export interface StockMetricsPanelProps { | ||
eps?: number; | ||
high52w?: number; | ||
low52w?: number; | ||
marketCap?: number; | ||
per?: string; | ||
price?: number; | ||
change?: number; | ||
volume?: number; | ||
} |