From 37f231ab2fc86e30305d4bbcccf86fb111856a6c Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Tue, 27 Feb 2024 14:49:19 +0900 Subject: [PATCH 01/10] feat: add highlighting function on ticker --- .../ticker/_components/ticker-drawer.tsx | 4 ++- .../(main)/ticker/_components/ticker-list.tsx | 32 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/app/(main)/ticker/_components/ticker-drawer.tsx b/src/app/(main)/ticker/_components/ticker-drawer.tsx index c1dce9f..2014b61 100644 --- a/src/app/(main)/ticker/_components/ticker-drawer.tsx +++ b/src/app/(main)/ticker/_components/ticker-drawer.tsx @@ -86,7 +86,9 @@ export const TickerDrawer = React.memo( )} - {drawerType === "name" && !!data && } + {drawerType === "name" && !!data && ( + + )} {drawerType === "count" && ( diff --git a/src/app/(main)/ticker/_components/ticker-list.tsx b/src/app/(main)/ticker/_components/ticker-list.tsx index a42c398..fa40146 100644 --- a/src/app/(main)/ticker/_components/ticker-list.tsx +++ b/src/app/(main)/ticker/_components/ticker-list.tsx @@ -10,7 +10,31 @@ interface TickerProps { onClick: (stock: Stock) => void; } -const TickerList = React.memo(({ data, hasShares, onClick }: TickerProps) => { +const TickerList = React.memo(({ data, tickerName, hasShares, onClick }: TickerProps) => { + const getHighlightText = React.useCallback( + (text?: string) => { + if (!tickerName || !text) return text; + const regex = new RegExp(tickerName, "gi"); + + return text.split(regex).reduce((acc: (string | React.ReactElement)[], cur = "", idx, arr) => { + acc.push(cur); + // 마지막 배열 순번이 아닐 경우에만 하이라이트 워딩 추가 + if (arr.length - 1 > idx) { + const match = text.match(regex); + const ticker = match ? match[idx] : tickerName; + + acc.push( + + {ticker} + + ); + } + return acc; + }, []); + }, + [tickerName] + ); + return (
@@ -19,8 +43,10 @@ const TickerList = React.memo(({ data, hasShares, onClick }: TickerProps) => {
-

{item.ticker}

-

{item.companyName}

+ {getHighlightText(item.ticker)} + + {getHighlightText(item.companyName)} +
{hasShares && ( From 8483281d09497533aa2ac97ff35811dfa8c696f4 Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Tue, 27 Feb 2024 15:00:21 +0900 Subject: [PATCH 02/10] style: add style on ticker list ui --- src/app/(main)/ticker/_components/ticker-list.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/(main)/ticker/_components/ticker-list.tsx b/src/app/(main)/ticker/_components/ticker-list.tsx index fa40146..6ec8762 100644 --- a/src/app/(main)/ticker/_components/ticker-list.tsx +++ b/src/app/(main)/ticker/_components/ticker-list.tsx @@ -40,10 +40,10 @@ const TickerList = React.memo(({ data, tickerName, hasShares, onClick }: TickerP
{data.map((item, index) => (
onClick(item)}> -
+
-
- {getHighlightText(item.ticker)} +
+ {getHighlightText(item.ticker)} {getHighlightText(item.companyName)} From 593ef36c9061ad211841c5fc95269af72eb64651 Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Tue, 27 Feb 2024 15:31:57 +0900 Subject: [PATCH 03/10] style: apply design qa about margin/padding --- src/app/(main)/ticker/_components/ticker-drawer.tsx | 2 ++ src/app/(main)/ticker/_components/ticker-footer.tsx | 2 +- src/components/ui/drawer.tsx | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/ticker/_components/ticker-drawer.tsx b/src/app/(main)/ticker/_components/ticker-drawer.tsx index 2014b61..08820e8 100644 --- a/src/app/(main)/ticker/_components/ticker-drawer.tsx +++ b/src/app/(main)/ticker/_components/ticker-drawer.tsx @@ -73,6 +73,8 @@ export const TickerDrawer = React.memo( clearInput={() => handleInputClear("name")} /> +
+ {drawerType !== "name" && ( ) => ( -
+
); DrawerHeader.displayName = "DrawerHeader"; From b10bb999676dc9da18bb4785ba9c921fa9fe1060 Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Tue, 27 Feb 2024 15:35:08 +0900 Subject: [PATCH 04/10] style: apply design qa on ticker-list --- src/app/(main)/ticker/_components/ticker-list.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/(main)/ticker/_components/ticker-list.tsx b/src/app/(main)/ticker/_components/ticker-list.tsx index 6ec8762..6b6fc83 100644 --- a/src/app/(main)/ticker/_components/ticker-list.tsx +++ b/src/app/(main)/ticker/_components/ticker-list.tsx @@ -37,7 +37,9 @@ const TickerList = React.memo(({ data, tickerName, hasShares, onClick }: TickerP return (
-
+
{data.map((item, index) => (
onClick(item)}>
From b7966084397a2adbb9e08ca2426f1b0d7e4891fb Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Tue, 27 Feb 2024 17:54:29 +0900 Subject: [PATCH 05/10] feat: add reset fc when user click overlay with edit type --- src/app/(main)/ticker/_components/ticker-content.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/(main)/ticker/_components/ticker-content.tsx b/src/app/(main)/ticker/_components/ticker-content.tsx index 10f934d..b9a9c37 100644 --- a/src/app/(main)/ticker/_components/ticker-content.tsx +++ b/src/app/(main)/ticker/_components/ticker-content.tsx @@ -114,6 +114,14 @@ const TickerContent = React.memo(() => { isDrawerOpenChange(false); }, [editStock, isDrawerOpenChange, resetData, selectedStock, tickerCount]); + const handleOverlayClick = React.useCallback(() => { + isDrawerOpenChange(false); + + if (drawerType === "edit") { + resetData(); + } + }, [drawerType, isDrawerOpenChange, resetData]); + return ( {
- isDrawerOpenChange(false)} /> + Date: Tue, 27 Feb 2024 17:58:21 +0900 Subject: [PATCH 06/10] style: change the dialog button height --- src/components/common/dialog/dialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/dialog/dialog.tsx b/src/components/common/dialog/dialog.tsx index 7abed47..8095d85 100644 --- a/src/components/common/dialog/dialog.tsx +++ b/src/components/common/dialog/dialog.tsx @@ -16,7 +16,7 @@ export const Dialog = React.memo(({ title }: DialogProps) => { {title} - From 2af18784801c4ee54c425185f5202533efce0a88 Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Tue, 27 Feb 2024 18:19:25 +0900 Subject: [PATCH 07/10] style: fix dialog modal according to qa --- src/components/common/dialog/dialog.tsx | 4 ++-- src/components/ui/dialog.tsx | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/common/dialog/dialog.tsx b/src/components/common/dialog/dialog.tsx index 8095d85..03a8cf8 100644 --- a/src/components/common/dialog/dialog.tsx +++ b/src/components/common/dialog/dialog.tsx @@ -11,9 +11,9 @@ interface DialogProps { export const Dialog = React.memo(({ title }: DialogProps) => { const { isDialogOpenChange } = useDialogStore(); return ( - + - {title} + {title}
- )} + ) : null}
{inputState === "error" && errorDescription &&

{errorDescription}

}