Skip to content

Commit

Permalink
added dropdown menu component, edited top nav
Browse files Browse the repository at this point in the history
  • Loading branch information
mertlsarac committed Aug 22, 2021
1 parent b2e85b6 commit 759fbe6
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 60 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import interactionPlugin from '@fullcalendar/interaction';
import { CalendarComponent } from './component/common/calendar/calendar.component';
import { SearchComponent } from './component/common/search/search.component';
import { RateBarComponent } from './component/common/rate-bar/rate-bar.component';
import { DropdownMenuComponent } from './component/common/dropdown-menu/dropdown-menu.component';

FullCalendarModule.registerPlugins( [
dayGridPlugin,
Expand Down Expand Up @@ -121,7 +122,8 @@ FullCalendarModule.registerPlugins( [
EventHamburgerMenuComponent,
CalendarComponent,
SearchComponent,
RateBarComponent
RateBarComponent,
DropdownMenuComponent
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="dropdown">
<div #toggleButton class="ng-content-area">
<ng-content (click)="toggleDropdown()"></ng-content>
</div>
<div *ngIf="isDropdownOpen" #dropdownContent class="dropdown-content">
<i class="material-icons">change_history</i>
<a *ngFor="let option of options; last as isLast" class="dropdown-item"
(mouseover)="option.hover = true" (mouseleave)="option.hover = false"
[ngStyle]="option?.hover && { 'background-color': option.backgroundColor }"
[style.margin-bottom]="!isLast ? '10px' : '0'" [href]="option.link">
<img [src]="option.brand.brandLogo" alt="logo" class="dropdown-item-logo" height="40"/>
<div class="dropdown-item-content">
<span>{{ option.header }}</span>
<p>{{ option.description }}</p>
</div>
</a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.dropdown {
position: relative;
}

.dropdown-content {
display: block;
position: absolute;
background-color: var(--card);
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 10;
top: 61px;
}

.dropdown-content i {
position: absolute;
top: -13px;
left: 22px;
font-size: 15px;
color: var(--lighter-contrast);
}

.dropdown-item {
display: flex;
width: 300px;
padding: 10px;
cursor: pointer;
}

.dropdown-item-logo {
margin-right: 20px;
}

.dropdown-item-content span {
font-size: 14px;
font-weight: 500;
}

.dropdown-item-content p {
margin-top: 10px;
}

.ng-content-area {
display: flex;
align-items: center;
cursor: pointer;
}

.dropdown:hover .dropdown-content {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { DropdownMenuComponent } from './dropdown-menu.component';

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

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

beforeEach(() => {
fixture = TestBed.createComponent(DropdownMenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
56 changes: 56 additions & 0 deletions src/app/component/common/dropdown-menu/dropdown-menu.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Component, ElementRef, Input, OnChanges, Renderer2, ViewChild } from '@angular/core';
import { ThemeService } from '../../../service/theme/theme.service';

export interface DropdownMenuOption {
backgroundColor: string,
brand: { brandLogo: string },
header: string,
description: string,
link: string,
hover?: boolean // this property only use on this class, do not set it from outside
}

@Component({
selector: 'app-dropdown-menu',
templateUrl: './dropdown-menu.component.html',
styleUrls: ['./dropdown-menu.component.scss']
})
export class DropdownMenuComponent {
isDropdownOpen = false
brand = {
brandLogo: '',
};

@Input() options: DropdownMenuOption[] = [
{
backgroundColor: 'rgba(255, 0, 0, 0.2)',
brand: { brandLogo: '' },
header: 'Open Template Hub',
description: 'Open Template Hub is an organization that develops open source micro servers as templates including authentication server, payment server and more..',
link: '/'
}
]

@ViewChild('toggleButton') toggleButton: ElementRef
@ViewChild('dropdownContent') dropdownContent: ElementRef

constructor(
private themeService: ThemeService,
private renderer: Renderer2
) {
this.brand = this.themeService.brand

this.renderer.listen('window', 'click', (e: Event) => {
if( this.toggleButton.nativeElement.contains( e.target ) ) {
this.toggleDropdown()
} else if ( !this.dropdownContent?.nativeElement.contains( e.target ) ) {
this.isDropdownOpen = false
}
} )
}

toggleDropdown() {
console.log('test')
this.isDropdownOpen = !this.isDropdownOpen
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,33 @@
<img [src]="brand.brandLogo" alt="logo" class="brand-logo" height="40"/>
<h2>Open Template Hub</h2>
</a>
<a *ngIf="currentUser" routerLink="{{URLS.dashboard.root}}">
<i class="material-icons">dashboard</i>
<div class="left-item-wrapper">
<a>
<app-dropdown-menu [options]="productMenuOptions">
<span>Products</span>
<i class="material-icons">expand_more</i>
</app-dropdown-menu>
</a>
<a>
<app-dropdown-menu [options]="servicesMenuOptions">
<span>Services</span>
<i class="material-icons">expand_more</i>
</app-dropdown-menu>
</a>
<a routerLink="{{URLS.maintenance}}">
<span>
Pricing
</span>
</a>
</div>
<a class="demo" routerLink="{{URLS.maintenance}}">
<span>
DASHBOARD
Request for Demo
</span>
</a>
<!--
<a *ngIf="!currentUser" routerLink="{{URLS.dashboard.createEvent}}">
<i class="material-icons">public</i>
<a class="contact-us" routerLink="{{URLS.maintenance}}">
<span>
CREATE EVENT
</span>
</a>
-->
<a *ngIf="!currentUser" routerLink="{{URLS.showroom}}">
<i class="material-icons">event</i>
<span>
EVENTS
</span>
</a>
<a *ngIf="!currentUser" routerLink="{{URLS.signup}}">
<i class="material-icons">person_add</i>
<span>
REGISTER
</span>
</a>
<a *ngIf="!currentUser" class="login" routerLink="{{URLS.login}}">
<i class="material-icons">fingerprint</i>
<span>
LOG IN
</span>
</a>
<a (click)="logout()" *ngIf="currentUser" href="javascript:void(0)" id=logout>
<i class="material-icons">exit_to_app</i>
<span>
LOGOUT
Contact Us
</span>
</a>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,48 @@
align-items: center;
font-size: 14px;
font-weight: 500;
margin-right: 10px;
cursor: pointer;
}

.top-nav a:first-child {
margin-right: auto;
.brand {
margin-right: 10px;
}

.top-nav .login {
.top-nav .demo {
color: var(--brand-color);
border-radius: 0;
border-bottom: var(--brand-color) 1px solid;
margin-right: 20px;
}

.top-nav .login:hover {
.top-nav .demo:hover {
color: white;
border-radius: 3px;
background: var(--brand-color);
}

.top-nav .contact-us {
background-color: var(--contrast);
}

.top-nav .brand > * {
margin: 0.2em;
}

.top-nav a i {
margin: 0.35em;
app-dropdown-menu i {
margin: 0.2em;
font-size: 22px;
}

.top-nav a i {
app-dropdown-menu i {
margin-left: 0;
}

.top-nav .left-item-wrapper {
margin-right: auto;
}

@media only screen and (max-width: 999px) {
.top-nav {
display: none;
Expand All @@ -56,6 +67,12 @@
}
}

@media only screen and (max-width: 1299px) {
.top-nav {
padding: 20px 40px;
}
}

@media (hover: hover) {

.top-nav a:first-child:hover {
Expand All @@ -66,7 +83,7 @@
background: var(--hover);
}

.bottom-nav .login:hover {
.bottom-nav .demo:hover {
color: white;
background: var(--brand-color);
}
Expand Down
Loading

0 comments on commit 759fbe6

Please sign in to comment.