Skip to content

Commit 9f52431

Browse files
authored
release: categories count update
Release
2 parents 811fd5a + 31922b2 commit 9f52431

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

assets/src/Components/CategoriesTabs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const CategoriesTabs = ( {
88
count,
99
category,
1010
setCurrentCategory,
11+
showCount = false,
1112
} ) => {
1213
return (
1314
<div className="editor-tabs">
@@ -31,7 +32,9 @@ const CategoriesTabs = ( {
3132
} }
3233
>
3334
<span className="editor">{ categories[ key ] }</span>
34-
<span className="count">{ count[ key ] }</span>
35+
{ showCount && (
36+
<span className="count">{ count[ key ] }</span>
37+
) }
3538
</a>
3639
);
3740
} ) }

assets/src/Components/CategorySelector.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const CategorySelector = ( {
1010
count,
1111
category,
1212
setCurrentCategory,
13+
showCount = false,
1314
} ) => {
1415
const [ open, setOpen ] = useState( false );
1516
const toggleDropdown = () => setOpen( ! open );
@@ -22,7 +23,7 @@ const CategorySelector = ( {
2223
<div className={ wrapClasses }>
2324
<Button onClick={ toggleDropdown } className="select ob-dropdown">
2425
<span>{ categories[ category ] }</span>
25-
<span className="count">{ count[ category ] }</span>
26+
<span className="count">{ showCount ? count[ category ] : '' }</span>
2627
<Dashicon
2728
size={ 14 }
2829
icon={ open ? 'arrow-up-alt2' : 'arrow-down-alt2' }
@@ -58,9 +59,11 @@ const CategorySelector = ( {
5859
<span>
5960
{ categories[ key ] }
6061
</span>
61-
<span className="count">
62-
{ count[ key ] }
63-
</span>
62+
{ showCount && (
63+
<span className="count">
64+
{ count[ key ] }
65+
</span>
66+
) }
6467
</a>
6568
</li>
6669
);

assets/src/Components/Search.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const Search = ( {
1919
setCurrentEditor,
2020
query,
2121
className,
22+
showCount = false,
2223
} ) => {
2324
const [ open, setOpen ] = useState( false );
2425
const toggleDropdown = () => setOpen( ! open );
@@ -72,9 +73,11 @@ const Search = ( {
7273
]
7374
}
7475
</span>
75-
<span className="count">
76-
{ count[ key ] }
77-
</span>
76+
{ showCount && (
77+
<span className="count">
78+
{ count[ key ] }
79+
</span>
80+
) }
7881
</a>
7982
</li>
8083
);
@@ -189,9 +192,11 @@ const Search = ( {
189192
.niceName
190193
}
191194
</span>
192-
<span className="count">
193-
{ count[ key ] }
194-
</span>
195+
{ showCount && (
196+
<span className="count">
197+
{ count[ key ] }
198+
</span>
199+
) }
195200
</a>
196201
</li>
197202
);

assets/src/Components/StarterSites/Filters.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ const Filters = ( {
7171

7272
const counted = getCounts();
7373

74+
const activeCount = getSitesForBuilder( editor ).length;
75+
const showCount = 50 <= activeCount;
76+
7477
return (
7578
<>
7679
{ ! isOnboarding && ! migration && (
@@ -89,6 +92,7 @@ const Filters = ( {
8992
categories={ CATEGORIES }
9093
editors={ EDITOR_MAP }
9194
onlyProSites={ onlyProBuilders }
95+
showCount={ showCount }
9296
/>
9397
{ isTabbedEditor && (
9498
<EditorSelector
@@ -101,6 +105,7 @@ const Filters = ( {
101105
<CategorySelector
102106
count={ counted.categories }
103107
categories={ CATEGORIES }
108+
showCount={ showCount }
104109
/>
105110
) }
106111
</div>
@@ -121,10 +126,19 @@ const Filters = ( {
121126
{ tiobDash.strings.starterSitesTabDescription }
122127
</p>
123128
) }
124-
<EditorSelector
125-
count={ counted.builders }
126-
EDITOR_MAP={ EDITOR_MAP }
127-
/>
129+
{ isTabbedEditor && (
130+
<EditorSelector
131+
count={ counted.builders }
132+
EDITOR_MAP={ EDITOR_MAP }
133+
/>
134+
) }
135+
{ ! isTabbedEditor && (
136+
<CategorySelector
137+
count={ counted.categories }
138+
categories={ CATEGORIES }
139+
showCount={ showCount }
140+
/>
141+
) }
128142

129143
<Search
130144
count={
@@ -135,6 +149,7 @@ const Filters = ( {
135149
categories={ CATEGORIES }
136150
editors={ EDITOR_MAP }
137151
onlyProSites={ onlyProBuilders }
152+
showCount={ showCount }
138153
/>
139154

140155
{ isTabbedEditor && (
@@ -148,6 +163,7 @@ const Filters = ( {
148163
<CategoriesTabs
149164
categories={ CATEGORIES }
150165
count={ counted.categories }
166+
showCount={ showCount }
151167
/>
152168
) }
153169
{ ! tiobDash.isValidLicense && (

0 commit comments

Comments
 (0)