mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-12 13:53:03 -05:00
feat(): challenge 58
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { CardComponent } from './card.component';
|
||||
|
||||
@Component({
|
||||
imports: [CardComponent],
|
||||
selector: 'app-root',
|
||||
template: `
|
||||
<app-card>
|
||||
<div title>Card 1</div>
|
||||
<div message>Message 1</div>
|
||||
</app-card>
|
||||
<app-card [small]="true">
|
||||
<div title>Card 2</div>
|
||||
<div message>Message 2</div>
|
||||
</app-card>
|
||||
`,
|
||||
host: {
|
||||
class: 'p-4 block flex flex-col gap-1',
|
||||
},
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class AppComponent {}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideZoneChangeDetection({ eventCoalescing: true })],
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-card',
|
||||
template: `
|
||||
@if (small()) {
|
||||
<ng-content select="[title]" />
|
||||
<ng-content select="[message]" />
|
||||
} @else {
|
||||
<div class="p-4">
|
||||
<div class="text-2xl">
|
||||
<ng-content select="[title]" />
|
||||
</div>
|
||||
<ng-content select="[message]" />
|
||||
</div>
|
||||
}
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
host: {
|
||||
class: 'p-4 border border-grey rounded-sm flex flex-col w-[200px]',
|
||||
},
|
||||
})
|
||||
export class CardComponent {
|
||||
small = input<boolean>(false);
|
||||
}
|
||||
13
apps/angular/58-content-projection-condition/src/index.html
Normal file
13
apps/angular/58-content-projection-condition/src/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>angular-content-projection-condition</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
7
apps/angular/58-content-projection-condition/src/main.ts
Normal file
7
apps/angular/58-content-projection-condition/src/main.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import { appConfig } from './app/app.config';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig).catch((err) =>
|
||||
console.error(err),
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
Reference in New Issue
Block a user