Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(theming): update angular to standalone #3970

Merged
merged 5 commits into from
Dec 30, 2024
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
```ts
import { Component, OnInit } from '@angular/core';
import {
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
],
})
export class ExampleComponent implements OnInit {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
```ts
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [
FormsModule,
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
],
})
export class ExampleComponent implements OnInit {
themeToggle = false;
Expand All @@ -33,18 +70,18 @@ export class ExampleComponent implements OnInit {
}

// Check/uncheck the toggle and update the theme based on isDark
initializeDarkTheme(isDark) {
initializeDarkTheme(isDark: boolean) {
this.themeToggle = isDark;
this.toggleDarkTheme(isDark);
}

// Listen for the toggle check/uncheck to toggle the dark theme
toggleChange(ev) {
this.toggleDarkTheme(ev.detail.checked);
toggleChange(event: CustomEvent) {
this.toggleDarkTheme(event.detail.checked);
}

// Add or remove the "dark" class on the document body
toggleDarkTheme(shouldAdd) {
toggleDarkTheme(shouldAdd: boolean) {
document.body.classList.toggle('dark', shouldAdd);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
```ts
import { Component } from '@angular/core';
import {
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';
Expand All @@ -8,6 +25,23 @@ import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
],
})
export class ExampleComponent {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
```ts
import { Component } from '@angular/core';
import {
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';
Expand All @@ -8,6 +25,23 @@ import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
],
})
export class ExampleComponent {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
```ts
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [
FormsModule,
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
],
})
export class ExampleComponent implements OnInit {
paletteToggle = false;
Expand All @@ -33,18 +70,18 @@ export class ExampleComponent implements OnInit {
}

// Check/uncheck the toggle and update the palette based on isDark
initializeDarkPalette(isDark) {
initializeDarkPalette(isDark: boolean) {
this.paletteToggle = isDark;
this.toggleDarkPalette(isDark);
}

// Listen for the toggle check/uncheck to toggle the dark palette
toggleChange(ev) {
this.toggleDarkPalette(ev.detail.checked);
toggleChange(event: CustomEvent) {
this.toggleDarkPalette(event.detail.checked);
}

// Add or remove the "ion-palette-dark" class on the html element
toggleDarkPalette(shouldAdd) {
toggleDarkPalette(shouldAdd: boolean) {
document.documentElement.classList.toggle('ion-palette-dark', shouldAdd);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
```ts
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [
FormsModule,
IonBackButton,
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonRange,
IonText,
IonTitle,
IonToggle,
IonToolbar,
],
})
export class ExampleComponent implements OnInit {
darkPaletteToggle = false;
Expand Down Expand Up @@ -39,34 +76,34 @@ export class ExampleComponent implements OnInit {
}

// Check/uncheck the toggle and update the palette based on isDark
initializeDarkPalette(isDark) {
initializeDarkPalette(isDark: boolean) {
this.darkPaletteToggle = isDark;
this.toggleDarkPalette(isDark);
}

// Check/uncheck the toggle and update the palette based on isHighContrast
initializeHighContrastPalette(isHighContrast) {
initializeHighContrastPalette(isHighContrast: boolean) {
this.highContrastPaletteToggle = isHighContrast;
this.toggleHighContrastPalette(isHighContrast);
}

// Listen for the toggle check/uncheck to toggle the dark palette
darkPaletteToggleChange(ev) {
this.toggleDarkPalette(ev.detail.checked);
darkPaletteToggleChange(event: CustomEvent) {
this.toggleDarkPalette(event.detail.checked);
}

// Listen for the toggle check/uncheck to toggle the high contrast palette
highContrastPaletteToggleChange(ev) {
this.toggleHighContrastPalette(ev.detail.checked);
highContrastPaletteToggleChange(event: CustomEvent) {
this.toggleHighContrastPalette(event.detail.checked);
}

// Add or remove the "ion-palette-dark" class on the html element
toggleDarkPalette(shouldAdd) {
toggleDarkPalette(shouldAdd: boolean) {
document.documentElement.classList.toggle('ion-palette-dark', shouldAdd);
}

// Add or remove the "ion-palette-high-contrast" class on the html element
toggleHighContrastPalette(shouldAdd) {
toggleHighContrastPalette(shouldAdd: boolean) {
document.documentElement.classList.toggle('ion-palette-high-contrast', shouldAdd);
}
}
Expand Down
Loading