Skip to content

Commit

Permalink
Fix filter alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekjain23 committed Jun 14, 2024
1 parent 550bf08 commit c0e589e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/theme/SearchBar/FilterDropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
import React, { forwardRef, useEffect } from 'react';
import React, { forwardRef, useEffect, useState } from 'react';
import {
facetNamesJson,
allFacets,
Expand All @@ -17,6 +17,7 @@ export const FilterDropdown = forwardRef(
({ selectedFacets, setSelectedFacets, styleProps = {} }, ref) => {
const { isActive: isAnnouncementBarActive } = useAnnouncementBar();
const actualFacets = allFacets[1];
const [isScrolled, setIsScrolled] = useState(false);

const handleCheckboxChange = (event) => {
const { value, checked } = event.target;
Expand Down Expand Up @@ -96,10 +97,20 @@ export const FilterDropdown = forwardRef(
});
}, [selectedFacets, setSelectedFacets]);

useEffect(() => {
const handleScroll = () => {
if (window.scrollY > 28) {
setIsScrolled(true);
}
};
handleScroll();
}, [window.scrollY]);

return (
<div
className={clsx('dropdown dropdown--hoverable', styles.dropdown, {
[styles.activeAnnouncementBar]: isAnnouncementBarActive,
[styles.isScrolled]: isScrolled,
})}
style={styleProps}
ref={ref}
Expand All @@ -110,7 +121,7 @@ export const FilterDropdown = forwardRef(
styles.filterButton,
)}
>
filter
filter
</button>
<ul className={clsx('dropdown__menu', styles.dropdownMenu)}>
<label>
Expand Down
6 changes: 6 additions & 0 deletions src/theme/SearchBar/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
.activeAnnouncementBar {
top: 200%;
}
.isScrolled {
top: 250%;
}
.dropdownMenu {
color: var(--ifm-navbar-link-color);
width: 210px;
Expand Down Expand Up @@ -42,6 +45,9 @@
.activeAnnouncementBar {
top: 340%;
}
.isScrolled {
top: 470%;
}
.dropdownMenu {
left: 65%;
}
Expand Down

0 comments on commit c0e589e

Please sign in to comment.