Skip to content

Commit 2ea68d7

Browse files
simplify categories as well
1 parent 000a9ef commit 2ea68d7

File tree

3 files changed

+12
-66
lines changed

3 files changed

+12
-66
lines changed

src/frontend/components/UI/CategoryFilter/index.tsx

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,16 @@ export default function CategoryFilter() {
2424
}
2525
}
2626

27-
const setCategoryOnly = (category: string) => {
28-
setCurrentCustomCategories([category])
29-
}
30-
31-
const selectAll = () => {
32-
setCurrentCustomCategories(
33-
['preset_uncategorized'].concat(customCategories.listCategories())
34-
)
35-
}
36-
37-
const toggleWithOnly = (
38-
toggle: JSX.Element,
39-
onOnlyClicked: () => void,
40-
category: string
41-
) => {
42-
return (
43-
<div className="toggleWithOnly" key={category}>
44-
{toggle}
45-
<button className="only" onClick={() => onOnlyClicked()}>
46-
{t('header.only', 'only')}
47-
</button>
48-
</div>
49-
)
50-
}
51-
52-
const categoryToggle = (categoryName: string, categoryValue?: string) => {
53-
const toggle = (
54-
<ToggleSwitch
55-
htmlId={categoryValue || categoryName}
56-
handleChange={() => toggleCategory(categoryValue || categoryName)}
57-
value={currentCustomCategories.includes(categoryValue || categoryName)}
58-
title={categoryName}
59-
/>
60-
)
61-
62-
const onOnlyClick = () => {
63-
setCategoryOnly(categoryValue || categoryName)
64-
}
27+
const resetCategories = () => setCurrentCustomCategories([])
6528

66-
return toggleWithOnly(toggle, onOnlyClick, categoryValue || categoryName)
67-
}
29+
const categoryToggle = (categoryName: string, categoryValue?: string) => (
30+
<ToggleSwitch
31+
htmlId={categoryValue || categoryName}
32+
handleChange={() => toggleCategory(categoryValue || categoryName)}
33+
value={currentCustomCategories.includes(categoryValue || categoryName)}
34+
title={categoryName}
35+
/>
36+
)
6837

6938
const categoriesList = customCategories.listCategories()
7039

@@ -94,9 +63,9 @@ export default function CategoryFilter() {
9463
<button
9564
type="reset"
9665
className="button is-primary"
97-
onClick={() => selectAll()}
66+
onClick={() => resetCategories()}
9867
>
99-
{t('header.select_all', 'Select All')}
68+
{t('header.reset', 'Reset')}
10069
</button>
10170
<button
10271
className="button is-secondary is-small"

src/frontend/components/UI/LibraryFilters/index.css

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,6 @@
6060
box-shadow: 4px 5px 5px 7px rgba(0, 0, 0, 0.2);
6161
}
6262
}
63-
64-
.toggleWithOnly {
65-
display: flex;
66-
67-
& label {
68-
flex-grow: 1;
69-
}
70-
.only {
71-
opacity: 0.01;
72-
background: none;
73-
border: none;
74-
color: var(--text);
75-
text-decoration: underline;
76-
cursor: pointer;
77-
&:hover {
78-
color: var(--accent);
79-
}
80-
}
81-
&:hover .only,
82-
&:focus-within .only {
83-
opacity: 1;
84-
}
85-
}
8663
}
8764

8865
body.isRTL .libraryFilters .dropdown {

src/frontend/components/UI/LibraryFilters/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default function LibraryFilters() {
136136
browser: false
137137
})
138138
setShowHidden(false)
139-
setShowNonAvailable(true)
139+
setShowNonAvailable(false)
140140
setShowFavourites(false)
141141
setShowInstalledOnly(false)
142142
setShowSupportOfflineOnly(false)

0 commit comments

Comments
 (0)