用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/SAP/fundamental-ngx --skill setup-project命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | setup-project |
| description | Set up a new Angular project with @fundamental-ngx installed, themed, and a working first component |
If $ARGUMENTS is empty, ask: (1) project name, (2) preferred SAP Fiori theme (default: horizon).
node --version # must be ≥ 18.19
ng version # Angular CLI must be installed
If Angular CLI is missing:
npm install -g @angular/cli
Report both versions. If Node < 18.19, stop and tell the user to upgrade Node before continuing.
If the user does not already have a project:
ng new [project-name] \
--routing \
--style=scss \
--ssr=false \
--package-manager=npm
cd [project-name]
If the user has an existing project, ask for its root path and cd there, then skip to Phase 3.
Attempt ng add first:
ng add @fundamental-ngx/core
ng add installs peer dependencies and patches angular.json. However, it is known to fail with "Can not add index to parent of type array" on the budget update step, and may silently skip the styles patch even when it reports success. After it runs:
angular.json "styles" array was updated (see Phase 4). If not, apply the patch manually.package.json now lists fundamental-styles and @sap-theming/theming-base-content. If not, install manually.If ng add fails entirely (exit code 1) or the environment is offline, install manually:
npm install \
@fundamental-ngx/core \
@fundamental-ngx/platform \
@fundamental-ngx/cdk \
@fundamental-ngx/i18n \
@angular/cdk \
fundamental-styles \
@sap-theming/theming-base-content
Note:
@fundamental-ngx/platformis not installed byng add @fundamental-ngx/core. If you plan to use platform form components (fdp-*), install it too.
Ask the user which theme they want, or use the argument. Map to file paths:
| Theme name | CSS variable file |
|---|---|
horizon (default) | sap_horizon/css_variables.css |
horizon-dark | sap_horizon_dark/css_variables.css |
quartz | sap_fiori_3/css_variables.css |
quartz-dark | sap_fiori_3_dark/css_variables.css |
hcb | sap_hcb/css_variables.css |
hcw | sap_hcw/css_variables.css |
In angular.json, set the "styles" array to:
"styles": [
"node_modules/@sap-theming/theming-base-content/content/Base/baseLib/[theme-folder]/css_variables.css",
"node_modules/fundamental-styles/dist/theming/[theme-folder].css",
"node_modules/fundamental-styles/dist/fundamental-styles.css",
"src/styles.scss"
]
Order matters — theming variables must come before component CSS, which must come before styles.scss.
CSS warnings: esbuild will emit
css-syntax-errorwarnings about the SAP theming metadata embedded in thecss_variables.cssfile (it stores JSON in a CSS custom property value). These are non-blocking — the styles work correctly. You can ignore them.
Also update the initial bundle budget in angular.json. @fundamental-ngx ships large bundles; the default Angular budget is too small:
{
"type": "initial",
"maximumWarning": "5MB",
"maximumError": "8MB"
}
@fundamental-ngx does not use Angular's animation system — its overlays, dialogs, and menus animate via CSS transitions from fundamental-styles. Do not add provideAnimationsAsync() or BrowserAnimationsModule unless your own application code needs Angular animations.
If you do need Angular animations for your own components, install
@angular/animationsseparately (npm install @angular/animations) and addprovideAnimationsAsync()toapp.config.ts. It is not a peer dependency of fundamental-ngx and is not installed byng add.
Generate a minimal smoke-test to confirm theming and components work.
Create src/app/hello/hello.component.ts:
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { ButtonModule } from '@fundamental-ngx/core/button';
import { MessageStripModule } from '@fundamental-ngx/core/message-strip';
@Component({
selector: 'app-hello',
template: `
<h1 style="font-family: var(--sapFontFamily); font-size: 1.5rem; margin: 1rem">Hello fundamental-ngx</h1>
<div style="padding: 1rem; display: flex; gap: 0.5rem; align-items: center">
<button fd-button fdType="emphasized" (click)="onClick()">Click me</button>
<button fd-button fdType="transparent" (click)="showMessage.set(false)">Reset</button>
</div>
@if (showMessage()) {
<fd-message-strip type="success" style="margin: 1rem"> Setup is working correctly! </fd-message-strip>
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ButtonModule, MessageStripModule]
})
export class HelloComponent {
showMessage = signal(false);
onClick(): void {
this.showMessage.set(true);
}
}
Note: Do NOT use
<h1 fd-title [level]="1">—[level]is not a valid input on thefd-titledirective in the currently published package. Use a plain<h1>with SAP CSS variables for font styling, or omit the title entirely.
Add HelloComponent to AppComponent's imports array and place <app-hello> in its template:
// src/app/app.component.ts (or app.ts in Angular 21)
import { HelloComponent } from './hello/hello.component';
@Component({
selector: 'app-root',
template: `<app-hello></app-hello>`,
imports: [HelloComponent]
})
export class AppComponent {}
ng serve
Open http://localhost:4200 and confirm:
If the buttons look unstyled:
angular.json styles array paths exist under node_modules/ng add ran without errors (check for postinstall failures)ButtonModule from @fundamental-ngx/core/button, NOT FundamentalNgxCoreModule; barrels are deprecated and cause tree-shaking to failfd-button is an ATTRIBUTE directive — <button fd-button>, never <fd-button>provideAnimationsAsync() is NOT needed — @fundamental-ngx animates via CSS, not Angular's animation system. Do not add it; doing so requires @angular/animations (which ng new does not install) and will cause a build error.ng add styles patch may silently fail — always verify the angular.json styles array after running ng add## Setup Complete: [ProjectName]
**Angular version:** 21.x
**Theme:** SAP Horizon (horizon)
**Packages installed:** @fundamental-ngx/core, @fundamental-ngx/platform, fundamental-styles
**Verification:** ✓ App served at http://localhost:4200 with SAP Fiori styling
**Next steps:**
- [ ] Run /scaffold form — generate your first form
- [ ] Run /scaffold table — generate your first data table
- [ ] Run /scaffold shell — add shellbar and side navigation
- [ ] See full component examples at https://sap.github.io/fundamental-ngx/
Add, rename, or remove i18n translation keys in fundamental-ngx (updates FdLanguage interface, .properties files, and generated types)
Audit existing code against project conventions and Angular 22+ best practices
Migrate a component or directive to Angular 22+ signal-based patterns
基于 SOC 职业分类