Skip to content

Commit

Permalink
feat: improves icons placement for expanding json (#2854)
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Mar 26, 2024
1 parent 21c775d commit 9c1b967
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
2 changes: 2 additions & 0 deletions assets/components.d.ts
Expand Up @@ -52,6 +52,8 @@ declare module 'vue' {
LogStd: typeof import('./components/LogViewer/LogStd.vue')['default']
LogViewer: typeof import('./components/LogViewer/LogViewer.vue')['default']
LogViewerWithSource: typeof import('./components/LogViewer/LogViewerWithSource.vue')['default']
'MaterialSymbols:collapseAllRounded': typeof import('~icons/material-symbols/collapse-all-rounded')['default']
'MaterialSymbols:expandAllRounded': typeof import('~icons/material-symbols/expand-all-rounded')['default']
'Mdi:announcement': typeof import('~icons/mdi/announcement')['default']
'Mdi:arrowUp': typeof import('~icons/mdi/arrow-up')['default']
'Mdi:check': typeof import('~icons/mdi/check')['default']
Expand Down
25 changes: 10 additions & 15 deletions assets/components/LogViewer/ComplexLogItem.vue
@@ -1,5 +1,10 @@
<template>
<div class="relative flex w-full gap-x-2">
<div class="group/item relative flex w-full gap-x-2" @click="expandToggle()">
<label class="swap swap-rotate invisible absolute -left-4 top-0.5 size-4 group-hover/item:visible">
<input type="checkbox" v-model="expanded" @click="expandToggle()" />
<material-symbols:expand-all-rounded class="swap-off text-secondary" />
<material-symbols:collapse-all-rounded class="swap-on text-secondary" />
</label>
<div v-if="showStd">
<log-std :std="logEntry.std"></log-std>
</div>
Expand All @@ -10,8 +15,8 @@
<log-level :level="logEntry.level"></log-level>
</div>
<div>
<ul class="fields cursor-pointer space-x-4" :class="{ expanded }" @click="expandToggle()">
<li v-for="(value, name) in validValues" class="inline-block">
<ul class="fields cursor-pointer space-x-4" :class="{ expanded }">
<li v-for="(value, name) in validValues">
<span class="text-light">{{ name }}=</span><span class="font-bold" v-if="value === null">&lt;null&gt;</span>
<template v-else-if="Array.isArray(value)">
<span class="font-bold" v-html="markSearch(JSON.stringify(value))"> </span>
Expand Down Expand Up @@ -52,18 +57,8 @@ const validValues = computed(() => {
}
.fields {
&:hover {
&::after {
content: "expand json";
@apply ml-2 inline-block text-secondary;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
}
&.expanded:hover {
&::after {
content: "collapse json";
}
li {
@apply inline-flex;
}
}
</style>
12 changes: 6 additions & 6 deletions assets/components/LogViewer/FieldList.vue
Expand Up @@ -11,19 +11,19 @@
></field-list>
</template>
<template v-else-if="Array.isArray(value)">
<a @click="toggleField(name)" class="link-primary cursor-pointer">
{{ hasField(name) ? "remove" : "add" }}&nbsp;</a
>
<a @click.stop="toggleField(name)" class="link-primary mr-2 cursor-pointer">
{{ hasField(name) ? "remove" : "add" }}
</a>
<span class="text-light">{{ name }}=</span>[
<span class="font-bold" v-for="(item, index) in value">
<span v-html="JSON.stringify(item)"></span><span v-if="index !== value.length - 1">,</span>
</span>
]
</template>
<template v-else>
<a @click="toggleField(name)" class="link-primary cursor-pointer">
{{ hasField(name) ? "remove" : "add" }}&nbsp;</a
>
<a @click.stop="toggleField(name)" class="link-primary mr-2 cursor-pointer">
{{ hasField(name) ? "remove" : "add" }}
</a>
<span class="text-light">{{ name }}=</span><span class="font-bold" v-html="value"></span>
</template>
</li>
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -73,6 +73,7 @@
"vue-router": "^4.3.0"
},
"devDependencies": {
"@iconify-json/material-symbols": "^1.1.74",
"@pinia/testing": "^0.1.3",
"@playwright/test": "^1.42.1",
"@types/d3-array": "^3.2.1",
Expand Down
10 changes: 9 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c1b967

Please sign in to comment.