Alert component displays a fixed-position notification banner in the bottom-right corner of the page. It’s used to show the educational disclaimer about the site not being official.
Features
- Fixed positioning in bottom-right corner
- Dismissible with close button
- Slide-in animation on page load
- Gradient background with border
- Responsive design
- Custom styling with glassmorphism effect
Usage
- Basic Usage
- In Layout
src/layouts/Layout.astro
Component Code
src/components/Alert.astro
Positioning
The alert is positioned fixed in the bottom-right corner:- Bottom: 20px from bottom edge
- Right: 20px from right edge
- Z-index: 1000 (appears above other content)
Close Button
The alert can be dismissed with an inline click handler:display: none on the container.
Styling Features
Gradient Background
Close Button Styling
- Circular shape
- Green theme matching alert border
- Scale effect on hover
- Positioned absolutely in top-right corner
Slide-In Animation
Warning Text
Link Styling
Responsive Behavior
The alert has a max-width to prevent it from being too large:Customization
Making it Reusable
To accept custom message and styling as props:src/components/Alert.astro
Persistent Dismissal
To remember the user dismissed the alert using localStorage:src/components/Alert.astro
Accessibility
Enhanced accessibility version:src/components/Alert.astro
