@@ -3,9 +3,9 @@ import { MouseEvent, PropsWithChildren, useState } from "react"
33import styled from "@emotion/styled"
44
55const StyledAccordionContainer = styled . div `
6- margin-left: 100px;
76 display: flex;
8- width: calc(100% - 400px - 100px);
7+ flex: 1;
8+ overflow: hidden;
99`
1010
1111export const AccordionContainer = ( { children } : PropsWithChildren ) => (
@@ -15,6 +15,7 @@ export const AccordionContainer = ({ children }: PropsWithChildren) => (
1515const StyledAccordionGroup = styled . div `
1616 height: 400px;
1717 display: flex;
18+ flex: 1;
1819 padding: 0 10px;
1920 flex-direction: row;
2021 border-right: 3px solid var(--default-color);
@@ -23,9 +24,9 @@ const StyledAccordionGroup = styled.div`
2324 }
2425`
2526
26- const AccordionContent = styled . div < { width : number } > `
27+ const AccordionContent = styled . div < { width : number | string | null } > `
2728 height: 100%;
28- width: ${ ( { width } ) => `${ width } px` } ;
29+ width: ${ ( { width } ) => ( typeof width !== "number" ? width : `${ width } px` ) } ;
2930 display: flex;
3031 flex-direction: column;
3132 justify-content: center;
@@ -144,10 +145,12 @@ type groupProps = PropsWithChildren<{
144145const getAvailableContentWidth = ( element : HTMLElement | null ) => {
145146 const parent = element ?. parentElement
146147 if ( ! parent ) return 0
148+ if ( parent . children . length === 1 ) return "100%"
147149 const barWidth = [ ...parent . children ] . reduce (
148150 ( width , element ) => Math . min ( width , ( element as HTMLElement ) . offsetWidth ) ,
149151 Infinity
150152 )
153+ console . log ( barWidth )
151154 return parent . offsetWidth - parent . children . length * barWidth
152155}
153156
@@ -158,7 +161,7 @@ export const AccordionGroup = ({
158161 onClick,
159162 onMouseDown,
160163} : groupProps ) => {
161- const [ contentWidth , setContentWidth ] = useState ( active ? 500 : 0 )
164+ const [ contentWidth , setContentWidth ] = useState < number | string | null > ( null )
162165
163166 return (
164167 < StyledAccordionGroup
0 commit comments