1
- import CogMenu from './CogMenu ' ;
1
+ import SubPanel from './SubPanel ' ;
2
2
import React , { Component , cloneElement } from 'react' ;
3
3
import PropTypes from 'prop-types' ;
4
- import { bem , icon } from '../../lib' ;
4
+ import { icon } from '../../lib' ;
5
5
import unpackPlotProps from '../../lib/unpackPlotProps' ;
6
6
7
- const classNames = {
8
- section : bem ( 'section' ) ,
9
- sectionHeading : bem ( 'section' , 'heading' ) ,
10
- sectionCogMenu : `${ bem ( 'section' , 'cog-menu' ) } ${ icon ( 'cog' ) } ` ,
11
- } ;
12
-
13
7
function childIsVisible ( child ) {
14
8
return Boolean ( ( child . props . plotProps || { } ) . isVisible ) ;
15
9
}
@@ -19,7 +13,7 @@ class Section extends Component {
19
13
super ( props , context ) ;
20
14
21
15
this . children = null ;
22
- this . cogMenu = null ;
16
+ this . subPanel = null ;
23
17
24
18
this . processAndSetChildren ( context ) ;
25
19
}
@@ -35,48 +29,43 @@ class Section extends Component {
35
29
}
36
30
37
31
const attrChildren = [ ] ;
38
- let cogMenu = null ;
32
+ let subPanel = null ;
39
33
40
34
for ( let i = 0 ; i < children . length ; i ++ ) {
41
35
let child = children [ i ] ;
42
36
if ( ! child ) {
43
37
continue ;
44
38
}
45
- if ( child . type === CogMenu ) {
46
- // Process the first cogMenu . Ignore the rest.
47
- if ( cogMenu ) {
39
+ if ( child . type === SubPanel ) {
40
+ // Process the first subPanel . Ignore the rest.
41
+ if ( subPanel ) {
48
42
continue ;
49
43
}
50
- cogMenu = child ;
44
+ subPanel = child ;
51
45
continue ;
52
46
}
53
47
54
48
let isAttr = ! ! child . props . attr ;
55
49
let plotProps = isAttr
56
50
? unpackPlotProps ( child . props , context , child . constructor )
57
- : { } ;
51
+ : { isVisible : true } ;
58
52
let childProps = Object . assign ( { plotProps} , child . props ) ;
59
53
childProps . key = i ;
60
-
61
- attrChildren . push ( cloneElement ( child , childProps , child . children ) ) ;
54
+ attrChildren . push ( cloneElement ( child , childProps ) ) ;
62
55
}
63
56
64
57
this . children = attrChildren . length ? attrChildren : null ;
65
- this . cogMenu = cogMenu ;
58
+ this . subPanel = subPanel ;
66
59
}
67
60
68
61
render ( ) {
69
62
const hasVisibleChildren = this . children . some ( childIsVisible ) ;
70
63
71
64
return hasVisibleChildren ? (
72
- < div className = { classNames . section } >
73
- < div className = { classNames . sectionHeading } >
65
+ < div className = " section" >
66
+ < div className = "section__heading" >
74
67
{ this . props . name }
75
- { this . cogMenu ? (
76
- < span >
77
- < i className = { classNames . sectionCogMenu } />
78
- </ span >
79
- ) : null }
68
+ { this . subPanel }
80
69
</ div >
81
70
{ this . children }
82
71
</ div >
0 commit comments