-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Website Redesign: Banner component (#727)
### Summary <!-- Required --> Created a reusable Full Width Banner component with the three variants from the figma below (We can add more variants in the future or change this as necessary). I also added disabled buttons instead of omitting them when the application is not open to keep it consistent. ### Notion/Figma Link https://www.figma.com/design/ttAGEX3pHmzuhMzp8uAyhz/DTI-New-Landing-Website?node-id=7-45&node-type=canvas https://github.com/user-attachments/assets/66be0777-0ae9-49e5-bbe9-f59771b22906
- Loading branch information
Showing
4 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import useScrollPosition from '../../src/hooks/useScrollPosition'; | ||
|
||
interface BannerProps { | ||
message: string; | ||
variant?: 'info' | 'alert' | 'success'; | ||
className?: string; | ||
navbarHeight?: number; | ||
} | ||
|
||
const variantStyles: Record<NonNullable<BannerProps['variant']>, string> = { | ||
info: 'bg-neutral-800', | ||
alert: 'bg-red-700', | ||
success: 'bg-black border-b-2 border-t-2 border-t-neutral-800 border-b-neutral-800' | ||
}; | ||
|
||
export default function Banner({ | ||
message, | ||
variant = 'info', | ||
className = '', | ||
navbarHeight = 130 | ||
}: BannerProps) { | ||
const { scrollY } = useScrollPosition(); | ||
|
||
const isFixed = scrollY > navbarHeight; | ||
|
||
const variantClass = variantStyles[variant] || ''; | ||
|
||
return ( | ||
<div | ||
className={`${ | ||
isFixed ? 'fixed' : 'absolute' | ||
} top-0 left-0 w-full text-white text-center text-xs sm:text-sm md:text-md lg:text-lg xl:text-xl 2xl:text-2xl px-6 py-4 z-50 ${variantClass} ${className}`} | ||
> | ||
{message} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters