Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions projects/docs/preview/markup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import { defineCustomElement as defineToggle } from '@ionic/core/components/ion-toggle.js';
import { defineCustomElement as defineSearchbar } from '@ionic/core/components/ion-searchbar.js';
import { defineCustomElement as defineTitle } from '@ionic/core/components/ion-title.js';
import { defineCustomElement as defineHeader } from '@ionic/core/components/ion-header.js';
import { defineCustomElement as defineText } from '@ionic/core/components/ion-text.js';
import { defineCustomElement as defineTabButton } from '@ionic/core/components/ion-tab-button.js';
import { defineCustomElement as defineTabBar } from '@ionic/core/components/ion-tab-bar.js';
import { defineCustomElement as defineAlert } from '@ionic/core/components/ion-alert.js';
import { defineCustomElement as defineActionSheet } from '@ionic/core/components/ion-action-sheet.js';
import { addIcons } from 'ionicons';
import { mailOutline, chatbubblesOutline } from 'ionicons/icons';
import { defineCustomElement as defineButtons } from '@ionic/core/components/ion-buttons.js';
Expand Down Expand Up @@ -30,3 +39,12 @@ defineSegment();
defineSegmentButton();
defineContent();
defineToolbar();
defineAlert();
defineActionSheet();
defineTabBar();
defineTabButton();
defineText();
defineHeader();
defineTitle();
defineSearchbar();
defineToggle();
10 changes: 5 additions & 5 deletions projects/docs/src/app/docs/guide-article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { guideCopyForLocale } from '../../../../../shared/guide-navigation';
export interface GuideContent {
readonly title: string;
readonly description: string;
readonly html: string;
readonly html?: string;
readonly headings: readonly { readonly id: string; readonly text: string }[];
readonly editUrl: string;
readonly previewSections?: readonly { readonly intro: string; readonly code: string; readonly label: string; readonly themes: 'all' | 'ios' | 'md' }[];
readonly previewSections?: readonly { readonly tallPreview?: boolean; readonly intro: string; readonly code: string; readonly label: string; readonly themes: 'all' | 'ios' | 'ios26' | 'md' }[];
}

@Component({
Expand Down Expand Up @@ -48,11 +48,11 @@ export interface GuideContent {
@if (guide().previewSections; as sections) {
@for (section of sections; track $index) {
<div class="example-intro" appHeadingLinks [innerHTML]="section.intro | safeHtml"></div>
<app-markup-preview [example]="$index" [label]="section.label" [themes]="section.themes" />
<div [innerHTML]="section.code | safeHtml"></div>
<app-markup-preview [example]="$index" [tallPreview]="section.tallPreview === true" [label]="section.label" [themes]="section.themes" />
<div appHeadingLinks [innerHTML]="section.code | safeHtml"></div>
}
} @else {
<div appHeadingLinks [innerHTML]="guide().html | safeHtml"></div>
<div appHeadingLinks [innerHTML]="(guide().html ?? '') | safeHtml"></div>
}
<p class="mt-10 text-sm">
<a [href]="guide().editUrl" i18n="@@editOnGitHub">Edit this page on GitHub</a>
Expand Down
9 changes: 5 additions & 4 deletions projects/docs/src/app/docs/markup-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { DomSanitizer } from '@angular/platform-browser';
<div class="preview">
<div class="themes" role="group" [attr.aria-label]="label()">
@for (platform of platforms; track platform.id) {
<button type="button" [disabled]="themes() !== 'all' && (platform.id === 'md' ? themes() !== 'md' : themes() !== 'ios')" [attr.aria-pressed]="selected() === platform" (click)="selected.set(platform)">
<button type="button" [disabled]="themes() !== 'all' && (themes() === 'ios' ? platform.id === 'md' : platform.id !== themes())" [attr.aria-pressed]="selected() === platform" (click)="selected.set(platform)">
{{ platform.name }}
</button>
}
</div>
<iframe [src]="url()" [title]="label() + ' · ' + selected().name" loading="lazy"></iframe>
<iframe [style.height]="tallPreview() ? '22rem' : null" [src]="url()" [title]="label() + ' · ' + selected().name" loading="lazy"></iframe>
</div>
`,
styles: `
Expand All @@ -25,11 +25,12 @@ import { DomSanitizer } from '@angular/platform-browser';
`,
})
export class MarkupPreview {
readonly tallPreview = input(false);
readonly example = input.required<number>();
readonly themes = input.required<'all' | 'ios' | 'md'>();
readonly themes = input.required<'all' | 'ios' | 'ios26' | 'md'>();
readonly label = input.required<string>();
protected readonly platforms = [{ id: 'ios', name: 'iOS 27' }, { id: 'ios26', name: 'iOS 26' }, { id: 'md', name: 'MD3' }] as const;
protected readonly selected = linkedSignal<(typeof this.platforms)[number]>(() => this.themes() === 'md' ? this.platforms[2] : this.platforms[0]);
protected readonly selected = linkedSignal<(typeof this.platforms)[number]>(() => this.platforms.find(platform => platform.id === this.themes()) ?? this.platforms[0]);
readonly #sanitizer = inject(DomSanitizer);
protected readonly url = computed(() => this.#sanitizer.bypassSecurityTrustResourceUrl(
`/assets/theme-preview/markup-${this.example()}-${this.selected().id}.html`,
Expand Down
Loading