Add demo-app-from-scratch (demo-app, but from scratch, including CSS)
This commit is contained in:
parent
1497598ace
commit
4f95338072
|
@ -0,0 +1,17 @@
|
|||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
ij_typescript_use_double_quotes = false
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
|
@ -0,0 +1,42 @@
|
|||
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
|
||||
|
||||
# Compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
/bazel-out
|
||||
|
||||
# Node
|
||||
/node_modules
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# IDEs and editors
|
||||
.idea/
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# Miscellaneous
|
||||
/.angular/cache
|
||||
.sass-cache/
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
|
||||
"recommendations": ["angular.ng-template"]
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ng serve",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "npm: start",
|
||||
"url": "http://localhost:4200/"
|
||||
},
|
||||
{
|
||||
"name": "ng test",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "npm: test",
|
||||
"url": "http://localhost:9876/debug.html"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "start",
|
||||
"isBackground": true,
|
||||
"problemMatcher": {
|
||||
"owner": "typescript",
|
||||
"pattern": "$tsc",
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": {
|
||||
"regexp": "(.*?)"
|
||||
},
|
||||
"endsPattern": {
|
||||
"regexp": "bundle generation complete"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "test",
|
||||
"isBackground": true,
|
||||
"problemMatcher": {
|
||||
"owner": "typescript",
|
||||
"pattern": "$tsc",
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": {
|
||||
"regexp": "(.*?)"
|
||||
},
|
||||
"endsPattern": {
|
||||
"regexp": "bundle generation complete"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
# DemoAppPrimeng
|
||||
|
||||
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.10.
|
||||
|
||||
## Development server
|
||||
|
||||
To start a local development server, run:
|
||||
|
||||
```bash
|
||||
ng serve
|
||||
```
|
||||
|
||||
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
||||
|
||||
```bash
|
||||
ng generate component component-name
|
||||
```
|
||||
|
||||
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
||||
|
||||
```bash
|
||||
ng generate --help
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To build the project run:
|
||||
|
||||
```bash
|
||||
ng build
|
||||
```
|
||||
|
||||
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
||||
|
||||
```bash
|
||||
ng test
|
||||
```
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
For end-to-end (e2e) testing, run:
|
||||
|
||||
```bash
|
||||
ng e2e
|
||||
```
|
||||
|
||||
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
||||
|
||||
## Additional Resources
|
||||
|
||||
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"demo-app-primeng": {
|
||||
"projectType": "application",
|
||||
"schematics": {},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"outputPath": "dist/demo-app-primeng",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
}
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.css"
|
||||
],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kB",
|
||||
"maximumError": "1MB"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "4kB",
|
||||
"maximumError": "8kB"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "demo-app-primeng:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "demo-app-primeng:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n"
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
"zone.js/testing"
|
||||
],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
}
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.css"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "demo-app-primeng",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/common": "^19.2.0",
|
||||
"@angular/compiler": "^19.2.0",
|
||||
"@angular/core": "^19.2.0",
|
||||
"@angular/forms": "^19.2.0",
|
||||
"@angular/platform-browser": "^19.2.0",
|
||||
"@angular/platform-browser-dynamic": "^19.2.0",
|
||||
"@angular/router": "^19.2.0",
|
||||
"@primeng/themes": "^19.1.2",
|
||||
"primeng": "^19.1.2",
|
||||
"rxjs": "~7.8.0",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^19.2.10",
|
||||
"@angular/cli": "^19.2.10",
|
||||
"@angular/compiler-cli": "^19.2.0",
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"jasmine-core": "~5.6.0",
|
||||
"karma": "~6.4.0",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage": "~2.2.0",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "~2.1.0",
|
||||
"typescript": "~5.7.2"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,5 @@
|
|||
<main class="main">
|
||||
<app-header />
|
||||
</main>
|
||||
|
||||
<router-outlet />
|
|
@ -0,0 +1,29 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AppComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have the 'demo-app-primeng' title`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('demo-app-primeng');
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, demo-app-primeng');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
import {HeaderComponent} from './header/header.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
imports: [RouterOutlet, HeaderComponent],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.css'
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'demo-app-primeng';
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import { providePrimeNG } from 'primeng/config';
|
||||
import Aura from '@primeng/themes/aura';
|
||||
|
||||
import { routes } from './app.routes';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideAnimationsAsync(),
|
||||
providePrimeNG({ theme: { preset: Aura, options: { darkModeSelector: false } } }),
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
provideRouter(routes)]
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
import { Routes } from '@angular/router';
|
||||
import {HomeComponent} from './home/home.component';
|
||||
import {HouseDetailsComponent} from './house-details/house-details.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: HomeComponent,
|
||||
title: 'Home Page',
|
||||
},
|
||||
{
|
||||
path: 'details/:id',
|
||||
component: HouseDetailsComponent,
|
||||
title: 'House Details',
|
||||
},
|
||||
];
|
|
@ -0,0 +1,21 @@
|
|||
a {
|
||||
text-decoration: none;
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
header {
|
||||
box-shadow: 0px 2px 5px var(--accent-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 5px;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
header > img {
|
||||
width: 40px;
|
||||
padding-bottom: 12px;
|
||||
margin-left: 10px;
|
||||
margin-right: 8px;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<a [routerLink]="['/']">
|
||||
<header>
|
||||
<img class="logo" src="assets/acai.png" />
|
||||
<h1>Acai Housing</h1>
|
||||
</header>
|
||||
</a>
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HeaderComponent } from './header.component';
|
||||
|
||||
describe('HeaderComponent', () => {
|
||||
let component: HeaderComponent;
|
||||
let fixture: ComponentFixture<HeaderComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HeaderComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HeaderComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
import { Component } from '@angular/core';
|
||||
import {RouterModule} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
imports: [RouterModule],
|
||||
templateUrl: './header.component.html',
|
||||
styleUrl: './header.component.css'
|
||||
})
|
||||
export class HeaderComponent {}
|
|
@ -0,0 +1,32 @@
|
|||
.search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 16px;
|
||||
width: 100%;
|
||||
|
||||
--p-button-padding-x: 20px;
|
||||
--p-button-padding-y: 15px;
|
||||
--p-button-primary-background: #0d6efd;
|
||||
}
|
||||
|
||||
p-floatlabel {
|
||||
max-width: min(500px, 50vw);
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#city-name {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.listing {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, 300px);
|
||||
justify-content: space-around;
|
||||
row-gap: 14px;
|
||||
column-gap: 14px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<section class="search">
|
||||
<p-floatlabel variant="in">
|
||||
<input id="city-name" onkeydown="return event.key != 'Enter' ? true : !!document.querySelector('.search-button').click()" type="City Name" pInputText [(ngModel)]="value" />
|
||||
<label for="city-name">City Name</label>
|
||||
</p-floatlabel>
|
||||
<p-button class="search-button" label="Submit" (click)="filterHouses(value)"/>
|
||||
</section>
|
||||
<section class="listing">
|
||||
<app-house-ad *ngFor="let house of filteredHouses" [house]="house" />
|
||||
</section>
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HomeComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
import { Component, inject } from '@angular/core';
|
||||
import {HouseService} from '../house.service';
|
||||
import {House} from '../house';
|
||||
import {HouseAdComponent} from '../house-ad/house-ad.component';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import { InputTextModule } from 'primeng/inputtext';
|
||||
import { ButtonModule } from 'primeng/button';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import { FloatLabelModule } from 'primeng/floatlabel';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
imports: [HouseAdComponent, CommonModule, InputTextModule, FormsModule, ButtonModule, FloatLabelModule],
|
||||
templateUrl: './home.component.html',
|
||||
styleUrl: './home.component.css'
|
||||
})
|
||||
export class HomeComponent {
|
||||
houses: House[] = [];
|
||||
filteredHouses: House[] = [];
|
||||
houseService = inject(HouseService);
|
||||
value = '';
|
||||
constructor () {
|
||||
this.houses = this.houseService.getHouses();
|
||||
this.filteredHouses = this.houses;
|
||||
}
|
||||
filterHouses(text: string) {
|
||||
if (!text)
|
||||
this.filteredHouses = this.houses;
|
||||
else
|
||||
this.filteredHouses = this.houses.filter((house) => house.location.includes(text))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
.ad {
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--secondary-color);
|
||||
border-radius: 30px;
|
||||
line-height: 2rem;
|
||||
--image-height: 200px;
|
||||
height: 380px;
|
||||
}
|
||||
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
row-gap: 10px;
|
||||
height: calc(100% - var(--image-height) - 15px);
|
||||
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.ad > img {
|
||||
width: 100%;
|
||||
height: var(--image-height);
|
||||
object-fit: cover;
|
||||
border-radius: 30px 30px 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ad h1 {
|
||||
font-size: 18pt;
|
||||
}
|
||||
.details a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.details a::after {
|
||||
content: "❯";
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.location-price {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<section class="ad">
|
||||
<img src="{{ house.img }}" />
|
||||
<div class="details">
|
||||
<div class="house-details">
|
||||
<h1>{{ house.name }}</h1>
|
||||
<div class="location-price">
|
||||
<span class="house-location">{{ house.location }}</span>
|
||||
<span class="house-price">{{ house.price }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<a [routerLink]="['/details', house.id]">To offer</a>
|
||||
</div>
|
||||
</section>
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HouseAdComponent } from './house-ad.component';
|
||||
|
||||
describe('HouseAdComponent', () => {
|
||||
let component: HouseAdComponent;
|
||||
let fixture: ComponentFixture<HouseAdComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HouseAdComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HouseAdComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
import { Component, Input } from '@angular/core';
|
||||
import {House} from '../house';
|
||||
import {RouterModule} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-house-ad',
|
||||
imports: [RouterModule],
|
||||
templateUrl: './house-ad.component.html',
|
||||
styleUrl: './house-ad.component.css'
|
||||
})
|
||||
export class HouseAdComponent {
|
||||
@Input() house !: House;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
.ad {
|
||||
margin: 10px;
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--secondary-color);
|
||||
border-radius: 30px;
|
||||
line-height: 3rem;
|
||||
--image-height: 500px;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: start;
|
||||
row-gap: 10px;
|
||||
height: calc(100% - var(--image-height) - 15px);
|
||||
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.ad > img {
|
||||
width: 100%;
|
||||
height: var(--image-height);
|
||||
object-fit: cover;
|
||||
border-radius: 30px 30px 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ad h1 {
|
||||
font-size: 18pt;
|
||||
}
|
||||
.details a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.details a::after {
|
||||
content: "❯";
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.location-price {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<section class="ad">
|
||||
<img src="{{ house?.img }}" />
|
||||
<div class="details">
|
||||
<h1>{{ house?.name }}</h1>
|
||||
<span class="house-location">Location: {{ house?.location }}</span>
|
||||
<span class="house-price">Buy for: {{ house?.price }}</span>
|
||||
</div>
|
||||
</section>
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HouseDetailsComponent } from './house-details.component';
|
||||
|
||||
describe('HouseDetailsComponent', () => {
|
||||
let component: HouseDetailsComponent;
|
||||
let fixture: ComponentFixture<HouseDetailsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HouseDetailsComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HouseDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
import { Component, inject } from '@angular/core';
|
||||
import { House } from '../house';
|
||||
import {HouseService} from '../house.service';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-house-details',
|
||||
imports: [],
|
||||
templateUrl: './house-details.component.html',
|
||||
styleUrl: './house-details.component.css'
|
||||
})
|
||||
export class HouseDetailsComponent {
|
||||
route = inject(ActivatedRoute);
|
||||
houseService = inject(HouseService);
|
||||
houseId = -1;
|
||||
house: House | undefined;
|
||||
constructor () {
|
||||
this.houseId = Number(this.route.snapshot.params['id']);
|
||||
this.house = this.houseService.getHouseById(this.houseId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HouseService } from './house.service';
|
||||
|
||||
describe('HouseService', () => {
|
||||
let service: HouseService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(HouseService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {House} from './house';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class HouseService {
|
||||
|
||||
houses: House[] = [
|
||||
{id: 1, price: "$ 1,414,000", location: 'Leipzig', name: 'Großes blaues Haus', img: 'https://images.pexels.com/photos/106399/pexels-photo-106399.jpeg'},
|
||||
{id: 2, price: "$ 1,600,000", location: 'Berlin', name: 'Fette Villa', img: 'https://thumbs.dreamstime.com/b/beautiful-new-home-exterior-clear-evening-provides-setting-luxurious-34711767.jpg'},
|
||||
{id: 3, price: "$ 1,100,000", location: 'Hannover', name: 'Gemütliches Haus mit Vorgarten', img: 'https://plus.unsplash.com/premium_photo-1689609950112-d66095626efb?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8aG9tZXxlbnwwfHwwfHx8MA%3D%3D'},
|
||||
{id: 4, price: "$ 1,050,000", location: 'Stuttgart', name: 'Haus mit Wiese', img: 'https://media.istockphoto.com/id/1255835530/photo/modern-custom-suburban-home-exterior.jpg?s=612x612&w=0&k=20&c=0Dqjm3NunXjZtWVpsUvNKg2A4rK2gMvJ-827nb4AMU4='},
|
||||
{id: 5, price: "$ 2,718,000", location: 'Saarland', name: 'Ganz normales Haus', img: 'https://images.pexels.com/photos/1396122/pexels-photo-1396122.jpeg?cs=srgb&dl=pexels-binyaminmellish-1396122.jpg&fm=jpg'},
|
||||
{id: 6, price: "$ 980,000", location: 'Hamburg', name: 'Weißes Haus', img: 'https://maddenhomedesign.com/wp-content/uploads/2021/11/NewDarlington-Front-1300x900.jpg'},
|
||||
]
|
||||
|
||||
constructor() { }
|
||||
|
||||
getHouses() {
|
||||
return this.houses;
|
||||
}
|
||||
getHouseById(id: number) {
|
||||
return this.houses.filter((house) => house.id == id)[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export interface House {
|
||||
id: number;
|
||||
price: string;
|
||||
location: string;
|
||||
name: string;
|
||||
img: string;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>DemoAppPrimeng</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,6 @@
|
|||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig)
|
||||
.catch((err) => console.error(err));
|
|
@ -0,0 +1,21 @@
|
|||
/* You can add global styles to this file, and also import other style files */
|
||||
|
||||
@font-face {
|
||||
font-family: "Acai Tech Font";
|
||||
src: url('/assets/futura\ light\ bt.ttf') format("truetype");
|
||||
}
|
||||
|
||||
* {
|
||||
--primary-color: #D6EDFF;
|
||||
--secondary-color: #ACD7EC;
|
||||
--button-color: #0D6EFD;
|
||||
--accent-color: #1C1C1C;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Acai Tech Font", Verdana, Tahoma;
|
||||
background-color: var(--primary-color);
|
||||
color: var(--accent-color);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"files": [
|
||||
"src/main.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/out-tsc",
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"skipLibCheck": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "bundler",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022"
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue