### Install @sofidevo/astro-dynamic-header
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Installs the dynamic header component package using npm.
```bash
npm i @sofidevo/astro-dynamic-header
```
--------------------------------
### Astro: Responsive Slot Behavior Example
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Illustrates how to apply CSS classes to slots for responsive behavior, showing a desktop-only button and a mobile CTA.
```astro
```
--------------------------------
### CSS: Styling Responsive Slots for Header
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Provides CSS examples for controlling the visibility of desktop slots on mobile devices and creating responsive variants for custom styling.
```css
/* Hide desktop slot on mobile devices */
@media (width < 768px) {
.cta-button {
display: none;
}
}
/* Or create responsive variants */
.desktop-only {
display: block;
}
@media (width < 768px) {
.desktop-only {
display: none;
}
}
```
--------------------------------
### Testing: Running Project Tests with npm
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Commands for running the project's test suite using npm, including options for watch mode and coverage reports.
```bash
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage report
npm run test:coverage
```
--------------------------------
### Basic Header Usage in Astro
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Demonstrates basic integration of the Header component in an Astro file, importing it and passing essential props like header type, logo source, and menu items.
```astro
---
// Option 1: Import from direct subpath (recommended)
import Header from '@sofidevo/astro-dynamic-header/Header';
// Option 2: Import from main entry point with types
import { HeaderProps, type MenuItemType } from '@sofidevo/astro-dynamic-header';
const menuItems = [
{ link: '/about', text: 'About' },
{ link: '/contact', text: 'Contact' },
];
---
```
--------------------------------
### Advanced Header Configuration in Astro
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Illustrates advanced usage of the Header component with nested menus and various customization props like background color, blur effects, and z-index.
```astro
---
import Header from '@sofidevo/astro-dynamic-header/Header';
import type { MenuItemType } from '@sofidevo/astro-dynamic-header';
const menuItems = [
{
link: '#',
text: 'Services',
submenu: [
{
link: '#',
text: 'Web Development',
submenu: [
{ link: '/web/frontend', text: 'Frontend' },
{ link: '/web/backend', text: 'Backend' },
{ link: '/web/fullstack', text: 'Full Stack' },
],
},
{ link: '/design', text: 'Design' },
{ link: '/consulting', text: 'Consulting' },
],
},
{ link: '/about', text: 'About' },
{ link: '/contact', text: 'Contact' },
];
---
```
--------------------------------
### Astro: Using Header Component with Slots
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Demonstrates how to use the Astro Dynamic Header component with both desktop and mobile slots, customizing its appearance and behavior.
```astro
---
import Header from '@sofidevo/astro-dynamic-header/Header';
const menuItems = [
{ link: '/about', text: 'About' },
{ link: '/services', text: 'Services' },
{ link: '/contact', text: 'Contact' },
];
---
```
--------------------------------
### TypeScript: Importing Header Component Types
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Demonstrates importing type definitions for the Astro Dynamic Header component, including MenuItemType, HeaderProps, and others.
```typescript
import type {
MenuItemType,
HeaderProps,
NavMenuProps,
MobileNavProps,
HamburgerButtonProps
} from '@sofidevo/astro-dynamic-header';
```
--------------------------------
### Troubleshooting: Astro Import Paths
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Provides solutions for import errors in Astro projects, including direct subpath imports and verifying TypeScript configuration.
```astro
---
import Header from '@sofidevo/astro-dynamic-header/Header';
import type { MenuItemType } from '@sofidevo/astro-dynamic-header';
---
```
--------------------------------
### Using Header Component Slots in Astro
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Demonstrates how to use the `slot-desktop` and `slot-panel` slots of the Header component to inject custom content into the header and mobile navigation panel.
```astro
---
import Header from '@sofidevo/astro-dynamic-header/Header';
const menuItems = [
{ link: '/about', text: 'About' },
{ link: '/contact', text: 'Contact' },
];
---
```
--------------------------------
### Troubleshooting: TypeScript Configuration for Imports
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Shows the necessary `tsconfig.json` configuration for resolving module imports correctly in Astro projects.
```json
{
"compilerOptions": {
"moduleResolution": "bundler", // or "nodenext"
"allowImportingTsExtensions": true
}
}
```
--------------------------------
### Astro tsconfig.json Configuration
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Provides the necessary TypeScript configuration for an Astro project to ensure correct module resolution and type checking when using the dynamic header component.
```json
{
"compilerOptions": {
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"strict": true,
"noEmit": true,
"jsx": "preserve"
},
"extends": "astro/tsconfigs/strict"
}
```
--------------------------------
### CSS: Customizing Header Component Variables
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Shows how to override default CSS custom properties to customize the appearance of the Astro Dynamic Header component.
```css
:root {
--light-spot-color: #00ffff;
--color-tertiary: #ffffff;
--color-hamburger-lines: #ffffff;
}
```
--------------------------------
### Menu Item Structure TypeScript Interface
Source: https://github.com/sofidevo/astro-dynamic-header/blob/main/README.md
Defines the TypeScript interface for menu items, including optional nested submenus, ensuring type safety for navigation data.
```typescript
interface MenuItemType {
link: string;
text: string;
submenu?: MenuItemType[];
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.