Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/components/button-group/toggle-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { property, query } from 'lit/decorators.js';
import { themes } from '../../theming/theming-decorator.js';
import { addKeyboardFocusRing } from '../common/controllers/focus-ring.js';
import { registerComponent } from '../common/definitions/register.js';
import { partNameMap } from '../common/util.js';
import { partMap } from '../common/part-map.js';
import { styles } from './themes/button.base.css.js';
import { all } from './themes/button.js';
import { styles as shared } from './themes/shared/button/button.common.css.js';
Expand Down Expand Up @@ -80,10 +80,7 @@ export default class IgcToggleButtonComponent extends LitElement {
protected override render() {
return html`
<button
part=${partNameMap({
toggle: true,
focused: this._kbFocus.focused,
})}
part=${partMap({ toggle: true, focused: this._kbFocus.focused })}
type="button"
?disabled=${this.disabled}
.ariaLabel=${this.ariaLabel}
Expand Down
14 changes: 4 additions & 10 deletions src/components/button/button-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EventEmitterMixin } from '../common//mixins/event-emitter.js';
import { addKeyboardFocusRing } from '../common/controllers/focus-ring.js';
import { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';
import type { Constructor } from '../common/mixins/constructor.js';
import { partNameMap } from '../common/util.js';
import { partMap } from '../common/part-map.js';

export interface IgcButtonEventMap {
// For analyzer meta only:
Expand Down Expand Up @@ -140,10 +140,7 @@ export abstract class IgcButtonBaseComponent extends EventEmitterMixin<
private renderButton() {
return html`
<button
part=${partNameMap({
base: true,
focused: this._kbFocus.focused,
})}
part=${partMap({ base: true, focused: this._kbFocus.focused })}
aria-label=${ifDefined(this.ariaLabel ?? nothing)}
?disabled=${this.disabled}
type=${ifDefined(this.type)}
Expand All @@ -158,13 +155,10 @@ export abstract class IgcButtonBaseComponent extends EventEmitterMixin<
private renderLinkButton() {
return html`
<a
part=${partNameMap({
base: true,
focused: this._kbFocus.focused,
})}
part=${partMap({ base: true, focused: this._kbFocus.focused })}
role="button"
aria-label=${ifDefined(this.ariaLabel ?? nothing)}
aria-disabled=${this.disabled ? 'true' : 'false'}
aria-disabled=${this.disabled}
href=${ifDefined(this.href)}
target=${ifDefined(this.target)}
download=${ifDefined(this.download)}
Expand Down
10 changes: 5 additions & 5 deletions src/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import { IgcCalendarResourceStringEN } from '../common/i18n/calendar.resources.j
import { createDateTimeFormatters } from '../common/localization/intl-formatters.js';
import type { Constructor } from '../common/mixins/constructor.js';
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
import { partMap } from '../common/part-map.js';
import {
clamp,
findElementFromEventPath,
first,
formatString,
last,
partNameMap,
} from '../common/util.js';
import IgcIconComponent from '../icon/icon.js';
import type { ContentOrientation } from '../types.js';
Expand Down Expand Up @@ -427,15 +427,15 @@ export default class IgcCalendarComponent extends EventEmitterMixin<
}

protected renderNavigationButtons() {
const parts = partNameMap({
const parts = {
'navigation-button': true,
vertical: this.orientation === 'vertical',
});
};

return html`
<div part="navigation-buttons">
<button
part=${parts}
part=${partMap(parts)}
aria-label=${this.previousButtonLabel}
@click=${this.navigatePrevious}
>
Expand All @@ -447,7 +447,7 @@ export default class IgcCalendarComponent extends EventEmitterMixin<
</button>

<button
part=${parts}
part=${partMap(parts)}
aria-label=${this.nextButtonLabel}
@click=${this.navigateNext}
>
Expand Down
13 changes: 6 additions & 7 deletions src/components/calendar/days-view/days-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { IgcCalendarResourceStringEN } from '../../common/i18n/calendar.resource
import { createDateTimeFormatters } from '../../common/localization/intl-formatters.js';
import type { Constructor } from '../../common/mixins/constructor.js';
import { EventEmitterMixin } from '../../common/mixins/event-emitter.js';
import { chunk, first, last, partNameMap, take } from '../../common/util.js';
import { partMap } from '../../common/part-map.js';
import { chunk, first, last, take } from '../../common/util.js';
import { IgcCalendarBaseComponent } from '../base.js';
import {
areSameMonth,
Expand Down Expand Up @@ -382,7 +383,6 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
const inactive = !areSameMonth(day, this._activeDate);

return {
date: true,
disabled: disabled || hidden,
first: this.isFirstInRange(day),
last: this.isLastInRange(day),
Expand All @@ -403,13 +403,12 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
const { changePreview, clearPreview } = this.getDayHandlers(day);

const props = this.getDayProperties(day, today);
const parts = partNameMap(props);

return html`
<span part=${parts}>
<span part=${partMap({ date: true, ...props })}>
Comment thread
damyanpetev marked this conversation as resolved.
<span
role="gridcell"
part=${parts.replace('date', 'date-inner')}
part=${partMap({ 'date-inner': true, ...props })}
Comment thread
damyanpetev marked this conversation as resolved.
aria-label=${ariaLabel}
aria-disabled=${props.disabled}
aria-selected=${props.selected}
Expand Down Expand Up @@ -438,8 +437,8 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<

protected renderWeekNumber(start: CalendarDay, last: boolean) {
return html`
<span role="rowheader" part=${partNameMap({ 'week-number': true, last })}>
<span part=${partNameMap({ 'week-number-inner': true, last })}>
<span role="rowheader" part=${partMap({ 'week-number': true, last })}>
<span part=${partMap({ 'week-number-inner': true, last })}>
${start.week}
</span>
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/calendar/helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function getDayViewDOM(element: IgcDaysViewComponent) {
get disabled() {
return Array.from(
root.querySelectorAll<HTMLElement>(
'span[part*="date-inner disabled"]'
'span[part~="date-inner"][part~="disabled"]'
)
);
},
Expand Down
9 changes: 4 additions & 5 deletions src/components/calendar/months-view/months-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { registerComponent } from '../../common/definitions/register.js';
import { createDateTimeFormatters } from '../../common/localization/intl-formatters.js';
import type { Constructor } from '../../common/mixins/constructor.js';
import { EventEmitterMixin } from '../../common/mixins/event-emitter.js';
import { chunk, partNameMap } from '../../common/util.js';
import { partMap } from '../../common/part-map.js';
import { chunk } from '../../common/util.js';
import { MONTHS_PER_ROW, areSameMonth, getViewElement } from '../helpers.js';
import { CalendarDay } from '../model.js';
import { styles } from '../themes/year-month-view.base.css.js';
Expand Down Expand Up @@ -119,14 +120,12 @@ export default class IgcMonthsViewComponent extends EventEmitterMixin<
const current = areSameMonth(now, entry);
const selected = this._value.month === entry.month;

const parts = { selected, current };

return html`
<span part=${partNameMap({ month: true, ...parts })}>
<span part=${partMap({ month: true, selected, current })}>
<span
role="gridcell"
data-value=${entry.month}
part=${partNameMap({ 'month-inner': true, ...parts })}
part=${partMap({ 'month-inner': true, selected, current })}
aria-selected=${selected}
aria-label=${ariaLabel}
tabindex=${active ? 0 : -1}
Expand Down
8 changes: 4 additions & 4 deletions src/components/calendar/years-view/years-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { blazorSuppressComponent } from '../../common/decorators/blazorSuppressC
import { registerComponent } from '../../common/definitions/register.js';
import type { Constructor } from '../../common/mixins/constructor.js';
import { EventEmitterMixin } from '../../common/mixins/event-emitter.js';
import { chunk, partNameMap } from '../../common/util.js';
import { partMap } from '../../common/part-map.js';
import { chunk } from '../../common/util.js';
import { YEARS_PER_ROW, getViewElement, getYearRange } from '../helpers.js';
import { CalendarDay } from '../model.js';
import { styles } from '../themes/year-month-view.base.css.js';
Expand Down Expand Up @@ -96,14 +97,13 @@ export default class IgcYearsViewComponent extends EventEmitterMixin<
protected renderYear(year: number, now: CalendarDay) {
const selected = this._value.year === year;
const current = year === now.year;
const parts = { selected, current };

return html`
<span part=${partNameMap({ year: true, ...parts })}>
<span part=${partMap({ year: true, selected, current })}>
<span
role="gridcell"
data-value=${year}
part=${partNameMap({ 'year-inner': true, ...parts })}
part=${partMap({ 'year-inner': true, selected, current })}
aria-selected=${selected}
tabindex=${selected ? 0 : -1}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/carousel/carousel-indicator-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LitElement, html } from 'lit';
import { themes } from '../../theming/theming-decorator.js';
import { addKeyboardFocusRing } from '../common/controllers/focus-ring.js';
import { registerComponent } from '../common/definitions/register.js';
import { partNameMap } from '../common/util.js';
import { partMap } from '../common/part-map.js';
import IgcCarouselIndicatorComponent from './carousel-indicator.js';
import { styles } from './themes/carousel-indicator-container.base.css.js';
import { all } from './themes/indicator-container.js';
Expand Down Expand Up @@ -39,7 +39,7 @@ export default class IgcCarouselIndicatorContainerComponent extends LitElement {
protected override render() {
return html`
<div
part=${partNameMap({
part=${partMap({
base: true,
focused: this._kbFocus.focused,
})}
Expand Down
18 changes: 11 additions & 7 deletions src/components/carousel/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { watch } from '../common/decorators/watch.js';
import { registerComponent } from '../common/definitions/register.js';
import type { Constructor } from '../common/mixins/constructor.js';
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
import { partMap } from '../common/part-map.js';
import {
asNumber,
createCounter,
Expand All @@ -40,7 +41,6 @@ import {
formatString,
isLTR,
last,
partNameMap,
wrap,
} from '../common/util.js';
import IgcIconComponent from '../icon/icon.js';
Expand Down Expand Up @@ -740,14 +740,18 @@ export default class IgcCarouselComponent extends EventEmitterMixin<
}

private indicatorTemplate() {
const parts = partNameMap({
const parts = {
indicators: true,
start: this.indicatorsOrientation === 'start',
});
};

return html`
<igc-carousel-indicator-container>
<div ${ref(this._indicatorsContainerRef)} role="tablist" part=${parts}>
<div
${ref(this._indicatorsContainerRef)}
role="tablist"
part=${partMap(parts)}
>
<slot
name="indicator"
@slotchange=${this.handleIndicatorSlotChange}
Expand All @@ -763,19 +767,19 @@ export default class IgcCarouselComponent extends EventEmitterMixin<
}

private labelTemplate() {
const parts = partNameMap({
const parts = {
label: true,
indicators: true,
start: this.indicatorsOrientation === 'start',
});
};
const value = formatString(
this.slidesLabelFormat,
this.current + 1,
this.total
);

return html`
<div part=${parts}>
<div part=${partMap(parts)}>
<span>${value}</span>
</div>
`;
Expand Down
11 changes: 6 additions & 5 deletions src/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { live } from 'lit/directives/live.js';

import { getThemeController, themes } from '../../theming/theming-decorator.js';
import { registerComponent } from '../common/definitions/register.js';
import { createCounter, partNameMap } from '../common/util.js';
import { partMap } from '../common/part-map.js';
import { createCounter } from '../common/util.js';
import IgcValidationContainerComponent from '../validation-container/validation-container.js';
import { IgcCheckboxBaseComponent } from './checkbox-base.js';
import { all } from './themes/checkbox-themes.js';
Expand Down Expand Up @@ -89,7 +90,7 @@ export default class IgcCheckboxComponent extends IgcCheckboxBaseComponent {

return html`
<label
part=${partNameMap({
part=${partMap({
base: true,
checked,
focused: this._kbFocus.focused,
Expand All @@ -113,14 +114,14 @@ export default class IgcCheckboxComponent extends IgcCheckboxBaseComponent {
@blur=${this.handleBlur}
@focus=${this.handleFocus}
/>
<span part=${partNameMap({ control: true, checked })}>
<span part=${partNameMap({ indicator: true, checked })}>
<span part=${partMap({ control: true, checked })}>
<span part=${partMap({ indicator: true, checked })}>
${this._isIndigo ? this.renderIndigo() : this.renderStandard()}
</span>
</span>
<span
.hidden=${this.hideLabel}
part=${partNameMap({ label: true, checked })}
part=${partMap({ label: true, checked })}
id=${this.labelId}
><slot></slot>
</span>
Expand Down
11 changes: 6 additions & 5 deletions src/components/checkbox/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { live } from 'lit/directives/live.js';

import { themes } from '../../theming/theming-decorator.js';
import { registerComponent } from '../common/definitions/register.js';
import { createCounter, partNameMap } from '../common/util.js';
import { partMap } from '../common/part-map.js';
import { createCounter } from '../common/util.js';
import { IgcCheckboxBaseComponent } from './checkbox-base.js';
import { styles as shared } from './themes/shared/switch/switch.common.css.js';
import { all } from './themes/switch-themes.js';
Expand Down Expand Up @@ -45,7 +46,7 @@ export default class IgcSwitchComponent extends IgcCheckboxBaseComponent {

return html`
<label
part=${partNameMap({ base: true, checked })}
part=${partMap({ base: true, checked })}
for=${this.inputId}
@pointerdown=${this._kbFocus.reset}
>
Expand All @@ -65,17 +66,17 @@ export default class IgcSwitchComponent extends IgcCheckboxBaseComponent {
@focus=${this.handleFocus}
/>
<span
part=${partNameMap({
part=${partMap({
control: true,
checked,
focused: this._kbFocus.focused,
})}
>
<span part=${partNameMap({ thumb: true, checked })}></span>
<span part=${partMap({ thumb: true, checked })}></span>
</span>
<span
.hidden=${this.hideLabel}
part=${partNameMap({ label: true, checked })}
part=${partMap({ label: true, checked })}
id=${this.labelId}
>
<slot></slot>
Expand Down
6 changes: 3 additions & 3 deletions src/components/chip/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export default class IgcChipComponent extends EventEmitterMixin<
return html`
<button
part="base"
.disabled="${this.disabled}"
aria-selected="${this.selected ? 'true' : 'false'}"
aria-disabled="${this.disabled ? 'true' : 'false'}"
.disabled=${this.disabled}
aria-selected=${this.selected}
aria-disabled=${this.disabled}
Comment on lines +132 to +133
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: We should probably set pattern for bool attrs. Wouldn't these be better off with the ? prefix to skip DOM false values? Applies across the board really.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really because aria-selected and the backing property are typed as string | null, so Lit kind of complains about the ? bindings there.
I do agree we should come with some mechanism that is not the verbose ifDefined(..blah blah) juggle that we currently do at some parts of the codebase.

@click=${this.handleSelect}
>
<span
Expand Down
Loading