Skip to content

Commit 48ed9e8

Browse files
authored
Styling fixes for new rendering approach (#28)
1 parent edf372b commit 48ed9e8

10 files changed

Lines changed: 51 additions & 54 deletions

File tree

dynamic-sdui-app/mcp-server/server.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,11 @@ def generate_dynamic_sdui_app() -> str:
275275
* *Example:* `chatService = inject(ChatService);`
276276
* **CRITICAL RULE 5 (Chat Service):** For any buttons or links related to search, discovery, or navigation (e.g., "View Details", "Explore"), you **must** import `ChatService` from `../../../chat/chat.service` and call `this.chatService.addUserPrompt()` with an appropriate instructional prompt.
277277
* **CRITICAL RULE 6 (Action Buttons):** For buttons that imply a stateful action (e.g., "Add to Cart", "Add to Wishlist"), simply log a message to the console (e.g., `console.log('Add to cart clicked')`).
278-
* **CRITICAL RULE 7 (Image Loading):** When using `<img>` tags, you **must** show a spinner if the `src` is `undefined` or `''`. Import `MatProgressSpinnerModule` (from `@angular/material/progress-spinner`) in the standalone component and use this structure:
278+
* **CRITICAL RULE 7 (Image Loading):** When using `<img>` tags, you **must** not show the image if `src` is `undefined` or `''`. Use this structure:
279279
* *Example:*
280280
```html
281281
@if (imageUrl()) {
282282
<img [src]="imageUrl()">
283-
} @else {
284-
<mat-spinner diameter="50"></mat-spinner>
285283
}
286284
```
287285
4. **Generate `app-context.ts`:**
@@ -571,16 +569,14 @@ def create_dynamic_component() -> str:
571569
* *Example:* chatService = inject(ChatService);
572570
* **CRITICAL RULE 5 (Chat Service):** For any buttons or links related to search, discovery, or navigation (e.g., "View Details", "Explore"), you **must** import ChatService from ../../../chat/chat.service and call this.chatService.addUserPrompt() with an appropriate instructional prompt.
573571
* **CRITICAL RULE 6 (Action Buttons):** For buttons that imply a stateful action (e.g., "Add to Cart", "Add to Wishlist"), simply log a message to the console (e.g., console.log('Add to cart clicked')).
574-
* **CRITICAL RULE 7 (Image Loading):** When using <img> tags, you **must** show a spinner if the src is undefined or ''. Import MatProgressSpinnerModule (from @angular/material/progress-spinner) in the standalone component and use this structure:
572+
* **CRITICAL RULE 7 (Image Loading):** When using `<img>` tags, you **must** not show the image if `src` is `undefined` or `''`. Use this structure:
575573
* *Example:*
576574
* HTML
577575
578576
```
579577
580578
@if (imageUrl()) {
581579
<img [src]="imageUrl()">
582-
} @else {
583-
<mat-spinner diameter="50"></mat-spinner>
584580
}
585581
586582
```

dynamic-sdui-app/src/app/apps/adev-docs/components/code-snippet.component.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,31 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { Component, input } from '@angular/core';
9+
import { Component, inject, input } from '@angular/core';
1010
import { CommonModule } from '@angular/common';
1111
import { Highlight } from 'ngx-highlightjs';
1212
import { MatIconModule } from '@angular/material/icon';
13-
import { MatProgressBarModule } from '@angular/material/progress-bar';
13+
import { MagicAiService } from '../../../magic-ai/magic-ai.service';
1414

1515
@Component({
1616
selector: 'adev-code-snippet',
1717
standalone: true,
18-
imports: [CommonModule, Highlight, MatIconModule, MatProgressBarModule],
19-
template: `@if (code() && language()) {
18+
imports: [CommonModule, Highlight, MatIconModule],
19+
template: `
20+
21+
@if (!code() || !language() || !this.magicAiService.isStreamComplete()) {
22+
<div class="code-snippet-container">
23+
<div class="placeholder-loading">
24+
<p>Loading...</p>
25+
</div>
26+
</div>
27+
} @else {
2028
<div class="code-snippet-container">
2129
<pre><code [highlight]="code()!" [language]="language()!"></code></pre>
2230
<button class="copy-button" (click)="copyCode()">
2331
<mat-icon>content_copy</mat-icon>
2432
</button>
2533
</div>
26-
} @else {
27-
<div class="code-snippet-container">
28-
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
29-
</div>
3034
}`,
3135
styles: [`.code-snippet-container {
3236
position: relative;
@@ -63,10 +67,23 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
6367
code {
6468
border: var(--adev-docs-border-default);
6569
border-radius: var(--adev-docs-border-radius-md);
70+
margin: 10px 0;
71+
}
72+
73+
.placeholder-loading {
74+
background-color: #282c34;
75+
min-height: 30px;
76+
color: #abb2bf;
77+
border: var(--adev-docs-border-default);
78+
border-radius: var(--adev-docs-border-radius-md);
79+
padding: 16px;
80+
font-family: var(--default-mono-font-family);
81+
margin: 10px 0;
6682
}
6783
`],
6884
})
6985
export class CodeSnippetComponent {
86+
magicAiService = inject(MagicAiService);
7087
code = input<string | undefined>();
7188
language = input<string | undefined>();
7289

dynamic-sdui-app/src/app/apps/magic-bookstore/app-context.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { FullReviewCardComponent } from './components/full-review-card.component
1515
import { GenreTagCloudComponent } from './components/genre-tag-cloud.component';
1616
import { BookSpecificationsComponent } from './components/book-specifications.component';
1717
import { AwardBadgeComponent } from './components/award-badge.component';
18-
import { BestsellerRibbonComponent } from './components/bestseller-ribbon.component';
1918
import { SeriesInfoCardComponent } from './components/series-info-card.component';
2019
import { BookDescriptionPanelComponent } from './components/book-description-panel.component';
2120
import { StockAvailabilityComponent } from './components/stock-availability.component';
@@ -88,14 +87,6 @@ const GENERATED_COMPONENT_CONTEXT_DATA: ComponentContext[] = [
8887
award: { type: 'Award', description: "The award object to display.", required: true },
8988
},
9089
},
91-
{
92-
name: 'BestsellerRibbonComponent',
93-
description: "Visually indicates a book's bestseller rank.",
94-
type: 'dynamicComponent',
95-
inputs: {
96-
rank: { type: 'number', description: "The bestseller rank of the book.", required: true },
97-
},
98-
},
9990
{
10091
name: 'SeriesInfoCardComponent',
10192
description: "Displays information about the book's series.",
@@ -141,7 +132,6 @@ const GENERATED_COMPONENT_MAP: { [key: string]: Type<any> } = {
141132
GenreTagCloudComponent: GenreTagCloudComponent,
142133
BookSpecificationsComponent: BookSpecificationsComponent,
143134
AwardBadgeComponent: AwardBadgeComponent,
144-
BestsellerRibbonComponent: BestsellerRibbonComponent,
145135
SeriesInfoCardComponent: SeriesInfoCardComponent,
146136
BookDescriptionPanelComponent: BookDescriptionPanelComponent,
147137
StockAvailabilityComponent: StockAvailabilityComponent,

dynamic-sdui-app/src/app/apps/magic-bookstore/components/author-bio-card.component.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88

99
import { Component, input } from '@angular/core';
1010
import { CommonModule } from '@angular/common';
11-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
1211
import { Author } from '../data-store';
1312

1413
@Component({
1514
selector: 'app-author-bio-card',
1615
standalone: true,
17-
imports: [CommonModule, MatProgressSpinnerModule],
16+
imports: [CommonModule],
1817
template: `@if (author(); as author) {
1918
<div class="author-card">
2019
<div class="author-image-container">
2120
@if (author.imageUrl) {
2221
<img [src]="author.imageUrl" alt="Photo of {{ author.name }}" class="author-image">
2322
} @else {
24-
<mat-spinner diameter="50"></mat-spinner>
23+
<div class="author-initials">{{ getInitials(author.name) }}</div>
2524
}
2625
</div>
2726
<div class="author-info">
@@ -60,8 +59,10 @@ import { Author } from '../data-store';
6059
object-fit: cover;
6160
}
6261
63-
mat-spinner {
64-
--mdc-circular-progress-active-indicator-color: var(--primary);
62+
.author-initials {
63+
font-size: 48px;
64+
font-weight: bold;
65+
color: var(--primary);
6566
}
6667
6768
.author-info {
@@ -87,4 +88,15 @@ mat-spinner {
8788
})
8889
export class AuthorBioCardComponent {
8990
author = input<Author>();
91+
92+
getInitials(name: string): string {
93+
if (!name) {
94+
return '';
95+
}
96+
const names = name.split(' ');
97+
if (names.length > 1) {
98+
return `${names[0][0]}${names[names.length - 1][0]}`;
99+
}
100+
return names[0][0];
101+
}
90102
}

dynamic-sdui-app/src/app/apps/magic-bookstore/components/book-cover-card.component.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import { Component, inject, input } from '@angular/core';
1010
import { CommonModule } from '@angular/common';
11-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
1211
import { Book } from '../data-store';
1312
import { ChatService } from '../../../chat/chat.service';
1413
import { RatingStarsComponent } from './rating-stars.component';
@@ -17,14 +16,12 @@ import { BestsellerRibbonComponent } from './bestseller-ribbon.component';
1716
@Component({
1817
selector: 'app-book-cover-card',
1918
standalone: true,
20-
imports: [CommonModule, MatProgressSpinnerModule, RatingStarsComponent, BestsellerRibbonComponent],
19+
imports: [CommonModule, RatingStarsComponent, BestsellerRibbonComponent],
2120
template: `@if (book(); as book) {
2221
<div class="book-card" (click)="viewDetails(book.title)">
2322
<div class="cover-container">
2423
@if (book.coverImgUrl) {
2524
<img [src]="book.coverImgUrl" alt="Cover of {{ book.title }}" class="book-cover">
26-
} @else {
27-
<mat-spinner diameter="50"></mat-spinner>
2825
}
2926
@if (book.bestsellerRank) {
3027
<app-bestseller-ribbon [rank]="book.bestsellerRank"></app-bestseller-ribbon>
@@ -65,7 +62,6 @@ import { BestsellerRibbonComponent } from './bestseller-ribbon.component';
6562
6663
.book-card:hover {
6764
box-shadow: var(--shadow-medium);
68-
transform: translateY(-2px);
6965
}
7066
7167
.cover-container {
@@ -92,14 +88,6 @@ import { BestsellerRibbonComponent } from './bestseller-ribbon.component';
9288
border-top-right-radius: var(--border-radius-md);
9389
}
9490
95-
mat-spinner {
96-
position: absolute;
97-
top: 50%;
98-
left: 50%;
99-
transform: translate(-50%, -50%);
100-
--mdc-circular-progress-active-indicator-color: var(--primary);
101-
}
102-
10391
.book-info {
10492
padding: var(--spacing-3);
10593
display: flex;

dynamic-sdui-app/src/app/apps/magic-bookstore/components/book-detail-hero.component.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@
88

99
import { Component, input, computed } from '@angular/core';
1010
import { CommonModule } from '@angular/common';
11-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
1211
import { Book } from '../data-store';
1312
import { RatingStarsComponent } from './rating-stars.component';
13+
import { BestsellerRibbonComponent } from './bestseller-ribbon.component';
1414

1515
@Component({
1616
selector: 'app-book-detail-hero',
1717
standalone: true,
18-
imports: [CommonModule, MatProgressSpinnerModule, RatingStarsComponent],
18+
imports: [CommonModule, RatingStarsComponent, BestsellerRibbonComponent],
1919
template: `@if (book(); as book) {
2020
<div class="hero-section">
2121
<div class="cover-image-container">
2222
@if (book.coverImgUrl) {
2323
<img [src]="book.coverImgUrl" alt="Cover of {{ book.title }}" class="book-cover-hero">
24-
} @else {
25-
<mat-spinner diameter="70"></mat-spinner>
24+
}
25+
@if (book.bestsellerRank) {
26+
<app-bestseller-ribbon [rank]="book.bestsellerRank"></app-bestseller-ribbon>
2627
}
2728
</div>
2829
<div class="details-container">
@@ -69,6 +70,7 @@ import { RatingStarsComponent } from './rating-stars.component';
6970
}
7071
7172
.cover-image-container {
73+
position: relative;
7274
flex-shrink: 0;
7375
width: 300px; /* Fixed width for the cover */
7476
height: 450px; /* Aspect ratio for book covers */
@@ -88,10 +90,6 @@ import { RatingStarsComponent } from './rating-stars.component';
8890
border-radius: var(--border-radius-lg);
8991
}
9092
91-
mat-spinner {
92-
--mdc-circular-progress-active-indicator-color: var(--primary);
93-
}
94-
9593
.details-container {
9694
flex-grow: 1;
9795
display: flex;

dynamic-sdui-app/src/app/apps/vacation-rentals/components/destination-card.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { ChatService } from '../../../chat/chat.service';
2929
}
3030
3131
:host(:hover) {
32-
transform: translateY(-4px);
3332
box-shadow: var(--haven-shadow-medium, 0px 6px 16px rgba(0, 0, 0, 0.08));
3433
}
3534

dynamic-sdui-app/src/app/apps/vacation-rentals/components/favorites-list.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import { DecimalPipe } from '@angular/common';
5757
5858
.favorite-item:hover {
5959
box-shadow: var(--haven-shadow-medium);
60-
transform: translateY(-2px);
6160
}
6261
6362
.favorite-item-content {

dynamic-sdui-app/src/app/apps/vacation-rentals/components/photo-gallery-grid.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ import { ChangeDetectionStrategy, Component, input } from '@angular/core';
9292
9393
.show-all-photos-button:hover {
9494
box-shadow: var(--haven-shadow-medium, 0px 6px 16px rgba(0, 0, 0, 0.08));
95-
transform: translateY(-2px);
9695
}
9796
9897
.show-all-photos-button .material-icons {

dynamic-sdui-app/src/app/apps/vacation-rentals/components/user-booking-card.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export type Booking = {
6868
6969
.card-container:hover {
7070
box-shadow: var(--haven-shadow-medium, 0px 6px 16px rgba(0, 0, 0, 0.08));
71-
transform: translateY(-2px);
7271
}
7372
7473
.image-wrapper {

0 commit comments

Comments
 (0)