Skip to content

Instantly share code, notes, and snippets.

@MichaelRegert
Created March 14, 2017 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelRegert/6c5d9d3c8b52aa99d1dc66a314239f0e to your computer and use it in GitHub Desktop.
Save MichaelRegert/6c5d9d3c8b52aa99d1dc66a314239f0e to your computer and use it in GitHub Desktop.
clarity subnav
<!--
~ Copyright (c) 2016 VMware, Inc. All Rights Reserved.
~ This software is released under MIT license.
~ The full license information can be found in LICENSE in the root directory of this project.
-->
<p>This is a page to help demonstrate routing.</p>
<button class="btn btn-primary" (click)="open = true">Show modal</button>
<clr-modal [(clrModalOpen)]="open">
<h3 class="modal-title">I have a nice title</h3>
<div class="modal-body">
<p>But not much to say...</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline" (click)="open = false">Cancel</button>
<button type="button" class="btn btn-primary" (click)="open = false">Ok</button>
</div>
</clr-modal>
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
// This software is released under MIT license.
// The full license information can be found in LICENSE in the root directory of this project.
/*
* Copyright (c) 2016 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { async, TestBed, ComponentFixture } from "@angular/core/testing";
import { ClarityModule } from 'clarity-angular';
import { AboutComponent } from './about.component';
describe('AboutComponent', () => {
let expectedMsg: string = 'This is a page to help demonstrate routing.';
let fixture: ComponentFixture<any>;
let compiled: any;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AboutComponent
],
imports: [
ClarityModule.forRoot()
]
});
fixture = TestBed.createComponent(AboutComponent);
fixture.detectChanges();
compiled = fixture.nativeElement;
});
afterEach(() => {
fixture.destroy();
});
it('should create the about page', async(() => {
expect(compiled).toBeTruthy();
}));
it(`should display: "${expectedMsg}"`, async(() => {
expect(compiled.querySelector("p").textContent).toMatch(expectedMsg);
}));
});
/*
* Copyright (c) 2016 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { Component } from '@angular/core';
@Component({
styleUrls: ['./about.component.scss'],
templateUrl: './about.component.html'
})
export class AboutComponent {
}
<clr-main-container>
<clr-header>
<div class="branding">
<a href="#" class="nav-link">
<span class="clr-icon clr-clarity-logo"></span>
<span class="title">Clarity</span>
</a>
</div>
<form class="search">
<label for="search_input">
<input id="search_input" type="text" placeholder="Search for Components...">
</label>
</form>
<div class="header-actions">
</div>
</clr-header>
<nav class="sub-nav" [clr-nav-level]="1">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['/home']"
[class.active]="router.url==='/home' || router.url==='/'">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['/about']" [class.active]="router.url==='/about'">About</a>
</li>
</ul>
</nav>
<div class="content-container">
<div class="content-area">
<router-outlet></router-outlet>
</div>
</div>
</clr-main-container>
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
// This software is released under MIT license.
// The full license information can be found in LICENSE in the root directory of this project.
.clr-icon {
&.clr-clarity-logo {
background-image: url(../images/clarity_logo.svg);
}
}
/* tslint:disable:no-unused-variable */
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { HomeComponent } from "./home/home.component";
import { AboutComponent } from "./about/about.component";
import { ClarityModule } from "clarity-angular";
import { ROUTING } from "./app.routing";
import { APP_BASE_HREF } from "@angular/common";
describe('AppComponent', () => {
let fixture: ComponentFixture<any>;
let compiled: any;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
AboutComponent,
HomeComponent
],
imports: [
ClarityModule.forRoot(),
ROUTING
],
providers: [{provide: APP_BASE_HREF, useValue: '/'}]
});
fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
compiled = fixture.nativeElement;
});
afterEach(() => {
fixture.destroy();
});
it('should create the app', async(() => {
expect(compiled).toBeTruthy();
}));
});
import { Component } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor(private router: Router) {
}
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { ClarityModule } from 'clarity-angular';
import { AppComponent } from './app.component';
import { ROUTING } from "./app.routing";
import { HomeComponent } from "./home/home.component";
import { AboutComponent } from "./about/about.component";
import { TestComponent } from "./test/test.component";
@NgModule({
declarations: [
AppComponent,
AboutComponent,
HomeComponent,
TestComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ClarityModule.forRoot(),
ROUTING
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
/*
* Copyright (c) 2016 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { ModuleWithProviders } from '@angular/core/src/metadata/ng_module';
import { Routes, RouterModule } from '@angular/router';
import { AboutComponent } from './about/about.component';
import { HomeComponent } from './home/home.component';
import { TestComponent } from './test/test.component';
export const ROUTES: Routes = [
{path: '', redirectTo: 'home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'about', component: AboutComponent},
{path: 'test', component: TestComponent}
];
export const ROUTING: ModuleWithProviders = RouterModule.forRoot(ROUTES);
<nav class="sidenav">
<section class="sidenav-content">
<a class="nav-link" href="/test">Test</a>
</section>
</nav>
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
// This software is released under MIT license.
// The full license information can be found in LICENSE in the root directory of this project.
/*
* Copyright (c) 2016 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { async, TestBed, ComponentFixture } from "@angular/core/testing";
import { ClarityModule } from 'clarity-angular';
import { HomeComponent } from './home.component';
describe('HomeComponent', () => {
let expectedMsg: string = 'This is a Clarity seed application. This is the default page that loads for the application.';
let fixture: ComponentFixture<any>;
let compiled: any;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
HomeComponent
],
imports: [
ClarityModule.forRoot()
]
});
fixture = TestBed.createComponent(HomeComponent);
fixture.detectChanges();
compiled = fixture.nativeElement;
});
afterEach(() => {
fixture.destroy();
});
it('should create the home page', async(() => {
expect(compiled).toBeTruthy();
}));
it(`should display: "${expectedMsg}"`, async(() => {
expect(compiled.querySelector("p").textContent).toMatch(expectedMsg);
}));
});
/*
* Copyright (c) 2016 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { Component } from "@angular/core";
import { Router } from "@angular/router";
@Component({
styleUrls: ['./home.component.scss'],
templateUrl: './home.component.html',
})
export class HomeComponent {
constructor(private router: Router) {
}
}
export * from './app.component';
export * from './app.module';
import { Component } from "@angular/core";
@Component({
styleUrls: ['./test.component.scss'],
templateUrl: './test.component.html',
})
export class TestComponent {
}
export const environment = {
production: true
};
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `angular-cli.json`.
export const environment = {
production: false
};
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Clarity Seed App</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico?v=2">
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
import './polyfills.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
// This file includes polyfills needed by Angular 2 and is loaded before
// the app. You can add your own extra polyfills to this file.
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
/* You can add global styles to this file, and also import other style files */
import './polyfills.ts';
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
declare var require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () {};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
let context = require.context('./', true, /\.spec\.ts/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start();
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": "../",
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es6",
"dom"
],
"mapRoot": "src",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"types": [
"jasmine",
"core-js",
"node"
]
},
"exclude": [
"node_modules",
"dist",
"test.ts"
]
}
// Typings reference file, you can add your own global typings here
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment