Skip to content

Commit 5716cfd

Browse files
authored
Merge pull request #242 from US-CBP/feature/table-iteration2
Feature/table iteration2
2 parents 11f2662 + 70f6e78 commit 5716cfd

File tree

9 files changed

+441
-74
lines changed

9 files changed

+441
-74
lines changed

packages/web-components/src/components/cbp-button/cbp-button.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109

110110
cbp-button {
111111
display: inline-block;
112+
width: var(--cbp-button-width);
113+
height: var(--cbp-button-height);
112114

113115
button, a {
114116
display: inline-flex;

packages/web-components/src/components/cbp-button/cbp-button.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,32 @@ export class CbpButton {
8686

8787

8888
/** A custom event emitted when the click event occurs for either a rendered button or anchor/link. */
89-
@Event() buttonClick!: EventEmitter;
89+
@Event() buttonClick: EventEmitter;
9090

9191
/** A custom event emitted when the component has completed loading and its internal lifecycles. */
92-
@Event() componentLoad!: EventEmitter;
92+
@Event() componentLoad: EventEmitter;
9393

9494

95-
handleClick() {
95+
handleClick(e): void {
9696
// If this is a control for something, manage state through stencil store
9797
if (this.controls) {
9898
// If the controlled element wasn't found, try to find it again
9999
if (!this.controlTarget) {
100100
this.controlTarget = this.controls ? document.querySelector(`#${this.controls}`) : undefined;
101101
}
102+
// Toggle the prop it controls
102103
if (this.controlTarget) {
103104
this.controlTarget[this.targetProp] = !this.controlTarget[this.targetProp];
104-
} else {
105+
}
106+
else {
105107
console.warn('cbp-button configuration error: the control target referenced by ID by the `control` property could not be found.');
106108
}
107109
}
108110

109111
this.buttonClick?.emit({
110112
host: this.host,
111113
nativeElement: this.button,
114+
nativeEvent: e,
112115
controls: this.controls ? this.controls : null,
113116
pressed: this.pressed,
114117
expanded: this.expanded,
@@ -189,14 +192,14 @@ export class CbpButton {
189192

190193
if (this.host.querySelector('[slot=cbp-button-custom]')) {
191194
return (
192-
<Host>
195+
<Host onClick={(e) => this.handleClick(e)}>
193196
<slot name="cbp-button-custom" />
194197
</Host>
195198
);
196199
}
197200
else if (this.tag === 'button') {
198201
return (
199-
<Host>
202+
<Host onClick={(e) => this.handleClick(e)}>
200203
<button
201204
{...this.persistedAttrs}
202205
{...attrs}
@@ -205,7 +208,7 @@ export class CbpButton {
205208
aria-pressed={pressed ? 'true' : null}
206209
aria-expanded={expanded ? 'true' : null}
207210
aria-controls={this.controls}
208-
onClick={() => this.handleClick()}
211+
//onClick={() => this.handleClick()}
209212
ref={el => (this.button = el)}
210213
>
211214
<slot />
@@ -215,7 +218,7 @@ export class CbpButton {
215218
}
216219
else {
217220
return (
218-
<Host>
221+
<Host onClick={(e) => this.handleClick(e)}>
219222
<a
220223
{...this.persistedAttrs}
221224
{...attrs}
@@ -226,7 +229,7 @@ export class CbpButton {
226229
aria-controls={this.controls}
227230
role={disabled ? 'link' : null}
228231
aria-disabled={disabled ? 'true' : null}
229-
onClick={() => this.handleClick()}
232+
//onClick={() => this.handleClick()}
230233
ref={el => (this.button = el)}
231234
>
232235
<slot />

packages/web-components/src/components/cbp-checkbox/cbp-checkbox.specs.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The Checkbox component wraps the slotted native form control (`input type="check
2222
* The user interactions are that of a native checkbox (`input type="checkbox"`) element:
2323
* Clicking anywhere on the form control or label text will place focus on the control and toggle its state.
2424
* Checkboxes are keyboard accessible by tabbing onto them in either direction, placing focus onto the native form control.
25-
* Pressing the spacebar will toggle the focused checkbox state, also emitting a custom event.
25+
* Pressing the Spacebar will toggle the focused checkbox state, also emitting a custom event.
2626

2727
### Responsiveness
2828

@@ -31,7 +31,9 @@ The Checkbox component wraps the slotted native form control (`input type="check
3131

3232
### Accessibility
3333

34-
* The native checkbox (`input type="checkbox"`) element and label text are wrapped within a `label` tag, forming an implicit label association (no `id` needed).
34+
* The native checkbox (`input type="checkbox"`) element and label text are wrapped within a `label` tag.
35+
* Additionally, if the slotted input has an `id` attribute, the checkbox component will use it to associate the `label` and `input` elements explicitly (implicit association does not work with voice software).
36+
* If the slotted input does not have an `id` specified, the component will generate an `id` to apply to the slotted input and make the explicit association with the label.
3537
* Full keyboard navigation is supported, as detailed under "User Interactions" above.
3638

3739
### Additional Notes and Considerations

packages/web-components/src/components/cbp-radio/cbp-radio.specs.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ The Radio component wraps the slotted native form control (`input type="radio"`)
3232

3333
### Accessibility
3434

35-
* The native radio button (`input type="radio"`) element and label text are wrapped within a `label` tag, forming an implicit label association (no `id` needed).
35+
* The native radio button (`input type="radio"`) element and label text are wrapped within a `label` tag.
36+
* Additionally, if the slotted input has an `id` attribute, the radio component will use it to associate the `label` and `input` elements explicitly (implicit association does not work with voice software).
37+
* If the slotted input does not have an `id` specified, the component will generate an `id` to apply to the slotted input and make the explicit association with the label.
3638
* Full keyboard navigation is supported, as detailed under "User Interactions" above.
3739

3840
### Additional Notes and Considerations

packages/web-components/src/components/cbp-radio/cbp-radio.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, Element, Prop, Event, EventEmitter, Watch, Host, h } from '@stencil/core';
2-
import { setCSSProps} from '../../utils/utils';
2+
import { setCSSProps, createNamespaceKey } from '../../utils/utils';
33

44

55
/**
@@ -21,6 +21,9 @@ export class CbpRadio {
2121
/** Optionally set the `value` attribute of the radio button at the component level. Not needed if the slotted radio button has a value. */
2222
@Prop() value: string;
2323

24+
/** Optionally specify the ID of the checkbox input here, which is used to generate related pattern node IDs and associate everything for accessibility */
25+
@Prop({ mutable: true }) fieldId: string = createNamespaceKey('cbp-radio');
26+
2427
/** Marks the radio button as checked by default when specified. */
2528
@Prop() checked: boolean;
2629

@@ -69,6 +72,8 @@ export class CbpRadio {
6972
this.formField = this.host.querySelector('input[type=radio]');
7073

7174
if (this.formField) {
75+
const radioId = this.formField.getAttribute('id');
76+
radioId ? this.fieldId = radioId : this.formField.setAttribute('id', this.fieldId);
7277
this.formField.addEventListener('change', () => this.handleChange());
7378
}
7479
}
@@ -86,7 +91,7 @@ export class CbpRadio {
8691
render() {
8792
return (
8893
<Host>
89-
<label>
94+
<label htmlFor={this.fieldId}>
9095
<slot />
9196
</label>
9297
</Host>

0 commit comments

Comments
 (0)