Skip to content

Commit

Permalink
feat(core): application frame enhancement (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux committed Sep 6, 2023
1 parent c0bb78f commit e4fe29d
Show file tree
Hide file tree
Showing 73 changed files with 1,447 additions and 408 deletions.
4 changes: 2 additions & 2 deletions packages/angular-test-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ import TabsRounded from 'src/preview-examples/tabs-rounded';
import Textarea from 'src/preview-examples/textarea';
import TextareaDisabled from 'src/preview-examples/textarea-disabled';
import TextareaReadonly from 'src/preview-examples/textarea-readonly';
import ThemeSwitcherService from 'src/preview-examples/theme-switcher';
import ThemeSwitcherExample from 'src/preview-examples/theme-switcher';
import Tile from 'src/preview-examples/tile';
import Timepicker from 'src/preview-examples/timepicker';
import Toast from 'src/preview-examples/toast';
Expand Down Expand Up @@ -200,7 +200,7 @@ import { NavigationTestComponent } from './components/navigation-test.component'
Textarea,
TextareaReadonly,
TextareaDisabled,
ThemeSwitcherService,
ThemeSwitcherExample,
Tile,
Timepicker,
ToggleButtonPrimaryGhost,
Expand Down
35 changes: 35 additions & 0 deletions packages/angular-test-app/src/preview-examples/theme-switcher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<ix-grid>
<ix-row>
<ix-col size="2">
<span>Light/Dark</span>
</ix-col>
<ix-col>
<ix-button (click)="toggleMode()">Toggle mode</ix-button>
</ix-col>
</ix-row>

<ix-row>
<ix-col size="2">Theme</ix-col>
<ix-col>
<ix-select
[selectedIndices]="selectedTheme"
(itemSelectionChange)="onItemSelectionChange($event)"
placeholder="Select a theme"
>
<ix-select-item
*ngFor="let theme of themes"
[label]="theme"
[value]="theme"
></ix-select-item>
</ix-select>
</ix-col>
</ix-row>

<ix-row>
<ix-col size="2">Use System</ix-col>
<ix-col>
<input type="checkbox" id="system" (change)="onSystemMode($event)" />
<label for="system"></label>
</ix-col>
</ix-row>
</ix-grid>
54 changes: 31 additions & 23 deletions packages/angular-test-app/src/preview-examples/theme-switcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,44 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { Component } from '@angular/core';
import { ThemeService } from '@siemens/ix-angular';
import { themeSwitcher } from '@siemens/ix';

@Component({
selector: 'app-example',
template: `
<ix-button class="mb-2" (click)="themeService.toggleMode()">
Toggle mode
</ix-button>
<ix-select
(itemSelectionChange)="onItemSelectionChange($event)"
placeholder="Select a theme"
>
<ix-select-item
label="Classic light"
value="theme-classic-light"
></ix-select-item>
<ix-select-item
label="Classic dark"
value="theme-classic-dark"
></ix-select-item>
</ix-select>
`,
templateUrl: './theme-switcher.html',
styles: [
`
ix-col {
align-items: center;
height: 2.5rem;
}
`,
],
})
export default class ThemeSwitcherService {
constructor(readonly themeService: ThemeService) {}
export default class ThemeSwitcherExample {
themes = ['theme-classic-light', 'theme-classic-dark'];
selectedTheme = this.themes[1];

constructor() {}

onItemSelectionChange(event: Event) {
const customEvent = event as CustomEvent<string | string[]>;
this.themeService.setTheme(customEvent.detail[0]);
const newTheme = customEvent.detail[0];
themeSwitcher.setTheme(newTheme);
this.selectedTheme = newTheme;
}

toggleMode() {
themeSwitcher.toggleMode();
}

onSystemMode({ target }: Event) {
if ((target as HTMLInputElement).checked) {
themeSwitcher.setVariant();
return;
}

themeSwitcher.setTheme(this.selectedTheme);
}
}
8 changes: 4 additions & 4 deletions packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ export declare interface IxAvatar extends Components.IxAvatar {}


@ProxyCmp({
inputs: ['applicationName', 'hideHeader']
inputs: ['applicationName', 'breakpoints', 'forceBreakpoint', 'hideHeader']
})
@Component({
selector: 'ix-basic-navigation',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['applicationName', 'hideHeader'],
inputs: ['applicationName', 'breakpoints', 'forceBreakpoint', 'hideHeader'],
})
export class IxBasicNavigation {
protected el: HTMLElement;
Expand Down Expand Up @@ -1260,15 +1260,15 @@ export declare interface IxMapNavigationOverlay extends Components.IxMapNavigati


@ProxyCmp({
inputs: ['applicationDescription', 'applicationName', 'breakpoints', 'enableMapExpand', 'enableSettings', 'enableToggleTheme', 'expand', 'forceBreakpoint', 'i18nCollapse', 'i18nExpand', 'i18nExpandSidebar', 'i18nLegal', 'i18nSettings', 'i18nToggleTheme', 'maxVisibleMenuItems', 'pinned', 'showAbout', 'showSettings'],
inputs: ['applicationDescription', 'applicationName', 'enableMapExpand', 'enableSettings', 'enableToggleTheme', 'expand', 'i18nCollapse', 'i18nExpand', 'i18nExpandSidebar', 'i18nLegal', 'i18nSettings', 'i18nToggleTheme', 'maxVisibleMenuItems', 'pinned', 'showAbout', 'showSettings'],
methods: ['toggleMapExpand', 'toggleMenu', 'toggleSettings', 'toggleAbout']
})
@Component({
selector: 'ix-menu',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['applicationDescription', 'applicationName', 'breakpoints', 'enableMapExpand', 'enableSettings', 'enableToggleTheme', 'expand', 'forceBreakpoint', 'i18nCollapse', 'i18nExpand', 'i18nExpandSidebar', 'i18nLegal', 'i18nSettings', 'i18nToggleTheme', 'maxVisibleMenuItems', 'pinned', 'showAbout', 'showSettings'],
inputs: ['applicationDescription', 'applicationName', 'enableMapExpand', 'enableSettings', 'enableToggleTheme', 'expand', 'i18nCollapse', 'i18nExpand', 'i18nExpandSidebar', 'i18nLegal', 'i18nSettings', 'i18nToggleTheme', 'maxVisibleMenuItems', 'pinned', 'showAbout', 'showSettings'],
})
export class IxMenu {
protected el: HTMLElement;
Expand Down
7 changes: 5 additions & 2 deletions packages/angular/src/theme/theme.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
*/

import { EventEmitter, Injectable, Output } from '@angular/core';
import { themeSwitcher, ThemeSwitcher } from '@siemens/ix';
import { themeSwitcher } from '@siemens/ix';

/**
* @deprecated Use themeSwitcher from core package `import { themeSwitcher } from '@siemens/ix';`
*/
@Injectable({
providedIn: 'root',
})
export class ThemeService {
@Output() themeChanged = new EventEmitter<string>();

private themeSwitcher: ThemeSwitcher;
private themeSwitcher: typeof themeSwitcher;

constructor() {
this.themeSwitcher = themeSwitcher;
Expand Down
Loading

0 comments on commit e4fe29d

Please sign in to comment.