Skip to content

Commit 6ba927c

Browse files
committed
feat: Body 컴포넌트 추가
1 parent e393728 commit 6ba927c

File tree

1 file changed

+13
-4
lines changed
  • frontend/src/components/Ranking/RankingTable

1 file changed

+13
-4
lines changed

frontend/src/components/Ranking/RankingTable/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Children } from 'react';
21
import styled, { css } from 'styled-components';
32

43
type TextAlignType = 'center' | 'right' | 'left';
@@ -7,6 +6,10 @@ interface HeadProps {
76
children?: React.ReactNode;
87
}
98

9+
interface BodyProps {
10+
children?: React.ReactNode;
11+
}
12+
1013
interface RowProps {
1114
children?: React.ReactNode;
1215
onClick?: () => void;
@@ -47,6 +50,13 @@ function Head({ children }: HeadProps) {
4750
);
4851
}
4952

53+
/**
54+
* Body 컴포넌트는 Ranking 컴포넌트의 자식 컴포넌트로 사용되어야 하고 Row 컴포넌트를 자식 컴포넌트로 가져야 합니다.
55+
*/
56+
function Body({ children }: BodyProps) {
57+
return <tbody>{children}</tbody>;
58+
}
59+
5060
/**
5161
* Row 컴포넌트는 Ranking 컴포넌트의 자식 컴포넌트로 사용되어야 합니다.
5262
*/
@@ -70,18 +80,17 @@ function Element({ children }: ElementProps) {
7080
* Ranking 컴포넌트는 Row와 Element 컴포넌트를 자식 컴포넌트로 가져야합니다.
7181
*/
7282
function RankingTable({ width, columnWidthList, columnAlignList, children }: RankingProps) {
73-
const doms = Children.toArray(children);
7483
return (
7584
<Container width={width} tdWidthList={columnWidthList} tdAlignList={columnAlignList}>
76-
{doms[0]}
77-
<tbody>{doms.slice(1)}</tbody>
85+
{children}
7886
</Container>
7987
);
8088
}
8189

8290
RankingTable.Head = Head;
8391
RankingTable.Row = Row;
8492
RankingTable.Element = Element;
93+
RankingTable.Body = Body;
8594

8695
export default RankingTable;
8796

0 commit comments

Comments
 (0)