Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filter applied bar #418

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions website/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
74 changes: 40 additions & 34 deletions website/src/pages/ShowcaseCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Option,
Spinner,
Badge,
Body1,
} from "@fluentui/react-components";
import ShowcaseCards from "./ShowcaseCards";
import useBaseUrl from "@docusaurus/useBaseUrl";
Expand All @@ -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";

Expand Down Expand Up @@ -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 ? (
<div
style={{
paddingTop: "32px",
display: "flex",
gap: "12px",
alignItems: "center",
}}
>
<div
style={{
fontSize: "14px",
fontWeight: "400",
lineHeight: "20px",
}}
>
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 ? (
<div className={styles.filterAppliedBar}>
<Body1>
Filters applied:
</div>
</Body1>
{selectedTags.map((tag, index) => {
const tagObject = Tags[tag];
const key = `showcase_checkbox_key_${tag}`;
Expand All @@ -150,21 +154,7 @@ function FilterAppliedBar({
size="extra-large"
color="brand"
shape="rounded"
icon={
colorMode != "dark" ? (
<img
src={useBaseUrl("/img/lightModePurpleClose.svg")}
height={20}
alt="Close"
/>
) : (
<img
src={useBaseUrl("/img/darkModePurpleClose.svg")}
height={20}
alt="Close"
/>
)
}
icon={<Dismiss20Filled />}
iconPosition="after"
className={styles.filterBadge}
onClick={() => {
Expand All @@ -189,20 +179,31 @@ export default function ShowcaseCardPage({
setSelectedTags,
readSearchTags,
replaceSearchTags,
setSelectedCheckbox,
}: {
setActiveTags: React.Dispatch<React.SetStateAction<TagType[]>>;
selectedTags: TagType[];
location;
setSelectedTags: React.Dispatch<React.SetStateAction<TagType[]>>;
readSearchTags: (search: string) => TagType[];
replaceSearchTags: (search: string, newTags: TagType[]) => string;
setSelectedCheckbox: React.Dispatch<React.SetStateAction<TagType[]>>;
}) {
const [selectedOptions, setSelectedOptions] = useState<string[]>([]);
const [loading, setLoading] = useState(true);
const [searchName, setSearchName] = useState<string | null>(null);
const [selectedUsers, setSelectedUsers] = useState<User[]>([]);
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(() => {
Expand Down Expand Up @@ -284,7 +285,12 @@ export default function ShowcaseCardPage({
</Combobox>
</div>
</div>
{/* <FilterAppliedBar clearAll={clearAll} selectedTags={selectedTags} /> */}
<FilterAppliedBar
clearAll={clearAll}
selectedTags={selectedTags}
readSearchTags={readSearchTags}
replaceSearchTags={replaceSearchTags}
/>
{loading ? (
<Spinner labelPosition="below" label="Loading..." />
) : (
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const App = () => {
<ShowcaseCardPage
setActiveTags={setActiveTags}
selectedTags={selectedTags}
setSelectedCheckbox={setSelectedCheckbox}
location={location}
setSelectedTags={setSelectedTags}
readSearchTags={readSearchTags}
Expand Down
27 changes: 22 additions & 5 deletions website/src/pages/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,32 @@
}

.filterBadge {
color: var(--ifm-color-purple);
color: var(--ifm-color-purple-light) !important;
cursor: pointer;
border-color: #d2ccf8 !important;
background: #f9f8fe !important;
}

.filterAppliedBar {
padding-top: 24px;
display: flex;
align-items: center;
gap: 12px;
}

.clearAll {
color: #6656d1;
cursor: pointer;
}

[data-theme="dark"] .clearAll {
color: #a79cf1;
cursor: pointer;
border: 1px solid #d2ccf8;
background: #f9f8fe;
}

[data-theme="dark"] .filterBadge {
border: 1px solid #221d46;
background: #3f3682;
border-color: #221d46 !important;
background: #3f3682 !important;
}

@media screen and (max-width: 996px) {
Expand Down