Add date to clock module

This commit is contained in:
pgrondek 2020-05-02 12:01:01 +02:00
parent c7bbe801f5
commit 939ccd8a0e
8 changed files with 42 additions and 42 deletions

View File

@ -24,7 +24,6 @@
"src/assets" "src/assets"
], ],
"styles": [ "styles": [
"./node_modules/@angular/material/prebuilt-themes/purple-green.css",
"src/styles.css" "src/styles.css"
], ],
"scripts": [] "scripts": []
@ -124,4 +123,4 @@
} }
}, },
"defaultProject": "angular-dashboard" "defaultProject": "angular-dashboard"
} }

View File

@ -1,3 +1,13 @@
@import "~@angular/material/prebuilt-themes/purple-green.css";
mat-sidenav-container { mat-sidenav-container {
height: 100%; height: 100%;
} }
mat-card-content {
text-align: center;
}
.mat-card {
background-color: pink;
}

View File

@ -1,5 +1,5 @@
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core'; import {LOCALE_ID, NgModule} from '@angular/core';
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {ClockComponent} from './clock/clock.component'; import {ClockComponent} from './clock/clock.component';
@ -7,11 +7,11 @@ import {LayoutModule} from '@angular/cdk/layout';
import {MatToolbarModule} from '@angular/material/toolbar'; import {MatToolbarModule} from '@angular/material/toolbar';
import {MatSidenavModule} from '@angular/material/sidenav'; import {MatSidenavModule} from '@angular/material/sidenav';
import {MatCardModule} from '@angular/material/card'; import {MatCardModule} from '@angular/material/card';
import { DashboardComponent } from './dashboard/dashboard.component'; import {DashboardComponent} from './dashboard/dashboard.component';
import { MatGridListModule } from '@angular/material/grid-list'; import {MatGridListModule} from '@angular/material/grid-list';
import { MatMenuModule } from '@angular/material/menu'; import {MatMenuModule} from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon'; import {MatIconModule} from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button'; import {MatButtonModule} from '@angular/material/button';
@NgModule({ @NgModule({
declarations: [ declarations: [

View File

@ -1,15 +1,9 @@
.dashboard-card { @import "../dashboard/card.css";
position: absolute;
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
}
.dashboard-card-content {
text-align: center;
}
.clock { .clock {
font-size: 10rem; font-size: 10rem;
} }
.date {
font-size: 3rem;
}

View File

@ -1,7 +1,10 @@
<mat-card class="dashboard-card"> <mat-card class="dashboard-card">
<mat-card-content class="dashboard-card-content"> <mat-card-content class="dashboard-card-content">
<div class="clock"> <div class="clock">
{{hour}}:{{minute | number: '2.0-0'}} {{time}}
</div>
<div class="date">
{{date}}
</div> </div>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>

View File

@ -1,4 +1,5 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {formatDate} from '@angular/common';
@Component({ @Component({
selector: 'app-clock', selector: 'app-clock',
@ -6,8 +7,8 @@ import {Component, OnInit} from '@angular/core';
styleUrls: ['./clock.component.css'] styleUrls: ['./clock.component.css']
}) })
export class ClockComponent implements OnInit { export class ClockComponent implements OnInit {
hour: number; date: string;
minute: number; time: string;
constructor() { constructor() {
} }
@ -19,8 +20,8 @@ export class ClockComponent implements OnInit {
private updateTime() { private updateTime() {
const date = new Date(Date.now()); const date = new Date(Date.now());
this.hour = date.getHours(); this.date = formatDate(date, 'EEEE, d LLLL yyyy', 'en');
this.minute = date.getMinutes(); this.time = formatDate(date, 'H:mm', 'en');
} }
private interval() { private interval() {

View File

@ -0,0 +1,11 @@
.dashboard-card {
position: absolute;
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
}
.dashboard-card-content {
text-align: center;
}

View File

@ -1,21 +1,3 @@
.grid-container { .grid-container {
margin: 20px; margin: 20px;
} }
.dashboard-card {
position: absolute;
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
}
.more-button {
position: absolute;
top: 5px;
right: 10px;
}
.dashboard-card-content {
text-align: center;
}