From dfb9d53a2557072ee096d9731845d15bf892af56 Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Wed, 15 Jan 2025 13:15:47 -0500 Subject: [PATCH] Checkbox improvements - Added `part="control", fixes #529 - Removed wrapper div which is no longer needed - Removed `form-control--has-hint` class which is no longer used anywhere --- src/components/checkbox/checkbox.ts | 73 +++++++++++++---------------- src/styles/native/checkbox.css | 6 +-- src/styles/shadow/form-control.css | 2 +- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/components/checkbox/checkbox.ts b/src/components/checkbox/checkbox.ts index db6718de2..99f07acc4 100644 --- a/src/components/checkbox/checkbox.ts +++ b/src/components/checkbox/checkbox.ts @@ -233,47 +233,40 @@ export default class WaCheckbox extends WebAwesomeFormAssociatedElement { // https://bugs.chromium.org/p/chromium/issues/detail?id=1413733 // return html` -
+ + + + + + + + + + ${this.hint} - - - ${this.hint} -
`; } } diff --git a/src/styles/native/checkbox.css b/src/styles/native/checkbox.css index 632e317b0..06ea80516 100644 --- a/src/styles/native/checkbox.css +++ b/src/styles/native/checkbox.css @@ -41,7 +41,7 @@ input[type='checkbox']:where(:not(:host *)) { } input[type='checkbox']:where(:not(:host *)), -:host .control { +:host [part~='control'] { flex: 0 0 auto; position: relative; display: inline-flex; @@ -75,7 +75,7 @@ input[type='checkbox']:where(:not(:host *)) + label, /* Checked */ input[type='checkbox']:is(:checked, :indeterminate):where(:not(:host *)), -[part~='base'] .control:has(:checked, :indeterminate) /* scoping this rule to :host breaks in Firefox */ { +[part~='base'] [part~="control"]:has(:checked, :indeterminate) /* scoping this rule to :host breaks in Firefox */ { color: var(--checked-icon-color); border-color: var(--border-color-checked); background-color: var(--background-color-checked); @@ -83,7 +83,7 @@ input[type='checkbox']:is(:checked, :indeterminate):where(:not(:host *)), /* Focus */ input[type='checkbox']:focus-visible:where(:not(:host *)), -[part~='base'] .control:has(> input:focus-visible:not(:disabled)) /* scoping this rule to :host breaks in Firefox */ { +[part~='base'] [part~="control"]:has(> input:focus-visible:not(:disabled)) /* scoping this rule to :host breaks in Firefox */ { outline: var(--wa-focus-ring); outline-offset: var(--wa-focus-ring-offset); } diff --git a/src/styles/shadow/form-control.css b/src/styles/shadow/form-control.css index 5aff69722..967b8b175 100644 --- a/src/styles/shadow/form-control.css +++ b/src/styles/shadow/form-control.css @@ -21,7 +21,7 @@ font-size: var(--wa-size-smaller, 85%); line-height: var(--wa-form-control-label-line-height); - &:not(.has-slotted, .form-control--has-hint *) { + &:not(.has-slotted) { display: none; } }