From 704a3d041780ee12486445640362b2854c28bcb3 Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Tue, 2 Apr 2024 11:44:31 +0200 Subject: [PATCH] Fix card height inconsistency TODO: Is CardLayout, card-layout, cardLayout etc., best names possiuble? Fix card expansion panel heights not being equal. This is due to limitations in CSS flex view. Heights of all cards are `100%` which gives them uniform loook on same row with all equal heights. However, their heights are set to `auto` when of the cards are open. In that case, their sizes are no longer equal in same row, cards with longer text/titles keeping more space. This is because when a card is open, its expansion panel grows in its own DOM element, increasing the height of the card. at same height on each line, their heights change completely when one of Heights gets fucked up when card is collapsing, this is big fix, fix this. Supporting changes: - Move card expander to its own component `CardExpansionPanel`. - Introduce `UseCardLayout` hook to do calculations instead of CSS to circumvent limitations in CSS flex view. --- .../Scripts/View/Cards/CardExpansionPanel.vue | 91 ++++++++++++ .../Scripts/View/Cards/CardList.vue | 15 +- .../Scripts/View/Cards/CardListItem.vue | 131 ++++++------------ .../Scripts/View/Cards/UseCardLayout.ts | 68 +++++++++ 4 files changed, 213 insertions(+), 92 deletions(-) create mode 100644 src/presentation/components/Scripts/View/Cards/CardExpansionPanel.vue create mode 100644 src/presentation/components/Scripts/View/Cards/UseCardLayout.ts diff --git a/src/presentation/components/Scripts/View/Cards/CardExpansionPanel.vue b/src/presentation/components/Scripts/View/Cards/CardExpansionPanel.vue new file mode 100644 index 00000000..6900d55d --- /dev/null +++ b/src/presentation/components/Scripts/View/Cards/CardExpansionPanel.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/src/presentation/components/Scripts/View/Cards/CardList.vue b/src/presentation/components/Scripts/View/Cards/CardList.vue index dd831327..44c7282e 100644 --- a/src/presentation/components/Scripts/View/Cards/CardList.vue +++ b/src/presentation/components/Scripts/View/Cards/CardList.vue @@ -7,9 +7,9 @@
@@ -46,6 +47,7 @@ import { injectKey } from '@/presentation/injectionSymbols'; import SizeObserver from '@/presentation/components/Shared/SizeObserver.vue'; import { hasDirective } from './NonCollapsingDirective'; import CardListItem from './CardListItem.vue'; +import { useCardLayout } from './UseCardLayout'; export default defineComponent({ components: { @@ -61,8 +63,14 @@ export default defineComponent({ const categoryIds = computed( () => currentState.value.collection.actions.map((category) => category.id), ); + const activeCategoryId = ref(undefined); + const cardLayout = useCardLayout({ + containerWidth: computed(() => width.value ?? 0), + totalCards: computed(() => categoryIds.value.length), + }); + function onSelected(categoryId: number, isExpanded: boolean) { activeCategoryId.value = isExpanded ? categoryId : undefined; } @@ -101,6 +109,7 @@ export default defineComponent({ width, categoryIds, activeCategoryId, + cardLayout, onSelected, }; }, diff --git a/src/presentation/components/Scripts/View/Cards/CardListItem.vue b/src/presentation/components/Scripts/View/Cards/CardListItem.vue index 454167f0..7afc289d 100644 --- a/src/presentation/components/Scripts/View/Cards/CardListItem.vue +++ b/src/presentation/components/Scripts/View/Cards/CardListItem.vue @@ -29,26 +29,12 @@ /> -
- -
-
- -
-
- -
-
-
+
@@ -56,30 +42,32 @@