File tree Expand file tree Collapse file tree 1 file changed +7
-21
lines changed
packages/filter/src/lib/utils Expand file tree Collapse file tree 1 file changed +7
-21
lines changed Original file line number Diff line number Diff line change 1
1
import { tokens } from '@equinor/eds-tokens' ;
2
2
import { StyledNormalText } from '../components/filterGroup/filterGroup.styles' ;
3
3
4
- export function getFilterHeaderText (
5
- isAllChecked : boolean ,
6
- name : string ,
7
- checkedValues : string [ ]
8
- ) : string | JSX . Element {
4
+ export function getFilterHeaderText ( isAllChecked : boolean , name : string , checkedValues : string [ ] ) : JSX . Element {
9
5
const selectedCount = checkedValues . length ;
10
-
11
- const hasBlank = checkedValues . includes ( '(Blank)' ) ;
12
- const nonBlankCount = hasBlank ? selectedCount - 1 : selectedCount ;
13
-
14
- if ( hasBlank && nonBlankCount > 0 ) {
15
- return < StyledNormalText > { `${ name } (Blank) (+${ nonBlankCount } )` } </ StyledNormalText > ;
16
- }
17
-
18
- if ( selectedCount === 1 && hasBlank ) {
19
- return < StyledNormalText > { `${ name } (Blank)` } </ StyledNormalText > ;
20
- }
21
-
22
6
const displayText = selectedCount > 0 ? `${ name } (+${ selectedCount } )` : name ;
23
7
24
- if ( isAllChecked || selectedCount === 0 ) {
25
- return < StyledNormalText > { displayText } </ StyledNormalText > ;
26
- }
8
+ const textComponent = < StyledNormalText > { displayText } </ StyledNormalText > ;
27
9
28
- return < div style = { { color : tokens . colors . interactive . primary__resting . hex } } > { displayText } </ div > ;
10
+ return isAllChecked || selectedCount === 0 ? (
11
+ textComponent
12
+ ) : (
13
+ < div style = { { color : tokens . colors . interactive . primary__resting . hex } } > { displayText } </ div >
14
+ ) ;
29
15
}
You can’t perform that action at this time.
0 commit comments