afv-library/skills/building-webapp-react-components/implementation/header-footer.md
k-j-kim 9ba064174a
feat: syncing webapp skills sync to afv @W-21338965@ (#57)
* feat: removing old webapp skills

* feat: adding sync of skills from webapps to afv

* feat: adding the first iteration of skills

* feat: pin template deps to latest npm versions and flatten skill folders

- Add pin-template-deps.js to resolve "*" deps to exact npm versions
- Integrate pinning into sync-template-skills npm script
- Remove check-template-skills-versions.js (no longer needed)
- Simplify workflow to single sync step
- Flatten skill output: one folder per skill with cleaned names

Made-with: Cursor

* fix: resolve skill validation errors

- Move .template-versions.json from skills/ to root
- Shorten skill names to meet 64-char limit:
  - salesforce-webapp-feature-micro-frontend-generating-micro-frontend-lwc → salesforce-webapp-micro-frontend-lwc
  - salesforce-webapp-feature-react-agentforce-conversation-client-integrating-agentforce-conversation-client → salesforce-webapp-agentforce-conversation-client
  - salesforce-webapp-feature-react-file-upload-implementing-file-upload → salesforce-webapp-react-file-upload
- Expand descriptions to meet 20-word minimum with trigger context

* Add webapp skills from template, sync script updates

- Rename skill folders from salesforce-webapp-* to *-webapp-* convention
- Update sync-template-skills.js: set SKILL.md front matter name to dest folder
- Remove sync-template-skills workflow and pin-template-deps script
- Add .synced-template-skills.json manifest, deploying-webapp-to-salesforce skill
- Replace salesforce-webapp-designing-webapp-ui-ux with designing-webapp-ui-ux

Made-with: Cursor

* Align SKILL.md front matter name with folder for all webapp skills

Made-with: Cursor

* Fix skill validation: description length and trigger context for configuring-webapp-metadata, creating-webapp

Made-with: Cursor

* Rename sync script to sync-webapp-skills, drop manifest file

- Rename sync-template-skills.js to sync-webapp-skills.js
- Update package.json script to sync-webapp-skills
- Remove .synced-template-skills.json creation and add to .gitignore

Made-with: Cursor

* Revert sync-react-b2e-sample and sync-react-b2x-sample to upstream version

Made-with: Cursor

* Sync script: pin b2e and b2x to latest, sync skills from template

- Pin both template packages to latest in sync-webapp-skills.js
- Update package.json / package-lock.json (b2x 1.109.0)
- Sync skills: managing-webapp-agentforce-conversation-client, bar-line-chart,
  remove building-webapp-analytics-charts and integrating-webapp-agentforce-conversation-client
- Minor skill content updates

Made-with: Cursor

* Remove interactive map, weather widget, and Unsplash skills (no longer in template)

Made-with: Cursor

---------

Co-authored-by: Hemant Singh Bisht <hsinghbisht@salesforce.com>
2026-03-19 22:46:27 +05:30

133 lines
5.2 KiB
Markdown

# Implementation — Header / Footer
### Rules
1. **Edit `appLayout.tsx` only** — header and footer are layout-level concerns. Never add them to individual page files.
2. **Never modify `routes.tsx` or `app.tsx`** — the router setup must remain intact.
3. **Create component files in `src/components/layout/`** — the designated location for layout-level components.
4. **Use the full-height flex column pattern** — wrap layout in `min-h-screen flex flex-col` so footer stays at bottom.
5. **Use shadcn and Tailwind** — compose from `@/components/ui`; style with Tailwind utility classes and design tokens.
6. **Use path aliases** — import with `@/components/layout/...` and `@/components/ui`; no deep relative paths.
7. **Preserve existing content** — if `appLayout.tsx` already has a `<NavigationMenu />` or other shell elements, keep them in place.
### Step 1 — Create the header component (if requested)
Create `src/components/layout/AppHeader.tsx`:
```tsx
import { cn } from "@/lib/utils";
interface AppHeaderProps {
className?: string;
}
export function AppHeader({ className }: AppHeaderProps) {
return (
<header
className={cn(
"w-full border-b bg-background px-4 sm:px-6 lg:px-8 py-4",
className,
)}
>
<div className="max-w-7xl mx-auto flex items-center justify-between">
<span className="text-lg font-semibold text-foreground">My App</span>
</div>
</header>
);
}
```
### Step 2 — Create the footer component (if requested)
Create `src/components/layout/AppFooter.tsx`:
```tsx
import { cn } from "@/lib/utils";
interface AppFooterProps {
className?: string;
}
export function AppFooter({ className }: AppFooterProps) {
return (
<footer
className={cn(
"w-full border-t bg-background px-4 sm:px-6 lg:px-8 py-4",
className,
)}
>
<div className="max-w-7xl mx-auto text-center text-sm text-muted-foreground">
&copy; {new Date().getFullYear()} My App. All rights reserved.
</div>
</footer>
);
}
```
### Step 3 — Edit `appLayout.tsx`
Open `src/appLayout.tsx` — this is the **only file to modify** for layout-level additions. Wrap existing content in a flex column and add header above and footer below `<Outlet />`:
```tsx
import { Outlet } from "react-router";
import { AppHeader } from "@/components/layout/AppHeader";
import { AppFooter } from "@/components/layout/AppFooter";
// Keep all existing imports unchanged
export default function AppLayout() {
return (
<div className="min-h-screen flex flex-col bg-background">
<AppHeader />
{/* Keep any existing NavigationMenu or other shell elements here */}
<main className="flex-1">
<Outlet />
</main>
<AppFooter />
</div>
);
}
```
### File Locations — Header / Footer
| Component | File | Export |
| ------------ | ------------------------------------- | ------------------------------ |
| Header | `src/components/layout/AppHeader.tsx` | Named export |
| Footer | `src/components/layout/AppFooter.tsx` | Named export |
| Layout shell | `src/appLayout.tsx` | Default export (edit in place) |
### Why `appLayout.tsx` — Not Pages or Routes
`AppLayout` is the single shell rendered at the root route. Every page is a child rendered via `<Outlet />`. Placing the header and footer here ensures they appear on every page without touching individual pages or the route registry.
```
AppLayout (appLayout.tsx)
├── AppHeader ← renders on every page
├── NavigationMenu ← keep if already present
├── <Outlet /> ← active page renders here
└── AppFooter ← renders on every page
```
### Useful Patterns — Header / Footer
- **Sticky header:** add `sticky top-0 z-50` to the `<header>` element
- **Separator:** use `<Separator />` from `@/components/ui` instead of `border-b`/`border-t` if a visible divider is preferred
- **Nav links in header:** use `<Button variant="ghost" asChild>` wrapping a React Router `<Link>`
- **Icons:** `lucide-react`; add `aria-hidden="true"` on decorative icons
- **Design tokens:** `bg-background`, `text-foreground`, `text-muted-foreground`, `border`, `bg-primary`
### Mobile hamburger / Menu icon — Must be functional
If the header includes a hamburger or `Menu` icon for mobile:
- **Do not** add a Menu/hamburger icon that does nothing. It must toggle a visible mobile menu.
- **Required:** (1) State: `const [isOpen, setIsOpen] = useState(false)`. (2) Button: `onClick={() => setIsOpen(!isOpen)}`, `aria-label="Toggle menu"`. (3) Conditional panel: `{isOpen && ( <div>...nav links...</div> )}` with responsive visibility (e.g. `md:hidden`). (4) Close on navigate: each link in the panel should `onClick={() => setIsOpen(false)}`.
- Implement in `appLayout.tsx` (or the component that owns the header). Use the `Menu` icon from `lucide-react`.
### Confirm — Header / Footer
- Header and footer appear on every page (navigate to at least two routes)
- Imports use path aliases (`@/components/layout/...`)
- No inline `style={{}}` — Tailwind only
- `src/routes.tsx` and `src/app.tsx` are unchanged