Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit f50d4ac

Browse files
danwenzelclintcs
andauthored
Remove gap between Checkbox or Toggle and summary, if there is no summary (#688)
* Remove gap between Checkbox or Toggle and summary if there is no summary * Update .changeset/cool-hornets-talk.md Co-authored-by: clintcs <[email protected]> --------- Co-authored-by: clintcs <[email protected]>
1 parent 0f44767 commit f50d4ac

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

.changeset/cool-hornets-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@crowdstrike/glide-core': patch
3+
---
4+
5+
- A Checkbox or Toggle without a summary no longer has extra space to the right.

src/checkbox.test.basics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ it('registers itself', async () => {
1616

1717
it('is accessible', async () => {
1818
const host = await fixture<GlideCoreCheckbox>(
19-
html`<glide-core-checkbox label="Label" tooltip="Tooltip">
19+
html`<glide-core-checkbox label="Label" summary="Summary" tooltip="Tooltip">
2020
<div slot="description">Description</div>
2121
</glide-core-checkbox>`,
2222
);

src/checkbox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ export default class GlideCoreCheckbox
368368
</div>
369369
</div>
370370
371-
<div id="summary" slot="summary">${this.summary}</div>
371+
${when(
372+
this.summary,
373+
() =>
374+
html`<div id="summary" slot="summary">${this.summary}</div>`,
375+
)}
372376
373377
<div id="description" slot="description">
374378
<slot

src/toggle.test.basics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ it('registers itself', async () => {
1414

1515
it('is accessible', async () => {
1616
const host = await fixture<GlideCoreToggle>(
17-
html`<glide-core-toggle label="Label" tooltip="Tooltip">
17+
html`<glide-core-toggle label="Label" summary="Summary" tooltip="Tooltip">
1818
<div slot="description">Description</div>
1919
</glide-core-toggle>`,
2020
);

src/toggle.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { html, LitElement } from 'lit';
33
import { createRef, ref } from 'lit/directives/ref.js';
44
import { customElement, property } from 'lit/decorators.js';
55
import { ifDefined } from 'lit/directives/if-defined.js';
6+
import { when } from 'lit/directives/when.js';
67
import packageJson from '../package.json' with { type: 'json' };
78
import styles from './toggle.styles.js';
89
import shadowRootMode from './library/shadow-root-mode.js';
@@ -118,7 +119,10 @@ export default class GlideCoreToggle extends LitElement {
118119
/>
119120
</div>
120121
121-
<div slot="summary" id="summary">${this.summary}</div>
122+
${when(
123+
this.summary,
124+
() => html`<div id="summary" slot="summary">${this.summary}</div>`,
125+
)}
122126
123127
<slot
124128
class="description"

0 commit comments

Comments
 (0)