Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(highlight): enhancements and code-health. #277

Merged
merged 26 commits into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f4e631d
bugfix(highlight:) Remove only empty lines at the beggining and end o…
emoralesb05 Jan 21, 2017
3c89987
check indentention on first code line as a guide
emoralesb05 Jan 21, 2017
4c74e0b
remove `html` lang workaround so code parsing is more generic now
emoralesb05 Jan 21, 2017
4a95d9e
fixed indendation in demo
emoralesb05 Jan 21, 2017
7347ea2
bugfix(highlight): Use Renderer to limit access to native DOM and Dom…
emoralesb05 Jan 21, 2017
35b2114
feature(highlight): Added [content] input to td-highlight to load con…
emoralesb05 Jan 21, 2017
ae2baf3
load README.md in highlight docs
emoralesb05 Jan 21, 2017
3c18b4e
update README.md for highlight
emoralesb05 Jan 21, 2017
fa6ae6e
remove info thats already in README.md
emoralesb05 Jan 21, 2017
3867496
update docblock in markdown
emoralesb05 Jan 21, 2017
ad5c8a4
polish README.md
emoralesb05 Jan 21, 2017
e109251
move scss rules so we can apply any pre-built theme instead of the co…
emoralesb05 Jan 21, 2017
d4d8ea5
update themeing in markdown and highlight
emoralesb05 Jan 22, 2017
3ae80ba
comment pre-built theme in theme.scss
emoralesb05 Jan 22, 2017
c2fd9de
feature(highlight): Mimicking VS Dark+ theme as closely as possible b…
emoralesb05 Jan 22, 2017
de12b03
changed color for regexp and link
emoralesb05 Jan 22, 2017
b878cd3
code-health(highlight): Added initial set of unit-tests.
emoralesb05 Jan 22, 2017
59d667b
wrong title in README.md
emoralesb05 Jan 22, 2017
4fe3b8e
replace npm code block with bash
emoralesb05 Jan 22, 2017
584af7d
fix README.md in markdown
emoralesb05 Jan 22, 2017
c611904
merge with dev
emoralesb05 Jan 22, 2017
7166d70
point to the main coveralls badge instead of develop branch
emoralesb05 Jan 22, 2017
8d73a54
remove methods and use regexp to remove leading and trailing new empt…
emoralesb05 Jan 22, 2017
39083da
feature(markdown): Remove only empty lines at the beginning and end o…
emoralesb05 Jan 22, 2017
5dbc4de
fixed indentation
emoralesb05 Jan 22, 2017
0706a75
fixed unit test typo
emoralesb05 Jan 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![npm version](https://badge.fury.io/js/%40covalent%2Fcore.svg)](https://badge.fury.io/js/%40covalent%2Fcore)
[![Join the chat at https://gitter.im/Teradata/covalent](https://badges.gitter.im/Teradata/covalent.svg)](https://gitter.im/Teradata/covalent?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Dependency Status](https://dependencyci.com/github/Teradata/covalent/badge)](https://dependencyci.com/github/Teradata/covalent)
[![Coverage Status](https://coveralls.io/repos/github/Teradata/covalent/badge.svg?branch=develop)](https://coveralls.io/github/Teradata/covalent?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/Teradata/covalent/badge.svg)](https://coveralls.io/github/Teradata/covalent)

<img alt="Covalent" src="https://cdn.rawgit.com/Teradata/covalent/develop/src/app/assets/icons/covalent.svg" width="150">

Expand Down
131 changes: 47 additions & 84 deletions src/app/components/components/highlight/highlight.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,110 +3,73 @@
<md-card-subtitle>Highlighting your code snippets</md-card-subtitle>
<md-divider></md-divider>
<md-card-content>
<p>Simply wrap your code snippets in <code><![CDATA[<td-highlight>]]></code></p>
<p>To use HTML brackets &lt; and &gt; wrap the code with &lt;![CDATA[ and ]]&gt; or replace with HTMLs character entities <![CDATA[ &lt; and &gt; ]]></p>
<p>Also, to display model binding, add spaces between curly braces like:<code>{{ '{' }} {{ '{' }} } }</code> and wrap them with &lt;![CDATA[ and ]]&gt;
<h3>Example:</h3>
<p>HTML usage:</p>
<td-highlight lang="html">
<![CDATA[
<![CDATA[
<td-highlight lang="html">
<h1>hello world!</h1>
<span>{ {property} }</span>
</td-highlight>
]]>
]]>
</td-highlight>
<p>here's what CSS looks like:</p>
<td-highlight lang="css">
pre {{'{'}}
display: block;
overflow-x: auto;
padding: 0;
margin: 0;
background: #002451;
color: white;
font-family: Menlo, Monaco, "Andale Mono", "lucida console", "Courier New", monospace;
line-height: 1.45;
tab-size: 2;
-webkit-font-smoothing: auto;
-webkit-text-size-adjust: none;
position: relative;
border-radius: 2px;
}
<td-highlight lang="css">
<![CDATA[
pre {
display: block;
overflow-x: auto;
padding: 0;
margin: 0;
background: #002451;
color: white;
font-family: Menlo, Monaco, "Andale Mono", "lucida console", "Courier New", monospace;
line-height: 1.45;
tab-size: 2;
-webkit-font-smoothing: auto;
-webkit-text-size-adjust: none;
position: relative;
border-radius: 2px;
}
]]>
</td-highlight>
<p>and JavaScript (typescript):</p>
<p>and TypeScript (javascript):</p>
<td-highlight lang="typescript">
<![CDATA[
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class Service {
@Injectable()
export class Service {

private _sources: {[key : string]: Subject<any>} = {};
private _observables: {[key: string]: Observable<any>} = {};
private _sources: {[key : string]: Subject<any>} = {};
private _observables: {[key: string]: Observable<any>} = {};

constructor(){
constructor(){

}
}

public register(name) : Observable<any> {
this._sources[name] = new Subject<any>();
this._observables[name] = this._sources[name].asObservable();
return this._observables[name];
}
public register(name) : Observable<any> {
this._sources[name] = new Subject<any>();
this._observables[name] = this._sources[name].asObservable();
return this._observables[name];
}

public emit(name: string): void {
if(this._sources[name]){
this._sources[name].next(null);
public emit(name: string): void {
if(this._sources[name]){
this._sources[name].next(null);
}
}
}
}
]]>
</td-highlight>
<h3>Setup:</h3>
<p><code>highlight.js</code> needs to be added as vendor (installed as a <code>highlight.js</code> dependency).</p>
<td-highlight lang="typescript">
<![CDATA[
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
...
'highlight.js/lib/**'
]
});
};
]]>
</td-highlight>
<p>Reference the module in the <code>system-config.js</code> file.</p>
<td-highlight lang="html">
<![CDATA[
const barrels: string[] = [
'highlight.js/lib',
];
System.config({
map: {
...
'highlight.js/lib': 'vendor/highlight.js/lib',
...
},
packages: cliSystemConfigPackages,
});
]]>
</td-highlight>
<p>Then, import the [CovalentHighlightModule] using the forRoot() method in your NgModule:</p>
<td-highlight lang="typescript">
<![CDATA[
import { CovalentHighlightModule } from '@covalent/highlight';
@NgModule({
imports: [
CovalentHighlightModule.forRoot(),
...
],
...
})
export class MyModule {}
]]>
</td-highlight>
</md-card-content>
</md-card>

<md-card>
<md-card-content>
<td-markdown [content]="content">
</td-markdown>
</md-card-content>
</md-card>
22 changes: 20 additions & 2 deletions src/app/components/components/highlight/highlight.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, HostBinding } from '@angular/core';
import { Component, HostBinding, OnInit } from '@angular/core';
import { Http, Response } from '@angular/http';

import { slideInDownAnimation } from '../../../app.animations';

Expand All @@ -8,9 +9,26 @@ import { slideInDownAnimation } from '../../../app.animations';
templateUrl: './highlight.component.html',
animations: [slideInDownAnimation],
})
export class HighlightDemoComponent {
export class HighlightDemoComponent implements OnInit {

@HostBinding('@routeAnimation') routeAnimation: boolean = true;
@HostBinding('class.td-route-animation') classAnimation: boolean = true;

content: string;

constructor(private _http: Http) {}

ngOnInit(): void {
let errorString: string = 'Warning: Resource could not be loaded.';
this._http.get('platform/highlight/README.md').subscribe((res: Response) => {
try {
this.content = res.text();
} catch (e) {
this.content = errorString;
}
}, (error: Error) => {
this.content = errorString;
});
}

}
Loading