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

feat(icon): add <rh-icon> #1732

Merged
merged 91 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
0d76143
chore: add red-hat-icon package
zeroedin Aug 1, 2024
b7722c4
feat(icon): add rh-icon
zeroedin Aug 1, 2024
d90924d
docs(icon): remove size css property
zeroedin Aug 1, 2024
8e81e08
Merge branch 'staging/charmander' into feat/rh-icon
zeroedin Aug 1, 2024
60612da
docs(icon): add icon to repostatus data
zeroedin Aug 2, 2024
22da6db
fix(icon): set default set to standard
zeroedin Aug 2, 2024
236553c
test(icon): add fallback test
zeroedin Aug 2, 2024
e613208
chore(icon): lint
zeroedin Aug 2, 2024
9296380
fix(icon): add rh-icon-size css prop for icon size modification
zeroedin Aug 5, 2024
00ae017
fix(icon): update standard size
zeroedin Aug 5, 2024
1a1aadc
docs(icons): add docs
zeroedin Aug 6, 2024
bb101ba
chore: remove errant changes
zeroedin Aug 6, 2024
c9bf646
chore: remove errant changes take 2
zeroedin Aug 6, 2024
46ad320
Merge branch 'staging/charmander' into feat/rh-icon
zeroedin Aug 6, 2024
cc7103e
docs(icon): improve readme add loading info to code tab
zeroedin Aug 6, 2024
6903d36
docs(icon): add loading info to readme
zeroedin Aug 6, 2024
e8c6811
chore(icon): add changeset
zeroedin Aug 6, 2024
0335a27
fix(icon): add accessible-label property
zeroedin Aug 8, 2024
efb3d09
docs(icon): improve demos
zeroedin Aug 8, 2024
e8815bb
docs: remove conflicting styles from demo template
zeroedin Aug 8, 2024
a561c5d
feat(icon): updated Overview and Style subpages, added a default size…
marionnegp Aug 9, 2024
14f5a94
docs(icon): update Style and Guidelines subpages
marionnegp Aug 9, 2024
9565a7d
docs(icon): update Accessibility subpage and subpage footer
marionnegp Aug 9, 2024
37046d7
docs(icon): add thumbnail and update content
marionnegp Aug 9, 2024
34a0fa9
docs(icon): improve default demo
zeroedin Aug 9, 2024
149645f
docs(icon): use accessible-label on sample element on overview
zeroedin Aug 9, 2024
009af05
docs(icon): update accessibility content and theme section
marionnegp Aug 9, 2024
31da37d
fix(icon): remove setting presentational role
zeroedin Aug 9, 2024
7a99cca
docs(icons): use built in two column grid
zeroedin Aug 9, 2024
3ef61d6
docs(icon): update accessibility tab
zeroedin Aug 9, 2024
b304bbe
docs(icon): add doc icons
zeroedin Aug 9, 2024
86442d6
docs: improve back to top styles
zeroedin Aug 9, 2024
e5c13c4
docs(icon): remove extra return whitespace
zeroedin Aug 9, 2024
721cfb2
docs(icons): update guidelines, remove alignment to other elements co…
zeroedin Aug 9, 2024
8d39e90
Merge branch 'staging/charmander' into feat/rh-icon
zeroedin Aug 12, 2024
44062ba
chore(icon): improve changeset
zeroedin Aug 12, 2024
030267d
docs(icon): reduce default demo content
zeroedin Aug 12, 2024
fd581d9
docs(icon): improve readme
zeroedin Aug 12, 2024
bab2b88
docs(icon): update overview content
zeroedin Aug 12, 2024
a43f488
style(icon): adjust render template format
zeroedin Aug 12, 2024
b25c8d4
Merge branch 'staging/charmander' into feat/rh-icon
bennypowers Aug 20, 2024
f8c1654
fix(icon): update for icons 1.1
bennypowers Aug 20, 2024
6d6f375
chore: icon dep
bennypowers Aug 20, 2024
3d0ca2f
fix: remove pf-icon dependency (wip)
bennypowers Aug 20, 2024
53dfb2e
chore: package lock
bennypowers Aug 20, 2024
055992c
chore: add optional esbuild darwin dep
zeroedin Aug 20, 2024
b9724d2
fix: patch pfe-tools demo css
zeroedin Aug 20, 2024
99bebe4
docs: update icons path in eleventy importmap
zeroedin Aug 20, 2024
d6f0c7d
docs: update icons path in dev server importmap
zeroedin Aug 20, 2024
905b032
docs(icon): update sets demo
zeroedin Aug 20, 2024
1bae798
docs(icon): improve set demo
zeroedin Aug 20, 2024
6d1b963
chore(icon): lint set demo
zeroedin Aug 20, 2024
8cb2a1a
docs: add base icon path to importmap
zeroedin Aug 20, 2024
1793e86
docs(icon): remove comment
zeroedin Aug 20, 2024
f9d580c
Merge branch 'staging/charmander' into feat/rh-icon
zeroedin Aug 20, 2024
fbe7c3a
docs(icon): lazy loading is default
zeroedin Aug 20, 2024
f8f0a82
fix(subnav): replace correct icon names and remove size attr
zeroedin Aug 20, 2024
ebddb35
chore: move @patternfly/icons to devDependencies
zeroedin Aug 20, 2024
8e92d7f
fix(icon): fix lazy loading
zeroedin Aug 21, 2024
e72eb5d
fix(icon): remove intersect options just just using defaults
zeroedin Aug 21, 2024
5d2dbbb
fix(icon): remove display contents from container
zeroedin Aug 21, 2024
2e82db8
fix(footer): update footer social icons to use rh-icon
zeroedin Aug 21, 2024
d50e6ac
fix(cta): update cta icons to use rh-icon
zeroedin Aug 21, 2024
a6ae4ee
test(navigation-secondary): remove unecessary icons
zeroedin Aug 21, 2024
50945f1
fix(back-to-top): update to use rh-icon
zeroedin Aug 21, 2024
113d5cd
fix(statistic): update to use rh-icon
zeroedin Aug 21, 2024
3e26ff1
docs(statistic): remove incorrect cssprop jsdoc
zeroedin Aug 21, 2024
1f862ae
fix(tabs): update to use rh-icon
zeroedin Aug 21, 2024
b8d6b7d
fix(tag): update to use rh-icon
zeroedin Aug 21, 2024
ed6ed2b
fix(statistic): remove unused ifDefined
zeroedin Aug 21, 2024
c7bc79b
fix(tile): update to use rh-icon
zeroedin Aug 21, 2024
d3a0bf4
fix(tile): missed pf-icon styles convert to rh-icon
zeroedin Aug 21, 2024
a09308a
chore(footer): lint lightdom styles
zeroedin Aug 21, 2024
65031e4
fix(icon): make load a private method
zeroedin Aug 21, 2024
11d7516
fix(cta): remove static import of icon dynamically imported later
zeroedin Aug 21, 2024
29dc711
fix(cta): update remaining pf-icon styles to rh-icon
zeroedin Aug 21, 2024
17a3e66
test(footer): remove x icon from fixture throwing false positive
zeroedin Aug 21, 2024
0e6f68c
fix(stat): remove setting size attr on icon, rh-icon doesnt suppport
zeroedin Aug 21, 2024
e9a368b
test(stat): correct icon size for large stat, remove check for size a…
zeroedin Aug 21, 2024
77b34f6
test(tag): skip slotted rh-icon test upstream issue
zeroedin Aug 21, 2024
43f2c8b
docs: toast
bennypowers Aug 22, 2024
e1fcf6e
docs(icon): sets
bennypowers Aug 22, 2024
32756eb
docs(icon): sets
bennypowers Aug 22, 2024
0fa5ede
feat(alert): toast
bennypowers Aug 25, 2024
5d072d0
docs: patch eleventy-plugin-lit
bennypowers Aug 25, 2024
950ecad
docs: changeset
bennypowers Aug 25, 2024
ee6cdef
docs: environment
bennypowers Aug 25, 2024
2d79b61
fix(alert): toast
bennypowers Aug 25, 2024
28608ed
fix(alert): toast animation
bennypowers Aug 25, 2024
36b8004
chore: build
bennypowers Aug 25, 2024
f915a02
fix(icon): hide content from at
bennypowers Aug 25, 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
6 changes: 3 additions & 3 deletions elements/rh-back-to-top/rh-back-to-top.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
display: none;
}

