|
1 | 1 | import * as _ from 'lodash'; |
2 | 2 | import * as React from 'react'; |
3 | | -import classNames from 'classnames'; |
4 | 3 |
|
5 | 4 | import './TypeDoc.css'; |
6 | 5 |
|
@@ -88,18 +87,17 @@ export default class TypeDoc extends React.Component<TypeDocProps> { |
88 | 87 |
|
89 | 88 | if (types.length === 0) return null; |
90 | 89 |
|
| 90 | + const isSelected = type.id === selectedId; |
91 | 91 | return ( |
92 | 92 | <div className="doc-category"> |
93 | 93 | <div className="title">{typesTitle}</div> |
94 | 94 | {_.map(types, (type) => { |
95 | 95 | let props: any = { |
96 | 96 | key: type.id, |
97 | | - className: classNames('item', { |
98 | | - '-selected': type.id === selectedId, |
99 | | - }), |
| 97 | + className: `item ${isSelected ? '-selected' : ''}`, |
100 | 98 | onClick: () => onSelectEdge(type.id), |
101 | 99 | }; |
102 | | - if (type.id === selectedId) props.ref = 'selectedItem'; |
| 100 | + if (isSelected) props.ref = 'selectedItem'; |
103 | 101 | return ( |
104 | 102 | <div {...props}> |
105 | 103 | <TypeLink |
@@ -133,25 +131,23 @@ export default class TypeDoc extends React.Component<TypeDocProps> { |
133 | 131 | <div className="doc-category"> |
134 | 132 | <div className="title">fields</div> |
135 | 133 | {fields.map((field) => { |
| 134 | + const hasArgs = !_.isEmpty(field.args); |
| 135 | + const isSelected = field.id === selectedId; |
| 136 | + |
136 | 137 | let props: any = { |
137 | 138 | key: field.name, |
138 | | - className: classNames('item', { |
139 | | - '-selected': field.id === selectedId, |
140 | | - '-with-args': !_.isEmpty(field.args), |
141 | | - }), |
| 139 | + className: `item ${isSelected ? '-selected' : ''} ${ |
| 140 | + hasArgs ? '-with-args' : '' |
| 141 | + }`, |
142 | 142 | onClick: () => onSelectEdge(field.id), |
143 | 143 | }; |
144 | | - if (field.id === selectedId) props.ref = 'selectedItem'; |
| 144 | + if (isSelected) props.ref = 'selectedItem'; |
145 | 145 | return ( |
146 | 146 | <div {...props}> |
147 | 147 | <a className="field-name"> |
148 | 148 | {highlightTerm(field.name, filter)} |
149 | 149 | </a> |
150 | | - <span |
151 | | - className={classNames('args-wrap', { |
152 | | - '-empty': _.isEmpty(field.args), |
153 | | - })} |
154 | | - > |
| 150 | + <span className={`args-wrap ${hasArgs ? '' : '-empty'}`}> |
155 | 151 | {!_.isEmpty(field.args) && ( |
156 | 152 | <span key="args" className="args"> |
157 | 153 | {_.map(field.args, (arg) => ( |
|
0 commit comments