1- import { Children } from 'react' ;
21import styled , { css } from 'styled-components' ;
32
43type 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+
1013interface 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 */
7282function 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
8290RankingTable . Head = Head ;
8391RankingTable . Row = Row ;
8492RankingTable . Element = Element ;
93+ RankingTable . Body = Body ;
8594
8695export default RankingTable ;
8796
0 commit comments