Skip to content

Commit

Permalink
feat(examples): enhance responsivenes of submenu (and related styles …
Browse files Browse the repository at this point in the history
…fixes)
  • Loading branch information
tomastrajan committed Mar 6, 2018
1 parent b148646 commit 4975389
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mat-sidenav-container {

@media (max-width: map-get($grid-breakpoints, sm)) {
.content {
padding-top: 54px;
padding-top: 56px;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.scss-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

mat-sidenav {
a {
.mat-list-item {
&.active {
color: mat-color($accent, default-contrast);
background-color: mat-color($accent);
Expand Down
40 changes: 19 additions & 21 deletions src/app/examples/examples/examples.component.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
<nav mat-tab-nav-bar class="d-none d-md-block">
<nav mat-tab-nav-bar >
<a mat-tab-link
class="d-none d-md-inline-flex"
*ngFor="let e of examples"
[routerLink]="e.link"
routerLinkActive #rla="routerLinkActive"
[active]="rla.isActive">
{{e.label}}
</a>
<span class="nav-responsive d-md-none"
*ngFor="let e of examples"
[routerLink]="e.link"
routerLinkActive #rla="routerLinkActive"
[matMenuTriggerFor]="examplesMenu">
<a *ngIf="rla.isActive"
mat-tab-link>
<mat-icon>menu</mat-icon> {{e.label}}
</a>
</span>
</nav>

<div class="nav-responsive d-md-none">
<span *ngFor="let e of examples"
[routerLink]="e.link"
routerLinkActive #rla="routerLinkActive">
<button *ngIf="rla.isActive" mat-raised-button
color="primary"
[matMenuTriggerFor]="examplesMenu">
<span><mat-icon>menu</mat-icon> {{e.label}}</span>
<mat-menu #examplesMenu="matMenu" [overlapTrigger]="false" class="nav-responsive-overlay">
<button mat-menu-item
*ngFor="let e of examples"
[routerLink]="e.link"
routerLinkActive="active">
{{e.label}}
</button>
</span>
<mat-menu #examplesMenu="matMenu">
<button mat-menu-item
*ngFor="let e of examples"
[routerLink]="e.link"
routerLinkActive #rla="routerLinkActive"
ngClass="{ active: rla.isActive }">
{{e.label}}
</button>
</mat-menu>
</div>
</mat-menu>


<div [@routerTransition]="o.isActivated && o.activatedRoute.routeConfig.path">
Expand Down
12 changes: 9 additions & 3 deletions src/app/examples/examples/examples.component.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
nav {
margin-bottom: 20px;

.mat-tab-link {
min-width: 130px;
}
}

.nav-responsive {
margin: 14px;
padding: 0 0 24px 0;

button {
a {
width: 100%;
display: inline-block;
padding-top: 14px;

mat-icon {
float: left;
position: relative;
top: 7px;
top: -1px;
}
}
}
19 changes: 19 additions & 0 deletions src/app/examples/examples/examples.component.scss-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import '~@angular/material/theming';

@mixin anms-examples-component-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);

anms-examples {
.nav-responsive {
border-bottom: 2px solid mat-color($primary);
}
}

.nav-responsive-overlay {
.active {
color: mat-color($accent, default-contrast);
background-color: mat-color($accent);
}
}
}
5 changes: 3 additions & 2 deletions src/app/examples/examples/examples.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { routerTransition } from '@app/core';
export class ExamplesComponent implements OnInit {
examples = [
{ link: 'todos', label: 'Todos' },
{ link: 'stock-market', label: 'Stock Market' },
{ link: 'stock-market', label: 'Stocks' },
{ link: 'theming', label: 'Theming' },
{ link: 'authenticated', label: 'Authenticated' }
{ link: 'notifications', label: 'Notifications' },
{ link: 'authenticated', label: 'Auth' }
];

constructor() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import '~@angular/material/theming';

@mixin anms-examples-component-theme($theme) {
@mixin anms-stock-market-component-theme($theme) {
$warn: map-get($theme, warn);

anms-stock-market {
Expand Down
2 changes: 1 addition & 1 deletion src/app/examples/todos/todos.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2>
<button class="todos-filter" mat-icon-button [matMenuTriggerFor]="todosFilter">
<mat-icon>filter_list</mat-icon>
</button>
<mat-menu class="todos-filter-menu" #todosFilter="matMenu" xPosition="before">
<mat-menu class="todos-filter-menu-overlay" #todosFilter="matMenu" xPosition="before">
<button mat-menu-item (click)="onFilterTodos('ALL')" [ngClass]="{ active: todos.filter === 'ALL' }">
<mat-icon>assignment</mat-icon>
<span>All</span>
Expand Down
23 changes: 10 additions & 13 deletions src/app/examples/todos/todos.component.scss-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
@mixin anms-todos-component-theme($theme) {
$accent: map-get($theme, accent);

// angular material overlay class
.cdk-overlay-container {
.todos-filter-menu {
.active {
color: mat-color($accent, default-contrast);
background-color: mat-color($accent);
.todos-filter-menu-overlay {
.active {
color: mat-color($accent, default-contrast);
background-color: mat-color($accent);

.mat-icon {
color: mat-color($accent, default-contrast);
}
.mat-icon {
color: mat-color($accent, default-contrast);
}

&:hover {
color: mat-color($accent, default-contrast);
background-color: mat-color($accent);
}
&:hover {
color: mat-color($accent, default-contrast);
background-color: mat-color($accent);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
@import 'app/examples/stock-market/stock-market.component.scss-theme';
@import 'app/examples/theming/parent/parent.component.scss-theme';
@import 'app/examples/theming/child/child.component.scss-theme';
@import 'app/examples/examples/examples.component.scss-theme';

@mixin custom-components-theme($theme) {
@include anms-styles-reset-theme($theme);
@include anms-app-component-theme($theme);
@include anms-about-component-theme($theme);
@include anms-big-input-component-theme($theme);
@include anms-todos-component-theme($theme);
@include anms-examples-component-theme($theme);
@include anms-stock-market-component-theme($theme);
@include anms-parent-component-theme($theme);
@include anms-child-component-theme($theme);
@include anms-examples-component-theme($theme);
}

.default-theme {
Expand Down

0 comments on commit 4975389

Please sign in to comment.