Skip to content

Commit eae6105

Browse files
committed
fix(NcChip): Remove space of chip icon if not set
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent adde6f9 commit eae6105

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/components/NcChip/NcChip.vue

+17-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
```vue
99
<template>
1010
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
11-
<NcChip text="Notes.txt" :icon-path="mdiFile" />
11+
<NcChip text="Notes.txt" />
12+
<NcChip text="Files" :icon-path="mdiFile" />
1213
<NcChip text="Color" type="tertiary" :icon-path="mdiPalette" />
1314
<NcChip text="Current time" type="primary" :icon-path="mdiClock" no-close />
1415
</div>
@@ -33,7 +34,7 @@ export default {
3334
It is also possible to use custom components for the icon by using the `icon` slot.
3435
In this example we are using the `NcAvatar` component to render the users avatar as the icon.
3536

36-
*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*
37+
*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*
3738

3839
Also it is possible to pass custom actions.
3940

@@ -69,8 +70,13 @@ export default {
6970
</docs>
7071

7172
<template>
72-
<div class="nc-chip" :class="{ [`nc-chip--${type}`]: true, 'nc-chip--no-actions': noClose && !hasActions() }">
73-
<span class="nc-chip__icon">
73+
<div class="nc-chip"
74+
:class="{
75+
[`nc-chip--${type}`]: true,
76+
'nc-chip--no-actions': noClose && !hasActions(),
77+
'nc-chip--no-icon': !hasIcon(),
78+
}">
79+
<span v-if="hasIcon()" class="nc-chip__icon">
7480
<!-- @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. -->
7581
<slot name="icon">
7682
<!-- The default icon wrapper uses a size of 18px to ensure the icon is not clipped by the round chip style -->
@@ -191,7 +197,6 @@ const onClose = () => {
191197
display: flex;
192198
flex-direction: row;
193199
align-items: center;
194-
gap: var(--default-grid-baseline);
195200
border-radius: var(--chip-radius);
196201
background-color: var(--color-background-hover);
197202

@@ -210,18 +215,25 @@ const onClose = () => {
210215
padding-inline-end: calc(1.5 * var(--default-grid-baseline));
211216
}
212217

218+
&--no-icon &__text {
219+
// Add some more space to the border
220+
padding-inline-start: calc(1.5 * var(--default-grid-baseline));
221+
}
222+
213223
&__text {
214224
// Allow to grow the text
215225
// this is only used if an app forces a width of the chip
216226
flex: 1 auto;
217227

218228
overflow: hidden;
219229
text-overflow: ellipsis;
230+
text-wrap: nowrap;
220231
}
221232

222233
&__icon {
223234
// Do neither grow nor shrink, size is fixed
224235
flex: 0 0 var(--chip-size);
236+
margin-inline-end: var(--default-grid-baseline);
225237

226238
line-height: 1;
227239
display: flex;

0 commit comments

Comments
 (0)