Skip to content

Commit

Permalink
Merge pull request #535 from nature-of-code/dev/styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongao97 authored Oct 13, 2023
2 parents 1ecbaaf + d4e072b commit 15d911b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
10 changes: 6 additions & 4 deletions magicbook/plugins/codesplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ Plugin.prototype = {

pairs.forEach((pair) => {
const code = pair.code.join('\n') + '\n';
const comments =
pair.comment.map((str) => str.replace('//', '').trim()).join('\n') +
'\n';
const comments = pair.comment.map((str) => str.replace('//', '').trim());
const className = pair.className.concat('pair');

// highlight the pair that has comment
Expand All @@ -105,7 +103,11 @@ Plugin.prototype = {
$('.pairs').append(
`<div class="${className.join(' ')}">
<pre><code class="code language-js">${code}</code></pre>
<div class="comment"><p>${comments}</p></div>
${
comments.length > 0
? `<div class="comment"><p>${comments.join('\n')}</p></div>`
: ''
}
</div>`,
);
});
Expand Down
3 changes: 2 additions & 1 deletion magicbook/stylesheets/components/chapter-opening.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
}

.chapter-opening-title {
margin-left: 5mm;
margin-left: 12mm;
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-between;
text-align: right;

h1 {
Expand Down
2 changes: 1 addition & 1 deletion magicbook/stylesheets/components/codesplit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

// add a margin between adjacent highlight pairs
&.highlight + .pair.highlight {
margin-top: 1pt;
border-top: 1pt solid $color-gray-100;
}

.comment {
Expand Down
11 changes: 4 additions & 7 deletions magicbook/stylesheets/components/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ table {
}
}

// codesplit
.codesplit {
padding: 0;

.pair {
background: $color-gray-200;
}
// block level code in table
pre {
background: $color-gray-100;
padding: 4pt 2pt;
}
}
6 changes: 6 additions & 0 deletions magicbook/stylesheets/components/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ strong {

pre {
margin: 0;
white-space: pre-wrap;
}

code {
Expand Down Expand Up @@ -125,6 +126,11 @@ figure {
max-width: 50%;
}

.half-width-right > figure,
.half-width-left > figure {
margin-top: 0;
}

// column list
.col-list {
display: flex;
Expand Down

0 comments on commit 15d911b

Please sign in to comment.