refactor: use css only last item detection (#10363)
The last item in the sidebar top level group has an indicator specified, the problem in our case is that the structure can be nested and have sub groups. So selecting the last item correctly can be tricky. Previous implementation relied on the using DOM queries to find the last item from a flat list of children, it would trigger on a `watch`. This was error-prone as well as non idiomatic. The new approach is CSS-only and reduces the unnecessary compute required. Codepen for reference: https://codepen.io/scmmishra/pen/yLmKNLW --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -49,44 +49,3 @@ const shouldRenderComponent = computed(() => {
|
||||
</component>
|
||||
</Policy>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.child-item::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 0.125rem;
|
||||
/* 0.5px */
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.child-item:first-child::before {
|
||||
border-radius: 4px 4px 0 0;
|
||||
}
|
||||
|
||||
.last-child-item::before {
|
||||
height: 20%;
|
||||
}
|
||||
|
||||
.last-child-item::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 12px;
|
||||
bottom: calc(50% - 2px);
|
||||
border-bottom-width: 0.125rem;
|
||||
border-left-width: 0.125rem;
|
||||
border-right-width: 0px;
|
||||
border-top-width: 0px;
|
||||
border-radius: 0 0 0 4px;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.app-rtl--wrapper .last-child-item::after {
|
||||
right: 0;
|
||||
border-bottom-width: 0.125rem;
|
||||
border-right-width: 0.125rem;
|
||||
border-left-width: 0px;
|
||||
border-top-width: 0px;
|
||||
border-radius: 0 0 4px 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user