Skip to content

Commit c72fffa

Browse files
fix(categories): keep durations readable for long names (#843)
1 parent be8e249 commit c72fffa

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

src/visualizations/CategoryTree.vue

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template lang="pug">
22
div(style="font-size: 0.9em")
3-
div.px-1(v-for="cat in category_hierarchy" @click="toggle(cat)" v-if="parents_expanded(cat)", :class="{'clickable': cat.children.length > 0}")
4-
span(:style="'padding-left: ' + (1.4 * cat.depth) + 'em'")
3+
div.px-1.category-row(v-for="cat in category_hierarchy" @click="toggle(cat)" v-if="parents_expanded(cat)", :class="{'clickable': cat.children.length > 0}")
4+
div.category-label(:style="'padding-left: ' + (1.4 * cat.depth) + 'em'")
55

66
// icon
77
span(v-if="cat.children.length > 0", style="opacity: 0.8")
@@ -12,11 +12,10 @@ div(style="font-size: 0.9em")
1212
span(v-else, style="opacity: 0.6")
1313
icon(name="circle", scale="0.4", style="margin-left: 1em; margin-right: 1.22em;")
1414

15-
// title
16-
| {{cat.subname}}
15+
span.category-title {{cat.subname}}
1716

1817
// time
19-
span(style="float: right")
18+
span.category-value
2019
span(v-if="show_perc")
2120
| {{Math.round(100 * cat.duration / total_duration, 1)}}%
2221
span(v-else)
@@ -27,6 +26,31 @@ div(style="font-size: 0.9em")
2726
</template>
2827

2928
<style lang="scss" scoped>
29+
.category-row {
30+
display: flex;
31+
align-items: flex-start;
32+
justify-content: space-between;
33+
gap: 0.75rem;
34+
}
35+
36+
.category-label {
37+
display: flex;
38+
flex: 1 1 auto;
39+
min-width: 0;
40+
align-items: flex-start;
41+
}
42+
43+
.category-title {
44+
min-width: 0;
45+
overflow-wrap: anywhere;
46+
}
47+
48+
.category-value {
49+
flex: 0 0 auto;
50+
white-space: nowrap;
51+
text-align: right;
52+
}
53+
3054
.clickable {
3155
cursor: pointer;
3256
}

0 commit comments

Comments
 (0)