Skip to content

Commit 20bd14d

Browse files
eyevanakylebuch8castastrophedependabot-preview[bot][ Cassondra ]
authored
feat: add button variant to pfe-autocomplete (#1108)
* feat: pfe-button component First pass at creating a button. * pfe-button readme, story, tests, and JS updates * adding code comments * first attempt at styling * Update elements/pfe-button/src/pfe-button.json Co-authored-by: [ Cassondra ] <[email protected]> * using denylistAttributes instead of blackListedAttributes * adding a React demo page * removing discovery and changelog documents * style: 💄 add button line-height * style: 💄 add button font-family * refactor: 🎨 interpolate variables expressions * refactor: 🎨 interpolate variables expressions * feat: 💄 add additional border vars * refactor: 🎨 interpolate, use new border vars, & cleanup * style: 💄 add correct bg color for control disabled state * refactor: 🎨 cleanup * fix: 🐛 add submit and button types to demo; tweak input style * feat: ✨ log click events in storybook * feat: use pf theme colors * using the pfe-var(line-height) variable * updating text in pfe-button test * Update pfe-button.scss Stylesheet suggestions; simplified the interpolation and reduced unnecessary selectors * Update pfe-button.scss Moved after to a region * fix: add custom click event to schema * fix: hover property overrides for variants * feat: add new variant to autocomplete * feat: add default text to new button * fix: need to select button starting with 'search-button' * fix: need to set dropdwon in slot change handler * feat: make demo page easier on the eyes * feat: add textual button example * fix: disabled styles need to apply outside of wrapper * feat: add style hooks for the textual button * fix: init autocomplete for new variant * feat: print local vars * feat: use pfe-button for external variant * fix: no longer need this * chore: cleanup * refactor: abstract input init * fix: import non-umd file of pfe-button * feat: add new attr to json schema * fix: pfe-btn import path * docs: update readme & storybook knobs * test: add test cases for textual btn * feat: pfe-button component First pass at creating a button. * pfe-button readme, story, tests, and JS updates * adding code comments * first attempt at styling * Update elements/pfe-button/src/pfe-button.json Co-authored-by: [ Cassondra ] <[email protected]> * using denylistAttributes instead of blackListedAttributes * removing discovery and changelog documents * style: 💄 add button line-height * style: 💄 add button font-family * refactor: 🎨 interpolate variables expressions * refactor: 🎨 interpolate variables expressions * feat: 💄 add additional border vars * refactor: 🎨 interpolate, use new border vars, & cleanup * style: 💄 add correct bg color for control disabled state * refactor: 🎨 cleanup * fix: 🐛 add submit and button types to demo; tweak input style * feat: ✨ log click events in storybook * feat: use pf theme colors * using the pfe-var(line-height) variable * updating text in pfe-button test * Update pfe-button.scss Stylesheet suggestions; simplified the interpolation and reduced unnecessary selectors * Update pfe-button.scss Moved after to a region * fix: add custom click event to schema * fix: hover property overrides for variants * feat: add new variant to autocomplete * feat: add default text to new button * fix: need to select button starting with 'search-button' * fix: need to set dropdwon in slot change handler * feat: make demo page easier on the eyes * feat: add textual button example * fix: disabled styles need to apply outside of wrapper * feat: add style hooks for the textual button * fix: init autocomplete for new variant * feat: print local vars * feat: use pfe-button for external variant * chore: cleanup * refactor: abstract input init * chore(deps-dev): bump @wdio/mocha-framework from 6.4.0 to 6.5.0 (#1129) Bumps [@wdio/mocha-framework](https://github.com/webdriverio/webdriverio) from 6.4.0 to 6.5.0. - [Release notes](https://github.com/webdriverio/webdriverio/releases) - [Changelog](https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md) - [Commits](webdriverio/webdriverio@v6.4.0...v6.5.0) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: [ Cassondra ] <[email protected]> * fix: import non-umd file of pfe-button * feat: add new attr to json schema * fix: pfe-btn import path * docs: update readme & storybook knobs * test: add test cases for textual btn * chore: update changelog * fix: lock file out of sync * fix: lock file * updating pfe-autocomplete baselines * updating pfe-autocomplete baseline images * trying to hide the webkit "X" * refactor: padding already applied elsewhere * Fix merge issue; update baselines Co-authored-by: Kyle Buchanan <[email protected]> Co-authored-by: [ Cassondra ] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: [ Cassondra ] <[email protected]>
1 parent dfbb971 commit 20bd14d

File tree

16 files changed

+635
-498
lines changed

16 files changed

+635
-498
lines changed

.storybook/color.js

Lines changed: 202 additions & 226 deletions
Large diffs are not rendered by default.

elements/pfe-autocomplete/README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
<pfe-autocomplete> is a Web Component that provides options in a dropdown list as user types in an input box by showing result from an api call.
44

55
## Install
6-
```
6+
7+
```
78
npm install @patternfly/pfe-autocomplete
89
```
910

10-
1111
Once installed, import it to your application:
12-
```
12+
13+
```
1314
import '@patternfly/pfe-autocomplete.umd.js';
1415
```
1516

1617
## Usage
17-
```html
18+
19+
``` html
1820
<pfe-autocomplete debounce="500" init-value="uni">
19-
<input placeholder="Enter Your Search Term"/>
21+
<input placeholder="Enter Your Search Term" />
2022
</pfe-autocomplete>
2123
```
2224

@@ -29,7 +31,7 @@ It is called inside component but we define it outside component. First param is
2931

3032
In the function, we add loading attribute then send api call. When result is ready, we remove loading attribute and pass the result to web component by calling callback function. Here is an example:
3133

32-
```
34+
```
3335
// autocomplete call
3436
searchAutocomplete.autocompleteRequest = function(params, callback) {
3537
var xhr = new XMLHttpRequest();
@@ -77,9 +79,12 @@ aria-announce-template is an optional attribute string you provide so you can pr
7779
**`aria-label`**
7880
This is an optional attribute string that you can provide on the input tag in the light DOM of pfe-autocomplete. The aria-label attribute will default to "Search".
7981

80-
```html
82+
**`button-text`**
83+
button-text is a string attribute. Add this attribute to the element when you want to have a textual search button to the right of the input field. The text in the button will contain the value you pass to the attribute. If an empty string ( `button-text=""` ) or no string ( `button-text` ) is provided, the text will default to "Search".
84+
85+
``` html
8186
<pfe-autocomplete>
82-
<input placeholder="Search" aria-label="Buscar" />
87+
<input placeholder="Search" aria-label="Buscar" />
8388
</pfe-autocomplete>
8489
```
8590

@@ -89,25 +94,28 @@ By observing `selected-value` attribute you can detect autocomplete selected val
8994
## Events
9095

9196
### pfe-autocomplete:search-event
92-
Fires when a user performs search. By listening to this event you can get selected phrase by getting `e.detail.searchValue`.
9397

94-
```
98+
Fires when a user performs search. By listening to this event you can get selected phrase by getting `e.detail.searchValue` .
99+
100+
```
95101
detail: {
96102
searchValue: String
97103
}
98104
```
99105

100106
### pfe-autocomplete:option-selected
107+
101108
Fires when a user selects an option from the dropdown list.
102109

103-
```
110+
```
104111
detail: {
105112
optionValue: String
106113
}
107114
```
108115

109116
## Get selected item
110-
User can select an item by clicking on search button, type press enter or select an item by using keyboard and press enter. The selected item can be captured by listening to an event(`pfe-autocomplete:search-event`) or observing attribute(`selected-value`) change.
117+
118+
User can select an item by clicking on search button, type press enter or select an item by using keyboard and press enter. The selected item can be captured by listening to an event( `pfe-autocomplete:search-event` ) or observing attribute( `selected-value` ) change.
111119

112120
## Dependencies
113121

elements/pfe-autocomplete/demo/index.html

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>PFElements: pfe-autocomplete Demo</title>
88

9-
<link rel="stylesheet" type="text/css" href="//overpass-30e2.kxcdn.com/overpass.css">
10-
119
<!-- Stylesheets for testing light DOM styles.
1210
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap-reboot.css">
1311
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/typebase.css/0.5.0/typebase.css">
@@ -40,12 +38,20 @@
4038
<pfe-band size="small">
4139
<h1 class="pfe-headline-1">&lt;pfe-autocomplete&gt;</h1>
4240
</pfe-band>
41+
<pfe-band color="lightest" size="small">
42+
<h2 class="pfe-headline-2">Textual Button</h2>
43+
<div>
44+
<pfe-autocomplete class="static" debounce="300" button-text="Search">
45+
<input placeholder="Enter Your Search Term" />
46+
</pfe-autocomplete>
47+
</div>
48+
</pfe-band>
4349

4450
<pfe-band color="lightest">
4551
<h2 class="pfe-headline-2" slot="pfe-band--header">Static Data</h2>
4652
<p class="pfe-text">Uses an array of strings.</p>
4753
<div>
48-
<pfe-autocomplete id="static" debounce="300">
54+
<pfe-autocomplete class="static" debounce="300">
4955
<input placeholder="Enter Your Search Term" />
5056
</pfe-autocomplete>
5157
</div>
@@ -71,7 +77,8 @@ <h2 class="pfe-headline-2" slot="pfe-band--header">Disabled</h2>
7177
</div>
7278
</pfe-band>
7379
<script>
74-
const staticAutocomplete = document.querySelector("#static");
80+
const staticAutocompletes = document.querySelectorAll(".static");
81+
7582
const items = [
7683
"Item 1",
7784
"Item 2",
@@ -91,16 +98,18 @@ <h2 class="pfe-headline-2" slot="pfe-band--header">Disabled</h2>
9198
"Red Hat Enterprise Linux"
9299
];
93100

94-
staticAutocomplete.autocompleteRequest = function (params, callback) {
95-
const regx = new RegExp("\^" + params.query, "i");
96-
callback(items.filter(function (item) {
97-
return regx.test(item);
98-
}));
99-
};
101+
staticAutocompletes.forEach(a => {
102+
a.autocompleteRequest = function (params, callback) {
103+
const regx = new RegExp("\^" + params.query, "i");
104+
callback(items.filter(function (item) {
105+
return regx.test(item);
106+
}));
107+
};
100108

101-
staticAutocomplete.addEventListener('pfe-autocomplete:search-event', function (e) {
102-
document.querySelector("#staticSelectedValue").textContent = e.detail.searchValue;
103-
});
109+
a.addEventListener('pfe-autocomplete:search-event', function (e) {
110+
document.querySelector("#staticSelectedValue").textContent = e.detail.searchValue;
111+
});
112+
})
104113

105114
const searchAutocomplete = document.querySelector('#search-lazy-loading');
106115

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
<div id="input-box-wrapper">
1+
<div id="wrapper">
2+
<div id="input-box-wrapper">
23
<!-- Input box -->
34
<slot></slot>
45

56
<!-- loading icon -->
67
<span class="loading" aria-hidden="true" hidden>
7-
<svg viewBox="0 0 40 40" enable-background="new 0 0 40 40">
8-
<path opacity="0.2" fill="#000" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946
8+
<svg viewBox="0 0 40 40" enable-background="new 0 0 40 40">
9+
<path opacity="0.2" fill="#000"
10+
d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946
911
s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634
10-
c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/>
11-
<path fill="#000" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0
12+
c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z" />
13+
<path fill="#000" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0
1214
C22.32,8.481,24.301,9.057,26.013,10.047z">
13-
<animateTransform attributeType="xml"
14-
attributeName="transform"
15-
type="rotate"
16-
from="0 20 20"
17-
to="360 20 20"
18-
dur="0.5s"
19-
repeatCount="indefinite"/>
20-
</path>
21-
</svg>
15+
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 20 20" to="360 20 20"
16+
dur="0.5s" repeatCount="indefinite" />
17+
</path>
18+
</svg>
2219
</span>
2320

2421
<!-- clear search button -->
@@ -36,8 +33,14 @@
3633
c-8.596,8.596-8.596,22.391,0,30.987l33.286,33.286c8.596,8.596,22.391,8.596,30.987,0L192.26,383.796
3734
c43.282,27.688,97.559,39.683,154.734,28.188c79.167-15.893,142.04-77.067,159.632-155.934
3835
C540.212,104.314,407.968-27.93,256.233,5.756z M435.857,208.37c0,72.869-59.075,131.944-131.944,131.944
39-
S171.969,281.239,171.969,208.37S231.043,76.426,303.913,76.426S435.857,135.501,435.857,208.37z"/>
36+
S171.969,281.239,171.969,208.37S231.043,76.426,303.913,76.426S435.857,135.501,435.857,208.37z" />
4037
</svg>
4138
</button>
39+
</div>
40+
<pfe-search-droplist id="dropdown"></pfe-search-droplist>
4241
</div>
43-
<pfe-search-droplist id="dropdown"></pfe-search-droplist>
42+
43+
<!-- Search button (when [button-text] attr provided) -->
44+
<pfe-button class="search-button--textual" hidden>
45+
<button class="search-button__text" disabled></button>
46+
</pfe-button>

0 commit comments

Comments
 (0)