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(logo-wall): added docs and patterns for logo wall #1772

Merged
merged 23 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
03276b0
(docs): adds logo wall patterns and docs
diwanshi Aug 16, 2024
1d150ab
remove unused logo files
diwanshi Aug 16, 2024
e666eca
Merge branch 'main' into pattern/logo-wall
diwanshi Aug 16, 2024
c1fe55c
updated styles to custom-element approach
diwanshi Aug 19, 2024
59576c5
adds lightdom css file for logo wall pattern
diwanshi Aug 19, 2024
1156605
moved lightdom css to logo-wall directory
diwanshi Aug 19, 2024
4336d76
fixes container query
diwanshi Aug 19, 2024
d8ee476
docs: add redhat mono font (#1775)
zeroedin Aug 21, 2024
2bdba77
docs: fix missed font path (#1776)
zeroedin Aug 21, 2024
8247450
updates custom-element approach to classitis approach
diwanshi Aug 21, 2024
04aa05e
updates svgs for hover and focus dark interaction states
diwanshi Aug 21, 2024
2df11c2
Merge branch 'main' into pattern/logo-wall
diwanshi Aug 21, 2024
477b33b
remove rh prefix from lightdom css file name
diwanshi Aug 21, 2024
98e5469
docs(color-accessibility): updated color guidance (#1747)
gradymcgee Aug 21, 2024
9329cc4
Merge branch 'main' into pattern/logo-wall
diwanshi Aug 21, 2024
e805e62
style(logo-wall): code formatting
bennypowers Aug 26, 2024
6e75bce
fix(logo-wall): use root vars
bennypowers Aug 26, 2024
8faea02
Merge branch 'staging/charmander' into pattern/logo-wall
bennypowers Aug 26, 2024
23ff822
docs(logo-wall): isolated patterns
bennypowers Aug 26, 2024
13e2f8e
docs(logo-wall): css links
bennypowers Aug 26, 2024
2b50154
docs(logo-wall): grady review
bennypowers Aug 26, 2024
1f975f9
Merge branch 'staging/charmander' into pattern/logo-wall
bennypowers Aug 26, 2024
dae9269
docs: pattern ordering
bennypowers Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/_includes/layouts/pages/pattern.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ importElements:
- rh-code-block
---
{% if hasToc %}
<link rel="stylesheet" href="{{ '/assets/javascript/elements/uxdot-toc-lightdom.css' | url }}">
<link rel="stylesheet" href="/assets/javascript/elements/uxdot-toc-lightdom.css">
{% endif %}
<link rel="stylesheet" href="{{ '/styles/pages/backpage.css' | url }}">
<link rel="stylesheet" href="/styles/pages/backpage.css">

<script type="module" src="{{ '/assets/javascript/elements/uxdot-feedback.js' | url }}"></script>
<script type="module" src="{{ '/assets/javascript/elements/uxdot-pattern.js' | url }}"></script>
<script type="module" src="/assets/javascript/elements/uxdot-feedback.js"></script>
<script type="module" src="/assets/javascript/elements/uxdot-pattern.js"></script>
{% if hasToc %}
<script type="module" src="{{ '/assets/javascript/elements/uxdot-toc.js' | url }}"></script>
<script type="module" src="/assets/javascript/elements/uxdot-toc.js"></script>
{% endif %}
{% if tokenSearch %}
<script type="module" src="{{ '/assets/javascript/elements/uxdot-search.js' | url }}"></script>
<script type="module" src="{{ '/assets/javascript/tokens.js' | url }}"></script>
<script type="module" src="/assets/javascript/elements/uxdot-search.js"></script>
<script type="module" src="/assets/javascript/tokens.js"></script>
{% endif %}
{% include 'partials/component/masthead.njk' %}
{% include 'partials/component/sidenav.njk' %}
Expand All @@ -39,7 +39,7 @@ importElements:
<div class="container">
{{ content | safe }}
</div>

</article>
{% include "partials/component/back-to-top.njk" %}
</main>
Expand Down
6 changes: 4 additions & 2 deletions docs/_plugins/shortcodes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ const {
RepoStatusTable,
} = require('./shortcodes/repoStatus.cjs');
const RenderInstallation = require('./shortcodes/renderInstallation.cjs');
const RenderCodeDocs = require('./shortcodes/renderCodeDocs.cjs');
const SpacerTokensTable = require('./shortcodes/spacerTokensTable.cjs');
const renderCodeDocs = require('./shortcodes/renderCodeDocs.cjs');
const UxdotPattern = require('./shortcodes/uxdotPattern.cjs');

module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(RepoStatusList);
eleventyConfig.addPlugin(RepoStatusChecklist);
eleventyConfig.addPlugin(RepoStatusTable);
eleventyConfig.addPlugin(RenderInstallation);
eleventyConfig.addPlugin(SpacerTokensTable);
eleventyConfig.addPlugin(renderCodeDocs);
eleventyConfig.addPlugin(RenderCodeDocs);
eleventyConfig.addPlugin(UxdotPattern);
};
62 changes: 62 additions & 0 deletions docs/_plugins/shortcodes/uxdotPattern.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { readFile } = require('node:fs/promises');
const { pathToFileURL } = require('node:url');
const cheerio = require('cheerio');

// for editor highlighting
const html = String.raw;

// because markdown, we have to replace newlines with a cookie crumb
const COMMENT = '<!--CSS_SAMPLE_NEWLINE-->';

/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
module.exports = function(eleventyConfig) {
eleventyConfig.addPairedShortcode('uxdotPattern', async function(content, kwargs) {
const baseUrl = pathToFileURL(this.page.inputPath);
const cssContent = kwargs.css && await readFile(new URL(kwargs.css, baseUrl), 'utf-8');
const jsContent = kwargs.js && await readFile(new URL(kwargs.js, baseUrl), 'utf-8');
return html`
<uxdot-pattern ${kwargs.stacked ? 'stacked' : ''}>
<h4 slot="heading">Example</h4>
${content}
<h4 slot="html-heading">HTML</h4>
<rh-code-block slot="html" actions="copy">
<span slot="action-label-copy">Copy to Clipboard</span>
<span slot="action-label-copy" hidden="" data-code-block-state="active">Copied!</span>
<script type="text/html">${content.trim().replaceAll(/\n/gm, COMMENT)}</script>
</rh-code-block>${!cssContent ? '' : html`
<h4 slot="css-heading">CSS</h4>
<rh-code-block slot="css" actions="copy">
<span slot="action-label-copy">Copy to Clipboard</span>
<span slot="action-label-copy"
hidden
data-code-block-state="active">Copied!</span>
<script type="text/css">${cssContent.replaceAll(/\n/gm, COMMENT)}</script>
</rh-code-block>`}${!jsContent ? '' : html`
<h4 slot="css-heading">JavaScript</h4>
<rh-code-block slot="js" actions="copy">
<span slot="action-label-copy">Copy to Clipboard</span>
<span slot="action-label-copy" hidden="" data-code-block-state="active">Copied!</span>
<script type="sample/javascript">${jsContent.replaceAll(/\n/gm, COMMENT)}</script>`}
</rh-code-block>
</uxdot-pattern>
`;
});

eleventyConfig.addTransform('uxdot-pattern-restore-newlines', function(content) {
const { outputPath } = this;
if (outputPath.match(/\/patterns\/.*\/examples\//)) {
const $ = cheerio.load(content);
$([
'script[type="text/css"]',
'script[type="text/html"]',
'script[type="sample/javascript"]',
].join()).each(function() {
const el = $(this);
el.text(el.text().replaceAll(COMMENT, '\n'));
});
return $.html();
} else {
return content;
}
});
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/assets/javascript/elements/uxdot-pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class UxdotPattern extends LitElement {
grid-area: example;
}

#example ::slotted(*) {
#example ::slotted(*:not(style)) {
display: block;
max-width: 360px;
}
Expand Down
Binary file added docs/assets/patterns/all-patterns-logo-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
163 changes: 132 additions & 31 deletions docs/foundations/color/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ subnav:
collection: sortedColor
order: 3
permalink: /foundations/color/accessibility/index.html
importElements:
- rh-alert
- rh-table
---

<link rel="stylesheet" href="{{ '/assets/packages/@rhds/elements/elements/rh-table/rh-table-lightdom.css' | url }}">
<style>
.pass {
color: var(--rh-color-green-60, #3D7317);
}
.fail {
color: var(--rh-color-red-orange-60, #B1380B);
}
</style>

## Approach

At our core, we believe in creating interactions and experiences that are
Expand All @@ -20,61 +33,149 @@ accessible to everyone.

## Using color alone

When considering methods of communication or feedback, do not use color (or
location) alone. Ensure there is a text label, icon, underline, or other visual
cue to communicate meaning. Consider how the following elements would look to a
When considering methods of communication or feedback, do not use color or
location alone. Ensure there is text, an icon, an underline, or other visual
cue to communicate meaning. Consider how these elements look to a
color blind user.

<uxdot-example>
<img alt="Dialog with a red-orange Leave button, a form field with a red bottom border, and progress steps without labels" src="/assets/color/using-color-alone.png">
<figure>
<img alt="Dialog with a gray leave button, a form field with a gray bottom border, and progress steps in gray without labels" src="/assets/color/color-a11y-using-color-alone.png">
<figcaption>
A simulation of what a color blind user might see when only color is used to communicate meaning.
</figcaption>
</figure>

## Color contrast

### Body and code text

Foreground body and code text (non-bold text **under 24px** and bold text **under 19px**) must have a contrast ratio of 4.5:1. Large foreground body and code text (non-bold text of **at least 24px** and bold text of **at least 19px**) must have a contrast ratio of 3:1.

<uxdot-example width-adjustment=”100%” variant="full" alignment="left" no-border>
<img alt="Two examples of dark text on light backgrounds and two examples of light text on dark backgrounds." src="/assets/color/color-a11y-contrast-body-code-text.png">
</uxdot-example>

## Contrast
We strive to adhere to [WCAG 2.1 AA](https://www.w3.org/WAI/WCAG21/Understanding/) requirements. Our text, links, interface elements, etc. are designed with sufficient contrast when used on top
of a canvas, surfaces, image backgrounds with low contrast, and near adjacent colors.
### Red text on backgrounds

### Text
Our primary brand color is known as Red Hat red (`#E00`). It has many applications, but on the web, it does not pass color contrast against all background colors, especially text at small sizes.

Small foreground text (non-bold text under 24px and bold text under 19px) must
have a contrast ratio of 4.5:1 and large foreground text (non-bold text of at
least 24px and bold text of at least 19px) must have a contrast ratio of 3:1.
If red text cannot be used, use dark gray or black text against lighter backgrounds, or light gray or white text against darker backgrounds. If you have questions about using other red colors, contact the [Brand team](https://www.redhat.com/en/about/brand/standards).

<uxdot-example>
<img alt="Contrast ratios for dark gray sections with black text that uses different weights and fonts" src="/assets/color/contrast-text.png">
<rh-alert state="warning">
<h4 slot="header">Warning</h4>
Black is usually a brand-only color, but it can be used very sparingly for backgrounds only if <code>gray-95</code> cannot be used.
</rh-alert>

<uxdot-example width-adjustment=”100%” variant="full" alignment="left" no-border>
<img alt="Several examples of red text over light and dark themed backgrounds showing some that pass and some that fail. There is also an example of dark gray text and black text against a light background as well as an example of light gray text and white text on a dark background." src="/assets/color/color-a11y-contrast-red-text-on-bgs.png">
</uxdot-example>

### Links
#### WCAG requirements

WCAG 2.0 level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. WCAG 2.1 requires a contrast ratio of at least 3:1 for graphics and UI components like form input borders. Use the table below to confirm you are using color contrast correctly before using red text.

The font sizes that are considered normal and large are as follows:
- normal: non-bold text under 18pt/24px and bold text under 14pt/19px
- large: non-bold text of at least 18pt/24px and bold text of at least 14pt/19px

<rh-table>
<table>
<thead>
<tr>
<th scope="col" data-label="Background color">Background color</th>
<th scope="col" data-label="Contrast ratio">Contrast ratio</th>
<th scope="col" data-label="Normal text">Normal text</th>
<th scope="col" data-label="Large text">Large text</th>
<th scope="col" data-label="Objects and UI components">Objects and UI components</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Background color"><code>white</code> (<code>#fff</code>)</td>
<td data-label="Contrast ratio"><span class="pass">4.53</span></td>
<td data-label="Normal text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Large text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Objects and UI components"><span class="pass">WCAG AA: Pass</span></td>
</tr>
<tr>
<td data-label="Background color"><code>gray-10</code> (<code>#f2f2f2</code>)</td>
<td data-label="Contrast ratio"><span class="fail">4.04</span></td>
<td data-label="Normal text"><span class="fail">WCAG AA: Fail</span></td>
<td data-label="Large text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Objects and UI components"><span class="pass">WCAG AA: Pass</span></td>
</tr>
<tr>
<td data-label="Background color"><code>gray-20</code> (<code>#e0e0e0</code>)</td>
<td data-label="Contrast ratio"><span class="fail">4.04</span></td>
<td data-label="Normal text"><span class="fail">WCAG AA: Fail</span></td>
<td data-label="Large text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Objects and UI components"><span class="pass">WCAG AA: Pass</span></td>
</tr>
<tr>
<td data-label="Background color"><code>gray-70</code> (<code>#383838</code>)</td>
<td data-label="Contrast ratio"><span class="fail">2.58</span></td>
<td data-label="Normal text"><span class="fail">WCAG AA: Fail</span></td>
<td data-label="Large text"><span class="fail">WCAG AA: Fail</span></td>
<td data-label="Objects and UI components"><span class="fail">WCAG AA: Fail</span></td>
</tr>
<tr>
<td data-label="Background color"><code>gray-80</code> (<code>#292929</code>)</td>
<td data-label="Contrast ratio"><span class="fail">3.21</span></td>
<td data-label="Normal text"><span class="fail">WCAG AA: Fail</span></td>
<td data-label="Large text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Objects and UI components"><span class="pass">WCAG AA: Pass</span></td>
</tr>
<tr>
<td data-label="Background color"><code>gray-90</code> (<code>#1f1f1f</code>)</td>
<td data-label="Contrast ratio"><span class="fail">3.63</span></td>
<td data-label="Normal text"><span class="fail">WCAG AA: Fail</span></td>
<td data-label="Large text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Objects and UI components"><span class="pass">WCAG AA: Pass</span></td>
</tr>
<tr>
<td data-label="Background color"><code>gray-95</code> (<code>#151515</code>)</td>
<td data-label="Contrast ratio"><span class="fail">4.03</span></td>
<td data-label="Normal text"><span class="fail">WCAG AA: Fail</span></td>
<td data-label="Large text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Objects and UI components"><span class="pass">WCAG AA: Pass</span></td>
</tr>
<tr>
<td data-label="Background color"><code>black</code> (<code>#000</code>)</td>
<td data-label="Contrast ratio"><span class="pass">4.63</span></td>
<td data-label="Normal text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Large text"><span class="pass">WCAG AA: Pass</span></td>
<td data-label="Objects and UI components"><span class="pass">WCAG AA: Pass</span></td>
</tr>
</tbody>
</table>
</rh-table>

If color is the only way to distinguish between links and surrounding text (e.g., if link underlines are removed), the contrast ratio between the link and surrounding text must be at least 3:1.

- Non-color cues must be used to signify when the link receives hover or focus (e.g., an underline)
### Links

To differentiate text links from their surrounding text without relying on color contrast, links in all states must be underlined. Links isolated within visually distinct sections (e.g., navigation menus) or with additional visual cues (e.g., CTA arrows) are exempt from this requirement, though you may still add underlines at your discretion.

<uxdot-example>
<img alt="Contrast ratio of a blue link next to black text and an example of a link's darker blue, underlined hover state" src="/assets/color/contrast-links.png">
<uxdot-example width-adjustment=”100%” variant="full" alignment="left" no-border>
<img alt="Contrast ratio of a blue link next to black text and an example of a link's darker blue, underlined hover state" src="/assets/color/color-a11y-contrast-links.png">
</uxdot-example>

### Graphical objects and UI components

Graphical objects and UI components should have a contrast ratio of at least 3:1
(e.g., within charts and infographics). If color is the only way to
distinguish between inline controls and their surrounding text, the contrast
ratio between the control and text must be at least 3:1.
Graphical objects and UI components like charts and infographics should have a contrast ratio of at least 3:1. If color is the only way to distinguish between inline controls and surrounding text, the contrast ratio between the control and text must be at least 3:1.

- Non-color cues (e.g., a border) must be used to signify when the element receives focus
- Non-color cues like borders must be used to signify when an element receives focus

### Layering

It is acceptable to layer colors with the same hue, saturation, or lightness on
white, black, or gray. However, layering them near or on top of each other might cause vibration. If you need to layer colors, follow [WCAG 2.1 AA](https://www.w3.org/WAI/WCAG21/Understanding/)
requirements.
You can layer colors on light or dark backgrounds. However, layering colors near or on top of other colors will cause vibration. For more information about layering colors, follow [WCAG 2.1 AA](https://www.w3.org/WAI/WCAG21/Understanding/) requirements.

<uxdot-example>
<img alt="Red CTA against a white background, blue button against a light gray background, and a light red-orange button against a black background" src="/assets/color/contrast-layering.png">
<uxdot-example width-adjustment=”100%” variant="full" alignment="left" no-border>
<img alt="Red CTA against a white background, blue button against a light gray background, and a light red-orange button against a black background" src="/assets/color/color-a11y-contrast-layering.png">
</uxdot-example>

### Tools
## Tools

TPGi’s [Colour Contrast Analyzer](https://www.tpgi.com/color-contrast-checker/) can help you identify colors and gauge their contrast from one another.
The [Colour Contrast Analyzer](https://www.tpgi.com/color-contrast-checker/) by TPGi can help you identify colors and gauge their contrast from one another.

<uxdot-feedback>
<h2>Foundations</h2>
Expand Down
1 change: 1 addition & 0 deletions docs/patterns/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ summaries:
sticky-banner: Anchors an offer to the bottom edge of a page
sticky-card: Anchors an offer to the right edge of a page
video-thumbnail: Overlays a button that indicates video playback
logo-wall: Visual arrangement of logos representing various brands, companies, or organizations
order: 0
tags:
- pattern
Expand Down
Loading
Loading