-
Notifications
You must be signed in to change notification settings - Fork 0
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
Layouts and menu #20
base: main
Are you sure you want to change the base?
Layouts and menu #20
Conversation
9718674
to
5aa53f0
Compare
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.
Don't be afraid to re-name or reorganize some variables to make this nav stuff less annoying to understand
@@ -1,28 +1,33 @@ | |||
<li class="usa-collection__item"> | |||
<div class="usa-prose padding-right-4"> |
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.
does the name of this component still make sense if you're pulling the collection item class out? also if these are items in a list, they should still be <li>
s
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.
This change was mostly to keep the look and feel of the existing cg-site--I'll defer to you on this--pages way or pre-existing cg-site look? They probably shouldn't be in a list as these are multi-part paginated code blocks. Semantically, it's fine either way.
_includes/doc-registry.html
Outdated
@@ -0,0 +1,31 @@ | |||
{%- assign documentation_navigation=site.documentation_navigation -%} |
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.
just curious, why the assignment? you can loop thru site.documentation_navigation
on the next line without assigning it.
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.
No idea. Not my change, but is a 1:1 from the old site. I'm updating to remove the assignment, but not actually sure where this template is used off the top of my head.
_includes/doc-registry.html
Outdated
{%- assign documentation_navigation=site.documentation_navigation -%} | ||
{%- for nav_item in documentation_navigation -%} | ||
<h2> {%- if nav_item.icon -%} | ||
<i class='fa fa-fw {{ nav_item.icon }}'></i> |
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.
these are the font awesome icon classes. Was it not possible to migrate these to USWDS icons?
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.
I don't even see a reference to this template. Deleting the file.
_includes/footer.html
Outdated
<a href="https://www.gsa.gov"> | ||
{% image_with_class "_img/gsa-logo.svg" "usa-identifier__logo" "GSA logo identifier" %} | ||
</a> | ||
<div class="footer-section-bottom usa-footer__primary-section bg-accent-warm-light border-top border-accent-warm-dark"> |
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.
can you tell me why you went full utility classes here instead of sticking with the identifier classes? I can't tell what's better about this implementation.
_includes/footer.html
Outdated
<li class="usa-footer__secondary-link"><a href="/contact">Customer support</a></li> | ||
<li class="usa-footer__secondary-link"><a href="mailto:[email protected]">Business | ||
inquiries</a></li> | ||
<li class="usa-footer__secondary-link"><a href="https://join.tts.gsa.gov/">Join our team</a> |
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.
IMO all external (and mailto) links should open in a new window. Also, there's no way you could be familiar with this already, but here's some guidance: https://github.com/cloud-gov/product/blob/main/ContentGuide.md#2-referring-to-external-or-non-government-entities
also join.tts.gsa.gov recently moved to https://tts.gsa.gov/join/
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.
I updated this to override 11ty's default URL filter and am using it {{ somelink | url }} in the template here going forward. Not ready to merge yet.
_includes/layouts/base.html
Outdated
{% include "menu.html" primary_navigation: pages.navigation.primary secondary_navigation: pages.navigation.secondary %} | ||
{% else %} | ||
{% include "menu.html" primary_navigation: site.primary_navigation secondary_navigation: site.secondary_navigation %} | ||
{% endcase %} |
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.
we use assign in so many places, it seems obv to do it here too. would something like this work? note that you'd need to rename the final keys for one of them (primary
-> primary_navigation
or vice-vera )
{% assign nav = site %}
{% if "pages" %} {% nav = pages.navigation %} {% endif %}
{% include "menu.html" primary_navigation: nav.primary secondary_navigation: nav.secondary %}
_includes/layouts/docs.html
Outdated
{% assign toc_content = content | toc | strip | strip_newlines %} | ||
{% assign empty_toc_content = '<ol id="toc" class="section-nav"></ol>' %} | ||
|
||
{% if showtoc != false and toc_content != '' and toc_content != empty_toc_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.
any way to simplify this logic? seems messy
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.
Simplified the logic by moving it to eleventy.js. Compiles fine, but won't be able to feature test until both this and documentation is merged in (PR not yet created).
@@ -6,15 +6,31 @@ | |||
This template is for a single page that does not have a date associated with it. For example, an about page. | |||
{% endcomment %} | |||
|
|||
<div id="main-content" class="usa-layout-docs usa-section"> | |||
<div class="usa-layout-docs usa-section {{background}} page-layout"> |
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.
what's background for, or where is it being set? if it's a color, wouldn't it be bg-{{color}}-{{shade}}
like .bg-primary-dark
?
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 comes from any given page's front matter so you'd set it there to whatever makes sense.
Example- some-page.html:
background: bg-primary-dark
It's not a convention I came up with... it's either from cg-site or pages-11ty (can't remember).
|
||
<div class="grid-row"> | ||
<div class="grid-col flex-4"></div> | ||
<div class="grid-col flex-1"><p><a href="{{ site.github_url }}/edit/{{ site.github_branch }}/{{ page.relative_path }}">Suggest edits</a></p></div> |
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.
new window!
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.
See .eleventy.js
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.
I don't follow -- can you explain?
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.
I think you already saw it by now because of another comment, but here: https://github.com/cloud-gov/site/pull/20/files#diff-c306e0a99961a16f5c5c83996caa0958b94006d97f97475049ea3a08036bb5b0
Eleventy now handles external links on all content and templates during the build through a custom function on the markdown-it plugin.
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.
.eleventy.js has custom code for external links processing now, but I think you already saw that and this comment was earlier.
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.
Eleventy now handles external links on all content and templates during the build through a custom function on the markdown-it plugin.
Hmm... That would work on markdown file content parsed by the markdown engine. This part is in a template. Are you sure it still works that way?
4bda9e7
to
1ea05ac
Compare
1ea05ac
to
c6a2f6a
Compare
}); | ||
|
||
config.addFilter("shouldShowTOC", (content, showToc) => { | ||
return !!showToc && content !== "" && content !== '<ol id="toc" class="section-nav"></ol>'; |
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.
For every new function/filter you add to the eleventy config, do me a solid and comment what it's for. I can kinda tell but it's always nice to have a little more what/why <3
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.
In another comment on the docs.html page, you asked for the template markup to be simpler and so I moved the logic to here. The new docs.html code looks like this now:
{% assign toc_content = content | prepTOCContent %}
{% if toc_content | shouldShowTOC: showtoc %}
<h2>Table of Contents</h2>
<div id="table-of-contents">
{{ toc_content }}
</div>
{% endif %}
The markup is simpler now, but the logic still needs to exist somewhere.
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.
If you're going to add custom functions/filters (magic) to eleventy, it needs to be commented in place for other people to understand what it is and how it works. Maybe you thought I meant here on the PR?
const token = tokens[idx]; | ||
const hrefAttr = token.attrs ? token.attrs.find(attr => attr[0] === 'href') : null; | ||
if (hrefAttr && /^https?:\/\//.test(hrefAttr[1])) { | ||
token.attrSet('target', '_blank'); |
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.
this is awesome and makes me happy. If you also add a class ("usa-link--external") I think we get the little visual indicator (docs) which would be nice in the article content.
const dom = new JSDOM(content); | ||
const links = dom.window.document.querySelectorAll("a[href^='http']"); | ||
|
||
links.forEach(link => { |
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.
oh maybe this is where to put the external link class? not the above one?
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.
Should be both. One is for markdown and the other is for html files.
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.
Oh. I understand the markdown one but I think doing it for HTML templates might be too heavy-handed overall. Rather than dynamically re-parsing the DOM during the build, i'd rather we just added the _blank etc when we code the HTML.
|
||
<div class="grid-row"> | ||
<div class="grid-col flex-4"></div> | ||
<div class="grid-col flex-1"><p><a href="{{ site.github_url }}/edit/{{ site.github_branch }}/{{ page.relative_path }}">Suggest edits</a></p></div> |
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.
can this one be in a new window too?
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 would be automatically from the 11ty build, yes.
@@ -48,3 +48,27 @@ const sideNavExpansion = function (event) { | |||
for (let i = 0; i < sideNavParents.length; i++) { | |||
sideNavParents[i].addEventListener('click', sideNavExpansion, false); | |||
} | |||
|
|||
|
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.
Can this be done more simply, with a parent class that handles the toggling? this is a lot of dom manipulation for what is effectively a few CSS changes.
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.
Probably, but if I make changes here I can't test them as the sidenav doesn't exist in this branch. We would have to wait until the PR for branch chore-dynamic-sidenav is up for review--that branch and PR does not exist yet. This block is a 1:1 from the Jekyll site with minimal changes to make it continue to function. Please let me know how you'd like me to proceed.
Something's broken in this build, see the build logs:
|
Is the build still broken? I think that mailto link might not work with your custom HTML link fixer |
Changes proposed in this pull request: