Skip to content
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

docs: feedback shortcode #1129

Merged
merged 10 commits into from
Sep 6, 2023
41 changes: 14 additions & 27 deletions docs/_includes/feedback.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
{% set searchName = doc.tagName if doc.tagName else (title | slug) %}
{% set related = searchName | relatedItems %}
<div class="multi-column--min-300-wide section section--palette-default container feedback">
{% section %}
{% if related.length %}
<h2>Related elements or patterns</h2>
<ul id="related-items-list">{% for item in related %}
<li>
<a href="{{ item.url}}">{{ item.text }}</a>
</li>{% endfor %}
</ul>
{% elseif title === 'Patterns' %}
<h2>Elements</h2>
<p>To learn how to use our elements in your designs, visit the <a href="{{ '/elements/' | url }}">Elements</a> section.</p>
{% else %}
<h2>Patterns</h2>
<p>To learn how to use our patterns in your designs, visit the <a href="{{ '/patterns/' | url }}">Patterns</a> section.</p>
{% endif %}
{% endsection %}
{% set related = (doc.tagName if doc.tagName else (title | slug)) | relatedItems %}

{% section %}
<h2>Feedback</h2>
<p>
To give feedback about anything on this page,
<a href="https://github.com/RedHat-UX/red-hat-design-system/discussions">contact us</a>.
</p>
{% endsection %}
</div>
{% feedback %}
{% if related.length %}
<h2>Related elements or patterns</h2>
<ul id="related-items-list">{% for item in related %}
<li>
<a href="{{ item.url}}">{{ item.text }}</a>
</li>{% endfor %}
</ul>
{% else %}
<h2>Other libraries</h2>
<p>To learn more about our other libraries, visit <a href="/get-started/">this page</a>.</p>
{% endif %}
{% endfeedback %}
7 changes: 4 additions & 3 deletions docs/_plugins/shortcodes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const RenderInstallation = require('./shortcodes/renderInstallation.cjs');
const ExampleImage = require('./shortcodes/example.cjs');
const Cta = require('./shortcodes/cta.cjs');
const Alert = require('./shortcodes/alert.cjs');
const Section = require('./shortcodes/section.cjs');
const { Section } = require('./shortcodes/section.cjs');
const Demo = require('./shortcodes/demo.cjs');
const SpacerTokensTable = require('./shortcodes/spacerTokensTable.cjs');
const TokensTable = require('./shortcodes/tokensTable.cjs');
const Feedback = require('./shortcodes/feedback.cjs');
const renderCodeDocs = require('./shortcodes/renderCodeDocs.cjs');

/** @typedef {import('@patternfly/pfe-tools/11ty/DocsPage').DocsPage} DocsPage */
Expand All @@ -18,17 +19,17 @@ const renderCodeDocs = require('./shortcodes/renderCodeDocs.cjs');
* @property {object} page
* @property {object} eleventy
*/

module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(Section);
eleventyConfig.addPlugin(RepoStatus);
eleventyConfig.addPlugin(Playground);
eleventyConfig.addPlugin(RenderInstallation);
eleventyConfig.addPlugin(ExampleImage);
eleventyConfig.addPlugin(Cta);
eleventyConfig.addPlugin(Alert);
eleventyConfig.addPlugin(Section);
eleventyConfig.addPlugin(Demo);
eleventyConfig.addPlugin(SpacerTokensTable);
eleventyConfig.addPlugin(TokensTable);
eleventyConfig.addPlugin(Feedback);
eleventyConfig.addPlugin(renderCodeDocs);
};
33 changes: 33 additions & 0 deletions docs/_plugins/shortcodes/feedback.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { section } = require('./section.cjs');

