Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(chip-set): correctly use MDC's HTML & classes #2683

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
54 changes: 19 additions & 35 deletions src/components/chip-set/chip-set.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,11 @@ limel-icon.mdc-chip__icon.mdc-chip__icon--leading {
align-items: center;
min-height: shared_input-select-picker.$height-of-mdc-text-field;
position: relative;

&.chip-set--with-label {
.lime-floating-label--float-above {
padding-left: functions.pxToRem(4);
}
}
width: 100%;

&.mdc-chip-set--input {
padding: functions.pxToRem(8);

width: 100%;
padding-top: 0.5rem;
padding-bottom: 0.5rem;

.mdc-chip--selected {
// When chip is selected with keyboard (backspace / arrow-keys) to be deleted
Expand Down Expand Up @@ -226,7 +220,6 @@ limel-icon.mdc-chip__icon.mdc-chip__icon--leading {
width: auto;
height: $height-of-chip-set-input;
line-height: $height-of-chip-set-input;
padding: 0 functions.pxToRem(12);

flex-grow: 1;
flex-shrink: 0;
Expand All @@ -251,6 +244,12 @@ limel-icon.mdc-chip__icon.mdc-chip__icon--leading {
}
}

.has-chips {
.mdc-text-field__input {
padding-left: 0.75rem;
}
}

.mdc-text-field--disabled .mdc-chip {
pointer-events: all;

Expand Down Expand Up @@ -284,6 +283,10 @@ limel-icon.mdc-chip__icon.mdc-chip__icon--leading {

transform: translateY(-34.75px) scale(0.75);
font-size: shared_input-select-picker.$cropped-label-hack--font-size;

.mdc-text-field--with-leading-icon & {
transform: translateY(-34.75px) translateX(-32px) scale(0.75);
}
}
}
}
Expand Down Expand Up @@ -315,38 +318,19 @@ limel-icon.mdc-chip__icon.mdc-chip__icon--leading {
}
}

.has-leading-icon {
&:not(.has-chips) {
.mdc-text-field__input {
padding-left: $leading-icon-space;
}
.mdc-text-field--with-leading-icon {
padding-left: 1rem !important;
.mdc-text-field__icon--leading {
margin-left: 0;
}

&:not(.has-chips) {
.mdc-floating-label {
&:not(.lime-floating-label--float-above) {
left: $leading-icon-space;
}
&.mdc-floating-label--float-above {
left: functions.pxToRem(4);
}
}
}

.mdc-chip {
&:first-of-type {
margin-left: 40px;
}
}

.search-icon {
transition: transform 0.2s ease;
position: absolute;
top: functions.pxToRem(16);
left: functions.pxToRem(16);
}

limel-icon {
background-color: transparent;
}
}

.delimiter {
Expand Down
38 changes: 20 additions & 18 deletions src/components/chip-set/chip-set.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,29 @@ export class ChipSet {
'force-invalid': this.isInvalid(),
'mdc-text-field--disabled': this.readonly || this.disabled,
'lime-text-field--readonly': this.readonly,
'has-chips mdc-text-field--label-floating':
this.value.length !== 0,
'has-leading-icon': this.leadingIcon !== null,
'has-chips': this.value.length !== 0,
'mdc-text-field--label-floating':
this.value.length !== 0 || this.editMode,
'mdc-text-field--with-leading-icon':
this.leadingIcon !== null,
'has-clear-all-button': this.clearAllButton,
}}
onClick={this.handleTextFieldFocus}
>
<div
class={{
'mdc-notched-outline': true,
'mdc-notched-outline--upgraded': true,
'mdc-text-field--required': this.required,
'lime-notched-outline--notched': this.floatLabelAbove(),
}}
dropzone-tip={this.dropZoneTip()}
>
<div class="mdc-notched-outline__leading" />
{this.renderLabel()}
<div class="mdc-notched-outline__trailing" />
</div>
{this.renderLeadingIcon()}
Copy link
Contributor

Choose a reason for hiding this comment

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

This change causes the next issue 👇

Screen.Recording.2024-01-04.at.13.06.59.mov

{this.value.map(this.renderInputChip)}
<input
tabIndex={INPUT_FIELD_TABINDEX}
Expand All @@ -418,20 +434,6 @@ export class ChipSet {
placeholder={this.isFull() ? '' : this.searchLabel}
readonly={this.isFull()}
/>
<div
class={{
'mdc-notched-outline': true,
'mdc-notched-outline--upgraded': true,
'mdc-text-field--required': this.required,
'lime-notched-outline--notched': this.floatLabelAbove(),
}}
dropzone-tip={this.dropZoneTip()}
>
<div class="mdc-notched-outline__leading" />
{this.renderLabel()}
<div class="mdc-notched-outline__trailing" />
</div>
{this.renderLeadingIcon()}
{this.renderEmptyValueForReadonly()}
{this.renderClearAllChipsButton()}
</div>,
Expand Down Expand Up @@ -744,7 +746,7 @@ export class ChipSet {
}

return (
<i class="mdc-text-field__icon search-icon">
<i class="material-icons mdc-text-field__icon mdc-text-field__icon--leading">
<limel-icon name={this.leadingIcon} />
</i>
);
Expand Down
Loading