Skip to content

Commit 5df650c

Browse files
committed
fix: improve positions table column alignment and PnL layout
Use percentage-based widths with flex-none for all desktop columns so headers and cell content align perfectly. Split PnL into two lines (percentage + dollar amount) for better readability.
1 parent 7c9e88a commit 5df650c

3 files changed

Lines changed: 62 additions & 26 deletions

File tree

src/common/components/TableNumber.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<Tooltip :content="tooltip">
3-
<div class="flex flex-col">
3+
<div class="flex w-full flex-col">
44
<div class="flex justify-end">{{ value }}</div>
55
<div class="flex flex-1 justify-end text-12 font-normal">{{ subValue }}</div>
66
</div>

src/common/components/TablePnl.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<div class="flex w-full flex-col">
3+
<div
4+
class="flex items-center justify-end gap-1 text-14 font-normal"
5+
:class="positive ? 'text-typography-success' : 'text-typography-error'"
6+
>
7+
<div
8+
class="flex w-[20px] items-center justify-center rounded p-0.5"
9+
:class="positive ? '!bg-success-muted' : '!bg-error-muted'"
10+
>
11+
<SvgIcon
12+
name="arrow"
13+
size="xs"
14+
:class="positive ? 'fill-icon-success' : 'rotate-180 fill-icon-error'"
15+
/>
16+
</div>
17+
{{ percent }}
18+
</div>
19+
<div
20+
class="flex justify-end text-12 font-normal"
21+
:class="positive ? 'text-typography-success' : 'text-typography-error'"
22+
>
23+
{{ amount }}
24+
</div>
25+
</div>
26+
</template>
27+
28+
<script lang="ts" setup>
29+
import { SvgIcon } from "web-components";
30+
31+
defineProps<{
32+
percent: string;
33+
amount: string;
34+
positive: boolean;
35+
}>();
36+
</script>

src/modules/leases/components/Leases.vue

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ import {
103103
104104
import { RouteNames } from "@/router";
105105
106-
import BigNumber, { type IBigNumber } from "@/common/components/BigNumber.vue";
106+
import BigNumber from "@/common/components/BigNumber.vue";
107107
import ListHeader from "@/common/components/ListHeader.vue";
108108
import EmptyState from "@/common/components/EmptyState.vue";
109109
import SharePnLDialog from "@/modules/leases/components/single-lease/SharePnLDialog.vue";
@@ -133,6 +133,7 @@ import { useRouter } from "vue-router";
133133
import type { IAction } from "./single-lease/Action.vue";
134134
import Action from "./single-lease/Action.vue";
135135
import TableNumber from "@/common/components/TableNumber.vue";
136+
import TablePnl from "@/common/components/TablePnl.vue";
136137
import type { LeaseInfo } from "@/common/api";
137138
138139
const leasesStore = useLeasesStore();
@@ -174,13 +175,13 @@ const columns = computed<TableColumnProps[]>(() =>
174175
{ label: "", class: "!flex-none w-[40px]" }
175176
]
176177
: [
177-
{ label: i18n.t("message.lease"), variant: "left", class: "max-w-[150px]" },
178-
{ label: i18n.t("message.asset"), variant: "left" },
179-
{ label: i18n.t("message.type"), variant: "left", class: "max-w-[45px]" },
180-
{ label: i18n.t("message.pnl"), class: "max-w-[200px]" },
181-
{ label: i18n.t("message.lease-size") },
182-
{ label: i18n.t("message.liquidation-lease-table"), class: "max-w-[200px]" },
183-
{ label: "", class: "max-w-[220px]" }
178+
{ label: i18n.t("message.lease"), variant: "left", class: "flex-[1.1_1_0%]" },
179+
{ label: i18n.t("message.asset"), variant: "left", class: "flex-[1.7_1_0%]" },
180+
{ label: i18n.t("message.type"), variant: "left", class: "flex-[0.6_1_0%]" },
181+
{ label: i18n.t("message.pnl"), class: "flex-[1.6_1_0%]" },
182+
{ label: i18n.t("message.lease-size"), class: "flex-[1.7_1_0%]" },
183+
{ label: i18n.t("message.liquidation-lease-table"), class: "flex-[1.5_1_0%]" },
184+
{ label: "", class: "flex-[1.8_1_0%]" }
184185
]
185186
);
186187
@@ -294,10 +295,13 @@ const leasesData = computed<TableRowItemProps[]>(() => {
294295
}
295296
296297
const liquidation = loading
297-
? { component: () => h("div", { class: "skeleton-box mb-2 rounded-[4px] w-[70px] h-[20px]" }) }
298+
? {
299+
component: () => h("div", { class: "skeleton-box mb-2 rounded-[4px] w-[70px] h-[20px]" }),
300+
class: "flex-[1.5_1_0%]"
301+
}
298302
: {
299303
value: formatPriceUsd(displayData.liquidationPrice.toString()),
300-
class: "max-w-[200px]"
304+
class: "flex-[1.5_1_0%]"
301305
};
302306
303307
const actions: Component[] = getActions(item, displayData);
@@ -311,36 +315,32 @@ const leasesData = computed<TableRowItemProps[]>(() => {
311315
click: () => {
312316
router.push(`/${RouteNames.LEASES}/${item.address}`);
313317
},
314-
class: "text-typography-link font-semibold max-w-[150px] cursor-pointer"
318+
class: "text-typography-link font-semibold flex-[1.1_1_0%] cursor-pointer"
315319
},
316320
{
317321
image: getAssetIcon(item),
318322
imageClass: "w-[32px] h-[32px]",
319323
value: asset?.shortName ?? "",
320324
subValue: asset?.name ?? "",
321325
variant: "left",
322-
textClass: "line-clamp-1 [display:-webkit-box]"
326+
textClass: "line-clamp-1 [display:-webkit-box]",
327+
class: "flex-[1.7_1_0%]"
323328
},
324329
{
325330
value: positionType,
326331
variant: "left",
327-
class: "max-w-[45px]"
332+
class: "flex-[0.6_1_0%]"
328333
},
329334
{
330335
component: () =>
331336
loading
332337
? h("div", { class: "skeleton-box mb-2 rounded-[4px] w-[70px] h-[20px]" })
333-
: h<IBigNumber>(BigNumber, {
334-
pnlStatus: {
335-
positive: pnlData.status,
336-
value: `${pnlData.status ? "+" : ""}${pnlData.percent}% (${hide.value ? "****" : pnlData.amount})`,
337-
badge: {
338-
content: pnlData.percent,
339-
base: false
340-
}
341-
}
338+
: h(TablePnl, {
339+
percent: `${pnlData.status ? "+" : ""}${pnlData.percent}%`,
340+
amount: hide.value ? "****" : pnlData.amount,
341+
positive: pnlData.status
342342
}),
343-
class: "max-w-[200px]"
343+
class: "flex-[1.6_1_0%] [&>div]:w-full [&>div>div]:w-full"
344344
},
345345
{
346346
component: () =>
@@ -351,12 +351,12 @@ const leasesData = computed<TableRowItemProps[]>(() => {
351351
subValue: value.subValue,
352352
tooltip: value.tooltip
353353
}),
354-
class: "font-semibold break-all"
354+
class: "flex-[1.7_1_0%] font-semibold break-all [&>div]:w-full [&>div>div]:w-full"
355355
},
356356
liquidation,
357357
{
358358
component: () => [...actions],
359-
class: "max-w-[220px] pr-4 cursor-pointer"
359+
class: "flex-[1.8_1_0%] pr-4 cursor-pointer"
360360
}
361361
]
362362
};

0 commit comments

Comments
 (0)