Skip to content

Commit 9b3ddad

Browse files
zeroedinbennypowers
authored andcommitted
fix(autocomplete): add color context provider and consumer
1 parent 46d9002 commit 9b3ddad

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

elements/pfe-autocomplete/pfe-autocomplete.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import type { DroplistSelectEvent, PfeSearchDroplist } from './pfe-search-dropli
33
import { LitElement, html } from 'lit';
44
import { customElement, property, state, query } from 'lit/decorators.js';
55

6+
import { ColorPalette, ColorTheme } from '@patternfly/pfe-core';
7+
68
import { ComposedEvent } from '@patternfly/pfe-core';
7-
import { pfelement, bound, observed } from '@patternfly/pfe-core/decorators.js';
9+
import { pfelement, bound, observed, colorContextConsumer, colorContextProvider, deprecation, } from '@patternfly/pfe-core/decorators.js';
810
import { deprecatedCustomEvent } from '@patternfly/pfe-core/functions/deprecatedCustomEvent.js';
911

12+
1013
import './pfe-search-droplist';
1114

15+
1216
import style from './pfe-autocomplete.scss';
1317

1418
export type AutocompleteRequestFunction =
@@ -109,6 +113,25 @@ export class PfeAutocomplete extends LitElement {
109113

110114
static readonly shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
111115

116+
/**
117+
* Sets color palette, which affects the element's styles as well as descendants' color theme.
118+
* Overrides parent color context.
119+
* Your theme will influence these colors so check there first if you are seeing inconsistencies.
120+
* See [Color](https://patternflyelements.org/theming/colors/) for default values
121+
*/
122+
@colorContextProvider()
123+
@property({ reflect: true, attribute: 'color-palette' }) colorPalette?: ColorPalette;
124+
125+
/** @deprecated use `color-palette` */
126+
@deprecation({ alias: 'colorPalette', attribute: 'color' }) color?: ColorPalette;
127+
128+
/**
129+
* Sets color theme based on parent context
130+
*/
131+
@colorContextConsumer()
132+
@property({ reflect: true }) on: ColorTheme = 'light';
133+
134+
112135
/**
113136
* Set this attribute when you want to set a value in input box when web component is added to page.
114137
*/

elements/pfe-autocomplete/pfe-search-droplist.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { customElement, property, state, query } from 'lit/decorators.js';
33
import { classMap } from 'lit/directives/class-map.js';
44
import { repeat } from 'lit/directives/repeat.js';
55

6-
import { ComposedEvent } from '@patternfly/pfe-core';
7-
import { pfelement, bound, observed } from '@patternfly/pfe-core/decorators.js';
6+
import { ComposedEvent, ColorTheme } from '@patternfly/pfe-core';
7+
8+
import { pfelement, bound, observed, colorContextConsumer } from '@patternfly/pfe-core/decorators.js';
89
import { deprecatedCustomEvent } from '@patternfly/pfe-core/functions/deprecatedCustomEvent.js';
910

1011
import style from './pfe-search-droplist.scss';
@@ -38,6 +39,12 @@ export class PfeSearchDroplist extends LitElement {
3839

3940
static readonly styles = [style];
4041

42+
/**
43+
* Sets color theme based on parent context
44+
*/
45+
@colorContextConsumer()
46+
@property({ reflect: true }) on: ColorTheme = 'light';
47+
4148
/** Set when the combo box dropdown is open */
4249
@property({ type: Boolean, reflect: true }) open = false;
4350

0 commit comments

Comments
 (0)