-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dev-app): rebuild the layout and improve styles
- Loading branch information
Showing
13 changed files
with
206 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import { Routes } from '@angular/router'; | ||
import { LayoutComponent } from './layout/layout.component'; | ||
import { ExamplesComponent } from './examples/examples.component'; | ||
import { HomeComponent } from './home/home.component'; | ||
import { PlaygroundComponent } from './playground/playground.component'; | ||
|
||
export const routes: Routes = [ | ||
{ path: '', pathMatch: 'full', redirectTo: 'home' }, | ||
{ path: 'home', component: HomeComponent }, | ||
{ path: 'examples', component: ExamplesComponent }, | ||
{ path: 'playground', component: PlaygroundComponent }, | ||
{ | ||
path: '', | ||
component: LayoutComponent, | ||
children: [ | ||
{ path: '', pathMatch: 'full', redirectTo: 'home' }, | ||
{ path: 'home', component: HomeComponent }, | ||
{ path: 'examples', component: ExamplesComponent }, | ||
{ path: 'playground', component: PlaygroundComponent }, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<main> | ||
<section> | ||
<gui-form [config]="config" [model]="model" [form]="form"></gui-form> | ||
</section> | ||
<section> | ||
<textarea [value]="model|json"></textarea> | ||
</section> | ||
</main> | ||
<section> | ||
<gui-form [config]="config" [model]="model" [form]="form"></gui-form> | ||
</section> | ||
<section> | ||
<textarea [value]="model|json" readonly></textarea> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
main { | ||
:host { | ||
display: grid; | ||
grid-template-columns: 320px 1fr; | ||
gap: 16px; | ||
height: 100%; | ||
padding: 16px; | ||
} | ||
|
||
section { | ||
position: relative; | ||
border: 1px solid; | ||
border: 1px solid var(--mat-divider-color); | ||
overflow: auto; | ||
} | ||
|
||
textarea { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
font-size: 12px; | ||
border: none; | ||
outline: none; | ||
resize: vertical; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
<a mat-button routerLink="/examples">Examples</a> | ||
<a mat-button routerLink="/playground">Playground</a> | ||
<p>Welcome to the development demos for GUI!</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<mat-sidenav-container [dir]="isRtl?'rtl':'ltr'"> | ||
<mat-sidenav-content> | ||
<mat-toolbar color="primary"> | ||
<div class="demo-links"> | ||
<a mat-button routerLink="/home">Home</a> | ||
<a mat-button routerLink="/examples">Examples</a> | ||
<a mat-button routerLink="/playground">Playground</a> | ||
</div> | ||
|
||
<div class="demo-config"> | ||
<button mat-button (click)="toggleThemeClass()">{{isDark ? 'Light' : 'Dark'}} theme</button> | ||
<button mat-button (click)="toggleRtl()">{{isRtl ? 'LTR' : 'RTL'}}</button> | ||
</div> | ||
</mat-toolbar> | ||
|
||
<div class="demo-content"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
</mat-sidenav-content> | ||
</mat-sidenav-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
mat-sidenav-container { | ||
height: 100%; | ||
} | ||
|
||
mat-toolbar { | ||
justify-content: space-between; | ||
} | ||
|
||
.demo-content { | ||
height: calc(100% - 64px); | ||
padding: 16px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { CommonModule, DOCUMENT } from '@angular/common'; | ||
import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatToolbarModule } from '@angular/material/toolbar'; | ||
import { Directionality } from '@angular/cdk/bidi'; | ||
import { MatSidenavModule } from '@angular/material/sidenav'; | ||
import { SettingsService } from '../settings.service'; | ||
|
||
@Component({ | ||
selector: 'app-layout', | ||
standalone: true, | ||
imports: [CommonModule, RouterModule, MatSidenavModule, MatToolbarModule, MatButtonModule], | ||
templateUrl: './layout.component.html', | ||
styleUrls: ['./layout.component.scss'], | ||
encapsulation: ViewEncapsulation.None, | ||
}) | ||
export class LayoutComponent implements OnInit { | ||
htmlElement!: HTMLHtmlElement; | ||
darkThemeClass = 'dark-theme'; | ||
isDark = false; | ||
isRtl = false; | ||
|
||
constructor( | ||
@Inject(DOCUMENT) private document: Document, | ||
private dir: Directionality, | ||
private settings: SettingsService | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.htmlElement = this.document.querySelector('html')!; | ||
this.isRtl = this.dir.value === 'rtl'; | ||
} | ||
|
||
toggleThemeClass() { | ||
this.isDark = !this.isDark; | ||
|
||
if (this.isDark) { | ||
this.htmlElement.classList.add(this.darkThemeClass); | ||
} else { | ||
this.htmlElement.classList.remove(this.darkThemeClass); | ||
} | ||
|
||
this.settings.themeChange.next(this.isDark ? 'dark' : 'light'); | ||
} | ||
|
||
toggleRtl() { | ||
this.isRtl = !this.isRtl; | ||
|
||
if (this.isRtl) { | ||
this.htmlElement.dir = 'rtl'; | ||
} else { | ||
this.htmlElement.dir = 'ltr'; | ||
} | ||
} | ||
} |
29 changes: 14 additions & 15 deletions
29
projects/dev-app/src/app/playground/playground.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
<main> | ||
<section> | ||
<ng-monaco-editor [style]="{height:'100%',width:'100%'}" | ||
[options]="{language:'json'}" | ||
[(ngModel)]="configStr" | ||
[ngModelOptions]="{updateOn:'blur'}" | ||
(ngModelChange)="onConfigChange()"></ng-monaco-editor> | ||
</section> | ||
<section> | ||
<gui-form [config]="config" [model]="model" [form]="form"></gui-form> | ||
</section> | ||
<section> | ||
<textarea [value]="model|json"></textarea> | ||
</section> | ||
</main> | ||
<section> | ||
<ng-monaco-editor dir="ltr" | ||
[style]="{height:'100%',width:'100%'}" | ||
[options]="{language:'json'}" | ||
[(ngModel)]="configStr" | ||
[ngModelOptions]="{updateOn:'blur'}" | ||
(ngModelChange)="onConfigChange()"></ng-monaco-editor> | ||
</section> | ||
<section> | ||
<gui-form [config]="config" [model]="model" [form]="form"></gui-form> | ||
</section> | ||
<section> | ||
<textarea [value]="model|json" readonly></textarea> | ||
</section> |
15 changes: 2 additions & 13 deletions
15
projects/dev-app/src/app/playground/playground.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
main { | ||
:host { | ||
display: grid; | ||
grid-template-columns: 1fr 320px 1fr; | ||
gap: 16px; | ||
height: 100%; | ||
padding: 16px; | ||
} | ||
|
||
section { | ||
position: relative; | ||
border: 1px solid; | ||
border: 1px solid var(--mat-divider-color); | ||
overflow: auto; | ||
} | ||
|
||
textarea { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
font-size: 12px; | ||
border: none; | ||
outline: none; | ||
resize: vertical; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Subject } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class SettingsService { | ||
themeChange = new Subject<'light' | 'dark'>(); | ||
|
||
constructor() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters