Skip to content

Commit

Permalink
fix(NcChip): Remove space of chip icon if not set
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jul 23, 2024
1 parent dd32d78 commit 187fd71
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/NcChip/NcChip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
```vue
<template>
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
<NcChip text="Notes.txt" :icon-path="mdiFile" />
<NcChip text="Notes.txt" />
<NcChip text="Files" :icon-path="mdiFile" />
<NcChip text="Color" type="tertiary" :icon-path="mdiPalette" />
<NcChip text="Current time" type="primary" :icon-path="mdiClock" no-close />
</div>
Expand All @@ -33,7 +34,7 @@ export default {
It is also possible to use custom components for the icon by using the `icon` slot.
In this example we are using the `NcAvatar` component to render the users avatar as the icon.

*Hint: If you use round icons like avatars you should set their size to `24px` (or use CSS variable `--chip-size`) to make then fully fill and align with the the chip*
*Hint: If you use round icons like avatars you should set their size to `24px` (or use CSS variable `--chip-size`) to make them fully fill and align with the the chip*

Also it is possible to pass custom actions.

Expand Down Expand Up @@ -70,7 +71,7 @@ export default {

<template>
<div class="nc-chip" :class="{ [`nc-chip--${type}`]: true, 'nc-chip--no-actions': noClose && !hasActions() }">
<span class="nc-chip__icon">
<span class="nc-chip__icon" :class="{ 'nc-chip__icon--empty': !hasIcon() }">
<!-- @slot The icon slot can be used to set the chip icon. Make sure that the icon is not exceeding a height of `24px`. For round icons a exact size of `24px` is recommended. -->
<slot name="icon">
<!-- The default icon wrapper uses a size of 18px to ensure the icon is not clipped by the round chip style -->
Expand Down Expand Up @@ -191,7 +192,6 @@ const onClose = () => {
display: flex;
flex-direction: row;
align-items: center;
gap: var(--default-grid-baseline);
border-radius: var(--chip-radius);
background-color: var(--color-background-hover);
Expand All @@ -217,11 +217,13 @@ const onClose = () => {
overflow: hidden;
text-overflow: ellipsis;
text-wrap: nowrap;
}
&__icon {
// Do neither grow nor shrink, size is fixed
flex: 0 0 var(--chip-size);
margin-inline-end: var(--default-grid-baseline);
line-height: 1;
display: flex;
Expand All @@ -232,6 +234,13 @@ const onClose = () => {
overflow: hidden;
height: var(--chip-size);
width: var(--chip-size);
&--empty {
flex: 1;
width: 0;
// Add some more space to the border
margin-inline-end: calc(2 * var(--default-grid-baseline));
}
}
&__actions {
Expand Down

0 comments on commit 187fd71

Please sign in to comment.