Fix for makeExample styling without linenumbers losing scrollbar + default handling of makeExamples with only one line
closes #427
This commit is contained in:
parent
83fab41666
commit
46ac6bdaa9
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
mixin makeExample(filePath, region, title, stylePatterns)
|
mixin makeExample(filePath, region, title, stylePatterns)
|
||||||
- var language = attributes.language || getExtn(filePath);
|
- var language = attributes.language || getExtn(filePath);
|
||||||
- var format = attributes.format || "linenums";
|
|
||||||
- var frag = getFrag(filePath, region);
|
- var frag = getFrag(filePath, region);
|
||||||
|
- var defaultFormat = frag.split('\n').length > 2 ? "linenums" : "";
|
||||||
|
- var format = attributes.format || defaultFormat;
|
||||||
if (title)
|
if (title)
|
||||||
.example-title #{title}
|
.example-title #{title}
|
||||||
code-example(language="#{language}" format="#{format}")
|
code-example(language="#{language}" format="#{format}")
|
||||||
|
@ -9,8 +9,6 @@ include ../../../_includes/_util-fns
|
|||||||
p Below are some examples of how you can add/customize code examples in a page.
|
p Below are some examples of how you can add/customize code examples in a page.
|
||||||
|
|
||||||
.showcase-content
|
.showcase-content
|
||||||
.l-sub-section
|
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
### Including a code example from the `_examples` folder
|
### Including a code example from the `_examples` folder
|
||||||
|
|
||||||
@ -78,7 +76,7 @@ include ../../../_includes/_util-fns
|
|||||||
|
|
||||||
+makeTabs('styleguide/js/index.html, styleguide/js/spec.js', null, 'index.html,unit test')
|
+makeTabs('styleguide/js/index.html, styleguide/js/spec.js', null, 'index.html,unit test')
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Marking up an example file for use by the `makeExample` and `makeTabs` mixins
|
### Marking up an example file for use by the `makeExample` and `makeTabs` mixins
|
||||||
|
|
||||||
@ -178,7 +176,7 @@ include ../../../_includes/_util-fns
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Including a named #docregion via the makeExample or makeTabs mixins.
|
### Including a named #docregion via the makeExample or makeTabs mixins.
|
||||||
|
|
||||||
@ -195,7 +193,7 @@ include ../../../_includes/_util-fns
|
|||||||
|
|
||||||
+makeExample('styleguide/js/app.js', 'class-w-annotations', "Extracted region")
|
+makeExample('styleguide/js/app.js', 'class-w-annotations', "Extracted region")
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Additional styling
|
### Additional styling
|
||||||
|
|
||||||
@ -249,7 +247,7 @@ include ../../../_includes/_util-fns
|
|||||||
-var stylePatterns = [{ pnk: /script (src=.*")/g }, {pnk: /(result)/ }];
|
-var stylePatterns = [{ pnk: /script (src=.*")/g }, {pnk: /(result)/ }];
|
||||||
+makeTabs('styleguide/js/index.html, styleguide/js/spec.js', null, 'index.html,unit test', stylePatterns)
|
+makeTabs('styleguide/js/index.html, styleguide/js/spec.js', null, 'index.html,unit test', stylePatterns)
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Including a JSON file or just parts of one
|
### Including a JSON file or just parts of one
|
||||||
|
|
||||||
@ -303,7 +301,6 @@ include ../../../_includes/_util-fns
|
|||||||
- var styles = { pnk: /(^.*dependencies[\s\S]* \})/gm };
|
- var styles = { pnk: /(^.*dependencies[\s\S]* \})/gm };
|
||||||
+makeJson('styleguide/package.json', {paths: 'name, version, dependencies '}, "Foo", styles )
|
+makeJson('styleguide/package.json', {paths: 'name, version, dependencies '}, "Foo", styles )
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Inline code and code examples provided directly i.e. not from an example file.
|
### Inline code and code examples provided directly i.e. not from an example file.
|
||||||
|
|
||||||
@ -324,14 +321,14 @@ include ../../../_includes/_util-fns
|
|||||||
code-example(format="linenums" language="javascript").
|
code-example(format="linenums" language="javascript").
|
||||||
//SOME CODE
|
//SOME CODE
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
h3 Specify starting line number
|
h3 Specify starting line number
|
||||||
|
|
||||||
code-example(language="javascript" format="linenums:4").
|
code-example(language="javascript" format="linenums:4").
|
||||||
code-example(language="html" format="linenums:4").
|
code-example(language="html" format="linenums:4").
|
||||||
var title = "This starts on line four";
|
var title = "This starts on line four";
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
h3 Specify a language
|
h3 Specify a language
|
||||||
|
|
||||||
p.
|
p.
|
||||||
@ -345,7 +342,7 @@ include ../../../_includes/_util-fns
|
|||||||
<h1>Title</h1>
|
<h1>Title</h1>
|
||||||
<p>This is some copy...</p>
|
<p>This is some copy...</p>
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
h3 Code Highlighting
|
h3 Code Highlighting
|
||||||
p.
|
p.
|
||||||
There are three types of highlights available
|
There are three types of highlights available
|
||||||
@ -366,7 +363,6 @@ include ../../../_includes/_util-fns
|
|||||||
// class="otl"
|
// class="otl"
|
||||||
var match = "The <span class='otl'>bird</span> ate <span class='otl'>bird</span> seed near the <span class='otl'>bird</span> bath ";
|
var match = "The <span class='otl'>bird</span> ate <span class='otl'>bird</span> seed near the <span class='otl'>bird</span> bath ";
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
h3 Code Tabs
|
h3 Code Tabs
|
||||||
p.
|
p.
|
||||||
Code Tabs are a great way to show different languages and versions
|
Code Tabs are a great way to show different languages and versions
|
||||||
@ -390,7 +386,6 @@ include ../../../_includes/_util-fns
|
|||||||
code-pane(format="linenums" name="Tab 2").
|
code-pane(format="linenums" name="Tab 2").
|
||||||
// TAB 2 CONTENT
|
// TAB 2 CONTENT
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Combining makeExample, makeTabs mixins with code-example style attributes
|
### Combining makeExample, makeTabs mixins with code-example style attributes
|
||||||
As mentioned above the `makeExample` and `makeTabs` mixins are built on top of the `code-example` style. By default
|
As mentioned above the `makeExample` and `makeTabs` mixins are built on top of the `code-example` style. By default
|
||||||
@ -416,7 +411,7 @@ include ../../../_includes/_util-fns
|
|||||||
|
|
||||||
+makeExample('styleguide/js/app.js', 'class-w-annotations')(format=".")
|
+makeExample('styleguide/js/app.js', 'class-w-annotations')(format=".")
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Code examples in angular/angular source code
|
### Code examples in angular/angular source code
|
||||||
|
|
||||||
@ -468,7 +463,7 @@ include ../../../_includes/_util-fns
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
.l-sub-section
|
|
||||||
:marked
|
:marked
|
||||||
### Cross references to Developer guide pages in angular/angular source comments.
|
### Cross references to Developer guide pages in angular/angular source comments.
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ figure.image-display
|
|||||||
advantage of a TypeScript short-cut in our declaration of the constructor parameters.
|
advantage of a TypeScript short-cut in our declaration of the constructor parameters.
|
||||||
|
|
||||||
Consider the first parameter:
|
Consider the first parameter:
|
||||||
+makeExample('displaying-data/ts/src/app/hero.ts', 'id-parameter')(format=".")
|
+makeExample('displaying-data/ts/src/app/hero.ts', 'id-parameter')
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
That brief syntax simultaneously
|
That brief syntax simultaneously
|
||||||
@ -221,7 +221,7 @@ figure.image-display
|
|||||||
|
|
||||||
The Angular `NgIf` directive will insert or remove an element based on a truthy/falsey condition.
|
The Angular `NgIf` directive will insert or remove an element based on a truthy/falsey condition.
|
||||||
We can see it in action by adding the following paragraph at the bottom of the template:
|
We can see it in action by adding the following paragraph at the bottom of the template:
|
||||||
+makeExample('displaying-data/ts/src/app/app.final.ts', 'message')(format=".")
|
+makeExample('displaying-data/ts/src/app/app.final.ts', 'message')
|
||||||
.alert.is-important
|
.alert.is-important
|
||||||
:marked
|
:marked
|
||||||
Don't forget the leading asterisk (\*) in front of `*ng-if`. It is an essential part of the syntax.
|
Don't forget the leading asterisk (\*) in front of `*ng-if`. It is an essential part of the syntax.
|
||||||
@ -243,11 +243,11 @@ figure.image-display
|
|||||||
As with the `NgFor`, we must add the `NgIf` directive to the component's metadata.
|
As with the `NgFor`, we must add the `NgIf` directive to the component's metadata.
|
||||||
|
|
||||||
We should extend our `import` statement as before ...
|
We should extend our `import` statement as before ...
|
||||||
+makeExample('displaying-data/ts/src/app/app.3.ts', 'import-ng-if')(format=".")
|
+makeExample('displaying-data/ts/src/app/app.3.ts', 'import-ng-if')
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
... and add it to the directives array:
|
... and add it to the directives array:
|
||||||
+makeExample('displaying-data/ts/src/app/app.3.ts', 'directives')(format=".")
|
+makeExample('displaying-data/ts/src/app/app.3.ts', 'directives')
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
Try it out. We have four items in the array so the message should appear.
|
Try it out. We have four items in the array so the message should appear.
|
||||||
@ -267,11 +267,11 @@ figure.image-display
|
|||||||
Let's simplify our lives, discard the `NgFor` and `NgIf`, use the constant for all of them.
|
Let's simplify our lives, discard the `NgFor` and `NgIf`, use the constant for all of them.
|
||||||
|
|
||||||
We'll revise our `import` statement one last time.
|
We'll revise our `import` statement one last time.
|
||||||
+makeExample('displaying-data/ts/src/app/app.final.ts', 'imports')(format=".")
|
+makeExample('displaying-data/ts/src/app/app.final.ts', 'imports')
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
and update the `directives` metadata
|
and update the `directives` metadata
|
||||||
+makeExample('displaying-data/ts/src/app/app.final.ts', 'directives')(format=".")
|
+makeExample('displaying-data/ts/src/app/app.final.ts', 'directives')
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
Pro tip: we register this constant in almost every template we write.
|
Pro tip: we register this constant in almost every template we write.
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
background: $steel;
|
background: $steel;
|
||||||
font-family: $mono-font;
|
font-family: $mono-font;
|
||||||
color: $snow;
|
color: $snow;
|
||||||
overflow: hidden;
|
width: auto;
|
||||||
|
overflow: auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user