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
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';

@Component({
selector: 'ng-styled-app-shell',
templateUrl: './app-shell.component.html',
styleUrls: ['./app-shell.component.css'],
})
export class AppShellComponent implements OnInit {
constructor() {}

ngOnInit(): void {}
}
export class AppShellComponent {}
2 changes: 2 additions & 0 deletions apps/ng-styled-webpage/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AppComponent],
imports: [RouterModule],
}).compileComponents();
});

Expand Down
2 changes: 1 addition & 1 deletion apps/ng-styled-webpage/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {
createTheme,
StyledModule,
Options,
StyledModule,
Theme,
} from '@design4pro/ng-styled';
import { create, Jss } from 'jss';
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>layout-footer works!</p>
<p>©{{ year }} DESIGN4PRO</p>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
templateUrl: './layout-footer.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LayoutFooterComponent {}
export class LayoutFooterComponent {
year = new Date().getFullYear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
width="48"
alt="Angular Logo"
/>
<h1 [ngClass]="classes.h1">Angular JSS <span>by DESIGN4PRO</span></h1>
<h1 [ngClass]="classes?.h1">Angular JSS <span>by DESIGN4PRO</span></h1>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { LayoutHeaderComponent } from './layout-header.component';

describe('LayoutHeaderComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { COMPONENT_STYLES } from './layout-header.component.styles';
})
@Styled(({ css }) => css(COMPONENT_STYLES))
export class LayoutHeaderComponent {
classes: any;
classes: { host: string; h1: string } | undefined;

@HostBinding('class')
get className() {
return this.classes.host;
return this.classes?.host;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AppModule } from '../app.module';
import { LayoutComponent } from './layout.component';

describe('LayoutComponent', () => {
Expand All @@ -8,7 +8,7 @@ describe('LayoutComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [LayoutComponent],
imports: [AppModule],
}).compileComponents();
});

Expand Down
4 changes: 2 additions & 2 deletions apps/ng-styled-webpage/src/app/layout/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { COMPONENT_STYLES } from './layout.component.styles';
})
@Styled(({ css }) => css(COMPONENT_STYLES))
export class LayoutComponent {
classes: any;
classes: { host: string } | undefined;

@HostBinding('class')
get className() {
return this.classes.host;
return this.classes?.host;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { HomeComponent } from './home.component';
import { HomeModule } from './home.module';

describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [HomeComponent],
imports: [HomeModule],
}).compileComponents();
});

Expand Down
2 changes: 1 addition & 1 deletion apps/ng-styled-webpage/src/app/page/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Styled, StyledProp } from '@design4pro/ng-styled';
})
export class HomeComponent {
title = 'Angular JSS';
classes: any;
classes: { root: string; title: string; hint: string } | undefined;

code = `
import { ChangeDetectionStrategy, Component } from '@angular/core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { SharedModule } from '../shared.module';
import { CodeComponent } from './code.component';

describe('CodeComponent', () => {
Expand All @@ -9,6 +9,7 @@ describe('CodeComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [CodeComponent],
imports: [SharedModule],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { GITHUB_STYLES } from './code.component.styles';
);
})
export class CodeComponent {
classes: any;
classes: { root: string } | undefined;

@Input()
code = '';
Expand Down
4 changes: 2 additions & 2 deletions libs/ng-styled/src/lib/styled.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';
import { JssStore } from './jss/context';
import {
StyledOptions,
styledOptionsFactory,
Expand All @@ -8,8 +9,7 @@ import {
STYLED_OPTIONS_INJECTOR,
STYLED_THEME_INJECTOR,
} from './styled.options';
import { StyledService, styledFactory } from './styled.service';
import { JssStore } from './jss/context';
import { styledFactory, StyledService } from './styled.service';
import defaultTheme from './theme/default-theme';
import { ThemeStore } from './theme/theme-context';

Expand Down
2 changes: 1 addition & 1 deletion libs/ng-styled/src/lib/styled.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from '@angular/core';
import { createGenerateId, SheetsRegistry } from 'jss';
import { StyledOptions, StyledTheme } from './styled.options';
import { JssContext, JssStore } from './jss/context';
import { manageSheet } from './jss/managers';
import { JssManagers, StaticStyles } from './jss/types';
import getSheetIndex from './jss/utils/get-sheet-index';
import { createStyleSheet } from './jss/utils/sheets';
import { StyledOptions, StyledTheme } from './styled.options';
import normalize from './styles/normalize';
import { ThemeContext, ThemeStore } from './theme/theme-context';
import shallowEqualObjects from './utils/shallow-equal-objects';
Expand Down
5 changes: 3 additions & 2 deletions libs/ng-styled/src/lib/theme/theme-context.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Injectable } from '@angular/core';
import { Store } from '../utils/store';
import defaultTheme from './default-theme';
import { Theme } from './types';

export class ThemeContext implements Partial<Theme> {}
export type ThemeContext = Partial<Theme>;

@Injectable()
export class ThemeStore extends Store<ThemeContext> {
private static instance: ThemeStore;

constructor() {
super(new ThemeContext());
super(defaultTheme);
}

static getInstance(): ThemeStore {
Expand Down