Skip to content

Commit 024f65c

Browse files
committed
fix(chip): styling discrepancies
1 parent 6c0897d commit 024f65c

File tree

4 files changed

+33
-43
lines changed

4 files changed

+33
-43
lines changed

src/components/chip/chip.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { LitElement, html, nothing } from 'lit';
2-
import { property } from 'lit/decorators.js';
2+
import { property, queryAssignedElements } from 'lit/decorators.js';
33
import { type Ref, createRef, ref } from 'lit/directives/ref.js';
44

55
import { themes } from '../../theming/theming-decorator.js';
66
import { addKeybindings } from '../common/controllers/key-bindings.js';
77
import { registerComponent } from '../common/definitions/register.js';
88
import type { Constructor } from '../common/mixins/constructor.js';
99
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
10+
import { isEmpty } from '../common/util.js';
1011
import IgcIconComponent from '../icon/icon.js';
1112
import type { StyleVariant } from '../types.js';
1213
import { styles } from './themes/chip.base.css.js';
@@ -84,6 +85,18 @@ export default class IgcChipComponent extends EventEmitterMixin<
8485
@property({ reflect: true })
8586
public variant!: StyleVariant;
8687

88+
@queryAssignedElements({ slot: 'prefix' })
89+
protected prefixes!: Array<HTMLElement>;
90+
91+
@queryAssignedElements({ slot: 'start' })
92+
protected contentStart!: Array<HTMLElement>;
93+
94+
@queryAssignedElements({ slot: 'suffix' })
95+
protected suffixes!: Array<HTMLElement>;
96+
97+
@queryAssignedElements({ slot: 'end' })
98+
protected contentEnd!: Array<HTMLElement>;
99+
87100
constructor() {
88101
super();
89102

@@ -120,7 +133,12 @@ export default class IgcChipComponent extends EventEmitterMixin<
120133
aria-disabled="${this.disabled ? 'true' : 'false'}"
121134
@click=${this.handleSelect}
122135
>
123-
<span part="prefix">
136+
<span
137+
part="prefix"
138+
.hidden=${isEmpty(this.prefixes) &&
139+
isEmpty(this.contentStart) &&
140+
!this.selected}
141+
>
124142
${this.selectable && this.selected
125143
? html`<slot name="select">
126144
<igc-icon name="selected" collection="default"></igc-icon>
@@ -130,7 +148,12 @@ export default class IgcChipComponent extends EventEmitterMixin<
130148
<slot name="prefix"></slot>
131149
</span>
132150
<slot></slot>
133-
<span part="suffix">
151+
<span
152+
part="suffix"
153+
.hidden=${isEmpty(this.suffixes) &&
154+
isEmpty(this.contentEnd) &&
155+
!this.removable}
156+
>
134157
<slot name="end"></slot>
135158
<slot name="suffix"></slot>
136159
${this.removable && !this.disabled

src/components/chip/themes/shared/chip.bootstrap.scss

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,22 @@ $theme: $bootstrap;
1313
}
1414
}
1515

16-
:host([variant='primary']) button,
17-
:host([variant='primary']) button:focus,
18-
:host([variant='primary']) button:hover,
19-
:host([selected][variant='primary']) button:not([disabled]) {
20-
color: contrast-color(primary, 700);
21-
}
22-
2316
:host([variant='primary']) button:focus {
2417
outline: rem(2px) solid color(primary, 200);
2518
}
2619

27-
:host([variant='info']) button,
28-
:host([variant='info']) button:focus,
29-
:host([variant='info']) button:hover,
30-
:host([selected][variant='info']) button:not([disabled]) {
31-
color: contrast-color(info, 700);
32-
}
33-
3420
:host([variant='info']) button:focus {
3521
outline: rem(2px) solid color(info, 200);
3622
}
3723

38-
:host([variant='success']) button,
39-
:host([variant='success']) button:focus,
40-
:host([variant='success']) button:hover,
41-
:host([selected][variant='success']) button:not([disabled]) {
42-
color: contrast-color(success, 700);
43-
}
44-
4524
:host([variant='success']) button:focus {
4625
outline: rem(2px) solid color(success, 200);
4726
}
4827

49-
:host([variant='warning']) button,
50-
:host([variant='warning']) button:focus,
51-
:host([variant='warning']) button:hover,
52-
:host([selected][variant='warning']) button:not([disabled]) {
53-
color: contrast-color(warn, 700);
54-
}
55-
5628
:host([variant='warning']) button:focus {
5729
outline: rem(2px) solid color(warn, 200);
5830
}
5931

60-
:host([variant='danger']) button,
61-
:host([variant='danger']) button:focus,
62-
:host([variant='danger']) button:hover,
63-
:host([selected][variant='danger']) button:not([disabled]) {
64-
color: contrast-color(error, 700);
65-
}
66-
6732
:host([variant='danger']) button:focus {
6833
outline: rem(2px) solid color(error, 200);
6934
}

src/components/chip/themes/shared/chip.common.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ $theme: $material;
3030
color: var-get($theme, 'disabled-text-color');
3131
}
3232

33-
igc-icon {
34-
--component-size: var(--chip-size);
35-
}
36-
3733
::slotted(*) {
3834
--default-size: var(--chip-size);
3935
}
@@ -45,4 +41,9 @@ $theme: $material;
4541
::slotted(igc-circular-progress) {
4642
--diameter: #{sizable(rem(14px), rem(18px), rem(24px))};
4743
}
44+
45+
igc-icon,
46+
::slotted(igc-icon) {
47+
--size: #{sizable(rem(18px), rem(18px), rem(24px))};
48+
}
4849
}

src/components/chip/themes/shared/chip.indigo.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ $theme: $indigo;
2323
border-color: var-get($theme, 'disabled-border-color');
2424
}
2525

26-
igc-icon {
26+
igc-icon,
27+
::slotted(igc-icon) {
2728
--size: #{sizable(rem(14px), rem(14px), rem(16px))};
2829
}
2930
}

0 commit comments

Comments
 (0)