Skip to content

Commit 661271a

Browse files
committed
Add styles with object id
1 parent 10e5f4d commit 661271a

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

src/app/app.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<window title="Angular app in window!">
2-
<view>
2+
<view id="app">
33
<image
4+
id="image"
45
[src]="'C:/temp/angular.png'"
56
[aspectRatioMode]="aspectRatioMode"
67
></image>

src/app/app.component.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import { Component } from '@angular/core';
1+
import { Component, ViewEncapsulation } from '@angular/core';
22
import { AspectRatioMode } from '@nodegui/nodegui';
33

44
@Component({
55
selector: 'app-root',
6-
templateUrl: './app.component.html'
6+
templateUrl: './app.component.html',
7+
styles: [
8+
`
9+
#app {
10+
background-color: gray;
11+
}
12+
#image {
13+
}
14+
`
15+
],
16+
encapsulation: ViewEncapsulation.None
717
})
818
export class AppComponent {
919
public name = 'World!';

src/lib/components/view.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ export class NgView extends QWidget implements NgComponent {
3232
name: string,
3333
value: string,
3434
namespace?: string | null
35-
): void {}
35+
): void {
36+
switch (name) {
37+
case 'id':
38+
this.setObjectName(value);
39+
break;
40+
41+
default:
42+
break;
43+
}
44+
}
3645

3746
public setProperty(name: string, value: any): void {
3847
throw new Error('Method not implemented.');

src/lib/renderer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class NodeguiRendererFactory implements RendererFactory2 {
2828
}
2929

3030
createRenderer(hostElement: any, type: RendererType2 | null): Renderer2 {
31+
if (type) {
32+
hostElement.setStyleSheet(type.styles);
33+
}
3134
return this.renderer;
3235
}
3336
}
@@ -49,6 +52,7 @@ export class NodeguiRenderer implements Renderer2 {
4952
if (Component) {
5053
return new Component();
5154
} else {
55+
// TODO create widget with name, may be customm component
5256
console.warn(`${name} component is not find in components map`);
5357
}
5458
}
@@ -150,6 +154,8 @@ export class NodeguiRenderer implements Renderer2 {
150154
value: any,
151155
flags?: RendererStyleFlags2
152156
): void {
157+
console.log('setStyle', style);
158+
153159
el.setStyle(style, value, flags);
154160
}
155161

0 commit comments

Comments
 (0)