module.exports = function(eleventyConfig) {
eleventyConfig.addPairedShortcode('feedback',
/**
* Demo
* A live component demo
* @param {string} content
* @param {object} options
* @param {string} options.headline (Optional) Text to go in the heading
* @param {string} options.palette Palette to apply, e.g. lightest, light see components/_section.scss
* @param {string} options.headingLevel The heading level, defaults to 3
*/
function demoShortcode(content) {
return /* html*/`

<div class="multi-column--min-300-wide section section--palette-default container feedback">
${section.call(this, content)?.trim() || /* html */`
<h2>Other libraries</h2>
<p>To learn more about our other libraries, visit <a href="/get-started/">this page</a>.</p>
`}
${section.call(this, /* html */`
<h2>Feedback</h2>
<p>
To give feedback about anything on this page,
<a href="https://github.com/RedHat-UX/red-hat-design-system/discussions">contact us</a>.
</p>
`)}
</div>

`;
});
};
13 changes: 6 additions & 7 deletions docs/_plugins/shortcodes/renderCodeDocs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import('@patternfly/pfe-tools/11ty/DocsPage.js');
module.exports = function(eleventyConfig) {
eleventyConfig.addPairedShortcode('renderCodeDocs',
function renderCodeDocs(content, kwargs = {}) {
/**
* NB: since the data for this shortcode is no a POJO,
* but a DocsPage instance, 11ty assigns it to this.ctx._
* @see https://github.com/11ty/eleventy/blob/bf7c0c0cce1b2cb01561f57fdd33db001df4cb7e/src/Plugins/RenderPlugin.js#L89-L93
* @type {DocsPage}
*/
/**
* NB: since the data for this shortcode is no a POJO,
* but a DocsPage instance, 11ty assigns it to this.ctx._
* @see https://github.com/11ty/eleventy/blob/bf7c0c0cce1b2cb01561f57fdd33db001df4cb7e/src/Plugins/RenderPlugin.js#L89-L93
* @type {DocsPage}
*/
const docsPage = this.ctx._;

const level = kwargs.level ?? 2;
Expand All @@ -33,4 +33,3 @@ module.exports = function(eleventyConfig) {
}
);
};

49 changes: 26 additions & 23 deletions docs/_plugins/shortcodes/section.cjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
const { attrMap } = require('./helpers.cjs');

module.exports = function(eleventyConfig) {
eleventyConfig.addPairedShortcode('section',
/**
* Section macro
* Creates a section of the page with a heading
*
* @param {string} content
* @param {object} options
* @param {string} options.headline Text to go in the heading
* @param {string} options.palette Palette to apply, e.g. lightest, light see components/_section.scss
* @param {string} options.headingLevel The heading level, defaults to 2
*/
function(content, {
headline = null,
palette = 'default',
headingLevel = '2',
style = null,
class: className = null,
} = {}) {
const classes = `section section--palette-${palette} ${className ?? ''} container`;
return /* html*/`
/**
* Section macro
* Creates a section of the page with a heading
*
* @param {string} content
* @param {object} options
* @param {string} options.headline Text to go in the heading
* @param {string} options.palette Palette to apply, e.g. lightest, light see components/_section.scss
* @param {string} options.headingLevel The heading level, defaults to 2
*/
function section(content, {
headline = null,
palette = 'default',
headingLevel = '2',
style = null,
class: className = null,
} = {}) {
const classes = `section section--palette-${palette} ${className ?? ''} container`;
return /* html*/`
<section ${attrMap({ style, class: classes })}>${!headline ? '' : `

${Array.from({ length: headingLevel }, () => '#').join('')} ${headline} {.section-title .pfe-jump-links-panel__section} `}
Expand All @@ -30,5 +28,10 @@ ${content}
</section>

`;
});
};
}

function Section(eleventyConfig) {
eleventyConfig.addPairedShortcode('section', section);
}

module.exports = { Section, section };
15 changes: 4 additions & 11 deletions docs/about/how-we-build.njk
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,7 @@ tags:

{%- endcall %}

<div class="multi-column--min-300-wide">

{% call about.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}

{% call about.section("Other resources") -%}
<p>To learn how to use our design system kit and libraries, visit <a href="../../get-started">this page</a>.</p>
{%- endcall %}

</div>
{% feedback %}
<h2>Other resources</h2>
<p>To learn how to use our design system kit and libraries, visit <a href="/get-started/">this page</a>.</p>
{% endfeedback %}
14 changes: 4 additions & 10 deletions docs/design-code-status.njk
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,8 @@ title: Design/code status

{%- endcall %}

<div class="multi-column--min-300-wide section section--palette-default container feedback">
{% feedback %}
<h2>Release notes</h2>
<p>To see what foundations, tokens, elements, or patterns have been released recently, visit <a href="/release-notes/">this page</a>.</p>
{% endfeedback %}

{% call components.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}

{% call components.section("Release notes") -%}
<p>To see what foundations or components have been released recently, visit <a href="../release-notes">this page</a>.</p>
{%- endcall %}

</div>
5 changes: 4 additions & 1 deletion docs/elements/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ summaries:
To request a new element or if updates need to be made to an existing element, <a href="https://github.com/RedHat-UX/red-hat-design-system/issues/new/choose" target="_blank">create a GitHub issue</a>.
{% endsection %}

{% include 'feedback.html' %}
{% feedback %}
<h2>Elements</h2>
bennypowers marked this conversation as resolved.
Show resolved Hide resolved
<p>To learn how to use our elements in your designs, visit the <a href="{{ '/elements/' | url }}">Elements</a> section.</p>
{% endfeedback %}
14 changes: 4 additions & 10 deletions docs/foundations/color.njk
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,8 @@ includeComponent:

{%- endcall %}

<div class="multi-column--min-300-wide section section--palette-default container feedback">
{% feedback %}
<h2>Foundations</h2>
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{% endfeedback %}

{% call foundations.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}

{% call foundations.section("Foundations") -%}
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{%- endcall %}

</div>
13 changes: 4 additions & 9 deletions docs/foundations/grid.njk
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,9 @@ tags:

{%- endcall %}

<div class="multi-column--min-300-wide section section--palette-default container feedback">
{% feedback %}
<h2>Foundations</h2>
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{% endfeedback %}

{% call foundations.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}

{% call foundations.section("Foundations") -%}
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{%- endcall %}

</div>
15 changes: 4 additions & 11 deletions docs/foundations/personalization.njk
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,7 @@ includeComponent:

{%- endcall %}

<div class="multi-column--min-300-wide section section--palette-default container feedback">

{% call components.section("Patterns") -%}
<p>To learn how to use our other patterns in your designs, visit the <a href="/patterns">Patterns</a> section.</p>
{%- endcall %}

{% call components.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}

</div>
{% feedback %}
<h2>Foundations</h2>
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{% endfeedback %}
14 changes: 4 additions & 10 deletions docs/foundations/spacing.njk
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,8 @@ tags:

{%- endcall %}

<div class="multi-column--min-300-wide section section--palette-default container feedback">
{% feedback %}
<h2>Foundations</h2>
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{% endfeedback %}

{% call foundations.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}

{% call foundations.section("Foundations") -%}
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{%- endcall %}

</div>
15 changes: 4 additions & 11 deletions docs/foundations/typography.njk
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,7 @@ tags:

{%- endcall %}

<div class="multi-column--min-300-wide section section--palette-default container feedback">

{% call foundations.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}

{% call foundations.section("Foundations") -%}
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{%- endcall %}

</div>
{% feedback %}
<h2>Foundations</h2>
<p>To learn how to use our other foundations in your designs, visit the <a href="/foundations">foundations</a> section.</p>
{% endfeedback %}
20 changes: 6 additions & 14 deletions docs/get-started.njk
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,9 @@ order: 0

{%- endcall %}

<!-- Cross links -->

<div class="multi-column--min-300-wide section section--palette-default container feedback">
<div>
{% call getstarted.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}
</div>
<div>
{% call getstarted.section("Explore") -%}
<p>Our libraries include <a href="../elements">elements</a>, <a href="fts-starter-kit">patterns</a>, <a href="icon-libraries">icons</a>, and <a href="product-logo-library">product logos</a> to help you design Red Hat experiences.</p>
{%- endcall %}
</div>
</div>
{% feedback %}
<h2>Explore</h2>
<p>Our libraries include <a href="/elements/">elements</a>, <a href="/patterns/">patterns</a>,
<a href="/get-started/icon-libraries">icons</a>,
and <a href="/get-started/product-logo-library">product logos</a> to help you design Red Hat experiences.</p>
{% endfeedback %}
18 changes: 4 additions & 14 deletions docs/get-started/design-system-kit.njk
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,7 @@ includeComponent:

{%- endcall %}

<!-- Cross links -->

<div class="multi-column--min-300-wide section section--palette-default container feedback">
<div>
{% call getstarted.section("Feedback") -%}
<p>To give feedback about anything on this page, <a href="mailto:[email protected]">contact us</a>.</p>
{%- endcall %}
</div>
<div>
{% call getstarted.section("Other libraries") -%}
<p>To learn more about our other libraries, visit <a href="../../get-started">this page</a>.</p>
{%- endcall %}
</div>
</div>
{% feedback %}
<h2>Other libraries</h2>
<p>To learn more about our other libraries, visit <a href="/get-started/">this page</a>.</p>
{% endfeedback %}
Loading