mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-07-30 19:50:42 +08:00
* 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>
4.4 KiB
4.4 KiB
Implementation — Page
Rules
- Edit the component that owns the UI, never output raw HTML — When editing the home page or any page content, modify the actual
.tsxfile that renders the target. If the target is inside a child component (e.g.<GlobalSearchInput />inHome.tsx), edit the child's file (e.g.GlobalSearchInput.tsx), not the parent. Do not wrap the component with extra elements in the parent; go into the component and change its JSX. Do not paste or generate raw HTML. routes.tsxis the only route registry — never add routes inapp.tsxor inside page files.- All pages are children of the AppLayout route — do not create top-level routes that bypass the layout shell.
- Default export per page — each page file has exactly one default-export component.
- Path aliases in all imports — use
@/pages/...,@/components/...; no deep relative paths. - No inline styles — Tailwind utility classes and design tokens only.
- Catch-all last —
path: '*'(NotFound) must always remain the last child in the layout route. - Never modify
appLayout.tsxwhen adding a page — layout changes are a separate concern.
Step 1 — Create the page file
Create src/pages/MyPage.tsx with a default export and the standard page container:
export default function MyPage() {
return (
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<h1 className="text-3xl font-bold text-foreground">My Page</h1>
<p className="mt-4 text-muted-foreground">Page content goes here.</p>
</div>
);
}
Use shadcn components from @/components/ui for UI elements. All styling via Tailwind — no inline style={{}}.
Step 2 — Register the route in routes.tsx
Open src/routes.tsx. Import the page and add it inside the layout route's children array:
import MyPage from "@/pages/MyPage";
// Inside the layout route's children array (before the catch-all):
{
path: "my-page",
element: <MyPage />,
handle: { showInNavigation: true, label: "My Page" },
},
pathis a relative segment (e.g.,"contacts"), not an absolute path.- Include
handle: { showInNavigation: true, label: "Label" }only if the page should appear in the navigation menu. - The catch-all
path: '*'must stay last.
Step 3 — Apply an auth guard (if needed)
| Access type | Guard | Behavior |
|---|---|---|
| Public | None | Direct child of layout |
| Authenticated only | <PrivateRoute> |
Redirects to login if not authenticated |
| Unauthenticated only (e.g., login) | <AuthenticationRoute> |
Redirects away if already authenticated |
Example — private page:
import { PrivateRoute } from "@/components/auth/private-route";
{
path: "settings",
element: <PrivateRoute><SettingsPage /></PrivateRoute>,
handle: { showInNavigation: true, label: "Settings" },
},
Use ROUTES.* constants from @/utils/authenticationConfig for auth-related paths — do not hardcode /login, /profile, etc.
File Conventions — Page
| Concern | Location |
|---|---|
| Page component | src/pages/<PageName>.tsx (default export) |
| Route definition | src/routes.tsx only |
| Layout shell | src/appLayout.tsx — do not modify for page additions |
| Auth config paths | ROUTES.* from @/utils/authenticationConfig |
State and Data
- Local state:
useState,useReducer,useRefinside the page component - Shared or complex state: extract to
src/hooks/with auseprefix (e.g.,useContacts) - Data fetching: prefer GraphQL (
executeGraphQL) or REST utilities insrc/api/; place shared data logic insrc/hooks/ - Auth context:
useAuth()from@/context/AuthContextwhen current user is needed — only valid underAuthProvider
Confirm — Page
- The page renders inside the app shell (header/nav visible)
- If
showInNavigation: true, the link appears in the navigation menu - No TypeScript errors; no broken imports; no missing exports
- Imports use path aliases (
@/, not deep relative paths)