13
13
// limitations under the License.
14
14
15
15
import React from 'react'
16
+ import classnames from 'classnames'
16
17
17
18
import Message from '@ttn-lw/lib/components/message'
18
19
19
20
import PropTypes from '@ttn-lw/lib/prop-types'
20
21
21
22
import Icon from '../icon'
22
- import Button from '../button '
23
+ import Link from '../link '
23
24
24
25
import Toggle from './toggle'
25
26
@@ -33,17 +34,23 @@ const Panel = ({
33
34
activeToggle,
34
35
onToggleClick,
35
36
buttonTitle,
37
+ path,
38
+ className,
39
+ messageDecorators,
36
40
} ) => (
37
- < div className = { styles . panel } >
38
- < div className = "d-flex j-between mb-cs-xl " >
41
+ < div className = { classnames ( styles . panel , className ) } >
42
+ < div className = "d-flex j-between mb-cs-m " >
39
43
< div className = "d-flex gap-cs-xs al-center" >
40
44
{ icon && < Icon icon = { icon } className = { styles . panelHeaderIcon } /> }
41
45
< Message content = { title } className = { styles . panelHeaderTitle } />
46
+ { messageDecorators }
42
47
</ div >
43
48
{ toggleOptions ? (
44
49
< Toggle options = { toggleOptions } active = { activeToggle } onToggleChange = { onToggleClick } />
45
50
) : (
46
- < Button message = { buttonTitle } unstyled className = { styles . button } />
51
+ < Link primary to = { path } className = { styles . button } >
52
+ < Message content = { buttonTitle } /> →
53
+ </ Link >
47
54
) }
48
55
</ div >
49
56
{ children }
@@ -54,8 +61,11 @@ Panel.propTypes = {
54
61
activeToggle : PropTypes . string ,
55
62
buttonTitle : PropTypes . string ,
56
63
children : PropTypes . node . isRequired ,
64
+ className : PropTypes . string ,
57
65
icon : PropTypes . string ,
66
+ messageDecorators : PropTypes . node ,
58
67
onToggleClick : PropTypes . func ,
68
+ path : PropTypes . string . isRequired ,
59
69
title : PropTypes . message . isRequired ,
60
70
toggleOptions : PropTypes . arrayOf ( PropTypes . shape ( { } ) ) ,
61
71
}
@@ -66,6 +76,8 @@ Panel.defaultProps = {
66
76
toggleOptions : undefined ,
67
77
activeToggle : undefined ,
68
78
onToggleClick : ( ) => null ,
79
+ className : undefined ,
80
+ messageDecorators : undefined ,
69
81
}
70
82
71
83
export default Panel
0 commit comments