Skip to content

Commit

Permalink
Merge pull request #464 from kbayliss/fix/markdown-styles
Browse files Browse the repository at this point in the history
Adding a fix from @kbayliss to address some spacing inconsistencies in the code blocks and markdown blocks being used for the blog.

Apply richtext styles to markdown blocks and improve spacing of markdown/code blocks
  • Loading branch information
vossisboss authored Feb 26, 2024
2 parents e8d4514 + 6c3b6b0 commit 15f5a01
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load wagtailcore_tags %}
<div class="grid">
<div class="grid-align">
<div class="code-block code-block--{{ self.block.name|default:'markdownblock' }}">
{{ code }}
</div>
</div>
43 changes: 43 additions & 0 deletions wagtailio/static/sass/abstracts/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,46 @@
@mixin z-index($key) {
z-index: z-index($key);
}

// Apply formatting for elements using richtext
@mixin richtext() {
a {
color: var(--color--link);
transition: color 0.3s;

&:hover {
color: var(--color--interaction);
}
}

b {
font-weight: $weight--bold;
}

ul,
ol {
list-style: outside;
padding-left: 20px;
margin-bottom: 20px;

@include media-query(medium) {
margin-bottom: 40px;
}
}

ol {
list-style: roman;
}

p {
margin: 0 0 20px;

@include media-query(large) {
margin: 0 0 40px;
}

&:last-child {
margin: 0;
}
}
}
23 changes: 23 additions & 0 deletions wagtailio/static/sass/components/_code-block.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.code-block {
@include sf-spacing(2);

grid-column: 2 / span 2;

@include media-query(medium) {
grid-column: 2 / span 3;
}

@include media-query(large) {
grid-column: 3 / span 3;
}

&--markdownblock {
// Ensure HTML components are styled correctly.
@include richtext();

// Make `CodeBlock` and code blocks within `MarkDownBlock` look the same.
pre {
@include sf-spacing(2);
}
}
}
11 changes: 0 additions & 11 deletions wagtailio/static/sass/components/_grid-align.scss

This file was deleted.

40 changes: 1 addition & 39 deletions wagtailio/static/sass/components/_rich-text.scss
Original file line number Diff line number Diff line change
@@ -1,43 +1,5 @@
.rich-text {
a {
color: var(--color--link);
transition: color 0.3s;

&:hover {
color: var(--color--interaction);
}
}

b {
font-weight: $weight--bold;
}

ul,
ol {
list-style: outside;
padding-left: 20px;
margin-bottom: 20px;

@include media-query(medium) {
margin-bottom: 40px;
}
}

ol {
list-style: roman;
}

p {
margin: 0 0 20px;

@include media-query(large) {
margin: 0 0 40px;
}

&:last-child {
margin: 0;
}
}
@include richtext();

&--sf {
@include sf-spacing(2);
Expand Down
2 changes: 1 addition & 1 deletion wagtailio/static/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@import 'components/code-snippet';
@import 'components/comparison-table';
@import 'components/cookie-message';
@import 'components/code-block';
@import 'components/cta';
@import 'components/cta-block';
@import 'components/document';
Expand All @@ -39,7 +40,6 @@
@import 'components/footer-menu';
@import 'components/get-started';
@import 'components/grid';
@import 'components/grid-align';
@import 'components/heading';
@import 'components/headline';
@import 'components/hero';
Expand Down
1 change: 1 addition & 0 deletions wagtailio/static/sass/vendor/_code-highlighting.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
white-space: pre-wrap;
padding: 1em;
font-size: 0.85em;
margin: 0;

@media (forced-colors: active) {
border: 1px solid;
Expand Down

0 comments on commit 15f5a01

Please sign in to comment.