Skip to content

Commit 180cddc

Browse files
committed
style(Viewer): refine layout and alignment in log viewer components
- Centered alignment for row pins and severity indicators in the CSS for improved visual consistency. - Adjusted height calculations in LogList.vue to enhance the display of log records, ensuring better spacing and readability. - Introduced a new function to determine pin block height based on record content, optimizing layout for expanded log entries.
1 parent 3065530 commit 180cddc

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

Viewer/src/components/LogList.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,26 +136,34 @@ function estimateRecordHeight(record: LogRecord) {
136136
if (record.body.includes("\n") || record.body.length > 160) {
137137
const lineCount = record.body.split("\n").length;
138138
const wrappedLines = Math.floor(record.body.length / 180);
139-
return Math.min(220, 38 + Math.max(lineCount - 1, wrappedLines) * 18);
139+
return Math.min(220, 34 + Math.max(lineCount - 1, wrappedLines) * 18);
140140
}
141141
142-
return 36;
142+
return 34;
143143
}
144144
145145
function measureVirtualElement(element: Element | ComponentPublicInstance | null) {
146146
if (element instanceof Element)
147147
rowVirtualizer.value.measureElement(element);
148148
}
149149
150-
function pinOffset(item: { start: number; size: number }) {
150+
function pinOffset(item: { start: number; size: number }, record: LogRecord) {
151151
if (compact.value)
152152
return 0;
153153
154154
const distancePastTop = scrollTop.value - item.start;
155155
if (distancePastTop <= 0)
156156
return 0;
157157
158-
return Math.min(distancePastTop, Math.max(0, item.size - 34));
158+
return Math.min(distancePastTop, Math.max(0, item.size - pinBlockHeight(record)));
159+
}
160+
161+
function pinBlockHeight(record: LogRecord) {
162+
return originSubtitle(record) ? 33 : 34;
163+
}
164+
165+
function isExpandedRecord(record: LogRecord) {
166+
return !compact.value && (record.body.includes("\n") || record.body.length > 160);
159167
}
160168
161169
function formatTime(timestamp: string) {
@@ -218,13 +226,14 @@ function segmentStyle(segment: MessageSegment) {
218226
record.severityText,
219227
{
220228
compact,
229+
expanded: isExpandedRecord(record),
221230
entering: enteringKeys.has(recordKey(record)),
222231
focused: selectedRecord ? recordKey(selectedRecord) === recordKey(record) : false,
223232
selected: selectedIds.has(recordKey(record))
224233
}
225234
]"
226235
:data-index="item.index"
227-
:style="{gridTemplateColumns: gridTemplate, '--row-y': `${item.start}px`, '--pin-y': `${pinOffset(item)}px`}"
236+
:style="{gridTemplateColumns: gridTemplate, '--row-y': `${item.start}px`, '--pin-y': `${pinOffset(item, record)}px`}"
228237
@click="emit('row-click', record, $event)"
229238
@dblclick="emit('open-payload', record)"
230239
>

Viewer/src/styles.css

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,30 @@ pre::-webkit-scrollbar-thumb:hover {
626626
}
627627

628628
.row-pin {
629-
align-self: start;
629+
align-self: center;
630630
position: relative;
631631
z-index: 1;
632-
margin-top: 3px;
633632
transform: translateY(var(--pin-y, 0));
634633
}
635634

635+
.message {
636+
align-self: center;
637+
}
638+
639+
.log-row.expanded .row-pin {
640+
align-self: start;
641+
transform: translateY(calc(var(--pin-y, 0px) + 3px));
642+
}
643+
644+
.log-row.expanded .origin.row-pin {
645+
transform: translateY(var(--pin-y, 0px));
646+
}
647+
648+
.log-row.expanded .message {
649+
align-self: start;
650+
padding-top: 4px;
651+
}
652+
636653
.id.row-pin,
637654
.time.row-pin {
638655
display: inline-flex;
@@ -641,11 +658,11 @@ pre::-webkit-scrollbar-thumb:hover {
641658
}
642659

643660
.origin.row-pin {
644-
margin-top: 0;
661+
align-self: center;
645662
}
646663

647664
.severity.row-pin {
648-
margin-top: 2px;
665+
align-self: center;
649666
}
650667

651668
.log-row.entering {

0 commit comments

Comments
 (0)