-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stark-demo): add pretty-print component to Showcase Demo
ISSUES CLOSED: #496
- Loading branch information
1 parent
fd74dde
commit 93557cb
Showing
35 changed files
with
527 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./pretty-print.component"; |
22 changes: 22 additions & 0 deletions
22
showcase/src/app/demo/pretty-print/pretty-print.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<example-viewer *ngFor="let fileType of fileTypes; trackBy: trackFileTypes" | ||
[extensions]="['HTML', 'SCSS', 'TS']" | ||
[filesPath]="fileType.path" | ||
[title]="fileType.title"> | ||
<mat-tab-group> | ||
<mat-tab label="{{ 'SHOWCASE.DEMO.PRETTY-PRINT.ORIGINAL_CODE' | translate }}"> | ||
<div class="code-block">{{ fileType.rawData }}</div> | ||
</mat-tab> | ||
<mat-tab label="{{ 'SHOWCASE.DEMO.PRETTY-PRINT.PRETTY_PRINTED' | translate }}"> | ||
<div class="code-block"> | ||
<stark-pretty-print [data]="fileType.rawData" | ||
[format]="fileType.format" | ||
[enableHighlighting]="false"></stark-pretty-print> | ||
</div> | ||
</mat-tab> | ||
<mat-tab label="{{ 'SHOWCASE.DEMO.PRETTY-PRINT.PRETTY_PRINTED_WITH_HIGHLIGHTING' | translate }}"> | ||
<stark-pretty-print [data]="fileType.rawData" | ||
[format]="fileType.format" | ||
[enableHighlighting]="true"></stark-pretty-print> | ||
</mat-tab> | ||
</mat-tab-group> | ||
</example-viewer> |
5 changes: 5 additions & 0 deletions
5
showcase/src/app/demo/pretty-print/pretty-print.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.code-block { | ||
background-color: #e6e6e6; | ||
overflow-x: auto; | ||
padding: 8px; | ||
} |
153 changes: 153 additions & 0 deletions
153
showcase/src/app/demo/pretty-print/pretty-print.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { Component, OnInit, Inject } from "@angular/core"; | ||
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core"; | ||
import { StarkPrettyPrintFormat } from "@nationalbankbelgium/stark-ui"; | ||
|
||
export interface FileType { | ||
format: StarkPrettyPrintFormat; | ||
title: string; | ||
path: string; | ||
rawData: string; | ||
} | ||
|
||
@Component({ | ||
selector: "showcase-demo-pretty-print", | ||
templateUrl: "./pretty-print.component.html", | ||
styleUrls: ["./pretty-print.component.scss"] | ||
}) | ||
export class PrettyPrintComponent implements OnInit { | ||
public fileTypes: FileType[] = []; | ||
|
||
public constructor(@Inject(STARK_LOGGING_SERVICE) public logger: StarkLoggingService) {} | ||
|
||
public ngOnInit(): void { | ||
this.addCss(); | ||
this.addScss(); | ||
this.addHtml(); | ||
this.addJavascript(); | ||
this.addTypescript(); | ||
this.addJson(); | ||
this.addXml(); | ||
this.addSql(); | ||
} | ||
|
||
public trackFileTypes(_index: number, fileType: any): string { | ||
return fileType.format; | ||
} | ||
|
||
private addCss(): void { | ||
const fileType: FileType = { | ||
format: "css", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.CSS", | ||
path: "pretty-print/css", | ||
rawData: [ | ||
"body{background: #D2DA9C url(leftcolbg.jpg)repeat-y left top;color: #FFF;}", | ||
"p{margin-bottom:1em}ul{margin-left:20px;margin-bottom:1em}" | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
|
||
private addScss(): void { | ||
const fileType: FileType = { | ||
format: "scss", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.SCSS", | ||
path: "pretty-print/scss", | ||
rawData: [ | ||
"$font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; }" | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
|
||
private addHtml(): void { | ||
const fileType: FileType = { | ||
format: "html", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.HTML", | ||
path: "pretty-print/html", | ||
rawData: [ | ||
"<!DOCTYPE html><html><head><style>body {background-color: powderblue;}h1{color: blue;}p{color: red;}", | ||
"</style></head><body><h1>This is a heading</h1><p>This is a paragraph.</p></body></html>" | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
|
||
private addJavascript(): void { | ||
const fileType: FileType = { | ||
format: "javascript", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.JAVASCRIPT", | ||
path: "pretty-print/javascript", | ||
rawData: [ | ||
"function calculateData(seed, operationFn) {", | ||
"var data = operationFn(seed);", | ||
"if (!data){", | ||
"data = 'could not calculate data';", | ||
"}", | ||
"return data;", | ||
"}" | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
|
||
private addTypescript(): void { | ||
const fileType: FileType = { | ||
format: "typescript", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.TYPESCRIPT", | ||
path: "pretty-print/typescript", | ||
rawData: [ | ||
"function calculateData(seed:any, operationFn:Function):any {", | ||
"var data:any = operationFn(seed);", | ||
"if (!data){", | ||
"data = 'could not calculate data';", | ||
"}", | ||
"return data;", | ||
"}" | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
|
||
private addJson(): void { | ||
const fileType: FileType = { | ||
format: "json", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.JSON", | ||
path: "pretty-print/json", | ||
rawData: [ | ||
'{"menu": { "id": "file", "value": "File",', | ||
'"menuitem": [{"value": "New", "onclick": "CreateNewDoc()"},', | ||
'{"value": "Open", "onclick": "OpenDoc()"},', | ||
'{"value": "Close", "onclick": "CloseDoc()"}]}}' | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
|
||
private addXml(): void { | ||
const fileType: FileType = { | ||
format: "xml", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.XML", | ||
path: "pretty-print/xml", | ||
rawData: [ | ||
'<menu id="file" value="File"><menuitem value="New" onclick="CreateNewDoc()" />', | ||
'<menuitem value="Open" onclick="OpenDoc()" />', | ||
'<menuitem value="Close" onclick="CloseDoc()" /></menu>' | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
|
||
private addSql(): void { | ||
const fileType: FileType = { | ||
format: "sql", | ||
title: "SHOWCASE.DEMO.PRETTY-PRINT.SQL", | ||
path: "pretty-print/sql", | ||
rawData: [ | ||
"SELECT DISTINCT Name FROM Production.Product AS p WHERE EXISTS (SELECT * ", | ||
"FROM Production.ProductModel AS pm WHERE p.ProductModelID = pm.ProductModelID ", | ||
"AND pm.Name LIKE 'Long-Sleeve Logo Jersey%')" | ||
].join("") | ||
}; | ||
this.fileTypes.push(fileType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h3>Original Code</h3> | ||
<pre class="code-block">{{rawCssData}}</pre> | ||
|
||
<h3>Pretty Printed</h3> | ||
<div class="code-block"> | ||
<stark-pretty-print [data]="rawCssData" format="css" [enableHighlighting]="false"></stark-pretty-print> | ||
</div> | ||
|
||
<h3>Pretty Printed & Highlighted</h3> | ||
<stark-pretty-print [data]="rawCssData" format="css" [enableHighlighting]="true"></stark-pretty-print> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.code-block { | ||
background-color: #e6e6e6; | ||
overflow-x: auto; | ||
padding: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "pretty-print-example", | ||
templateUrl: "./pretty-print.component.html", | ||
styleUrls: ["./pretty-print.component.scss"] | ||
}) | ||
export class PrettyPrintComponent implements OnInit { | ||
public rawCssData: string; | ||
|
||
public ngOnInit(): void { | ||
this.rawCssData = [ | ||
"body{background: #D2DA9C url(leftcolbg.jpg)repeat-y left top;color: #FFF;}", | ||
"p{margin-bottom:1em}ul{margin-left:20px;margin-bottom:1em}" | ||
].join(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h3>Original Code</h3> | ||
<pre class="code-block">{{rawHtmlData}}</pre> | ||
|
||
<h3>Pretty Printed</h3> | ||
<div class="code-block"> | ||
<stark-pretty-print [data]="rawHtmlData" format="hHtml" [enableHighlighting]="false"></stark-pretty-print> | ||
</div> | ||
|
||
<h3>Pretty Printed & Highlighted</h3> | ||
<stark-pretty-print [data]="rawHtmlData" format="hHtml" [enableHighlighting]="true"></stark-pretty-print> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.code-block { | ||
background-color: #e6e6e6; | ||
overflow-x: auto; | ||
padding: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "pretty-print-example", | ||
templateUrl: "./pretty-print.component.html", | ||
styleUrls: ["./pretty-print.component.scss"] | ||
}) | ||
export class PrettyPrintComponent implements OnInit { | ||
public rawHtmlData: string; | ||
|
||
public ngOnInit(): void { | ||
this.rawHtmlData = [ | ||
"<!DOCTYPE html><html><head><style>body {background-color: powderblue;}h1{color: blue;}p{color: red;}", | ||
"</style></head><body><h1>This is a heading</h1><p>This is a paragraph.</p></body></html>" | ||
].join(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h3>Original Code</h3> | ||
<pre class="code-block">{{rawJavascriptData}}</pre> | ||
|
||
<h3>Pretty Printed</h3> | ||
<div class="code-block"> | ||
<stark-pretty-print [data]="rawJavascriptData" format="javascript" [enableHighlighting]="false"></stark-pretty-print> | ||
</div> | ||
|
||
<h3>Pretty Printed & Highlighted</h3> | ||
<stark-pretty-print [data]="rawJavascriptData" format="javascript" [enableHighlighting]="true"></stark-pretty-print> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.code-block { | ||
background-color: #e6e6e6; | ||
overflow-x: auto; | ||
padding: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "pretty-print-example", | ||
templateUrl: "./pretty-print.component.html", | ||
styleUrls: ["./pretty-print.component.scss"] | ||
}) | ||
export class PrettyPrintComponent implements OnInit { | ||
public rawJavascriptData: string; | ||
|
||
public ngOnInit(): void { | ||
this.rawJavascriptData = [ | ||
"function calculateData(seed, operationFn) {", | ||
"var data = operationFn(seed);", | ||
"if (!data){", | ||
"data = 'could not calculate data';", | ||
"}", | ||
"return data;", | ||
"}" | ||
].join(""); | ||
} | ||
} |
Oops, something went wrong.