From 5336e48f7ad4d1b0e92423cb94df8657077ba4dd Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 09:00:12 +0300 Subject: [PATCH 01/29] docs: picker targets --- .../rh-context-demo/rh-context-demo.css | 3 ++- .../rh-context-demo/rh-context-demo.ts | 21 ++++++++++++------- .../rh-context-picker/rh-context-picker.ts | 11 ++++++---- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/elements/rh-context-demo/rh-context-demo.css b/lib/elements/rh-context-demo/rh-context-demo.css index d62c2b0e0f..41513da610 100644 --- a/lib/elements/rh-context-demo/rh-context-demo.css +++ b/lib/elements/rh-context-demo/rh-context-demo.css @@ -5,7 +5,8 @@ position: relative; } -rh-surface { color: var(--rh-color-text-primary); } +rh-surface, +.on { color: var(--rh-color-text-primary); } #picker-container { display: flex; diff --git a/lib/elements/rh-context-demo/rh-context-demo.ts b/lib/elements/rh-context-demo/rh-context-demo.ts index 8a0171f916..a859d945a3 100644 --- a/lib/elements/rh-context-demo/rh-context-demo.ts +++ b/lib/elements/rh-context-demo/rh-context-demo.ts @@ -1,7 +1,7 @@ import { LitElement, type PropertyValues, html } from 'lit'; import { customElement } from 'lit/decorators/custom-element.js'; import { property } from 'lit/decorators/property.js'; -import { classMap } from 'lit/directives/class-map.js'; +import { classMap } from 'lit-html/directives/class-map.js'; import { colorContextProvider, type ColorPalette } from '../../context/color/provider.js'; import { ContextChangeEvent } from '../rh-context-picker/rh-context-picker.js'; @@ -10,11 +10,11 @@ import '@rhds/elements/rh-surface/rh-surface.js'; import style from './rh-context-demo.css'; -import surfaceStyles from '@rhds/tokens/css/color-context-consumer.css.js'; +import consumerStyles from '@rhds/tokens/css/color-context-consumer.css.js'; @customElement('rh-context-demo') export class RhContextDemo extends LitElement { - static readonly styles = [style, surfaceStyles]; + static readonly styles = [style, consumerStyles]; static formAssociated = true; @@ -23,26 +23,26 @@ export class RhContextDemo extends LitElement { @property() label = 'Color Palette'; @colorContextProvider() - @property({ attribute: 'color-palette', reflect: true }) colorPalette = this.value; + @property({ attribute: 'color-palette', reflect: true }) + colorPalette = this.value; #internals = this.attachInternals(); protected override render() { const { value = 'darkest' } = this; - const [on = 'dark'] = value.match(/dark|light/) ?? []; + const on = this.value.replace(/est|er/, ''); return html` -
+
- + `; } @@ -61,8 +61,13 @@ export class RhContextDemo extends LitElement { } #onChange(event: Event) { + const picker = this.shadowRoot?.getElementById('picker'); if (event instanceof ContextChangeEvent) { + if (event.target !== picker && event.provider && (event.provider !== this)) { + return; + } this.#setValue(event.colorPalette); + event.preventDefault(); } } diff --git a/lib/elements/rh-context-picker/rh-context-picker.ts b/lib/elements/rh-context-picker/rh-context-picker.ts index cc8645a5dc..5af1c00e35 100644 --- a/lib/elements/rh-context-picker/rh-context-picker.ts +++ b/lib/elements/rh-context-picker/rh-context-picker.ts @@ -5,6 +5,7 @@ import type { ColorTheme } from '@rhds/elements/lib/context/color/consumer.js'; import { html, LitElement, type ComplexAttributeConverter } from 'lit'; import { customElement } from 'lit/decorators/custom-element.js'; import { property } from 'lit/decorators/property.js'; +import { classMap } from 'lit/directives/class-map.js'; import { colorContextConsumer } from '@rhds/elements/lib/context/color/consumer.js'; import { InternalsController } from '@patternfly/pfe-core/controllers/internals-controller.js'; @@ -18,14 +19,16 @@ import { ColorSurfaceLightest as lightest, } from '@rhds/tokens/color.js'; -import { classMap } from 'lit/directives/class-map.js'; - import '@rhds/elements/rh-tooltip/rh-tooltip.js'; import style from './rh-context-picker.css'; export class ContextChangeEvent extends Event { - constructor(public colorPalette: ColorPalette) { + constructor( + public colorPalette: ColorPalette, + /** the context provider targeted by this element */ + public provider: HTMLElement | null, + ) { super('change', { bubbles: true, cancelable: true }); } } @@ -129,7 +132,7 @@ export class RhContextPicker extends LitElement { #setValue(value: this['value']) { this.#internals.setFormValue(value); - if (value !== this.value && this.dispatchEvent(new ContextChangeEvent(value))) { + if (value !== this.value && this.dispatchEvent(new ContextChangeEvent(value, this.#target))) { this.value = value; this.sync(); } From 195cdff11770271f4787775b0078410ff680cdfa Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 08:56:47 +0300 Subject: [PATCH 02/29] fix(surface): set but don't inherit surface colors --- elements/rh-surface/rh-surface.css | 12 ++++++++++++ elements/rh-surface/rh-surface.ts | 15 +++++++++------ package-lock.json | 8 ++++---- package.json | 2 +- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/elements/rh-surface/rh-surface.css b/elements/rh-surface/rh-surface.css index 58c7216afa..42ed489c5c 100644 --- a/elements/rh-surface/rh-surface.css +++ b/elements/rh-surface/rh-surface.css @@ -3,3 +3,15 @@ background-color: var(--rh-color-surface); color: var(--rh-color-text-primary); } + +.on.dark, +.on.light { + --rh-color-surface: unset; +} + +#slot.palette-lightest { --rh-color-surface: var(--rh-color-surface-lightest, #ffffff); } +#slot.palette-lighter { --rh-color-surface: var(--rh-color-surface-lighter, #f2f2f2); } +#slot.palette-light { --rh-color-surface: var(--rh-color-surface-light, #e0e0e0); } +#slot.palette-dark { --rh-color-surface: var(--rh-color-surface-dark, #383838); } +#slot.palette-darker { --rh-color-surface: var(--rh-color-surface-darker, #1f1f1f); } +#slot.palette-darkest { --rh-color-surface: var(--rh-color-surface-darkest, #151515); } diff --git a/elements/rh-surface/rh-surface.ts b/elements/rh-surface/rh-surface.ts index 2e71d25f80..01fd313355 100644 --- a/elements/rh-surface/rh-surface.ts +++ b/elements/rh-surface/rh-surface.ts @@ -1,5 +1,4 @@ import type { ColorPalette } from '@rhds/elements/lib/context/color/provider.js'; -import type { ColorTheme } from '@rhds/elements/lib/context/color/consumer.js'; import { LitElement, html } from 'lit'; import { customElement } from 'lit/decorators/custom-element.js'; @@ -39,12 +38,16 @@ export class RhSurface extends LitElement { @colorContextProvider() @property({ reflect: true, attribute: 'color-palette' }) colorPalette?: ColorPalette; - get #on() { - return this.colorPalette?.replace(/e(st|r)/, '') ?? 'light'; - } - render() { - return html``; + const { colorPalette = 'lightest' } = this; + const on = colorPalette?.replace(/e(st|r)/, '') ?? 'light'; + return html``; } #onSlotchange() { diff --git a/package-lock.json b/package-lock.json index b866083e11..2b4560035e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@lit/context": "^1.1.2", "@patternfly/pfe-core": "^4.0.1", "@rhds/icons": "^1.1.1", - "@rhds/tokens": "^2.1.0-next.11", + "@rhds/tokens": "^2.1.0-next.13", "lit": "^3.2.0", "tslib": "^2.6.3" }, @@ -4886,9 +4886,9 @@ "integrity": "sha512-Cqpr9bmMbcSk/NMkp12qaOnSag7jEHU1zFKmsnJN/21BIYUAL6+mdyfsRe4dxzOkSSmjqCypiFJYcJ8KFNAMyA==" }, "node_modules/@rhds/tokens": { - "version": "2.1.0-next.11", - "resolved": "https://registry.npmjs.org/@rhds/tokens/-/tokens-2.1.0-next.11.tgz", - "integrity": "sha512-CSQAqhB8iKWD/uBWKaj/wf+uGYQfPXEYAB8NcXg1+cg77oOvMNz9uK7pWVucfDoWAAB4i2IgBAqURvPvK5TPNg==", + "version": "2.1.0-next.13", + "resolved": "https://registry.npmjs.org/@rhds/tokens/-/tokens-2.1.0-next.13.tgz", + "integrity": "sha512-FRdKY2B7C3IiXjbtIbGnY0+dcPRiYvmWmmR73FKB1g3eOX1Ad6E08WKTGJUTou//hPC37uikhHEW0gIHfm6jjg==", "dependencies": { "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0", "highlight.js": "^11.10.0", diff --git a/package.json b/package.json index b4509e4df9..688c3f1eab 100644 --- a/package.json +++ b/package.json @@ -286,7 +286,7 @@ "@lit/context": "^1.1.2", "@patternfly/pfe-core": "^4.0.1", "@rhds/icons": "^1.1.1", - "@rhds/tokens": "^2.1.0-next.11", + "@rhds/tokens": "^2.1.0-next.13", "lit": "^3.2.0", "tslib": "^2.6.3" }, From 83b60a4b0a1a7215f97c33009bd68238e946d088 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 09:00:20 +0300 Subject: [PATCH 03/29] docs(card): bar pattern --- docs/patterns/card/patterns/title-bar.html | 2 -- elements/rh-card/demo/color-context.html | 20 +++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/docs/patterns/card/patterns/title-bar.html b/docs/patterns/card/patterns/title-bar.html index 44d9fa117a..652b273949 100644 --- a/docs/patterns/card/patterns/title-bar.html +++ b/docs/patterns/card/patterns/title-bar.html @@ -16,8 +16,6 @@

Card title

padding: var(--rh-space-lg) var(--rh-space-2xl); flex-direction: row; gap: var(--rh-space-lg); - } - & h4 { font-weight: var(--rh-font-weight-heading-regular); font-size: var(--rh-font-size-body-text-md); font-family: var(--rh-font-family-body-text); diff --git a/elements/rh-card/demo/color-context.html b/elements/rh-card/demo/color-context.html index 97efe9bb89..15b6cb0a11 100644 --- a/elements/rh-card/demo/color-context.html +++ b/elements/rh-card/demo/color-context.html @@ -87,27 +87,21 @@

Custom header

} } &.bar { + --rh-card-header-background-on-light: var(--rh-color-surface-light, #e0e0e0); + --rh-card-header-background-on-dark: var(--rh-color-surface-dark, #383838); &::part(header) { margin: 0; - padding: var(--rh-space-lg, 16px) var(--rh-space-xl, 24px); - text-transform: uppercase; + padding: var(--rh-space-lg, 16px) var(--rh-space-2xl, 32px); + flex-direction: row; + gap: var(--rh-space-lg, 16px); font-weight: var(--rh-font-weight-heading-regular, 300); font-size: var(--rh-font-size-body-text-md, 1rem); - background-color: var(--bar-header-context-background-color); - } - &::part(body) { - /* margin: var(--rh-space-lg, 16px) var(--rh-space-xl, 24px); */ + font-family: var(--rh-font-family-body-text, RedHatText, 'Red Hat Text', 'Noto Sans Arabic', 'Noto Sans Hebrew', 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans Malayalam', 'Noto Sans SC', 'Noto Sans TC', 'Noto Sans Thai', Helvetica, Arial, sans-serif); + text-transform: uppercase; /* deprecated? */ } } } - [color-palette^="light"] { - --bar-header-context-background-color: var(--rh-color-surface-light, #e0e0e0); - } - [color-palette^="dark"] { - --bar-header-context-background-color: var(--rh-color-surface-dark, #383838); - } - label[for="picker"] { display: block; } From fff59de92e918682e1178ca797a86453c613a816 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 09:00:37 +0300 Subject: [PATCH 04/29] fix(accordion): style guidelines --- elements/rh-accordion/rh-accordion-header.css | 8 ++++++++ elements/rh-accordion/rh-accordion-header.ts | 2 -- elements/rh-accordion/rh-accordion-panel.css | 8 ++++++++ elements/rh-accordion/rh-accordion.css | 2 -- elements/rh-accordion/rh-accordion.ts | 5 +---- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/elements/rh-accordion/rh-accordion-header.css b/elements/rh-accordion/rh-accordion-header.css index 0eda1df3f6..907839767f 100644 --- a/elements/rh-accordion/rh-accordion-header.css +++ b/elements/rh-accordion/rh-accordion-header.css @@ -155,6 +155,14 @@ span { inset-inline-start: 0; } +.expanded.on.light { + --rh-color-surface: var(--rh-color-surface-lightest, #ffffff); +} + +.expanded.on.dark { + --rh-color-surface: var(--rh-color-surface-darkest, #151515); +} + @container (min-width: 576px) { #header-container:not(.bottom) { flex-direction: row; diff --git a/elements/rh-accordion/rh-accordion-header.ts b/elements/rh-accordion/rh-accordion-header.ts index 001d27db68..5c7d75f999 100644 --- a/elements/rh-accordion/rh-accordion-header.ts +++ b/elements/rh-accordion/rh-accordion-header.ts @@ -47,8 +47,6 @@ const isAccordion = (x: EventTarget): x is RhAccordion => */ @customElement('rh-accordion-header') export class RhAccordionHeader extends LitElement { - static readonly version = '{{version}}'; - static readonly styles = [styles]; @property({ type: Boolean, reflect: true }) expanded = false; diff --git a/elements/rh-accordion/rh-accordion-panel.css b/elements/rh-accordion/rh-accordion-panel.css index 66bce675f6..61afe418f9 100644 --- a/elements/rh-accordion/rh-accordion-panel.css +++ b/elements/rh-accordion/rh-accordion-panel.css @@ -55,6 +55,14 @@ background-color: var(--rh-color-surface); } +.expanded.on.light { + --rh-color-surface: var(--rh-color-surface-lightest, #ffffff); +} + +.expanded.on.dark { + --rh-color-surface: var(--rh-color-surface-darkest, #151515); +} + .body:after { content: ''; position: absolute; diff --git a/elements/rh-accordion/rh-accordion.css b/elements/rh-accordion/rh-accordion.css index 501d10d88d..b8f1300f3c 100644 --- a/elements/rh-accordion/rh-accordion.css +++ b/elements/rh-accordion/rh-accordion.css @@ -1,6 +1,4 @@ #container { - height: 100%; - width: 100%; color: var(--rh-color-text-primary); background-color: var(--rh-color-surface); } diff --git a/elements/rh-accordion/rh-accordion.ts b/elements/rh-accordion/rh-accordion.ts index dbb1a55f42..9d1b9d6f22 100644 --- a/elements/rh-accordion/rh-accordion.ts +++ b/elements/rh-accordion/rh-accordion.ts @@ -81,10 +81,7 @@ export class RhAccordion extends LitElement { * * ``` */ - @property({ - attribute: 'expanded-index', - converter: NumberListConverter, - }) + @property({ attribute: 'expanded-index', converter: NumberListConverter }) get expandedIndex() { return this.#expandedIndex; } From 016c59af82815b6ea6c98440ad56fc4802d9c2f8 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 09:33:55 +0300 Subject: [PATCH 05/29] fix(alert): theme tokens --- elements/rh-alert/rh-alert.css | 194 ++++++++++++++++----------------- elements/rh-alert/rh-alert.ts | 14 ++- 2 files changed, 105 insertions(+), 103 deletions(-) diff --git a/elements/rh-alert/rh-alert.css b/elements/rh-alert/rh-alert.css index 67e8a8bff6..6ffea56242 100644 --- a/elements/rh-alert/rh-alert.css +++ b/elements/rh-alert/rh-alert.css @@ -1,19 +1,67 @@ :host { - --_background-color: var(--rh-color-teal-10, #daf2f2); - --_border-color: var(--rh-color-teal-50, #37a3a3); - --_header-color: var(--rh-color-teal-70, #004d4d); - --_icon-color: var(--rh-color-teal-50, #37a3a3); - --_font-family: var(--rh-font-family-body-text, RedHatText, 'Red Hat Text', 'Noto Sans Arabic', 'Noto Sans Hebrew', 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans Malayalam', 'Noto Sans SC', 'Noto Sans TC', 'Noto Sans Thai', Helvetica, Arial, sans-serif); - display: block; max-width: var(--_max-width, initial); } -:host([hidden]) { - display: none; +header { + display: flex; + align-items: center; + justify-content: flex-start; +} + +.hasBody header { + margin-block-end: var(--rh-space-xs, 4px); +} + +header ::slotted(*) { + font-family: var(--_font-family) !important; + font-size: var(--rh-font-size-body-text-sm, 0.875rem) !important; + font-weight: var(--rh-font-weight-heading-bold, 700) !important; + margin: 0 !important; +} + +header ::slotted(:is(h1,h2,h3,h4,h5,h6)) { + padding-block: 2px var(--rh-space-xs, 4px) !important; /* 2px is a non standard value */ +} + +footer.hasActions { + margin-block-start: var(--rh-space-lg, 16px); +} + +footer ::slotted([slot='actions']:not(rh-button[variant='link' i])) { + margin-inline-end: var(--rh-space-xl, 24px) !important; + padding: 0 !important; + border: none !important; + background-color: transparent !important; + color: var(--rh-color-interactive-primary-default) !important; + font-size: var(--rh-font-size-body-text-sm, 0.875rem) !important; + font-family: var(--_font-family) !important; +} + +/* TODO: separate focus and hover styles */ +footer ::slotted([slot='actions']:focus) { + text-decoration: underline !important; + color: var(--rh-color-interactive-primary-hover) !important; +} + +footer ::slotted([slot='actions']:hover) { + cursor: pointer !important; + text-decoration: underline !important; + color: var(--rh-color-interactive-primary-hover) !important; +} + +footer ::slotted(rh-button[variant='link' i]) { + display: inline-block; + translate: calc(-1 * var(--rh-space-lg, 16px)); } #container { + --_background-color: var(--rh-color-teal-10, #daf2f2); + --_border-color: var(--rh-color-teal-50, #37a3a3); + --_header-color: var(--rh-color-teal-70, #004d4d); + --_icon-color: var(--rh-color-teal-50, #37a3a3); + --_font-family: var(--rh-font-family-body-text, RedHatText, 'Red Hat Text', 'Noto Sans Arabic', 'Noto Sans Hebrew', 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans Malayalam', 'Noto Sans SC', 'Noto Sans TC', 'Noto Sans Thai', Helvetica, Arial, sans-serif); + border-width: var(--rh-border-width-md, 2px); border-style: solid; border-block-start-color: var(--_border-color); @@ -29,35 +77,53 @@ font-family: var(--_font-family); } -#left-column { - display: inline-block; - vertical-align: top; +#container.info { + --_border-color: var(--rh-color-status-note); + --_icon-color: var(--rh-color-icon-status-info); + --_header-color: var(--rh-color-status-note); + --_background-color: var(--rh-color-surface-status-info); } -#middle-column { - display: inline-block; - vertical-align: top; +#container.success { + --_border-color: var(--rh-color-status-success); + --_icon-color: var(--rh-color-icon-status-success); + --_header-color: var(--rh-color-status-success); + --_background-color: var(--rh-color-surface-status-success); } -header { - display: flex; - align-items: center; - justify-content: flex-start; +#container.warning { + --_border-color: var(--rh-color-status-warning); + --_icon-color: var(--rh-color-icon-status-warning); + --_header-color: var(--rh-color-status-warning); + --_background-color: var(--rh-color-surface-status-warning); } -.hasBody header { - margin-block-end: var(--rh-space-xs, 4px); +#container.danger { + --_border-color: var(--rh-color-status-danger); + --_icon-color: var(--rh-color-icon-status-danger); + --_header-color: var(--rh-color-status-danger); + --_background-color: var(--rh-color-surface-status-danger); } -header ::slotted(*) { - font-family: var(--_font-family) !important; - font-size: var(--rh-font-size-body-text-sm, 0.875rem) !important; - font-weight: var(--rh-font-weight-heading-bold, 700) !important; - margin: 0 !important; +#container.toast { + --_background-color: var(--rh-color-surface-lightest, #ffffff); + --_max-width: 550px; + --_box-shadow: var(--rh-box-shadow-lg, 0 6px 8px 2px rgba(21, 21, 21, 0.3)); } -header ::slotted(:is(h1,h2,h3,h4,h5,h6)) { - padding-block: 2px var(--rh-space-xs, 4px) !important; /* 2px is a non standard value */ +#container.alternate { + --_border-inline-color: var(--_border-color); + --_border-block-end-color: var(--_border-color); +} + +#left-column { + display: inline-block; + vertical-align: top; +} + +#middle-column { + display: inline-block; + vertical-align: top; } #header-actions { @@ -79,7 +145,7 @@ header ::slotted(:is(h1,h2,h3,h4,h5,h6)) { } #close-button { - color: var(--rh-color-text-secondary-on-light, #4d4d4d); + color: var(--rh-color-text-secondary); background-color: transparent; border: none; height: var(--rh-length-xl, 24px); @@ -88,7 +154,7 @@ header ::slotted(:is(h1,h2,h3,h4,h5,h6)) { } #close-button:hover { - color: var(--rh-color-text-primary-on-light, #151515); + color: var(--rh-color-text-primary); } #description { @@ -99,73 +165,3 @@ header ::slotted(:is(h1,h2,h3,h4,h5,h6)) { margin-block: 0 !important; padding: 0 !important; } - -footer.hasActions { - margin-block-start: var(--rh-space-lg, 16px); -} - -footer ::slotted([slot='actions']:not(rh-button[variant='link' i])) { - margin-inline-end: var(--rh-space-xl, 24px) !important; - padding: 0 !important; - border: none !important; - background-color: transparent !important; - color: var(--rh-color-interactive-primary-default-on-light, #0066cc) !important; - font-size: var(--rh-font-size-body-text-sm, 0.875rem) !important; - font-family: var(--_font-family) !important; -} - -/* TODO: separate focus and hover styles */ -footer ::slotted([slot='actions']:focus) { - text-decoration: underline !important; - color: var(--rh-color-interactive-primary-hover-on-light, #003366) !important; -} - -footer ::slotted([slot='actions']:hover) { - cursor: pointer !important; - text-decoration: underline !important; - color: var(--rh-color-interactive-primary-hover-on-light, #003366) !important; -} - -footer ::slotted(rh-button[variant='link' i]) { - display: inline-block; - translate: calc(-1 * var(--rh-space-lg, 16px)); -} - -:host([state='info' i]) { - --_border-color: var(--rh-color-blue-40, #4394e5); - --_icon-color: var(--rh-color-blue-40, #4394e5); - --_header-color: var(--rh-color-blue-70, #003366); - --_background-color: var(--rh-color-blue-10, #e0f0ff); -} - -:host([state='success' i]) { - --_border-color: var(--rh-color-green-60, #3d7317); - --_icon-color: var(--rh-color-green-60, #3d7317); - --_header-color: var(--rh-color-green-70, #204d00); - --_background-color: var(--rh-color-green-10, #e9f7df); -} - -:host([state='warning' i]) { - --_border-color: var(--rh-color-yellow-40, #dca614); - --_icon-color: var(--rh-color-yellow-40, #dca614); - --_header-color: var(--rh-color-yellow-70, #73480b); - --_background-color: var(--rh-color-yellow-10, #fff4cc); -} - -:host([state='danger' i]) { - --_border-color: #c9190b; /* WARNING: not a recognized token value */ - --_icon-color: #c9190b; /* WARNING: not a recognized token value */ - --_header-color: #7d1007; /* WARNING: not a recognized token value */ - --_background-color: var(--rh-color-red-10, #fce3e3); -} - -:host([variant='toast' i]) { - --_background-color: var(--rh-color-surface-lightest, #ffffff); - --_max-width: 550px; - --_box-shadow: var(--rh-box-shadow-lg, 0 6px 8px 2px rgba(21, 21, 21, 0.3)); -} - -:host([variant='alternate' i]) { - --_border-inline-color: var(--_border-color); - --_border-block-end-color: var(--_border-color); -} diff --git a/elements/rh-alert/rh-alert.ts b/elements/rh-alert/rh-alert.ts index fb5b869f45..d3874b381b 100644 --- a/elements/rh-alert/rh-alert.ts +++ b/elements/rh-alert/rh-alert.ts @@ -11,6 +11,7 @@ import '@rhds/elements/rh-surface/rh-surface.js'; import styles from './rh-alert.css'; import toastStyles from './rh-alert-toast-styles.css'; +import consumerStyles from '@rhds/tokens/css/color-context-consumer.css.js'; interface ToastOptions { id?: string; @@ -65,9 +66,7 @@ export class AlertCloseEvent extends Event { */ @customElement('rh-alert') export class RhAlert extends LitElement { - static readonly version = '{{version}}'; - - static readonly styles = [styles]; + static readonly styles = [styles, consumerStyles]; private static toaster: HTMLElement; @@ -189,9 +188,16 @@ export class RhAlert extends LitElement { render() { const hasActions = this.#slots.hasSlotted('actions'); const hasBody = this.#slots.hasSlotted(SlotController.default as unknown as string); + const { state, variant = '' } = this; return html` From eb95ea4077f8369431de3a17c18d2f3611c61153 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 10:05:34 +0300 Subject: [PATCH 06/29] fix(badge): context, styles doesn't implement status tokens, yet --- elements/rh-badge/rh-badge.css | 52 ++++++++++++++++------------------ elements/rh-badge/rh-badge.ts | 23 +++++++++++---- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/elements/rh-badge/rh-badge.css b/elements/rh-badge/rh-badge.css index d53a239471..c30fde3fca 100644 --- a/elements/rh-badge/rh-badge.css +++ b/elements/rh-badge/rh-badge.css @@ -1,46 +1,44 @@ -:host { - --_color: var(--rh-color-text-primary-on-light, #151515); - --_background-color: var(--rh-color-surface-lighter, #f2f2f2); - - aspect-ratio: var(--_aspect-ratio); +span { display: inline-flex; align-items: center; justify-content: center; position: relative; white-space: nowrap; text-align: center; - background-color: var(--_background-color); + aspect-ratio: var(--_aspect-ratio); + background-color: var(--rh-color-surface-lighter); border-radius: var(--rh-border-radius-pill, 64px); - color: var(--_color); + color: var(--rh-color-text-primary); + min-width: var(--_badge-size); font-size: var(--rh-font-size-body-text-xs, 0.75rem); font-weight: 700; line-height: var(--rh-line-height-body-text, 1.5); - min-width: var(--_badge-size, var(--rh-length-2xl, 32px)); - padding-left: var(--rh-space-md, 8px); - padding-right: var(--rh-space-md, 8px); + padding-inline: var(--rh-space-md, 8px); } -:host([state='info']) { - --_color: var(--rh-color-text-primary-on-dark, #ffffff); - --_background-color: var(--rh-color-accent-base-on-light, #0066cc); -} +.info { background-color: var(--rh-color-status-note); } +.success { background-color: var(--rh-color-status-success); } +.moderate { background-color: var(--rh-color-status-caution); } +.important { background-color: var(--rh-color-status-warning); } +.critical { background-color: var(--rh-color-status-danger); } -:host([state='success']) { - --_color: var(--rh-color-text-primary-on-dark, #ffffff); - --_background-color: var(--rh-color-green-60, #3d7317); -} +.info.on.light { color: var(--rh-color-text-primary-on-dark, #ffffff); } -:host([state='moderate']) { - --_color: var(--rh-color-text-primary-on-light, #151515); - --_background-color: var(--rh-color-yellow-40, #dca614); +:is(.info,.success,.moderate,.important,.critical).on.dark { + color: var(--rh-color-text-primary-on-light, #151515); } -:host([state='important']) { - --_color: var(--rh-color-text-primary-on-dark, #ffffff); - --_background-color: var(--rh-color-red-60, #a60000); +/* TODO: remove when adopting themable tokens */ + +/* +.on.moderate:is(.light, .dark) { + color: var(--rh-color-text-primary-on-light, #151515); } -:host([state='critical']) { - --_color: var(--rh-color-text-primary-on-dark, #ffffff); - --_background-color: var(--rh-color-red-60, #a60000); +.on.light.info, +.on.light.success, +.on.light.important, +.on.light.critical { + color: var(--rh-color-text-primary-on-dark, #ffffff); } +*/ diff --git a/elements/rh-badge/rh-badge.ts b/elements/rh-badge/rh-badge.ts index 5fb9d4b408..84787ec26b 100644 --- a/elements/rh-badge/rh-badge.ts +++ b/elements/rh-badge/rh-badge.ts @@ -1,6 +1,9 @@ import { LitElement, html } from 'lit'; import { customElement } from 'lit/decorators/custom-element.js'; import { property } from 'lit/decorators/property.js'; +import { classMap } from 'lit-html/directives/class-map.js'; + +import { colorContextConsumer } from '@rhds/elements/lib/context/color/consumer.js'; import styles from './rh-badge.css'; @@ -18,14 +21,19 @@ import styles from './rh-badge.css'; */ @customElement('rh-badge') export class RhBadge extends LitElement { - static readonly version = '{{version}}'; - static readonly styles = [styles]; + @colorContextConsumer() private on?: string; + /** * Denotes the state-of-affairs this badge represents */ - @property({ reflect: true }) state?: 'info' | 'success' | 'moderate' | 'important' | 'critical'; + @property({ reflect: true }) state?: + | 'info' + | 'success' + | 'moderate' + | 'important' + | 'critical'; /** * Sets a numeric value for a badge. @@ -42,13 +50,18 @@ export class RhBadge extends LitElement { @property({ reflect: true, type: Number }) threshold?: number; override render() { - const { threshold, number, textContent } = this; + const { threshold, number, textContent, on = '', state = '' } = this; const displayText = (threshold && number && (threshold < number)) ? `${threshold.toString()}+` : (number != null) ? number.toString() : textContent ?? ''; + return html` - ${displayText} + ${displayText} `; } } From 028b62404a7d63ffef86740c5e52cdeb872d929d Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 10:35:57 +0300 Subject: [PATCH 07/29] fix(button): disabled on dark does not add semantic tokens --- elements/rh-button/rh-button.css | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/elements/rh-button/rh-button.css b/elements/rh-button/rh-button.css index 7f0267be2c..ad221ab605 100644 --- a/elements/rh-button/rh-button.css +++ b/elements/rh-button/rh-button.css @@ -3,10 +3,6 @@ height: max-content; } -:host([hidden]) { - display: none !important; -} - [hidden] { display: none !important; } @@ -526,6 +522,11 @@ button[disabled] { --_color: var(--rh-color-text-secondary-on-light, #4d4d4d); --_background-color: var(--rh-color-surface-light, #e0e0e0); + + &.dark { + --_color: var(--rh-color-gray-40, #a3a3a3); + --_background-color: var(--rh-color-surface-dark, #383838); + } } :host(:disabled) button:after { From 71bdbcfee9d6e29f3d2e2c4a4f3cd84068c50f12 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 10:39:35 +0300 Subject: [PATCH 08/29] fix(blockquote): border style --- elements/rh-blockquote/rh-blockquote.css | 10 ++-------- elements/rh-blockquote/rh-blockquote.ts | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/elements/rh-blockquote/rh-blockquote.css b/elements/rh-blockquote/rh-blockquote.css index e79d11f8ea..7a93352e12 100644 --- a/elements/rh-blockquote/rh-blockquote.css +++ b/elements/rh-blockquote/rh-blockquote.css @@ -56,13 +56,7 @@ rh-icon { } } -:host([highlight]) { - --_border-width: 8px; - --_border-color: #43adaf; - --_border-style: solid; -} - -:host([highlight]) figure { - border-inline-start: var(--_border-width) var(--_border-style) var(--_border-color); +.highlight { + border-inline-start: var(--rh-length-md, 8px) solid var(--rh-color-accent-brand); padding-inline-start: var(--rh-length-xl, 24px); } diff --git a/elements/rh-blockquote/rh-blockquote.ts b/elements/rh-blockquote/rh-blockquote.ts index 136ba3887c..2b756a0863 100644 --- a/elements/rh-blockquote/rh-blockquote.ts +++ b/elements/rh-blockquote/rh-blockquote.ts @@ -54,9 +54,9 @@ export class RhBlockquote extends LitElement { @property({ reflect: true }) size: 'default' | 'large' = 'default'; render() { - const { on = '' } = this; + const { highlight, on = '' } = this; return html` -
+
From 2039074cf2379e3699587f1ae4907d5bac60ca2b Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 10:44:57 +0300 Subject: [PATCH 09/29] fix(health-index): border colors --- .../rh-health-index/demo/color-context.html | 17 +++++++---------- elements/rh-health-index/rh-health-index.css | 6 +----- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/elements/rh-health-index/demo/color-context.html b/elements/rh-health-index/demo/color-context.html index 7ec85e1571..313892a21d 100644 --- a/elements/rh-health-index/demo/color-context.html +++ b/elements/rh-health-index/demo/color-context.html @@ -18,7 +18,6 @@

Default

E
F
-
  • LG

    A
    @@ -28,7 +27,6 @@

    LG

    E
    F
  • -
  • XL

    A
    @@ -48,7 +46,7 @@

    XL

    \ No newline at end of file + } + diff --git a/elements/rh-health-index/rh-health-index.css b/elements/rh-health-index/rh-health-index.css index 1d8bfddda2..8528649f2f 100644 --- a/elements/rh-health-index/rh-health-index.css +++ b/elements/rh-health-index/rh-health-index.css @@ -23,7 +23,7 @@ --_color-text-inactive: var(--rh-color-gray-70, #383838); --_color-text: var(--_color-text-inactive); --_color-fill: var(--rh-color-surface-lightest, #ffffff); - --_color-border: var(--rh-color-border-subtle-on-light, #c7c7c7); + --_color-border: var(--rh-color-border-subtle); } #grade { @@ -198,10 +198,6 @@ * Dark Color Theme *****************************************************************************/ -#container.dark { - --_color-border: var(--rh-color-border-subtle-on-dark, #707070); -} - #container.dark .box { --_color-text-active: var(--rh-color-white, #ffffff); --_color-fill: var(--rh-color-surface-darkest, #151515); From bd6f03a58d5ad859b2546bb4327066f22ebfc317 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 10:58:09 +0300 Subject: [PATCH 10/29] fix(tabs): context in panel --- elements/rh-tabs/rh-tab-panel.ts | 4 +--- elements/rh-tabs/rh-tab.ts | 2 -- elements/rh-tabs/rh-tabs.ts | 19 ++++--------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/elements/rh-tabs/rh-tab-panel.ts b/elements/rh-tabs/rh-tab-panel.ts index 2bdec511ab..7abdd8bb51 100644 --- a/elements/rh-tabs/rh-tab-panel.ts +++ b/elements/rh-tabs/rh-tab-panel.ts @@ -16,8 +16,6 @@ import styles from './rh-tab-panel.css'; */ @customElement('rh-tab-panel') export class RhTabPanel extends LitElement { - static readonly version = '{{version}}'; - static readonly styles = [styles]; /** @@ -48,7 +46,7 @@ export class RhTabPanel extends LitElement { render() { const { on = '' } = this; return html` -
    +
    `; diff --git a/elements/rh-tabs/rh-tab.ts b/elements/rh-tabs/rh-tab.ts index ea0b7fafef..208e05ca40 100644 --- a/elements/rh-tabs/rh-tab.ts +++ b/elements/rh-tabs/rh-tab.ts @@ -44,8 +44,6 @@ export class TabExpandEvent extends Event { */ @customElement('rh-tab') export class RhTab extends LitElement { - static readonly version = '{{version}}'; - static readonly styles = [styles]; /** True when the tab is selected */ diff --git a/elements/rh-tabs/rh-tabs.ts b/elements/rh-tabs/rh-tabs.ts index 6e82005077..5f5b895aa3 100644 --- a/elements/rh-tabs/rh-tabs.ts +++ b/elements/rh-tabs/rh-tabs.ts @@ -83,30 +83,19 @@ export class RhTabs extends LitElement { @property({ attribute: false }) activeTab?: RhTab; - /** - * Sets color theme based on parent context - */ @colorContextConsumer() private on?: ColorTheme; - /** - * Sets color context for child components, overrides parent context - */ + /** Sets color context for child components, overrides parent context */ @colorContextProvider() @property({ reflect: true, attribute: 'color-palette' }) colorPalette?: ColorPalette; - /** - * Aligns tabs to the center - */ + /** Aligns tabs to the center */ @property({ reflect: true, type: Boolean }) centered? = false; - /** - * Sets tabs to a boxed style with or without an inset - */ + /** Sets tabs to a boxed style with or without an inset */ @property({ reflect: true }) box?: 'box' | 'inset'; - /** - * Sets the alignment of the tabs vertical - */ + /** Sets the alignment of the tabs vertical */ @property({ reflect: true, type: Boolean }) vertical = false; @query('[part="tabs"]') private tabList!: HTMLElement; From 0152ee3772b8f73c2454b10656fb9428dad10871 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 11:15:57 +0300 Subject: [PATCH 11/29] docs(tabs): links in demo --- elements/rh-tabs/demo/color-context.html | 14 ++++++++++++++ elements/rh-tabs/demo/long-tab-content.html | 16 +++++++++++++++- elements/rh-tabs/demo/nested.html | 13 +++++++++++++ elements/rh-tabs/demo/rh-tabs.html | 16 ++++++++++++++++ elements/rh-tabs/demo/right-to-left.html | 16 ++++++++++++++++ elements/rh-tabs/demo/vertical.html | 16 ++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) diff --git a/elements/rh-tabs/demo/color-context.html b/elements/rh-tabs/demo/color-context.html index 6fb18c5e19..2b1a0df340 100644 --- a/elements/rh-tabs/demo/color-context.html +++ b/elements/rh-tabs/demo/color-context.html @@ -71,3 +71,17 @@ }); + diff --git a/elements/rh-tabs/demo/long-tab-content.html b/elements/rh-tabs/demo/long-tab-content.html index 7e64c3319d..a8ecb5a0a2 100644 --- a/elements/rh-tabs/demo/long-tab-content.html +++ b/elements/rh-tabs/demo/long-tab-content.html @@ -24,7 +24,21 @@ Cloud - + + diff --git a/elements/rh-tabs/demo/nested.html b/elements/rh-tabs/demo/nested.html index 39a8fc124c..cdd7f678be 100644 --- a/elements/rh-tabs/demo/nested.html +++ b/elements/rh-tabs/demo/nested.html @@ -28,6 +28,19 @@ rh-tab-panel { padding: 0; } + + a { + color: var(--rh-color-interactive-primary-default); + &:hover { color: var(--rh-color-interactive-primary-hover); } + &:focus-within { color: var(--rh-color-interactive-primary-focus); } + &:active { color: var(--rh-color-interactive-primary-active); } + &:visited { + color: var(--rh-color-interactive-primary-visited); + &:hover { color: var(--rh-color-interactive-primary-visited-hover); } + &:focus-within { color: var(--rh-color-interactive-primary-visited-focus); } + &:active { color: var(--rh-color-interactive-primary-visited-active); } + } + } + + + diff --git a/elements/rh-tabs/demo/right-to-left.html b/elements/rh-tabs/demo/right-to-left.html index 56a96e4411..fbfdb0a50c 100644 --- a/elements/rh-tabs/demo/right-to-left.html +++ b/elements/rh-tabs/demo/right-to-left.html @@ -90,3 +90,19 @@ + + + diff --git a/elements/rh-tabs/demo/vertical.html b/elements/rh-tabs/demo/vertical.html index c2cf351497..ac77cbe3cf 100644 --- a/elements/rh-tabs/demo/vertical.html +++ b/elements/rh-tabs/demo/vertical.html @@ -14,3 +14,19 @@ + + + From 1848ec6a95b6585d6e9d9f87356696bc516906b8 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 11:25:09 +0300 Subject: [PATCH 12/29] fix(icon): container size --- elements/rh-icon/rh-icon.css | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/elements/rh-icon/rh-icon.css b/elements/rh-icon/rh-icon.css index 0ec4afabee..44d42ef549 100644 --- a/elements/rh-icon/rh-icon.css +++ b/elements/rh-icon/rh-icon.css @@ -1,12 +1,18 @@ :host { - display: inline-block; line-height: 0; + aspect-ratio: 1/1; + display: inline-flex; + place-content: center; +} + +#container { + display: contents; } svg { width: var(--rh-icon-size, var(--rh-size-icon-01, 16px)); fill: currentcolor; - aspect-ratio: 1; + aspect-ratio: 1/1; } .standard svg { From 968e938f0c7c4385a25faaa522b262411b244bec Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 11:53:16 +0300 Subject: [PATCH 13/29] fix(badge): tests and backgrounds --- elements/rh-badge/rh-badge.css | 28 +++--------- elements/rh-badge/test/rh-badge.spec.ts | 59 +++++++++++++++++-------- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/elements/rh-badge/rh-badge.css b/elements/rh-badge/rh-badge.css index c30fde3fca..ca5a4c6d0e 100644 --- a/elements/rh-badge/rh-badge.css +++ b/elements/rh-badge/rh-badge.css @@ -6,7 +6,7 @@ span { white-space: nowrap; text-align: center; aspect-ratio: var(--_aspect-ratio); - background-color: var(--rh-color-surface-lighter); + background-color: var(--rh-color-surface-lighter, #f2f2f2); border-radius: var(--rh-border-radius-pill, 64px); color: var(--rh-color-text-primary); min-width: var(--_badge-size); @@ -16,29 +16,15 @@ span { padding-inline: var(--rh-space-md, 8px); } -.info { background-color: var(--rh-color-status-note); } -.success { background-color: var(--rh-color-status-success); } -.moderate { background-color: var(--rh-color-status-caution); } -.important { background-color: var(--rh-color-status-warning); } -.critical { background-color: var(--rh-color-status-danger); } +.on.dark { background-color: var(--rh-color-surface-darker, #1f1f1f); } +.on.info { background-color: var(--rh-color-status-note); } +.on.success { background-color: var(--rh-color-status-success); } +.on.moderate { background-color: var(--rh-color-status-caution); } +.on.important { background-color: var(--rh-color-status-warning); } +.on.critical { background-color: var(--rh-color-status-danger); } .info.on.light { color: var(--rh-color-text-primary-on-dark, #ffffff); } :is(.info,.success,.moderate,.important,.critical).on.dark { color: var(--rh-color-text-primary-on-light, #151515); } - -/* TODO: remove when adopting themable tokens */ - -/* -.on.moderate:is(.light, .dark) { - color: var(--rh-color-text-primary-on-light, #151515); -} - -.on.light.info, -.on.light.success, -.on.light.important, -.on.light.critical { - color: var(--rh-color-text-primary-on-dark, #ffffff); -} -*/ diff --git a/elements/rh-badge/test/rh-badge.spec.ts b/elements/rh-badge/test/rh-badge.spec.ts index bd08e72477..6d7704e7c5 100644 --- a/elements/rh-badge/test/rh-badge.spec.ts +++ b/elements/rh-badge/test/rh-badge.spec.ts @@ -1,8 +1,8 @@ import { tokens } from '@rhds/tokens'; import { expect, html } from '@open-wc/testing'; import { createFixture } from '@patternfly/pfe-tools/test/create-fixture.js'; -import { hexToRgb, getColor } from '@patternfly/pfe-tools/test/hex-to-rgb.js'; import { RhBadge } from '@rhds/elements/rh-badge/rh-badge.js'; +import { RhSurface } from '@rhds/elements/rh-surface/rh-surface.js'; describe('', function() { it('should upgrade', async function() { @@ -13,11 +13,18 @@ describe('', function() { .and .to.be.an.instanceOf(RhBadge); }); + it(`should have a background color '--rh-color-surface-lighter' when state is unset`, async function() { + const element = await createFixture (html``); + // NB: querying shadow root in tests is bad, mmkay? + const styles = getComputedStyle(element.shadowRoot!.querySelector('.on')!); + expect(styles.backgroundColor).to.be.colored(tokens.get('--rh-color-surface-lighter')!); + }); }); it('should have a pill shape and padding on left and right only', async function() { const element = await createFixture(html``); - const elStyles = getComputedStyle(element); + // NB: querying shadow root in tests is bad, mmkay? + const elStyles = getComputedStyle(element.shadowRoot!.querySelector('.on')!); expect(elStyles.getPropertyValue('border-radius')).to.equal('64px'); expect(elStyles.getPropertyValue('padding-top')).to.equal('0px'); @@ -26,22 +33,38 @@ it('should have a pill shape and padding on left and right only', async function expect(elStyles.getPropertyValue('padding-left')).to.equal('8px'); }); -for (const [state, color] of Object.entries({ - default: tokens.get('--rh-color-surface-lighter'), - info: tokens.get('--rh-color-interactive-blue-darker'), - success: tokens.get('--rh-color-green-60'), - moderate: tokens.get('--rh-color-yellow-40'), - important: tokens.get('--rh-color-red-60'), - critical: tokens.get('--rh-color-red-60'), +for (const [state, token] of Object.entries({ + info: '--rh-color-status-note-on-light', + success: '--rh-color-status-success-on-light', + moderate: '--rh-color-status-caution-on-light', + important: '--rh-color-status-warning-on-light', + critical: '--rh-color-status-danger-on-light', })) { - it(`should have a background color of '${color}' when state is ${state}`, async function() { - const el = await createFixture(html``); - - if (state !== 'default') { - el.setAttribute('state', state); - } - - const [r, g, b] = getColor(el, 'background-color'); - expect([r, g, b]).to.deep.equal(hexToRgb(color)); + describe(`state="${state}"`, function() { + let element: RhBadge; + let styles: CSSStyleDeclaration; + beforeEach(async function() { + element = await createFixture(html` + + `); + }); + beforeEach(async function() { + // NB: querying shadow root in tests is bad, mmkay? + styles = getComputedStyle(element.shadowRoot!.querySelector('.on')!); + }); + it(`should have a background color '${token}'`, async function() { + expect(styles.backgroundColor).to.be.colored(tokens.get(token)!); + }); + describe('on a dark background', function() { + const darkToken = token.replace('on-light', 'on-dark'); + beforeEach(async function() { + await createFixture(html` + ${element} + `); + }); + it(`should have a background color '${darkToken}'`, async function() { + expect(styles.backgroundColor).to.be.colored(tokens.get(darkToken)!); + }); + }); }); } From bb369486e5178aa6b064b7e5f93991b5ff958f48 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 16:29:50 +0300 Subject: [PATCH 14/29] docs(card): links --- elements/rh-card/docs/20-guidelines.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/elements/rh-card/docs/20-guidelines.md b/elements/rh-card/docs/20-guidelines.md index 0c5e506c7b..31502a5c1f 100644 --- a/elements/rh-card/docs/20-guidelines.md +++ b/elements/rh-card/docs/20-guidelines.md @@ -167,7 +167,7 @@ Cards have the potential to contain lots of content, like a combination of text, links, images, multimedia, etc. Ensure content serves the use case, but keep things simple at the same time. Don’t use too much content in one card, distribute extra content to other cards or somewhere else on the page. A -[Sticky card]({{ '/patterns/sticky-card/' | url }}) is a kind of card that can +[Sticky card](/patterns/sticky-card/) is a kind of card that can contain similar content, but it sticks to the side of a page and it’s always present until a user dismisses it. @@ -213,7 +213,7 @@ content. For example, grouping a basic card with a pricing card will look bad because they’re not very similar. - Grouping of a card + Grouping of a card These cards can be grouped together because they have similar styles and @@ -228,12 +228,12 @@ maximum width of six columns. ### Other components Cards can include complex components if necessary. For example, the -[Filter]({{ '/patterns/filter/' | url }}) pattern requires an Accordion or a -[Disclosure]({{ '/patterns/disclosure/' | url }}) to sort a content set. Don't +[Filter](/patterns/filter/) pattern requires an Accordion or a +[Disclosure](/patterns/disclosure/) to sort a content set. Don't place any other complex components in card layouts. - Alternative card usage + Alternative card usage ## Best practices @@ -242,21 +242,21 @@ The minimum width of a card in any layout is four columns and the maximum number of cards that can be used in a row is three. - Too many cards + Too many cards Don’t use a primary call to action in any card unless the primary action of a page is positioned inside of that card. - Card width error + Card width error Don’t use multiple calls to action in one card. Instead, distribute them to other cards. - Multiple calls to action + Multiple calls to action ## Behavior @@ -269,7 +269,7 @@ determined by the tallest card. Don’t place inconsistent amounts of content in cards, as this will impact how scannable the group will appear to users. - Card height behavior + Card height behavior ### Interactivity @@ -279,7 +279,7 @@ elements inside should all be interactive. Otherwise, each interactive element should continue to be interactive, but not the card container. - Card interaction + Card interaction ## Interaction states From 947e69e7ca311e71720143662ba67fce77003673 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 16:32:08 +0300 Subject: [PATCH 15/29] docs(theming): backgrounds --- docs/theming/color-palettes.css | 15 ++- docs/theming/color-palettes.md | 191 +++++++++++++++++++------------- docs/theming/developers.md | 2 + 3 files changed, 129 insertions(+), 79 deletions(-) diff --git a/docs/theming/color-palettes.css b/docs/theming/color-palettes.css index bf335273a8..d45c3d7ff6 100644 --- a/docs/theming/color-palettes.css +++ b/docs/theming/color-palettes.css @@ -1,3 +1,7 @@ +.container > rh-alert { + width: 100%; +} + #elements-grid { &::part(example) { display: block; @@ -21,12 +25,21 @@ } } +.surface-grid, .tile-grid { display: grid; padding: 0; list-style-type: none; - grid-template-columns: 1fr 1fr 1fr; gap: var(--rh-space-sm); + grid-template-columns: 1fr 1fr 1fr; +} + +.surface-grid { + grid-template-columns: 1fr 1fr; +} + +.icon-card { + --rh-icon-size: var(--rh-size-icon-07); } .pullquote-card { diff --git a/docs/theming/color-palettes.md b/docs/theming/color-palettes.md index 6aecbda506..39e91b8027 100644 --- a/docs/theming/color-palettes.md +++ b/docs/theming/color-palettes.md @@ -37,13 +37,12 @@ less effort and greater cross-property consistency. ## What are color palettes -There are various color palettes within our design system. The palettes you will -use the most for the majority of your projects are the lightest and darkest -themes. +RHDS defines six color palettes They range from lightest to darkest, and those +are the two palettes you will use the most for the majority of your projects. - examples of several elements against a white surface + examples of several elements against a white surface {% uxdotPattern id="elements-grid", stacked=true %} @@ -56,10 +55,11 @@ themes. *HTML* and *CSS* system with some supporting JavaScript[^1]. The color palette system has two main parts: **providers** and **consumers**. Providers actively define a color palette, while consumers passively accept -their theme from the nearest provider ancestor. +their background color from the nearest provider ancestor. - HTML design systems help teams ship better digital experiences, faster. + HTML design systems help teams ship better digital experiences, + faster. Color palettes allow for the creation of different experiences using the same @@ -68,8 +68,8 @@ space, text, and more. Layouts, content, and imagery usually stay the same. ## Choosing a color palette -How you choose a color palette is based on content, user experience, and accessibility -needs. +How you choose a color palette is based on content, user experience, and +accessibility needs. ### Lightest color palette @@ -83,65 +83,32 @@ light elements and patterns have dark counterparts.

    Brand red and accessibility

    -

    Do not apply the Red Hat red color to text in dark environments - unless it meets WCAG 2.1 AA - requirements.

    -
    - -### Inline color palettes Beta -Inlining a color palette is when a section switches palette and looks different -than the rest of the page or interface. Some use cases include highlighting an -important section on a page or adding a sidebar to an interface. Use inline -theming only for major shifts in color. For minor shifts, use a different -surface color from the same theme. + Do not apply the Red Hat red color to text in dark environments unless it + meets [WCAG 2.1 AA][wcag21aa] requirements. - -

    Update from the team

    -

    The design system team is working on creating inline theming best - practices in the near future. Contact - us if you would like to contribute.

    - - wireframe of a dark theme section sandwiched by two light theme sections - - - - wireframe of cards in a dark theme section extending into a light theme section - - - - wireframe of dark theme navigation framing the top and left sides of a light theme content area - - ## Illustrations and imagery -Illustrations and imagery should align to the theme. The light theme should -feature imagery with light colors and vice versa. Imagery with high contrast is -only acceptable if it has a transparent background. If you cannot find -theme-specific imagery, contact the Brand team. - - -

    More information

    -

    High contrast is using bright elements, patterns, or images in dark -environments and vice versa. This is useful to focus attention or create -visual tension.

    -
    +Illustrations and imagery should align to the color palette. The light color +palette should feature imagery with light colors and vice versa. Imagery with +high contrast is only acceptable if it has a transparent background. If you +cannot find color-palette-specific imagery, contact the Brand team. Developers +have a number of [art-direction][artdirection] techniques at their disposal for +creating themable, responsive graphics. - correct uses of an illustration with a transparent background and one illustration incorrectly using a white background in a dark theme area -## Color theme consumers and theme tokens +## Color consumers and theme tokens ### Color palette providers + **Providers** define the **color palette** for themselves and their child -elements. There are six main color palettes: +elements. There are six color palettes in RHDS:
    1. Lightest
    2. @@ -153,27 +120,50 @@ elements. There are six main color palettes:
    Context providers typically use the `lightest` color palette as the default. -Authors may define the color palette of a container using the `color-palette` HTML -attribute. So for example, to create a card with the darkest color palette, use -this HTML: +Authors may define the color palette of a container using the `color-palette` +HTML attribute. So for example, to create a card with the darkest color palette, +use this HTML: {% uxdotPattern class="card-snippet-grid", fullHeight=true %} {% include './patterns/card-default-vs-set-palette.html' %} {% enduxdotPattern %} -### Color theme consumers -**Consumers**, which adopt a **color theme**. Color themes correspond to the -active color palette, and represent the quality of the background colour: - -1. light -1. dark - -Child elements which are providers will automatically adapt, applying their own -**color theme** as needed. Page authors *do not need to and should not customize* -colors of consumer elements. - -Color palette containers can be nested, such that child elements will always -adopt the color theme corresponding to the nearest container's palette. +A color palette provider is a **surface** on which a particular color palette is +active, as well as a **container** for themable consumer elements. + +### Color consumers + +Consumers are elements which automatically adapt to their background surface. +Color **Consumers** adopt a **background** color based on the palette of the +surface they are on. In other words, the background of a consumer corresponds to +the color palette of it's containing surface. There are two backgrounds in RHDS: + +
      +
    • + + + Light + +
    • + +
    • + + + Dark +
    • +
    + +These backgrounds don't represent a specific colour, but rather they indicate +whether the background is light or dark. This is so things like icons, text, +and border colours can be chosen which will contrast enough with the background +to remain legible. In other words, the background is the *color context* in +which a consumer finds itself. + +Page authors *do not need to and should not customize* colors of + consumer elements, but instead should set custom values for [theme + tokens][theming]. Color palette containers can be nested, such that child + elements will always adopt the color theme corresponding to the nearest + container's palette. Extending our card example from above, if our page author then adds an `` to the card, it will *automatically* adopt the dark color theme. The @@ -184,23 +174,68 @@ page author need not and should not customize the CTA. {% enduxdotPattern %} - - Color palettes lets authors write more HTML, simpler CSS, and less JavaScript - + Color palettes lets authors write more HTML, simpler CSS, and + less JavaScript -To summarize: color providers can have one of up to six palettes, three dark and -three light, and they provide a `dark` or `light` theme to their children. +To summarize: color providers can adopt one six palettes, three dark and +three light, and they provide a `dark` or `light` background to their children. ## Combination elements + Some elements are both providers and consumers. Card, for example is both a -provider and a consumer. It can accept the color theme of its parent context and it -can also set its own color palette. +provider and a consumer. It can accept the color theme of its parent context and +it can also set its own color palette. {% uxdotPattern class="card-snippet-grid", fullHeight=true %} {% include './patterns/card-consumer-provider.html' %} {% enduxdotPattern %} +## Inline color palettes Beta + +Inlining a color palette is when a section switches palette and looks different +than the rest of the page or interface. Some use cases include highlighting an +important section on a page or adding a sidebar to an interface. Use inline +palettes only for major shifts in color. For minor shifts, use a related color +palette, e.g. from `lightest` to `light`. + + +

    Update from the team

    + + The design system team is working on creating inline color palette best + practices in the near future. [Contact us][contact] if you would like to + contribute. + +
    + + + wireframe of a dark palette section sandwiched by two light palette sections + + + + wireframe of cards in a dark palette section extending into a light palette section + + + + wireframe of dark palette navigation framing the top and left sides of a light palette content area + + + +

    More information

    +

    High contrast is using bright elements, patterns, or images in dark +environments and vice versa. This is useful to focus attention or create +visual tension.

    +
    + {% include 'partials/component/feedback.html' %} -[^1]: As the web platform [improves](https://results.web-platform-tests.org/results/css/css-values/attr-container-style-query.html?label=experimental&label=master&aligned), the RHDS authors expect that eventually no JavaScript will be required for this feature. +[^1]: As the web platform [improves][wpt], the RHDS authors expect that eventually no JavaScript will be required for this feature. + +[wpt]: https://results.web-platform-tests.org/results/css/css-values/attr-container-style-query.html?label=experimental&label=master&aligned +[contact]: https://github.com/RedHat-UX/red-hat-design-system/discussions +[artdirection]: /theming/developers/#art-direction +[theming]: /theming/customizing/ +[wcag21aa]: https://www.w3.org/WAI/WCAG21/Understanding/ diff --git a/docs/theming/developers.md b/docs/theming/developers.md index f4ecf3f00b..b1faeb6af6 100644 --- a/docs/theming/developers.md +++ b/docs/theming/developers.md @@ -2,3 +2,5 @@ title: Developers order: 4 --- + +- From eff824466332a1b4c9f0cfb172c1af0379db87a5 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 18:13:10 +0300 Subject: [PATCH 16/29] docs(theming): stub for developer --- docs/theming/developers.md | 57 +++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/docs/theming/developers.md b/docs/theming/developers.md index b1faeb6af6..79f1df94cd 100644 --- a/docs/theming/developers.md +++ b/docs/theming/developers.md @@ -3,4 +3,59 @@ title: Developers order: 4 --- -- +## Context Protocol + +## Style Queries + +Your page markup declares a custom surface: + +```html +
    + GO! +
    +``` + +And your document css sets the desired color context: + +```css +.custom-surface { + container: surface; + & .dark { --rh-background-context: dark; } + & .light { --rh-background-context: light; } +} +``` + +Internally / in shared CSS: + +```css +@container style (--rh-context-background: dark) { + --rh-color-text-primary: var(--rh-color-text-primary-on-dark) +} +``` + +## Art Direction + +Art direction is the process of + +### Inline SVG + +```html + + + +``` + +### `` Planned + +```html + + + Logo for Red Hat partner Google Cloud + +``` From 444abc8e85a998e8e837cc8e38c0882cd737c863 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 18:18:26 +0300 Subject: [PATCH 17/29] docs: deps --- docs/theming/developers.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/theming/developers.md b/docs/theming/developers.md index 79f1df94cd..a386c8feb9 100644 --- a/docs/theming/developers.md +++ b/docs/theming/developers.md @@ -3,6 +3,31 @@ title: Developers order: 4 --- + + + + + + ## Context Protocol ## Style Queries From 55e3a22bf2f4b03e305ce08ff17186062ffcdf6e Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 11 Sep 2024 18:23:05 +0300 Subject: [PATCH 18/29] docs: more prose --- docs/theming/developers.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/theming/developers.md b/docs/theming/developers.md index a386c8feb9..23fe175374 100644 --- a/docs/theming/developers.md +++ b/docs/theming/developers.md @@ -45,8 +45,8 @@ And your document css sets the desired color context: ```css .custom-surface { container: surface; - & .dark { --rh-background-context: dark; } - & .light { --rh-background-context: light; } + &.dark { --rh-background-context: dark; } + &.light { --rh-background-context: light; } } ``` @@ -60,10 +60,13 @@ Internally / in shared CSS: ## Art Direction -Art direction is the process of +Art direction is the process of selecting art assets based on the context in +which they are used. ### Inline SVG +Page authors using _inline SVG_ can use theme tokens to style graphics. + ```html ``` +This approach _does not work_ with svg loaded through the `` tag, or with +raster graphics, however another approach is in development which could help: + ### `` Planned ```html @@ -84,3 +90,5 @@ Art direction is the process of Logo for Red Hat partner Google Cloud ``` + +Join the [discussion](https://github.com/orgs/RedHat-UX/discussions/1780) From 2033705fad460712a221efafbd640f3a4fee5db8 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Thu, 12 Sep 2024 13:09:45 +0300 Subject: [PATCH 19/29] feat(tag): context, compact, href, desaturated Closes #1843 --- .changeset/heavy-roses-poke.md | 4 + .changeset/rotten-bottles-suffer.md | 8 + .changeset/seven-bats-grin.md | 8 + .changeset/wild-apples-enjoy.md | 9 + elements/rh-tag/demo/color-context.html | 540 ++++++++++++++++-- .../rh-tag/demo/desaturated-with-icon.html | 11 + elements/rh-tag/demo/desaturated.html | 11 + .../rh-tag/demo/filled-color-with-icon.html | 16 +- elements/rh-tag/demo/filled-color.html | 6 +- elements/rh-tag/demo/outline-with-icon.html | 24 +- elements/rh-tag/demo/outline.html | 2 +- elements/rh-tag/rh-tag.css | 326 ++++++++--- elements/rh-tag/rh-tag.ts | 38 +- 13 files changed, 833 insertions(+), 170 deletions(-) create mode 100644 .changeset/heavy-roses-poke.md create mode 100644 .changeset/rotten-bottles-suffer.md create mode 100644 .changeset/seven-bats-grin.md create mode 100644 .changeset/wild-apples-enjoy.md create mode 100644 elements/rh-tag/demo/desaturated-with-icon.html create mode 100644 elements/rh-tag/demo/desaturated.html diff --git a/.changeset/heavy-roses-poke.md b/.changeset/heavy-roses-poke.md new file mode 100644 index 0000000000..3a8a3690b8 --- /dev/null +++ b/.changeset/heavy-roses-poke.md @@ -0,0 +1,4 @@ +--- +"@rhds/elements": minor +--- +`` added `red-orange`, `yellow`, and `teal` colors. **NOTE** that `cyan` is now deprecated, but will continue to work using the `teal` colors. diff --git a/.changeset/rotten-bottles-suffer.md b/.changeset/rotten-bottles-suffer.md new file mode 100644 index 0000000000..294007c677 --- /dev/null +++ b/.changeset/rotten-bottles-suffer.md @@ -0,0 +1,8 @@ +--- +"@rhds/elements": minor +--- +``: added desaturated variant: + +```html +New +``` diff --git a/.changeset/seven-bats-grin.md b/.changeset/seven-bats-grin.md new file mode 100644 index 0000000000..d3a7c2ac21 --- /dev/null +++ b/.changeset/seven-bats-grin.md @@ -0,0 +1,8 @@ +--- +"@rhds/elements": minor +--- +``: added `size` attribute. + +```html +New +``` diff --git a/.changeset/wild-apples-enjoy.md b/.changeset/wild-apples-enjoy.md new file mode 100644 index 0000000000..571b66f43f --- /dev/null +++ b/.changeset/wild-apples-enjoy.md @@ -0,0 +1,9 @@ +--- +"@rhds/elements": minor +--- +``: added `href` attribute + +```html +Info +``` diff --git a/elements/rh-tag/demo/color-context.html b/elements/rh-tag/demo/color-context.html index c420426cf8..00106498ef 100644 --- a/elements/rh-tag/demo/color-context.html +++ b/elements/rh-tag/demo/color-context.html @@ -1,65 +1,495 @@ -

    Filled Color

    - Red - Orange - Green - Cyan - Blue - Purple - Gray - - -

    Outline

    - Red - Orange - Green - Cyan - Blue - Purple - Gray - - -

    Filled Color With Icon

    - Red - Orange - - Green - - - Cyan - Blue - - Purple - - - Gray +
    +
    Filled
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    +
    Filled with icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    -

    Filled Color With Icon

    - Red - Orange - - Green - - - Cyan - Blue - - Purple -
    Filled with slotted icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Filled with link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Filled with icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Filled with slotted icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Outline
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Outlined with icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Outlined with slotted icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Outline with link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Outlined with icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Outlined with slotted icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Desaturated
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Desaturated with icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Desaturated with slotted icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Desaturated with link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Desaturated with icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Desaturated with slotted icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + + +
    Compact filled
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact filled with icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact filled with slotted icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact filled with link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact filled with icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact filled with slotted icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact outline
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact outlined with icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact outlined with slotted icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact outline with link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact outlined with icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact outlined with slotted icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact desaturated
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact desaturated with icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact desaturated with slotted icon
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact desaturated with link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact desaturated with icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    + +
    Compact desaturated with slotted icon and link
    +
    + Red + Red Orange + Orange + Yellow + Green + Teal + Blue + Purple + Gray +
    +
    +
    + +
    - Gray - + + + + +} diff --git a/elements/rh-tag/demo/desaturated-with-icon.html b/elements/rh-tag/demo/desaturated-with-icon.html new file mode 100644 index 0000000000..e56385ce52 --- /dev/null +++ b/elements/rh-tag/demo/desaturated-with-icon.html @@ -0,0 +1,11 @@ +Red +Orange +Green +Cyan +Blue +Purple +Gray + + diff --git a/elements/rh-tag/demo/desaturated.html b/elements/rh-tag/demo/desaturated.html new file mode 100644 index 0000000000..0317a7ad85 --- /dev/null +++ b/elements/rh-tag/demo/desaturated.html @@ -0,0 +1,11 @@ +Red +Orange +Green +Cyan +Blue +Purple +Gray + + diff --git a/elements/rh-tag/demo/filled-color-with-icon.html b/elements/rh-tag/demo/filled-color-with-icon.html index 50acce570e..52f02d0ea5 100644 --- a/elements/rh-tag/demo/filled-color-with-icon.html +++ b/elements/rh-tag/demo/filled-color-with-icon.html @@ -1,10 +1,12 @@ -Red -Orange -Green -Cyan -Blue -Purple -Gray +Red +Red Orange +Orange +Yellow +Green +Teal +Blue +Purple +Gray diff --git a/elements/rh-tag/demo/outline-with-slotted-icon.html b/elements/rh-tag/demo/outline-with-slotted-icon.html new file mode 100644 index 0000000000..b5a9b9705a --- /dev/null +++ b/elements/rh-tag/demo/outline-with-slotted-icon.html @@ -0,0 +1,23 @@ +Red +Red Orange +Orange +Yellow +Green +Teal +Blue +Purple +Gray + + + + From 4bd4931edd17743eff6f7dbbccbb234851361fa8 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Sun, 15 Sep 2024 10:41:59 +0300 Subject: [PATCH 27/29] fix(blockquote): on --- elements/rh-blockquote/rh-blockquote.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elements/rh-blockquote/rh-blockquote.ts b/elements/rh-blockquote/rh-blockquote.ts index cbeb9da38b..566c3deb14 100644 --- a/elements/rh-blockquote/rh-blockquote.ts +++ b/elements/rh-blockquote/rh-blockquote.ts @@ -54,7 +54,7 @@ export class RhBlockquote extends LitElement { @property({ reflect: true }) size: 'default' | 'large' = 'default'; render() { - const { highlight, on = 'lightest' } = this; + const { highlight, on = 'light' } = this; return html`
    From 8e4cea509dec77efef7d020544616a9cc645ff83 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Sun, 15 Sep 2024 11:23:49 +0300 Subject: [PATCH 28/29] fix(accordion): drop shadow also refactors expand/collapse code --- elements/rh-accordion/context.ts | 2 + elements/rh-accordion/rh-accordion.css | 5 +- elements/rh-accordion/rh-accordion.ts | 146 ++++++++++++------------- 3 files changed, 76 insertions(+), 77 deletions(-) diff --git a/elements/rh-accordion/context.ts b/elements/rh-accordion/context.ts index 64dd3ac94c..b6adb2d80e 100644 --- a/elements/rh-accordion/context.ts +++ b/elements/rh-accordion/context.ts @@ -3,6 +3,8 @@ import { createContextWithRoot } from '@patternfly/pfe-core/functions/context.js export interface RhAccordionContext { accents?: 'inline' | 'bottom'; large: boolean; + /** if this accordion has at least one expanded panel */ + expanded: boolean; } export const context = createContextWithRoot(Symbol('rh-accordion-context')); diff --git a/elements/rh-accordion/rh-accordion.css b/elements/rh-accordion/rh-accordion.css index b8f1300f3c..2eb688c1de 100644 --- a/elements/rh-accordion/rh-accordion.css +++ b/elements/rh-accordion/rh-accordion.css @@ -1,6 +1,10 @@ #container { color: var(--rh-color-text-primary); background-color: var(--rh-color-surface); + + &.expanded { + box-shadow: var(--rh-box-shadow-sm, 0 2px 4px 0 rgba(21, 21, 21, 0.2)); + } } ::slotted(rh-accordion-header:first-child) { @@ -16,7 +20,6 @@ ::slotted(rh-accordion-header:is([expanded])) { display: block; border-block-end: 0; - box-shadow: var(--rh-box-shadow-sm, 0 2px 4px 0 rgba(21, 21, 21, 0.2)); } ::slotted(rh-accordion-panel:is([expanded])) { diff --git a/elements/rh-accordion/rh-accordion.ts b/elements/rh-accordion/rh-accordion.ts index 9d1b9d6f22..b2db7b07f9 100644 --- a/elements/rh-accordion/rh-accordion.ts +++ b/elements/rh-accordion/rh-accordion.ts @@ -47,8 +47,6 @@ export class AccordionCollapseEvent extends ComposedEvent { */ @customElement('rh-accordion') export class RhAccordion extends LitElement { - static readonly version = '{{version}}'; - static readonly styles = [styles]; static isAccordion(target: EventTarget | null): target is RhAccordion { @@ -72,6 +70,25 @@ export class RhAccordion extends LitElement { */ @property({ attribute: true, reflect: true }) accents?: 'inline' | 'bottom'; + /** + * If this accordion uses large styles + */ + @property({ reflect: true, type: Boolean }) large = false; + + /** + * If this accordion has a border + */ + @property({ reflect: true, type: Boolean }) bordered = true; + + /** + * Color Palette for this accordion. + * @see https://ux.redhat.com/theming/color-palettes/ + */ + @colorContextProvider() + @property({ reflect: true, attribute: 'color-palette' }) colorPalette?: ColorPalette; + + @colorContextConsumer() private on?: ColorTheme; + /** * Sets and reflects the currently expanded accordion 0-based indexes. * Use commas to separate multiple indexes. @@ -81,34 +98,44 @@ export class RhAccordion extends LitElement { * * ``` */ - @property({ attribute: 'expanded-index', converter: NumberListConverter }) + @property({ + attribute: 'expanded-index', + converter: NumberListConverter, + hasChanged(value, old) { + return JSON.stringify(old) !== JSON.stringify(value); + }, + }) get expandedIndex() { return this.#expandedIndex; } set expandedIndex(value) { - const old = this.#expandedIndex; this.#expandedIndex = value; - if (JSON.stringify(old) !== JSON.stringify(value)) { - this.requestUpdate('expandedIndex', old); - this.collapseAll().then(async () => { - for (const i of this.expandedIndex) { - await this.expand(i, this); - } - }); - } + this.#expanded = !!this.#expandedIndex.length; + this.headers.forEach((header, i) => { + const expanded = this.#expandedIndexSet.has(i); + header.expanded = expanded; + const panel = this.panels[i]; + if (panel) { + panel.expanded = expanded; + panel.hidden = !expanded; + } + }); } - @property({ reflect: true, type: Boolean }) large = false; - - @property({ reflect: true, type: Boolean }) bordered = true; + /** All headers for this accordion */ + get headers() { + return this.#allHeaders(); + } - @colorContextProvider() - @property({ reflect: true, attribute: 'color-palette' }) colorPalette?: ColorPalette; + /** All panels for this accordion */ + get panels() { + return this.#allPanels(); + } - @colorContextConsumer() private on?: ColorTheme; + #expandedIndexSet = new Set(); - protected expandedSets = new Set(); + #expanded = false; #expandedIndex: number[] = []; @@ -123,31 +150,22 @@ export class RhAccordion extends LitElement { this.addEventListener('change', this.#onChange as EventListener); this.#mo.observe(this, { childList: true }); this.updateAccessibility(); - const { headers } = this; - headers.forEach((header, index) => { - if (header.expanded) { - this.#expandHeader(header, index); - const panel = this.#panelForHeader(header); - if (panel) { - this.#expandPanel(panel); - panel.hidden = !panel.expanded; - } - } - }); } override render(): TemplateResult { - const { on = '' } = this; + const { on = 'light' } = this; + const expanded = this.#expanded; return html` -
    +
    `; } protected override async getUpdateComplete(): Promise { const c = await super.getUpdateComplete(); const results = await Promise.all([ - ...this.#allHeaders().map(x => x.updateComplete), - ...this.#allPanels().map(x => x.updateComplete), + ...this.headers.map(x => x.updateComplete), + ...this.panels.map(x => x.updateComplete), ]); return c && results.every(Boolean); } @@ -155,13 +173,15 @@ export class RhAccordion extends LitElement { @observes('accents') @observes('large') @observes('bordered') + @observes('expandedIndex') private contextChanged() { this.ctx = this.#makeContext(); } #makeContext(): RhAccordionContext { const { accents = 'inline', large } = this; - return { accents, large }; + const expanded = this.#expanded; + return { accents, large, expanded }; } #panelForHeader(header: RhAccordionHeader) { @@ -173,35 +193,15 @@ export class RhAccordion extends LitElement { } } - #expandHeader(header: RhAccordionHeader, index = this.#getIndex(header)) { + #expand(index: number) { // If this index is not already listed in the expandedSets array, add it - this.expandedSets.add(index); - this.#expandedIndex = [...this.expandedSets as Set]; - header.expanded = true; - } - - #expandPanel(panel: RhAccordionPanel) { - panel.expanded = true; - panel.hidden = false; - } - - async #collapseHeader(header: RhAccordionHeader, index = this.#getIndex(header)) { - if (!this.expandedSets) { - await this.updateComplete; - } - this.expandedSets.delete(index); - header.expanded = false; - await header.updateComplete; + this.expandedIndex = [...this.#expandedIndexSet.add(index)]; } - async #collapsePanel(panel: RhAccordionPanel) { - await panel.updateComplete; - if (!panel.expanded) { - return; + #collapse(index: number) { + if (this.#expandedIndexSet.delete(index)) { + this.expandedIndex = [...this.#expandedIndexSet]; } - - panel.expanded = false; - panel.hidden = true; } #onChange(event: AccordionHeaderChangeEvent) { @@ -213,6 +213,7 @@ export class RhAccordion extends LitElement { this.collapse(index); } } + this.requestUpdate('expandedIndex'); } #allHeaders(accordion: RhAccordion = this): RhAccordionHeader[] { @@ -240,14 +241,6 @@ export class RhAccordion extends LitElement { return -1; } - get headers() { - return this.#allHeaders(); - } - - get panels() { - return this.#allPanels(); - } - /** * Initialize the accordion by connecting headers and panels * with aria controls and labels; set up the default disclosure @@ -302,8 +295,7 @@ export class RhAccordion extends LitElement { } // If the header and panel exist, open both - this.#expandHeader(header, index); - this.#expandPanel(panel); + this.#expand(index); header.focus(); @@ -316,8 +308,7 @@ export class RhAccordion extends LitElement { * Expands all accordion items. */ public async expandAll() { - this.headers.forEach(header => this.#expandHeader(header)); - this.panels.forEach(panel => this.#expandPanel(panel)); + this.headers.forEach((_, i) => this.#expand(i)); await this.updateComplete; } @@ -333,8 +324,7 @@ export class RhAccordion extends LitElement { return; } - this.#collapseHeader(header); - this.#collapsePanel(panel); + this.#collapse(index); this.dispatchEvent(new AccordionCollapseEvent(header, panel)); await this.updateComplete; @@ -344,8 +334,7 @@ export class RhAccordion extends LitElement { * Collapses all accordion items. */ public async collapseAll() { - this.headers.forEach(header => this.#collapseHeader(header)); - this.panels.forEach(panel => this.#collapsePanel(panel)); + this.headers.forEach((_, i) => this.#collapse(i)); await this.updateComplete; } } @@ -354,4 +343,9 @@ declare global { interface HTMLElementTagNameMap { 'rh-accordion': RhAccordion; } + + interface HTMLElementEventMap { + 'expand': AccordionExpandEvent; + 'collapse': AccordionCollapseEvent; + } } From b01acdca50ce8afac9d35fe717957e2adff5f739 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Sun, 15 Sep 2024 11:34:55 +0300 Subject: [PATCH 29/29] fix(alert): use rh-icon --- elements/rh-alert/demo/toast.html | 12 ++++++-- elements/rh-alert/rh-alert.ts | 48 ++++++++++++------------------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/elements/rh-alert/demo/toast.html b/elements/rh-alert/demo/toast.html index 2fecacae0e..338614767c 100644 --- a/elements/rh-alert/demo/toast.html +++ b/elements/rh-alert/demo/toast.html @@ -23,7 +23,7 @@

    Success

    Confirm - +

    Warning

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eleifend elit sed est egestas, a sollicitudin mauris tincidunt.

    @@ -31,13 +31,21 @@

    Warning

    Confirm
    - +

    Danger

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eleifend elit sed est egestas, a sollicitudin mauris tincidunt.

    Dismiss Confirm
    + + +

    Error

    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eleifend elit sed est + egestas, a sollicitudin mauris tincidunt.

    + Dismiss + Confirm +