-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add styles for gists #295
Add styles for gists #295
Conversation
This is a good fix, thanks chris. I wonder though if there is a way to only include the css if there is a gist linked on the page, as this is a lot of css to add to every page. I will have a think. |
I think something like this could work, but you'd need probably need to convert the gist scss file to css, and add a new entry for it in webpack:
|
Thanks @helenb - that's a nice idea. Reckon we should do the same for the codehilite css as well (if there's a RAW HTML streamfield on the page)? |
tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/markdown_block.html
Outdated
Show resolved
Hide resolved
{% load wagtailcore_tags wagtailimages_tags static %} | ||
{% load wagtailcore_tags wagtailimages_tags util_tags static %} | ||
|
||
{% block extra_css %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, I believe the Work page also uses StoryBlock
so can in theory have these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, doesn't seem to work directly on the work_page.html
- I guess it's because the streamfields are nested on this page and are not directly in page.body
?
-
work_page.html:
{% include_block page.body %} -
work_section_block.html:
Line 16 in 41b7d85
{% include_block value.content %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems to work if you add the extra_css
block in work_page_base.html
🤷🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StoryBlock is used by:
- blog page
- standard page
- impact report page
- service page
- work page
- historical work page
We could add it to all of these, or possibly just add the check in the base template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Markdown is also in the StoryBlock so available in all the same page templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From Helens debugging it seems that the streamfields are nested within Sections on the Work pages so the filter as it is right now doesn't work on work_base_page.html
@register.filter(name="has_markdown_block")
def has_markdown_block(value):
print('running')
if not isinstance(value, StreamValue):
return False
print('still running')
for block in value._raw_data:
print(block["type"])
if block["type"] == "markdown":
print('found markdown')
return True
On work pages this always prints 'Section' so I guess we'd need to adjust the filter to search within the sections rather than the page.body
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helen helped out on Slack and the filter been updated to search nested streamfields within sections and it's now been added to base.html
- ca994a5
Next: add docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/raw_html_block.html
Outdated
Show resolved
Hide resolved
tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/markdown_block.html
Outdated
Show resolved
Hide resolved
tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/raw_html_block.html
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{% load wagtailcore_tags wagtailimages_tags static %} | ||
{% load wagtailcore_tags wagtailimages_tags util_tags static %} | ||
|
||
{% block extra_css %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StoryBlock is used by:
- blog page
- standard page
- impact report page
- service page
- work page
- historical work page
We could add it to all of these, or possibly just add the check in the base template.
Please ignore all the above! I forgot I needed to restart the tooling as webpack had been updated! doh! |
@chris-lawton these changes could do with some documentation. |
…) or raw html blocks have been used
dfbf46a
to
f53aa9b
Compare
Good call. Once i've figured out how they're added to the pages then i'll add in 👍 |
Docs changes looked great. I just tested again with a work page, and although the code works fine on a published page, unfortunately I'm still seeing an error in the preview. So suspect the code needs some further tweaking which I'm hoping @zerolab might be able to have some thoughts on. |
Link to Ticket
Description of Changes Made
Styles for codehilite have been added to the build but these only kick in when a programming language is added in code block streamfield.
When a link to a github gist is added via a raw HTML streamfileld then different classes are used for styling, not
codehilite
.I've found a github repo where
gist
's are styled so have added that to the build. After doing so there are no colour contrast issues being reported by aXe.How to Test
Screenshots
Before
After
MR Checklist
Unit tests
Documentation
Browser testing
Data protection
Accessibility
Sustainability
Pattern library