diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index 39c43708..f670fd32 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 0.5.0 (Unreleased) +## 0.5.0 (2024-07-31) ### Features Added -### Breaking Changes - -### Bugs Fixed - -### Other Changes +- [[418]](https://github.com/Azure/awesome-azd/pull/418) Implement filter applied bar and "Clear All" button. ## 0.4.0 (2024-05-20) diff --git a/website/src/pages/ShowcaseCardPage.tsx b/website/src/pages/ShowcaseCardPage.tsx index e594d9f7..699aac6b 100644 --- a/website/src/pages/ShowcaseCardPage.tsx +++ b/website/src/pages/ShowcaseCardPage.tsx @@ -16,6 +16,7 @@ import { Option, Spinner, Badge, + Body1, } from "@fluentui/react-components"; import ShowcaseCards from "./ShowcaseCards"; import useBaseUrl from "@docusaurus/useBaseUrl"; @@ -24,6 +25,7 @@ import { useColorMode } from "@docusaurus/theme-common"; import { useHistory } from "@docusaurus/router"; import { toggleListItem } from "@site/src/utils/jsUtils"; import { prepareUserState } from "./index"; +import { Dismiss20Filled } from "@fluentui/react-icons"; const TagQueryStringKey2 = "tags"; @@ -116,29 +118,31 @@ function filterUsers( function FilterAppliedBar({ clearAll, selectedTags, + readSearchTags, + replaceSearchTags, }: { clearAll; selectedTags: TagType[]; + readSearchTags: (search: string) => TagType[]; + replaceSearchTags: (search: string, newTags: TagType[]) => string; }) { - const { colorMode } = useColorMode(); - return selectedTags.length > 0 ? ( -
-
+ const history = useHistory(); + const toggleTag = (tag: TagType, location: Location) => { + const tags = readSearchTags(location.search); + const newTags = toggleListItem(tags, tag); + const newSearch = replaceSearchTags(location.search, newTags); + history.push({ + ...location, + search: newSearch, + state: prepareUserState(), + }); + } + + return selectedTags && selectedTags.length > 0 ? ( +
+ Filters applied: -
+ {selectedTags.map((tag, index) => { const tagObject = Tags[tag]; const key = `showcase_checkbox_key_${tag}`; @@ -150,21 +154,7 @@ function FilterAppliedBar({ size="extra-large" color="brand" shape="rounded" - icon={ - colorMode != "dark" ? ( - Close - ) : ( - Close - ) - } + icon={} iconPosition="after" className={styles.filterBadge} onClick={() => { @@ -189,6 +179,7 @@ export default function ShowcaseCardPage({ setSelectedTags, readSearchTags, replaceSearchTags, + setSelectedCheckbox, }: { setActiveTags: React.Dispatch>; selectedTags: TagType[]; @@ -196,13 +187,23 @@ export default function ShowcaseCardPage({ setSelectedTags: React.Dispatch>; readSearchTags: (search: string) => TagType[]; replaceSearchTags: (search: string, newTags: TagType[]) => string; + setSelectedCheckbox: React.Dispatch>; }) { const [selectedOptions, setSelectedOptions] = useState([]); const [loading, setLoading] = useState(true); const [searchName, setSearchName] = useState(null); const [selectedUsers, setSelectedUsers] = useState([]); + const history = useHistory(); + const searchParams = new URLSearchParams(location.search); const clearAll = () => { setSelectedTags([]); + setSelectedCheckbox([]); + searchParams.delete("tags"); + history.push({ + ...location, + search: searchParams.toString(), + state: prepareUserState(), + }); }; useEffect(() => { @@ -284,7 +285,12 @@ export default function ShowcaseCardPage({
- {/* */} + {loading ? ( ) : ( diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx index d1124761..364f03ab 100644 --- a/website/src/pages/index.tsx +++ b/website/src/pages/index.tsx @@ -85,6 +85,7 @@ const App = () => {