Skip to content

Commit e8415db

Browse files
Tutorial Page Layout (#13)
* add styles for tutorial info, add helpers * add tutorial page layout
1 parent 9769b9e commit e8415db

File tree

10 files changed

+113
-7
lines changed

10 files changed

+113
-7
lines changed

src/css/doc.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@
939939
padding: 0.25rem 0;
940940
}
941941

942-
.doc .conum[data-value] {
942+
.doc .conum[data-value],
943+
.doc .step {
943944
@include text-overline;
944945

945946
color: var(--ds-text-inverse);
@@ -963,6 +964,12 @@
963964
display: none;
964965
}
965966

967+
.doc .step {
968+
position: relative;
969+
top: -0.25em;
970+
margin-right: var(--ds-space-q);
971+
}
972+
966973
.doc hr {
967974
border: solid var(--section-divider-color);
968975
border-width: 2px 0 0;

src/css/ds-button.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
}
1616
}
1717

18+
a.ds-button:hover {
19+
text-decoration: none;
20+
}
21+
1822
/* icon button */
1923
.ds-button--is-icon {
2024
height: var(--ds-space-5);
@@ -24,10 +28,12 @@
2428

2529
.ds-button--leading-icon {
2630
margin-right: var(--ds-space-1);
31+
display: flex;
2732
}
2833

2934
.ds-button--trailing-icon {
3035
margin-left: var(--ds-space-1);
36+
display: flex;
3137
}
3238

3339
.ds-button--variant-outlined {

src/css/site.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@
2323
@import "footer.css";
2424
@import "highlight.css";
2525
@import "print.css";
26+
@import "tutorial-info.css";

src/css/tutorial-info.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.tutorial-info {
2+
display: flex;
3+
align-items: center;
4+
gap: var(--ds-space-2h);
5+
margin-bottom: var(--ds-space-3);
6+
}
7+
8+
.tutorial-info .info-item {
9+
display: flex;
10+
gap: var(--ds-space-1);
11+
}
12+
13+
.tutorial-info .tutorial-actions {
14+
margin-left: auto;
15+
}

src/helpers/stepcount.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
3+
module.exports = (html) => {
4+
const matches = html.toString().match(/class="step"/g)
5+
if (!matches) return undefined
6+
return matches.length
7+
}

src/helpers/svg.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
const fs = require('fs')
4+
const path = require('path')
5+
6+
module.exports = (iconName) => {
7+
const pathName = path.join(__dirname, '/src/img/', iconName + '.svg')
8+
const content = fs.readFileSync(pathName, 'utf8')
9+
return content
10+
}

src/img/colab.svg

Lines changed: 18 additions & 0 deletions
Loading

src/layouts/tutorial.hbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
{{> head defaultPageTitle='Untitled'}}
5+
</head>
6+
<body class="article{{#with (or page.attributes.role page.role)}} {{{this}}}{{/with}}">
7+
{{> header}}
8+
{{> body}}
9+
{{> footer}}
10+
</body>
11+
</html>

src/partials/article.hbs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<article class="doc">
2-
{{#with page.title}}
3-
<h1 class="page">{{{this}}}</h1>
4-
{{/with}}
5-
{{{page.contents}}}
6-
{{> pagination}}
7-
</article>
2+
{{#with page.title}}
3+
<h1 class="page">{{{this}}}</h1>
4+
{{/with}}
5+
{{#if (eq page.layout 'tutorial')}}
6+
{{> tutorial-info}}
7+
{{/if}}
8+
{{{page.contents}}}
9+
{{> pagination}}
10+
</article>

src/partials/tutorial-info.hbs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div class="tutorial-info">
2+
{{#with page.attributes.skill-level}}
3+
<div class="info-item">
4+
<span class="material-icons">network_check</span>
5+
{{{this}}}
6+
</div>
7+
{{/with}}
8+
{{#with (stepcount page.contents)}}
9+
<div class="info-item">
10+
<span class="material-icons">playlist_add_check</span>
11+
{{{this}}} Steps
12+
</div>
13+
{{/with}}
14+
{{#with page.attributes.time-commitment}}
15+
<div class="info-item">
16+
<span class="material-icons">query_builder</span>
17+
{{{this}}}
18+
</div>
19+
{{/with}}
20+
<div class="tutorial-actions">
21+
{{#with page.attributes.colab-link}}
22+
<a href="{{{this}}}" target="_blank" class="colab ds-button ds-button--variant-outlined ds-button--color-neutral">
23+
<div class="ds-button--leading-icon">{{{svg 'colab'}}}</div>
24+
Run this on Colab
25+
</a>
26+
{{/with}}
27+
</div>
28+
</div>

0 commit comments

Comments
 (0)