-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
419 additions
and
87 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
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
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
12 changes: 12 additions & 0 deletions
12
{{cookiecutter.slug}}/frontend.angular/src/app/app.config.server.ts
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 @@ | ||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; | ||
import { provideServerRendering } from '@angular/platform-server'; | ||
import { BACKEND_URL, appConfig } from './app.config'; | ||
|
||
const serverConfig: ApplicationConfig = { | ||
providers: [ | ||
provideServerRendering(), | ||
{ provide: BACKEND_URL, useValue: 'http://localhost:8000' } | ||
] | ||
}; | ||
|
||
export const config = mergeApplicationConfig(appConfig, serverConfig); |
23 changes: 16 additions & 7 deletions
23
{{cookiecutter.slug}}/frontend.angular/src/app/app.config.ts
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,28 +1,37 @@ | ||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; | ||
import { ApplicationConfig, InjectionToken, provideZoneChangeDetection } from '@angular/core'; | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { provideHttpClient, withXsrfConfiguration } from '@angular/common/http'; | ||
import { provideHttpClient, withFetch, withXsrfConfiguration } from '@angular/common/http'; | ||
import { provideClientHydration } from '@angular/platform-browser'; | ||
import { provideAnimations } from '@angular/platform-browser/animations'; | ||
import { provideRouter } from '@angular/router'; | ||
|
||
import { routes } from './app.routes'; | ||
|
||
export const BACKEND_URL = new InjectionToken<string>('BackendUrl'); | ||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideAnimations(), | ||
provideZoneChangeDetection({ eventCoalescing: true }), | ||
provideRouter(routes), | ||
provideClientHydration(), | ||
provideHttpClient(withXsrfConfiguration({ | ||
cookieName: 'csrftoken', | ||
headerName: 'X-CSRFToken' | ||
})), | ||
provideHttpClient( | ||
withFetch(), | ||
withXsrfConfiguration({ | ||
cookieName: 'csrftoken', | ||
headerName: 'X-CSRFToken' | ||
})), | ||
// The language is used as the base_path for finding the right | ||
// static-files. For example /nl/static/main.js | ||
// However the routing is done from a base path starting from | ||
// the root e.g. /home | ||
// The server should then switch index.html based on a language | ||
// cookie with a fallback to Dutch e.g. /nl/static/index.html | ||
{ provide: APP_BASE_HREF, useValue: '/' } | ||
{ provide: APP_BASE_HREF, useValue: '/' }, | ||
// because proxy doesn't work for SSR, support a wonky workaround | ||
// by manually specifying the URL where the backend is running | ||
// https://github.com/angular/angular-cli/issues/27144 | ||
// By default it is empty, because in the browser this isn't needed | ||
{ provide: BACKEND_URL, useValue: '' } | ||
] | ||
}; |
16 changes: 16 additions & 0 deletions
16
...iecutter.slug}}/frontend.angular/src/app/dark-mode-toggle/dark-mode-toggle.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<p class="control"> | ||
@if (dark) { | ||
<a class="button" title="Switch to light mode" i18n-title (click)="toggle()"> | ||
<span class="icon"> | ||
<fa-icon [icon]="faMoon"></fa-icon> | ||
</span> | ||
</a> | ||
} | ||
@else { | ||
<a class="button" title="Switch to dark mode" i18n-title (click)="toggle()"> | ||
<span class="icon"> | ||
<fa-icon [icon]="faSun"></fa-icon> | ||
</span> | ||
</a> | ||
} | ||
</p> |
Empty file.
23 changes: 23 additions & 0 deletions
23
...utter.slug}}/frontend.angular/src/app/dark-mode-toggle/dark-mode-toggle.component.spec.ts
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,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DarkModeToggleComponent } from './dark-mode-toggle.component'; | ||
|
||
describe('DarkModeToggleComponent', () => { | ||
let component: DarkModeToggleComponent; | ||
let fixture: ComponentFixture<DarkModeToggleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [DarkModeToggleComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DarkModeToggleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
...okiecutter.slug}}/frontend.angular/src/app/dark-mode-toggle/dark-mode-toggle.component.ts
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,32 @@ | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; | ||
import { faSun, faMoon } from '@fortawesome/free-solid-svg-icons'; | ||
import { Subscription } from 'rxjs'; | ||
import { DarkModeService } from '../services/dark-mode.service'; | ||
|
||
@Component({ | ||
selector: '{{cookiecutter.app_prefix}}-dark-mode-toggle', | ||
standalone: true, | ||
imports: [FontAwesomeModule], | ||
templateUrl: './dark-mode-toggle.component.html', | ||
styleUrl: './dark-mode-toggle.component.scss' | ||
}) | ||
export class DarkModeToggleComponent implements OnDestroy { | ||
private subscriptions!: Subscription[]; | ||
faSun = faSun; | ||
faMoon = faMoon; | ||
dark = false; | ||
|
||
constructor(private darkModeService: DarkModeService) { | ||
this.subscriptions = [ | ||
this.darkModeService.theme$.subscribe(theme => this.dark = theme === 'dark')]; | ||
} | ||
|
||
toggle() { | ||
this.darkModeService.toggle(); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.subscriptions.forEach(s => s.unsubscribe()); | ||
} | ||
} |
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
5 changes: 3 additions & 2 deletions
5
{{cookiecutter.slug}}/frontend.angular/src/app/footer/footer.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,3 +1,4 @@ | ||
.lab-logo { | ||
max-width: 400px; | ||
.centre-logo { | ||
width: 450px; | ||
max-width: calc(100vw - 7rem); | ||
} |
20 changes: 17 additions & 3 deletions
20
{{cookiecutter.slug}}/frontend.angular/src/app/footer/footer.component.ts
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,29 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, Inject, LOCALE_ID, OnDestroy } from '@angular/core'; | ||
import { formatDate } from '@angular/common'; | ||
import { Subscription } from 'rxjs'; | ||
import { environment } from '../../environments/environment'; | ||
import { DarkModeService } from '../services/dark-mode.service'; | ||
|
||
@Component({ | ||
selector: '{{cookiecutter.app_prefix}}-footer', | ||
templateUrl: './footer.component.html', | ||
styleUrls: ['./footer.component.scss'], | ||
standalone: true | ||
}) | ||
export class FooterComponent { | ||
export class FooterComponent implements OnDestroy { | ||
environment = environment; | ||
buildTime!: string; | ||
dark = false; | ||
subscriptions!: Subscription[]; | ||
|
||
constructor() { } | ||
constructor(@Inject(LOCALE_ID) localeId: string, darkModeService: DarkModeService) { | ||
this.buildTime = formatDate(new Date(environment.buildTime), $localize`:@@dateFormat:MMMM dd, yyyy`, localeId); | ||
this.subscriptions = [ | ||
darkModeService.theme$.subscribe(theme => this.dark = theme === 'dark')]; | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.subscriptions.forEach(s => s.unsubscribe()); | ||
} | ||
|
||
} |
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
Oops, something went wrong.