pf-icon {
/* override icon size as default sm variant is incorrect */
--pf-icon--size: var(--rh-font-size-body-text-xs, 0.75rem);
rh-icon {
/* Non Standard Icon size */
--rh-icon-size: var(--rh-font-size-body-text-xs, 0.75rem);

vertical-align: -0.125rem;
}
Expand Down
4 changes: 2 additions & 2 deletions elements/rh-back-to-top/rh-back-to-top.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ifDefined } from 'lit/directives/if-defined.js';

import { Logger } from '@patternfly/pfe-core/controllers/logger.js';

import '@patternfly/elements/pf-icon/pf-icon.js';
import '@rhds/elements/rh-icon/rh-icon.js';

import styles from './rh-back-to-top.css';

Expand Down Expand Up @@ -87,7 +87,7 @@ export class RhBackToTop extends LitElement {
return html`
<a href="${ifDefined(this.href)}" ?hidden="${!this.#visible}" part="trigger">
<slot>Back to top</slot>
<pf-icon icon="angle-up" set="fas"></pf-icon>
<rh-icon set="ui" icon="caret-up"></rh-icon>
</a>
`;
}
Expand Down
18 changes: 8 additions & 10 deletions elements/rh-cta/rh-cta.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ pf-icon {
margin-inline-start: var(--rh-space-md, 8px);
}

