// africanies-button copy-paste examples. export /** * */ const BUTTON_VARIANTS = `// Variants. Primary / ghost-primary / secondary (stroked) pick up SFN green / // STN orange from ModeColorService. flat is neutral chrome (Cancel, Filters). import { Component } from '@angular/core'; import { ButtonComponent, type ButtonVariant, } from '@africanies/africanies-ui'; @Component({ selector: 'app-shipment-actions', standalone: true, imports: [ButtonComponent], template: \`
@for (v of variants; track v) {
{{ v }}
}
\`, }) export class ShipmentActionsComponent { protected readonly variants: ButtonVariant[] = [ 'primary', 'secondary', 'flat', 'ghost', 'ghost-primary', 'ghost-danger', 'underline', 'danger', ]; protected readonly labels: Record = { primary: 'Save shipment', secondary: 'Save draft', flat: 'Filters', ghost: 'Cancel', 'ghost-primary': 'Add row', 'ghost-danger': 'Remove', underline: 'Learn more', danger: 'Delete', }; }`; export /** * */ const BUTTON_SIZES = `// sm | md | lg. Default is md. Use sm in toolbars/dialogs; save lg for hero CTAs. import { Component } from '@angular/core'; import { ButtonComponent, type ButtonSize, } from '@africanies/africanies-ui'; @Component({ selector: 'app-button-sizes', standalone: true, imports: [ButtonComponent], template: \`
@for (s of sizes; track s) {
size={{ s }}
}
\`, }) export class ButtonSizesComponent { protected readonly sizes: ButtonSize[] = ['sm', 'md', 'lg']; }`; export /** * */ const BUTTON_MATRIX = `// Full variant × size grid — handy for QA, not something you'd ship on a product page. import { Component } from '@angular/core'; import { ButtonComponent, type ButtonSize, type ButtonVariant, } from '@africanies/africanies-ui'; @Component({ selector: 'app-button-matrix', standalone: true, imports: [ButtonComponent], template: \` @for (s of sizes; track s) { } @for (v of variants; track v) { @for (s of sizes; track s) { } }
Variant{{ s }}
{{ v }}
\`, }) export class ButtonMatrixComponent { protected readonly variants: ButtonVariant[] = [ 'primary', 'secondary', 'ghost', 'danger', ]; protected readonly sizes: ButtonSize[] = ['sm', 'md', 'lg']; }`; export /** * */ const BUTTON_ICONS = `// Drop inside the button — same focus ring as the label. // Icon-only? Put aria-label on the host. import { Component } from '@angular/core'; import { AfricaniesIconComponent } from '@africanies/africanies-icons'; import { ButtonComponent } from '@africanies/africanies-ui'; @Component({ selector: 'app-button-icons', standalone: true, imports: [ButtonComponent, AfricaniesIconComponent], template: \`
\`, }) export class ButtonIconsComponent {}`; export /** * */ const BUTTON_LINKS = `// Same look on — use routerLink for in-app, href for external. import { Component } from '@angular/core'; import { RouterLink } from '@angular/router'; import { ButtonComponent } from '@africanies/africanies-ui'; @Component({ selector: 'app-button-links', standalone: true, imports: [ButtonComponent, RouterLink], template: \` \`, }) export class ButtonLinksComponent {}`; export /** * */ const BUTTON_DISABLED = `// [disabled] works on buttons and anchors (anchors get aria-disabled + tabindex=-1). // Use this for unavailable actions — in-flight work belongs on [loading]. import { Component, signal } from '@angular/core'; import { ButtonComponent } from '@africanies/africanies-ui'; @Component({ selector: 'app-button-disabled', standalone: true, imports: [ButtonComponent], template: \`
Ghost link
\`, }) export class ButtonDisabledComponent { protected readonly saving = signal(false); }`; export /** * */ const BUTTON_LOADING = `// Default loading state is the circular spinner. Label stays in the layout // (invisible) so the button does not shrink while the request is in flight. import { Component, signal } from '@angular/core'; import { ButtonComponent } from '@africanies/africanies-ui'; @Component({ selector: 'app-button-loading', standalone: true, imports: [ButtonComponent], template: \`
\`, }) export class ButtonLoadingComponent { protected readonly saving = signal(false); protected save(): void { this.saving.set(true); // POST → finalize in subscribe/finalize and set saving false. } }`; export /** * */ const BUTTON_CONTEXT = `// Typical toolbar: ghost cancel → secondary draft → primary submit. // Toggle SFN/STN in the sidebar to see primary shift color. import { Component, inject, signal } from '@angular/core'; import { ModeColorService } from '@africanies/africanies-theme'; import { ButtonComponent } from '@africanies/africanies-ui'; @Component({ selector: 'app-shipment-toolbar', standalone: true, imports: [ButtonComponent], template: \`

Shipment {{ ref() }}

Draft · {{ route() }}

\`, }) export class ShipmentToolbarComponent { protected readonly modeColor = inject(ModeColorService); protected readonly ref = signal('SFN-1042'); protected readonly route = signal('Lagos → London'); protected readonly saving = signal(false); protected cancel(): void { // Navigate away or close parent overlay ref. } protected saveDraft(): void { this.saving.set(true); // POST draft → finalize in subscribe/finalize and set saving false. } protected submit(): void { this.saving.set(true); // POST submit → on success close overlay or navigate to detail. } }`; export /** * */ const BUTTON_COPY = `// Clipboard control — icon flips to check on success. // Optional [announce]="true" also fires a toast when ToastService is provided. import { Component, signal } from '@angular/core'; import { CopyButtonComponent } from '@africanies/africanies-ui'; @Component({ selector: 'app-copy-demo', standalone: true, imports: [CopyButtonComponent], template: \`
{{ reference() }}
\`, }) export class CopyDemoComponent { protected readonly reference = signal('SFN-1042'); protected readonly snippet = signal(''); } `;