Skip to content

Commit eba3191

Browse files
authored
Merge pull request #5879 from nextcloud-libraries/fix/nc-list-item-height
fix(NcListItem): Make paddings smaller again on Nextcloud 30
2 parents 5eb88f9 + bf4e529 commit eba3191

1 file changed

Lines changed: 41 additions & 13 deletions

File tree

src/components/NcListItem/NcListItem.vue

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@
356356
class="list-item"
357357
:class="{
358358
'list-item--compact': compact,
359+
'list-item--legacy': isLegacy,
359360
'list-item--one-line': oneLine,
360361
}"
361362
@mouseover="handleMouseover"
@@ -585,6 +586,15 @@ export default {
585586
'update:menuOpen',
586587
],
587588
589+
setup() {
590+
const [major] = window._oc_config?.version.split('.', 2) ?? []
591+
const isLegacy = major && Number.parseInt(major) < 30
592+
593+
return {
594+
isLegacy,
595+
}
596+
},
597+
588598
data() {
589599
return {
590600
hovered: false,
@@ -780,7 +790,7 @@ export default {
780790
781791
// NcListItem
782792
.list-item {
783-
--list-item-padding: 8px;
793+
--list-item-padding: var(--default-grid-baseline);
784794
// The content are two lines of text and respect the 1.5 line height
785795
--list-item-height: calc(2 * var(--default-line-height));
786796
--list-item-border-radius: var(--border-radius-element, 32px);
@@ -790,9 +800,7 @@ export default {
790800
position: relative;
791801
flex: 0 0 auto;
792802
justify-content: flex-start;
793-
// we need to make sure the elements are not cut off by the border
794-
padding-inline: calc((var(--list-item-height) - var(--list-item-border-radius)) / 2);
795-
padding-block: var(--list-item-padding);
803+
padding: var(--list-item-padding);
796804
width: 100%;
797805
border-radius: var(--border-radius-element, 32px);
798806
cursor: pointer;
@@ -812,18 +820,29 @@ export default {
812820
}
813821
814822
&--compact {
815-
--list-item-padding: 2px;
823+
--list-item-padding: calc(0.5 * var(--default-grid-baseline)) var(--default-grid-baseline);
824+
825+
&:not(:has(.list-item-content__subname)) {
826+
--list-item-height: var(--default-clickable-area);
827+
}
816828
}
817-
.list-item-content__details {
818-
display: flex;
819-
flex-direction: column;
820-
justify-content: end;
821-
align-items: end;
829+
830+
&--legacy {
831+
--list-item-padding: calc(2 * var(--default-grid-baseline));
832+
833+
&.list-item--compact {
834+
--list-item-padding: var(--default-grid-baseline) calc(2 * var(--default-grid-baseline));
835+
}
822836
}
837+
823838
&--one-line {
824839
--list-item-height: var(--default-clickable-area);
825840
--list-item-border-radius: var(--border-radius-element, calc(var(--default-clickable-area) / 2));
826-
--list-item-padding: 2px;
841+
--list-item-padding: var(--default-grid-baseline);
842+
843+
&#{&}--legacy {
844+
--list-item-padding: 2px calc((var(--list-item-height) - var(--list-item-border-radius)) / 2);
845+
}
827846
828847
.list-item-content__main {
829848
display: flex;
@@ -859,8 +878,9 @@ export default {
859878
display: flex;
860879
flex: 1 0;
861880
justify-content: space-between;
862-
padding-left: 8px;
881+
padding-left: calc(2 * var(--default-grid-baseline));
863882
min-width: 0;
883+
864884
&__main {
865885
flex: 1 0;
866886
width: 0;
@@ -871,6 +891,13 @@ export default {
871891
}
872892
}
873893
894+
&__details {
895+
display: flex;
896+
flex-direction: column;
897+
justify-content: end;
898+
align-items: end;
899+
}
900+
874901
&__actions {
875902
flex: 0 0 auto;
876903
align-self: center;
@@ -894,8 +921,9 @@ export default {
894921
margin: 0 5px;
895922
}
896923
}
924+
897925
&__extra {
898-
margin-top: 4px;
926+
margin-top: var(--default-grid-baseline);
899927
}
900928
}
901929

0 commit comments

Comments
 (0)