Skip to content

Commit f66ba58

Browse files
committed
fix(cta): explicit color context support
1 parent 6883aa3 commit f66ba58

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

.changeset/stupid-humans-brake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@patternfly/pfe-cta": patch
3+
---
4+
5+
Add color context support via explicitly defined attributes. See https://github.com/patternfly/patternfly-elements/pull/1976

elements/pfe-cta/pfe-cta.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
import type { ColorPalette, ColorTheme } from '@patternfly/pfe-core';
2+
13
import { LitElement, html, svg } from 'lit';
24
import { customElement, property, state } from 'lit/decorators.js';
35

46
import { ComposedEvent } from '@patternfly/pfe-core';
5-
import { pfelement, bound, initializer } from '@patternfly/pfe-core/decorators.js';
67
import { deprecatedCustomEvent } from '@patternfly/pfe-core/functions/deprecatedCustomEvent.js';
78
import { Logger } from '@patternfly/pfe-core/controllers/logger.js';
9+
import {
10+
bound,
11+
colorContextConsumer,
12+
colorContextProvider,
13+
deprecation,
14+
initializer,
15+
pfelement,
16+
} from '@patternfly/pfe-core/decorators.js';
817

918
import style from './pfe-cta.scss';
1019

@@ -87,8 +96,23 @@ export class PfeCta extends LitElement {
8796
*/
8897
@property({ reflect: true }) priority?: 'primary'|'secondary';
8998

90-
/** Color */
91-
@property({ reflect: true }) color?: 'accent'|'base'|'complement'|'lightest';
99+
/**
100+
* Sets color palette, which affects the element's styles as well as descendants' color theme.
101+
* Overrides parent color context.
102+
* Your theme will influence these colors so check there first if you are seeing inconsistencies.
103+
* See [CSS Custom Properties](#css-custom-properties) for default values
104+
*/
105+
@colorContextProvider()
106+
@property({ reflect: true, attribute: 'color-palette' }) colorPalette?: ColorPalette;
107+
108+
/** @deprecated use `color-palette` */
109+
@deprecation({ alias: 'colorPalette', attribute: 'color' }) color?: ColorPalette;
110+
111+
/**
112+
* Sets color theme based on parent context
113+
*/
114+
@colorContextConsumer()
115+
@property({ reflect: true }) on?: ColorTheme;
92116

93117
/**
94118
* `priority="secondary"` has a `wind` variant (`variant="wind"`) that can be applied to change the style of the secondary call-to-action.

0 commit comments

Comments
 (0)