Skip to content

Commit

Permalink
feat: add withBorderOnScroll prop for Navigation component (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
goshander authored Mar 15, 2024
1 parent 8f9d177 commit b172089
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/models/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface HeaderData {
rightItems?: NavigationItemModel[];
iconSize?: number;
withBorder?: boolean;
withBorderOnScroll?: boolean;
}

export interface FooterColumn {
Expand Down
1 change: 1 addition & 0 deletions src/navigation/__stories__/Navigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ NavigationWithBorder.args = {
header: {
...data.navigation.header,
withBorder: true,
withBorderOnScroll: true,
},
} as NavigationData,
};
Expand Down
10 changes: 9 additions & 1 deletion src/navigation/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ export interface NavigationProps extends ClassNameProps {
}

export const Navigation: React.FC<NavigationProps> = ({data, logo, className}) => {
const {leftItems, rightItems, iconSize = 20, withBorder = false} = data;
const {
leftItems,
rightItems,
iconSize = 20,
withBorder = false,
withBorderOnScroll = true,
} = data;
const [isSidebarOpened, setIsSidebarOpened] = useState(false);
const [activeItemId, setActiveItemId] = useState<string | undefined>(undefined);
const [showBorder, setShowBorder] = useState(withBorder);
Expand All @@ -43,6 +49,8 @@ export const Navigation: React.FC<NavigationProps> = ({data, logo, className}) =
const onSidebarOpenedChange = (isOpen: boolean) => setIsSidebarOpened(isOpen);

useEffect(() => {
if (!withBorderOnScroll) return () => {};

const showBorderOnScroll = () => {
if (!showBorder) {
setShowBorder(window.scrollY > 0);
Expand Down

0 comments on commit b172089

Please sign in to comment.