diff --git a/.eleventy.js b/.eleventy.js index 305e89cc..d7088d0b 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,10 +1,12 @@ -const { DateTime } = require('luxon'); const fs = require('fs'); const pluginRss = require('@11ty/eleventy-plugin-rss'); const pluginNavigation = require('@11ty/eleventy-navigation'); const markdownIt = require('markdown-it'); +const markdownItAttrs = require('markdown-it-attrs'); const markdownItAnchor = require('markdown-it-anchor'); +const { readableDate, htmlDateString, head, min, filterTagList } = require("./config/filters"); const { headingLinks } = require("./config/headingLinks"); +const { contrastRatio, humanReadableContrastRatio } = require("./config/wcagColorContrast"); const yaml = require("js-yaml"); const svgSprite = require("eleventy-plugin-svg-sprite"); const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); @@ -23,10 +25,14 @@ module.exports = function (config) { // Specific scripts to guides config.addPassthroughCopy("./assets/_common/js/*"); - // + config.addPassthroughCopy({'./assets/_common/_img/favicons/favicon.ico': './favicon.ico' }); config.addPassthroughCopy({'./assets/_common/_img/favicons': './img/favicons' }); + // Set download paths + // Place files for download in assets/{guide}/dist/{filename.ext} + config.addPassthroughCopy("./assets/**/dist/*"); + // Add plugins config.addPlugin(pluginRss); config.addPlugin(pluginNavigation); @@ -51,41 +57,18 @@ module.exports = function (config) { // Allow yaml to be used in the _data dir config.addDataExtension("yaml", contents => yaml.load(contents)); - config.addFilter('readableDate', (dateObj) => { - return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat( - 'dd LLL yyyy' - ); - }); - + // Filters + // Add filter function defintions to config/filters.js, then add the functions + // to the import statement above and define like the other filters. + config.addFilter('readableDate', readableDate); // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string - config.addFilter('htmlDateString', (dateObj) => { - return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd'); - }); - - // Get the first `n` elements of a collection. - config.addFilter('head', (array, n) => { - if (!Array.isArray(array) || array.length === 0) { - return []; - } - if (n < 0) { - return array.slice(n); - } - - return array.slice(0, n); - }); - - // Return the smallest number argument - config.addFilter('min', (...numbers) => { - return Math.min.apply(null, numbers); - }); - - function filterTagList(tags) { - return (tags || []).filter( - (tag) => ['all', 'nav', 'post', 'posts'].indexOf(tag) === -1 - ); - } - + config.addFilter('htmlDateString', htmlDateString); + config.addFilter('head', head); // Get the first `n` elements of a collection. + config.addFilter('min', min); // Return the smallest number argument config.addFilter('filterTagList', filterTagList); + // Color contrast checkers for the color matrix in the Brand guide + config.addFilter('contrastRatio', contrastRatio); + config.addFilter('humanReadableContrastRatio', humanReadableContrastRatio); // Create an array of all tags config.addCollection('tagList', function (collection) { @@ -97,7 +80,7 @@ module.exports = function (config) { return filterTagList([...tagSet]); }); - // Customize Markdown library and settings: + // Customize Markdown library and settings let markdownLibrary = markdownIt({ html: true, breaks: false, @@ -105,7 +88,7 @@ module.exports = function (config) { }).use(markdownItAnchor, { permalink: headingLinks, slugify: config.getFilter('slug'), - }); + }).use(markdownItAttrs); config.setLibrary('md', markdownLibrary); // Override Browsersync defaults (used only with --serve) diff --git a/_data/navigation.yaml b/_data/navigation.yaml index cf337d5e..3ecc9216 100644 --- a/_data/navigation.yaml +++ b/_data/navigation.yaml @@ -13,6 +13,34 @@ agile: - name: More 18F guides url: https://18f.gsa.gov/guides/ +brand: + - name: Introduction + url: /brand/ + - name: Logo + url: /brand/logo/ + - name: Color palette + url: /brand/color-palette/ + - name: Typography + url: /brand/typography/ + - name: Icons + url: /brand/icons/ + - name: Templates + url: /brand/templates/ + - name: Images + url: /brand/images/ + - name: Principles + url: /brand/principles/ + - name: More 18F guides + url: https://18f.gsa.gov/guides/ + +content-guide: + - name: About this guide + url: /content-guide/ + - name: Our approach + url: /content-guide/our-approach/ + - name: Our style + url: /content-guide/our-style/ + engineering: - name: Home url: /engineering/ @@ -27,14 +55,6 @@ engineering: - name: Security url: /engineering/security/ -content-guide: - - name: About this guide - url: /content-guide/ - - name: Our approach - url: /content-guide/our-approach/ - - name: Our style - url: /content-guide/our-style/ - eng-hiring: - name: Overview url: /eng-hiring/ @@ -72,4 +92,3 @@ product: url: /product/deliver/ - name: Enable partners url: /product/partners/ - diff --git a/_data/titles_roots.yaml b/_data/titles_roots.yaml index a32dd1f5..c9ac8f95 100644 --- a/_data/titles_roots.yaml +++ b/_data/titles_roots.yaml @@ -1,17 +1,20 @@ # Title for each guide that will appear in the header, as well as the root subdirectory for the guide -default: +default: title: 18F Approaches root: / -accessibility: +accessibility: title: Accessibility root: /accessibility/ -agile: +agile: title: Agile root: /agile/ -content-guide: +brand: + title: Visual identity + root: /brand/ +content-guide: title: Content Guide root: /content-guide/ -derisking: +derisking: title: De-risking Guide root: /derisking/ eng-hiring: diff --git a/_includes/brand/color-matrix.html b/_includes/brand/color-matrix.html new file mode 100644 index 00000000..ef3d39b6 --- /dev/null +++ b/_includes/brand/color-matrix.html @@ -0,0 +1,112 @@ + + + +
+ {% for foreground in palette %} + |
+
+ {{ foreground.name | capitalize }} text
+
+ Aa
+
+ + #{{ foreground.hex }} + |
+ {% endfor %}
+ |
+
+
+
+
+ {{ background.name | capitalize }} background
+ + #{{ background.hex }} + |
+ {% for foreground in palette %}
+ {% assign ratio = foreground.hex | contrastRatio: background.hex %}
+ {% if ratio >= 3.1 %}
+
+ {% if ratio >= 4.5 %}
+
+
+
+ Aa ★
+
+
+
+
+ {% else %}
+
+ {{ foreground.name | capitalize }} elements on {{ background.name }} background + is 508-compliant, with a contrast ratio of {{ ratio | humanReadableContrastRatio }}. +
+
+ {% endif %}
+ {{ foreground.name | capitalize }} elements on {{ background.name }} background + is 508-compliant, with a contrast ratio of {{ ratio | humanReadableContrastRatio }}. We recommend using this combination only for non-text elements. + |
+ {% else %}
+
+
+ Do not use {{ foreground.name }} text on {{ background.name }} background; it is not 508-compliant, with a contrast ratio of {{ ratio | humanReadableContrastRatio }}.
+
+ |
+ {% endif %}
+ {% endfor %}
+
+
Very content-guide
{{ color.name }}
+#{{ color.hex }}
+