svg {
rh-icon {
vertical-align: middle;
margin-inline-start: var(--rh-space-md, 8px);
display: inline;
display: inline-block;
fill: currentcolor;
width: var(--_arrow-size);
height: var(--_arrow-size);
translate: 0 0;
transition: translate var(--_trans);

Expand Down Expand Up @@ -157,11 +155,11 @@ a:focus-within,
--_text-decoration: var(--rh-cta-hover-text-decoration, var(--_hover-text-decoration));
}

:host(:hover) #container svg {
:host(:hover) #container rh-icon {
translate: 3px 0;
}

:host(:hover) #container.rtl svg {
:host(:hover) #container.rtl rh-icon {
translate: -3px 0;
}

Expand Down Expand Up @@ -655,12 +653,12 @@ a:focus-within,

/* chrome <= 103 */
@supports not (translate: 0 0) {
svg {
rh-icon {
transform: translate(0, 0);
transition: transform var(--_trans);
}

#container.rtl svg { transform: translate(0, 0) rotate(180deg); }
:host(:hover) #container svg { transform: translate(3px, 0); }
:host(:hover) #container.rtl svg { transform: translate(-3px, 0) rotate(180deg); }
#container.rtl rh-icon { transform: translate(0, 0) rotate(180deg); }
:host(:hover) #container rh-icon { transform: translate(3px, 0); }
:host(:hover) #container.rtl rh-icon { transform: translate(-3px, 0) rotate(180deg); }
}
27 changes: 11 additions & 16 deletions elements/rh-cta/rh-cta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { DirController } from '../../lib/DirController.js';

import { colorContextConsumer, type ColorTheme } from '../../lib/context/color/consumer.js';

import type { IconNameFor, IconSetName } from '@rhds/icons';

import '@rhds/elements/rh-icon/rh-icon.js';

import style from './rh-cta.css';

function isSupportedContent(el: Element | null): el is HTMLAnchorElement | HTMLButtonElement {
Expand Down Expand Up @@ -108,12 +112,12 @@ export class RhCta extends LitElement {
/**
* Icon name
*/
@property({ reflect: true }) icon?: string;
@property({ reflect: true }) icon?: IconNameFor<IconSetName>;

/**
* Icon set
*/
@property({ attribute: 'icon-set' }) iconSet = 'far';
@property({ attribute: 'icon-set' }) iconSet: IconSetName = 'ui';

/**
* Sets color theme based on parent context
Expand All @@ -122,7 +126,7 @@ export class RhCta extends LitElement {

protected override async getUpdateComplete(): Promise<boolean> {
if (this.icon) {
await import('@patternfly/elements/pf-icon/pf-icon.js');
await import('@rhds/elements/rh-icon/rh-icon.js');
}
return super.getUpdateComplete();
}
Expand All @@ -143,24 +147,15 @@ export class RhCta extends LitElement {
const svg = isDefault;
const iconOrSvg = isDefault || !!icon;
const follower = !iconOrSvg ? '' : variant !== 'brick' && icon ? html`<!--
--><pf-icon icon=${icon}
set=${iconSet ?? 'far'}
size="md"></pf-icon>` : variant ? '' : html`<!--
--><svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 31.56 31.56"
width="1em"
focusable="false"
aria-hidden="true">
<path d="M15.78 0l-3.1 3.1 10.5 10.49H0v4.38h23.18l-10.5 10.49 3.1 3.1 15.78-15.78L15.78 0z" />
</svg>`;
--><rh-icon icon=${icon} set=${iconSet ?? 'ui'}></rh-icon>` : variant ? '' : html`<!--
--><rh-icon set="ui" icon="arrow-right"></rh-icon>`;
return html`
<span id="container"
part="container"
class=${classMap({ rtl, icon: !!icon, svg, [on]: !!on })}
@slotchange=${this.firstUpdated}>${variant === 'brick' && icon ? html`
<pf-icon size="md"
icon=${icon}
set="${iconSet ?? 'far'}"></pf-icon>` : ''}${href ? html`
<rh-icon icon=${icon}
set="${iconSet ?? 'ui'}"></rh-icon>` : ''}${href ? html`
<a href=${href}
download="${ifDefined(download)}"
rel="${ifDefined(rel)}"
Expand Down
2 changes: 1 addition & 1 deletion elements/rh-footer/demo/rh-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<rh-footer-social-link slot="social-links" icon="linkedin"><a href="https://www.linkedin.com/company/red-hat" data-analytics-region="social-links-exit" data-analytics-category="Footer|social-links" data-analytics-text="LinkedIn">LinkedIn</a></rh-footer-social-link>
<rh-footer-social-link slot="social-links" icon="youtube"><a href="https://www.youtube.com/user/RedHatVideos" data-analytics-region="social-links-exit" data-analytics-category="Footer|social-links" data-analytics-text="YouTube">YouTube</a></rh-footer-social-link>
<rh-footer-social-link slot="social-links" icon="facebook"><a href="https://www.facebook.com/redhatinc" data-analytics-region="social-links-exit" data-analytics-category="Footer|social-links" data-analytics-text="Facebook">Facebook</a></rh-footer-social-link>
<rh-footer-social-link slot="social-links" icon="twitter"><a href="https://twitter.com/RedHat" data-analytics-region="social-links-exit" data-analytics-category="Footer|social-links" data-analytics-text="Twitter">X/Twitter</a></rh-footer-social-link>
<rh-footer-social-link slot="social-links" icon="x"><a href="https://twitter.com/RedHat" data-analytics-region="social-links-exit" data-analytics-category="Footer|social-links" data-analytics-text="Twitter">X/Twitter</a></rh-footer-social-link>
<h3 slot="links" data-analytics-text="Products">Products</h3>
<ul slot="links">
<li><a href="https://redhat.com/en/technologies/linux-platforms/enterprise-linux" data-analytics-category="Footer|Products" data-analytics-text="Red Hat Enterprise Linux">Red Hat Enterprise Linux</a></li>
Expand Down
2 changes: 1 addition & 1 deletion elements/rh-footer/rh-footer-social-link.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:host {
display: block;

--pf-icon--size: var(--rh-footer--social-icon--size, var(--rh-size-icon-02, 24px));
--rh-icon-size: var(--rh-footer--social-icon--size, var(--rh-size-icon-02, 24px));
}

[hidden] {
Expand Down
15 changes: 5 additions & 10 deletions elements/rh-footer/rh-footer-social-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ export class RhFooterSocialLink extends LitElement {
const newDiv = oldDiv.cloneNode(true) as Element;
// remove the _rendered content
newDiv.querySelectorAll('[_rendered]').forEach(i => i.remove());
/* Temporary fix for x-twitter icon and pf-icon not supporting that icon given font awesome v5 */
if (this.icon === 'twitter') {
newDiv.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" fill="currentcolor" height="24" width="24" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"/></svg><span hidden>${newDiv.innerHTML}</span>`;
} else {
// NB: icons are restricted to fab set, so as not to require a minor release
// rh-icon is slated to deal with this problem in-house
newDiv.innerHTML = `<pf-icon icon="${this.icon ?? ''}"
set="fab"
loading="eager">${newDiv.innerHTML}</pf-icon>`;
}
// NB: icons are restricted to social set, so as not to require a minor release
// rh-icon is slated to deal with this problem in-house
newDiv.innerHTML = `<rh-icon icon="${this.icon ?? ''}"
set="social"
loading="eager">${newDiv.innerHTML}</rh-icon>`;
// add a11y settings
newDiv.setAttribute('aria-label', newDiv.textContent || '');
if (!newDiv.getAttribute('aria-label')) {
Expand Down
2 changes: 1 addition & 1 deletion elements/rh-footer/rh-footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { classMap } from 'lit/directives/class-map.js';

import { getRandomId } from '@patternfly/pfe-core/functions/random.js';
import { Logger } from '@patternfly/pfe-core/controllers/logger.js';
import '@patternfly/elements/pf-icon/pf-icon.js';
import '@rhds/elements/rh-icon/rh-icon.js';
import '@rhds/elements/rh-accordion/rh-accordion.js';

export { RhFooterUniversal } from './rh-footer-universal.js';
Expand Down
4 changes: 2 additions & 2 deletions elements/rh-footer/test/rh-footer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<rh-cta><a href="#blocks">Sign up now</a></rh-cta>
</rh-footer-block>
<rh-footer-block slot="main-secondary">
<h3 slot="header">Select a language</h3>

Check failure on line 87 in elements/rh-footer/test/rh-footer.spec.ts

View workflow job for this annotation

GitHub Actions / JUnit Test Report

Accessibility Violations --- Rule: color-contrast Impact: serious Elements must meet minimum color contrast ratio thresholds (https://dequeuniversity.com/rules/axe/4.10/color-contrast?application=axeAPI) Issue target: rh-icon[icon="twitter"],span[part="fallback"] Context: <span part="fallback"><slot></slot></span> Fix any of the following: Element has insufficient color contrast of 2.52 (foreground color: #a3a3a3, background color: #ffffff, font size: 12.0pt (16px), font weight: normal). Expected contrast ratio of 4.5:1 ---
Raw output
Error: Accessibility Violations
---
Rule: color-contrast
Impact: serious
Elements must meet minimum color contrast ratio thresholds (https://dequeuniversity.com/rules/axe/4.10/color-contrast?application=axeAPI)

Issue target: rh-icon[icon="twitter"],span[part="fallback"]
Context: <span part="fallback"><slot></slot></span>
Fix any of the following:
  Element has insufficient color contrast of 2.52 (foreground color: #a3a3a3, background color: #ffffff, font size: 12.0pt (16px), font weight: normal). Expected contrast ratio of 4.5:1
---
  at processResults (node_modules/chai-a11y-axe/src/accessible.js:87:15)
  at node_modules/chai-a11y-axe/src/accessible.js:123:7
<p>insert language switcher here...</p>
</rh-footer-block>
<rh-footer-universal slot="universal">
Expand Down Expand Up @@ -430,8 +430,8 @@
const element = await fixture<RhFooter>(KITCHEN_SINK_TEMPLATE);
const socialLink = element.querySelector('rh-footer-social-link');
await aTimeout(200);
// we need to reach into pf-icon to get the actual size of the svg.
const icon = socialLink?.querySelector('pf-icon')?.shadowRoot?.querySelector('svg');
// we need to reach into rh-icon to get the actual size of the svg.
const icon = socialLink?.querySelector('rh-icon')?.shadowRoot?.querySelector('svg');
if (icon) {
expect(getComputedStyle(icon).height).to.equal(tokens.get('--rh-size-icon-02'));
}
Expand Down
Loading
Loading