-
Notifications
You must be signed in to change notification settings - Fork 3
주식리스트 테이블 레이아웃 구현 #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2950a86
#90 feat(fe):테이블 type, columns 구현
handje 6b52c8c
#90 fix(fe): 주식리스트 파일명 변경
handje e9452d8
#90 feat(fe):index파일 추가
handje 2e226e8
#90 feat(fe):데이터 테이블 구현
handje ffa04e2
#90 fix(fe):테이블 sorting 오류 수정
handje 030c471
#90 fix(fe):주식 slug네이밍 수정 및 타입 추가
handje 045ffc0
#90 feat(fe): 테이블 link 연결
handje f76ed2d
#90 refactor(fe):메인페이지 임시 버튼 삭제
handje 45a6647
#90 refactor(fe):디자인시스템 DataTable삭제 및 의존성 삭제
handje File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,2 +1 @@ | ||
| export { default as StockDetailLayout } from './ui/stock-detail-layout'; | ||
| export { default as StocksList } from './ui/stocks-list'; | ||
| export { StockDetailLayout, StocksList } from './ui'; |
This file contains hidden or 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,2 @@ | ||
| export { type Stock } from './stock.types'; | ||
| export { columns } from './stocks-table.columns'; |
8 changes: 8 additions & 0 deletions
8
src/frontend/apps/web/src/features/stock/model/stock.types.ts
This file contains hidden or 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,8 @@ | ||
| export type Stock = { | ||
| id: string; | ||
| name: string; | ||
| currPrice: string; | ||
| fluctuation: string; | ||
| volume: string; | ||
| slug: string; | ||
| }; | ||
61 changes: 61 additions & 0 deletions
61
src/frontend/apps/web/src/features/stock/model/stocks-table.columns.tsx
This file contains hidden or 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,61 @@ | ||
| import { ColumnDef } from '@tanstack/react-table'; | ||
| import { Stock } from './stock.types'; | ||
| import { Button } from '@workspace/ui/components'; | ||
| import { ArrowUpDown } from 'lucide-react'; | ||
|
|
||
| export const columns: ColumnDef<Stock>[] = [ | ||
| { | ||
| accessorKey: 'name', | ||
| header: () => <div className="text-left">종목명</div>, | ||
| cell: ({ row }) => <div className="text-left">{row.getValue('name')}</div>, | ||
| }, | ||
| { | ||
| id: 'currPrice', | ||
| accessorFn: (row) => parseFloat(row.currPrice), | ||
| header: ({ column }) => ( | ||
| <Button | ||
| variant="ghost" | ||
| onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')} | ||
| > | ||
| 현재가 | ||
| <ArrowUpDown /> | ||
| </Button> | ||
| ), | ||
| cell: ({ row }) => { | ||
| const price = parseFloat(row.getValue('currPrice')); | ||
| const formatted = new Intl.NumberFormat('en-US', { | ||
| style: 'decimal', | ||
| currency: 'KRW', | ||
| }).format(price); | ||
| return <div className="text-right font-medium">{`${formatted}원`}</div>; | ||
| }, | ||
| }, | ||
| { | ||
| id: 'fluctuation', | ||
| accessorFn: (row) => parseFloat(row.fluctuation), | ||
| header: ({ column }) => ( | ||
| <Button | ||
| variant="ghost" | ||
| onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')} | ||
| > | ||
| 등락률 | ||
| <ArrowUpDown /> | ||
| </Button> | ||
| ), | ||
| cell: ({ row }) => <div>{row.getValue('fluctuation')}%</div>, | ||
| }, | ||
| { | ||
| id: 'volume', | ||
| accessorFn: (row) => parseFloat(row.volume), | ||
| header: ({ column }) => ( | ||
| <Button | ||
| variant="ghost" | ||
| onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')} | ||
| > | ||
| 거래량 | ||
| <ArrowUpDown /> | ||
| </Button> | ||
| ), | ||
| cell: ({ row }) => <div>{row.getValue('volume')}</div>, | ||
| }, | ||
| ]; |
This file contains hidden or 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,2 @@ | ||
| export { default as StockDetailLayout } from './stock-detail-layout'; | ||
| export { default as StocksList } from './stocks-list-table'; |
108 changes: 108 additions & 0 deletions
108
src/frontend/apps/web/src/features/stock/ui/stocks-list-table.tsx
This file contains hidden or 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,108 @@ | ||
| 'use client'; | ||
|
|
||
| import { SortingState, flexRender, getCoreRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table'; | ||
| import { useState } from 'react'; | ||
| import { Stock, columns } from '../model'; | ||
| import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@workspace/ui/components'; | ||
| import { useRouter } from 'next/navigation'; | ||
|
|
||
| const Stockdata: Stock[] = [ | ||
| { | ||
| id: '1', | ||
| name: '삼성전자', | ||
| currPrice: '53700', | ||
| fluctuation: '+0.00', | ||
| volume: '1000', | ||
| slug: 'samsung-electronics', | ||
| }, | ||
| { | ||
| id: '2', | ||
| name: 'SK하이닉스', | ||
| currPrice: '221000', | ||
| fluctuation: '+0.68', | ||
| volume: '1000', | ||
| slug: 'sk-hynix', | ||
| }, | ||
| { | ||
| id: '3', | ||
| name: '카카오', | ||
| currPrice: '35750', | ||
| fluctuation: '+0.00', | ||
| volume: '1000', | ||
| slug: 'kakao', | ||
| }, | ||
| { | ||
| id: '4', | ||
| name: '네이버', | ||
| currPrice: '204000', | ||
| fluctuation: '-0.24', | ||
| volume: '1000', | ||
| slug: 'naver', | ||
| }, | ||
| { | ||
| id: '5', | ||
| name: '한화에어로스페이스', | ||
| currPrice: '411500', | ||
| fluctuation: '+7.30', | ||
| volume: '1000', | ||
| slug: 'hanwha-aerospace', | ||
| }, | ||
| ]; | ||
|
|
||
| const StocksListTable = () => { | ||
| const [sorting, setSorting] = useState<SortingState>([]); | ||
| const router = useRouter(); | ||
|
|
||
| const table = useReactTable({ | ||
| data: Stockdata, | ||
| columns, | ||
| onSortingChange: setSorting, | ||
| getCoreRowModel: getCoreRowModel(), | ||
| getSortedRowModel: getSortedRowModel(), | ||
| state: { | ||
| sorting, | ||
| }, | ||
| }); | ||
| return ( | ||
| <div className="w-3/4 shadow-s"> | ||
| <Table> | ||
| <TableHeader> | ||
| {table.getHeaderGroups().map((headerGroup) => ( | ||
| <TableRow key={headerGroup.id}> | ||
| {headerGroup.headers.map((header) => { | ||
| return <TableHead key={header.id}>{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}</TableHead>; | ||
| })} | ||
| </TableRow> | ||
| ))} | ||
| </TableHeader> | ||
| <TableBody> | ||
| {table.getRowModel().rows?.length ? ( | ||
| table.getRowModel().rows.map((row) => ( | ||
| <TableRow | ||
| key={row.id} | ||
| className="cursor-pointer" | ||
| onClick={() => { | ||
| router.push(`/${row.original.slug ?? ''}`); | ||
| }} | ||
| > | ||
| {row.getVisibleCells().map((cell) => ( | ||
| <TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell> | ||
| ))} | ||
| </TableRow> | ||
| )) | ||
| ) : ( | ||
| <TableRow> | ||
| <TableCell | ||
| colSpan={columns.length} | ||
| className="h-24 text-center" | ||
| > | ||
| No results. | ||
| </TableCell> | ||
| </TableRow> | ||
| )} | ||
| </TableBody> | ||
| </Table> | ||
| </div> | ||
| ); | ||
| }; | ||
| export default StocksListTable; |
52 changes: 0 additions & 52 deletions
52
src/frontend/apps/web/src/features/stock/ui/stocks-list.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
44 changes: 0 additions & 44 deletions
44
src/frontend/packages/ui/src/components/DataTable/data-table.stories.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 파일명을 stock.type.d.ts만 바꿔주시면 감사하겠습니당
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KimKyuHoi 제가 찾아봤을때에는 전역 타입이 아니고 model내부에서의 타입은 .types.ts.를 많이 사용한다해서 파일명으로 사용하긴 했습니다!
혹시 이 부분에 대해 type.d.ts가 더 좋은 네이밍 일까요?