Skip to content

Commit

Permalink
added dialog box on feed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gururajj77 committed Jan 11, 2024
1 parent a80ae34 commit a5eea4f
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/feed/feed.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<section class="feed-container">
<CustomButton [buttonName]="'Write'" />
<CustomButton [buttonName]="'Write'" (click)="openWrite()" />
<post-dialog [isDialogOpen]="openDialogBox" (closeWrite)="openWrite()" />
<h2 class="feed-title">News Feed</h2>
<div class="feed-list">
<!-- Repeat this block for each post -->
<div class="feed-item">
<div class="author-info">
<div class="author-image"></div>
Expand Down
7 changes: 6 additions & 1 deletion src/app/feed/feed.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ import { Component, inject } from '@angular/core';
import { Auth } from '@angular/fire/auth';
import { CustomButtonComponent } from '../shared/components/custom-button/custom-button.component';
import { SnackbarService } from '../shared/components/snackbar/snackbar.service';
import { PostDialogComponent } from './post-dialog/post-dialog.component';

@Component({
selector: 'app-feed',
standalone: true,
imports: [CustomButtonComponent],
imports: [CustomButtonComponent, PostDialogComponent],
templateUrl: './feed.component.html',
styleUrl: './feed.component.scss'
})
export class FeedComponent {

private readonly auth: Auth = inject(Auth);
openDialogBox: boolean = false
openWrite() {
this.openDialogBox = !this.openDialogBox;
}



Expand Down
13 changes: 13 additions & 0 deletions src/app/feed/post-dialog/post-dialog.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="post-dialog-overlay" [class.show]="isDialogOpen">
<div class="post-dialog">
<textarea
class="post-text"
placeholder="What's on your mind?"
rows="4"
></textarea>
<div class="dialog-actions">
<button class="btn-save" (click)="savePost()">Save</button>
<button class="btn-cancel" (click)="closeDialog()">Cancel</button>
</div>
</div>
</div>
91 changes: 91 additions & 0 deletions src/app/feed/post-dialog/post-dialog.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
@import "../.../../../../partials/variables";

.post-dialog-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
justify-content: center;
align-items: center;

&.show {
display: flex;
}
}

.post-dialog {
background: #fff;
padding: 2rem;
border-radius: 0;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
width: 90%;
max-width: 500px;
}

.post-text {
width: calc(100% - 2rem);
border: 1px solid #ccc;
border-radius: 0;
padding: 1rem;
margin-bottom: 1rem;
resize: vertical;

&:focus {
border-color: $inactive-color;
outline: none;
}
}

.dialog-actions {
text-align: right;
}

.btn-save,
.btn-cancel {
padding: 0.5rem 1rem;
border: none;
border-radius: 0;
margin-left: 0.5rem;
cursor: pointer;
font-weight: bold;
transition: background-color 0.3s;
}

.btn-save {
background-color: $accent-color;
color: #fff;

&:hover {
background-color: darken($accent-color, 10%);
}
}

.btn-cancel {
background-color: #fff;
color: $accent-color;
border: 1px solid $accent-color;

&:hover {
background-color: lighten($accent-color, 40%);
}
}

/* Responsive styling */
@media (max-width: 768px) {
.post-dialog {
padding: 1rem;
width: 95%;
}
.post-text {
padding: 0.5rem;
width: calc(100% - 1rem);
}
.btn-save,
.btn-cancel {
padding: 0.5rem;
}
}
23 changes: 23 additions & 0 deletions src/app/feed/post-dialog/post-dialog.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { PostDialogComponent } from './post-dialog.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PostDialogComponent]
})
.compileComponents();

fixture = TestBed.createComponent(PostDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
27 changes: 27 additions & 0 deletions src/app/feed/post-dialog/post-dialog.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
selector: 'post-dialog',
standalone: true,
imports: [],
templateUrl: './post-dialog.component.html',
styleUrl: './post-dialog.component.scss'
})
export class PostDialogComponent {

@Input() isDialogOpen: boolean = false;
@Output() closeWrite = new EventEmitter<boolean>();
openDialog(): void {
this.isDialogOpen = true;
}

closeDialog(): void {
this.isDialogOpen = false;
this.closeWrite.emit(true);
}

savePost(): void {
this.closeDialog();
}

}
4 changes: 4 additions & 0 deletions src/app/shared/components/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
align-items: center;
background-color: #fff;
padding: 0 2rem;
height: 70px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.header-nav {
display: flex;
Expand Down Expand Up @@ -51,6 +54,7 @@
.header {
justify-content: space-between;
padding: 1rem;
height: 50px;
}
.header-nav {
display: flex;
Expand Down

0 comments on commit a5eea4f

Please sign in to comment.