|
| 1 | +<script setup lang="ts"> |
| 2 | +import { ref } from 'vue'; |
| 3 | +import { CommandData } from '../types'; |
| 4 | +import JsonTree from './JsonTree.vue'; |
| 5 | +
|
| 6 | +defineProps<{ log: CommandData }>() |
| 7 | +const level = ref(1) |
| 8 | +// function toggleGroupCollapse() { |
| 9 | +// log.collapsed = !log.collapsed; |
| 10 | +// } |
| 11 | +</script> |
| 12 | + |
| 13 | +<template> |
| 14 | + <div |
| 15 | + v-if="log.level === 'table'" |
| 16 | + > |
| 17 | + <ConsoleTable :data="log.args[0]" :columns="log.args[1]" /> |
| 18 | + </div> |
| 19 | + <div |
| 20 | + class="log console-{{ log.level }}" |
| 21 | + :style="{ paddingLeft: level * 15 + 'px' }" |
| 22 | + > |
| 23 | + <span v-if="log.count && log.count > 1" class="count">{{ log.count }}x</span> |
| 24 | + |
| 25 | + <div |
| 26 | + v-if="log.level === 'trace' || log.level === 'assert'" |
| 27 | + class="arrow" |
| 28 | + >▶</div> |
| 29 | + |
| 30 | + <span v-if="log.level === 'assert'" class="assert">Assertion failed:</span> |
| 31 | + |
| 32 | + <span v-if="log.level === 'clear'" class="info">Console was cleared</span> |
| 33 | + <span v-if="log.level === 'unclonable'" class="info error">Message could not be cloned. Open devtools to see it</span> |
| 34 | + <div v-if="log.level === 'group'" class="arrow" :class="{ expand: !log.collapsed }" @click="toggleGroupCollapse">▶</div> |
| 35 | + <span v-if="log.level === 'group'" class="title">{{ log.label }}</span> |
| 36 | + |
| 37 | + <span v-if="log.level.startsWith('system')"> |
| 38 | + <template v-for="arg in log.args"> |
| 39 | + {{ arg }} |
| 40 | + </template> |
| 41 | + </span> |
| 42 | + |
| 43 | + <JSONNode v-if="log.level === 'table'" :value="log.args[0]" /> |
| 44 | + <template v-else> |
| 45 | + <template v-for="arg in log.args"> |
| 46 | + <JsonTree :data="arg" /> |
| 47 | + </template> |
| 48 | + </template> |
| 49 | + |
| 50 | + <div |
| 51 | + v-for="(_, idx) in new Array(level - 1)" |
| 52 | + class="outline" |
| 53 | + :style="{ left: idx * 15 + 15 + 'px' }" |
| 54 | + /> |
| 55 | + </div> |
| 56 | + |
| 57 | +</template> |
| 58 | + |
| 59 | +<style> |
| 60 | + .log { |
| 61 | + border-bottom: 1px solid #eee; |
| 62 | + padding: 5px 10px 0px; |
| 63 | + display: flex; |
| 64 | + position: relative; |
| 65 | + font-size: 12px; |
| 66 | + font-family: var(--font-mono); |
| 67 | + } |
| 68 | +
|
| 69 | + .log > :global(*) { |
| 70 | + margin-right: 10px; |
| 71 | + font-family: var(--font-mono); |
| 72 | + } |
| 73 | +
|
| 74 | + .console-warn, .console-system-warn { |
| 75 | + background: #fffbe6; |
| 76 | + border-color: #fff4c4; |
| 77 | + } |
| 78 | +
|
| 79 | + .console-error, .console-assert { |
| 80 | + background: #fff0f0; |
| 81 | + border-color: #fed6d7; |
| 82 | + } |
| 83 | +
|
| 84 | + .console-group, .arrow { |
| 85 | + cursor: pointer; |
| 86 | + user-select: none; |
| 87 | + } |
| 88 | +
|
| 89 | + .console-trace, .console-assert { |
| 90 | + border-bottom: none; |
| 91 | + } |
| 92 | +
|
| 93 | + .console-assert + .trace { |
| 94 | + background: #fff0f0; |
| 95 | + border-color: #fed6d7; |
| 96 | + } |
| 97 | +
|
| 98 | + .trace { |
| 99 | + border-bottom: 1px solid #eee; |
| 100 | + font-size: 12px; |
| 101 | + font-family: var(--font-mono); |
| 102 | + padding: 4px 0 2px; |
| 103 | + } |
| 104 | +
|
| 105 | + .trace > :global(div) { |
| 106 | + margin-left: 15px; |
| 107 | + } |
| 108 | +
|
| 109 | + .count { |
| 110 | + color: #999; |
| 111 | + font-size: 12px; |
| 112 | + line-height: 1.2; |
| 113 | + } |
| 114 | +
|
| 115 | + .info { |
| 116 | + color: #666; |
| 117 | + font-family: var(--font) !important; |
| 118 | + font-size: 12px; |
| 119 | + } |
| 120 | +
|
| 121 | + .error { |
| 122 | + color: #da106e; /* todo make this a var */ |
| 123 | + } |
| 124 | +
|
| 125 | + .outline { |
| 126 | + border-left: 1px solid #9c9cab; |
| 127 | + position: absolute; |
| 128 | + top: 0; |
| 129 | + bottom: -1px; |
| 130 | + } |
| 131 | +
|
| 132 | + .arrow { |
| 133 | + position: absolute; |
| 134 | + font-size: 0.6em; |
| 135 | + transition: 150ms; |
| 136 | + transform-origin: 50% 50%; |
| 137 | + transform: translateY(1px) translateX(-50%); |
| 138 | + } |
| 139 | +
|
| 140 | + .arrow.expand { |
| 141 | + transform: translateY(1px) translateX(-50%) rotateZ(90deg); |
| 142 | + } |
| 143 | +
|
| 144 | + .title { |
| 145 | + font-family: var(--font-mono); |
| 146 | + font-size: 13px; |
| 147 | + font-weight: bold; |
| 148 | + padding-left: 11px; |
| 149 | + height: 19px; |
| 150 | + } |
| 151 | +
|
| 152 | + .assert { |
| 153 | + padding-left: 11px; |
| 154 | + font-weight: bold; |
| 155 | + color: #da106e; |
| 156 | + } |
| 157 | +</style> |
0 commit comments