feat(checkbox): add shadow part for label (#28604)

Issue number: Part of #28300 

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
Developers are unable to adjust margin, width, etc. of the checkbox
label

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Checkbox label has a shadow part.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
As part of this work, I investigated moving `pointer-events: none` up
the DOM tree so developers wouldn't be able to override it with the
shadow part. In my testing, I was unable to see any difference in
behavior with vs without `pointer-events: none`. Therefore, I removed it
entirely.
This commit is contained in:
Shawn Taylor
2023-12-01 11:26:05 -05:00
committed by GitHub
parent a34188f7db
commit f9f5654ab0
4 changed files with 20 additions and 12 deletions

View File

@ -18,6 +18,7 @@ import type { CheckboxChangeEventDetail } from './checkbox-interface';
* @slot - The label text to associate with the checkbox. Use the "labelPlacement" property to control where the label is placed relative to the checkbox.
*
* @part container - The container for the checkbox mark.
* @part label - The label text describing the checkbox.
* @part mark - The checkmark used to indicate the checked state.
*/
@Component({
@ -284,6 +285,7 @@ export class Checkbox implements ComponentInterface {
'label-text-wrapper': true,
'label-text-wrapper-hidden': el.textContent === '',
}}
part="label"
>
<slot></slot>
</div>