Skip to content

feat(chip): enhance multi-select group affordance #9286

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

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
47 changes: 45 additions & 2 deletions packages/calcite-components/src/components/chip/chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
.container.is-circle {
@apply w-6 h-6;
}

.multiple {
.select-icon {
padding-inline: var(--calcite-spacing-xxs);
}
}

.multiple.image--slotted {
.select-icon {
padding-inline-start: var(--calcite-spacing-xs);
padding-inline-end: var(--calcite-spacing-sm);
}
}
}

:host([scale="m"]) {
Expand All @@ -30,6 +43,19 @@
.container.is-circle {
@apply w-8 h-8;
}

.multiple {
.select-icon {
padding-inline: var(--calcite-spacing-xs);
}
}

.multiple.image--slotted {
.select-icon {
padding-inline-start: var(--calcite-spacing-sm);
padding-inline-end: var(--calcite-spacing-md);
}
}
}

:host([scale="l"]) {
Expand All @@ -45,6 +71,19 @@
.container.is-circle {
@apply w-11 h-11;
}

.multiple {
.select-icon {
padding-inline: var(--calcite-spacing-sm);
}
}

.multiple.image--slotted {
.select-icon {
padding-inline-start: var(--calcite-spacing-md);
padding-inline-end: var(--calcite-spacing-xl);
}
}
}

:host {
Expand Down Expand Up @@ -77,7 +116,7 @@
}
}

:host([scale="s"]) .container.image--slotted {
:host([scale="s"]) .container:not(.multiple).image--slotted {
padding-inline-start: calc(theme("spacing[0.5]") / 2);
}

Expand Down Expand Up @@ -200,7 +239,7 @@
opacity: 0.5;
}
}
.container:not(.is-circle).image--slotted .select-icon.select-icon--active {
.container:not(.is-circle):not(.multiple).image--slotted .select-icon.select-icon--active {
margin-inline-end: var(--calcite-chip-spacing-s-internal);
}

Expand All @@ -212,6 +251,10 @@
opacity: 1;
}

.multiple .select-icon {
@apply flex justify-center items-center;
}

slot[name="image"]::slotted(*) {
@apply rounded-half flex h-full w-full overflow-hidden;
}
Expand Down
33 changes: 33 additions & 0 deletions packages/calcite-components/src/components/chip/chip.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,36 @@ export const darkModeRTL_TestOnly = (): string => html`
`;

darkModeRTL_TestOnly.parameters = { themes: modesDarkDefault };

export const multiPadding = (): string => html`
<div style="display: flex; flex-direction: row; gap: 50px;">
<div>
<calcite-chip-group label="demo-group-label" selection-mode="multiple" scale="s">
<calcite-chip kind="inverse" selected closable value="KML"> KML </calcite-chip>
</calcite-chip-group>
<calcite-chip-group label="demo-group-label" selection-mode="multiple" scale="m" style="padding-top: 16px">
<calcite-chip kind="inverse" selected closable value="KML"> KML </calcite-chip>
</calcite-chip-group>
<calcite-chip-group label="demo-group-label" selection-mode="multiple" scale="l" style="padding-top: 16px">
<calcite-chip kind="inverse" selected closable value="KML"> KML </calcite-chip>
</calcite-chip-group>
</div>
<div>
<calcite-chip-group label="demo-group-label" selection-mode="multiple" scale="s">
<calcite-chip kind="inverse" selected icon="file-kml" closable value="KML">
KML <calcite-avatar slot="image" full-name="Alluvial"></calcite-avatar
></calcite-chip>
</calcite-chip-group>
<calcite-chip-group label="demo-group-label" selection-mode="multiple" scale="m" style="padding-top: 16px">
<calcite-chip kind="inverse" selected icon="file-kml" closable value="KML">
KML<calcite-avatar slot="image" full-name="Alluvial"></calcite-avatar>
</calcite-chip>
</calcite-chip-group>
<calcite-chip-group label="demo-group-label" selection-mode="multiple" scale="l" style="padding-top: 16px">
<calcite-chip kind="inverse" selected closable value="KML">
KML<calcite-avatar slot="image" full-name="Alluvial"></calcite-avatar>
</calcite-chip>
</calcite-chip-group>
</div>
</div>
`;
4 changes: 2 additions & 2 deletions packages/calcite-components/src/components/chip/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ export class Chip
renderSelectionIcon(): VNode {
const icon =
this.selectionMode === "multiple" && this.selected
? ICONS.checked
? ICONS.checkedMultiple
: this.selectionMode === "multiple"
? ICONS.unchecked
? ICONS.uncheckedMultiple
: this.selected
? ICONS.checkedSingle
: undefined;
Expand Down
2 changes: 2 additions & 0 deletions packages/calcite-components/src/components/chip/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ export const ICONS = {
unchecked: "circle",
checkedSingle: "circle-f",
checked: "check-circle-f",
uncheckedMultiple: "square",
checkedMultiple: "check-square-f",
};
Loading