11import React , { useState } from 'react'
22import { Card , Collapse } from 'react-bootstrap'
33import { Icon } from '../Icon'
4+ import { ColorVariant } from '../../interfaces'
45
56interface Props {
67 /** Defines the color of the panel */
7- color ?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'light' | 'dark'
8+ color ?: ColorVariant
89 /** The body for the panel */
910 children ?: React . ReactNode
1011 /** The title for the Panel */
@@ -21,24 +22,27 @@ const Panel = (props: Props) => {
2122 const { color, children, footer, title, collapsible, collapsed } = props
2223 const [ open , setOpen ] = useState ( ! collapsed )
2324
25+ const collapseIcon = (
26+ < span style = { { float : 'right' } } >
27+ < Icon
28+ icon = { open ? 'up-arrow' : 'down-arrow' }
29+ onClick = { ( ) => setOpen ( ! open ) }
30+ aria-controls = "collapse-body"
31+ aria-expanded = { open }
32+ />
33+ </ span >
34+ )
35+
2436 return (
2537 < Card border = { color } >
2638 { title && (
2739 < Card . Header style = { { textAlign : 'left' } } >
2840 { title }
29- { collapsible && (
30- < span style = { { float : 'right' } } >
31- < Icon
32- icon = { open ? 'up-arrow' : 'down-arrow' }
33- onClick = { ( ) => setOpen ( ! open ) }
34- aria-controls = "collapse-body"
35- aria-expanded = { open }
36- />
37- </ span >
38- ) }
41+ { collapsible && collapseIcon }
3942 </ Card . Header >
4043 ) }
4144 < Card . Body style = { { textAlign : 'left' } } >
45+ { collapsible && ! title && collapseIcon }
4246 < Collapse in = { open } >
4347 < div id = "collapse-body" > { children } </ div >
4448 </ Collapse >
0 commit comments