Skip to content

Commit

Permalink
Fix vertical spacing in nested CmkList
Browse files Browse the repository at this point in the history
We handle margins in CmkListItem via a css variant. These variants were
also being applied to nested CmkListItem even if they shouldn't have
that variant. This is due to VueJS allowing scoped descendant rules to
break out of scope for recursive components.

cmklist
   cmklistitem - has `only` class
       cmklist
          cmklistitem - thinks it's the `only` variant

Reference (second bullet point)
https://vuejs.org/api/sfc-css-features.html#scoped-style-tips

Visible in quick setup step 2 -> host filter on multiple tags.

Change-Id: Ib3552c426a59c9ceedf219cf031e62de228b5d0a
  • Loading branch information
cellador committed Dec 18, 2024
1 parent ebcd536 commit 19b3793
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions packages/cmk-frontend-vue/src/components/CmkList/CmkListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,34 @@ const { buttonPadding = '16px' } = defineProps<{
padding-top: calc(var(--spacing) - var(--button-padding-top));
padding-left: v-bind(buttonPadding);
}
}

.cmk-list-item--first {
.cmk-list-item__button-container {
padding-top: var(--button-padding-top);
}
&.cmk-list-item--first {
> .cmk-list-item__button-container {
padding-top: var(--button-padding-top);
}

.cmk-list-item__content {
padding-top: 0;
> .cmk-list-item__content {
padding-top: 0;
}
}
}

.cmk-list-item--last {
.cmk-list-item__button-container,
.cmk-list-item__content {
padding-bottom: 0;
&.cmk-list-item--last {
> .cmk-list-item__button-container,
> .cmk-list-item__content {
padding-bottom: 0;
}
}
}

.cmk-list-item--only {
.cmk-list-item__button-container {
padding-top: var(--button-padding-top);
padding-bottom: var(--button-padding-top);
}
&.cmk-list-item--only {
> .cmk-list-item__button-container {
padding-top: var(--button-padding-top);
padding-bottom: var(--button-padding-top);
}

.cmk-list-item__content {
padding-top: 0;
padding-bottom: 0;
> .cmk-list-item__content {
padding-top: 0;
padding-bottom: 0;
}
}
}
</style>

0 comments on commit 19b3793

Please sign in to comment.