|
| 1 | +<!--copied from https://github.com/LeavesMC/Documentation , original license is MPL-2.0--> |
| 2 | + |
| 3 | +<script setup lang="ts"> |
| 4 | +import ConfigViewerNode from './ConfigViewerNode.vue' |
| 5 | +import { Ref, ref } from 'vue' |
| 6 | +import IconExpand from './icons/IconExpand.vue' |
| 7 | +import IconCollapse from './icons/IconCollapse.vue' |
| 8 | +
|
| 9 | +const props = defineProps({ |
| 10 | + data: Object, |
| 11 | + name: String, |
| 12 | +}) |
| 13 | +
|
| 14 | +const node: Ref<ConfigViewerNode> = ref() |
| 15 | +
|
| 16 | +function expandAll() { |
| 17 | + node.value.expandAll() |
| 18 | +} |
| 19 | +
|
| 20 | +function collapseAll() { |
| 21 | + node.value.collapseAll() |
| 22 | +} |
| 23 | +</script> |
| 24 | + |
| 25 | +<template> |
| 26 | + <div class="config-lang-yml vp-adaptive-theme"> |
| 27 | + <span class="lang" |
| 28 | + >{{ name }} |
| 29 | + <div style="text-align: end; display: flex; flex-wrap: nowrap; gap: 8px; margin-left: 6px; margin-top: 6px;"> |
| 30 | + <IconExpand role="button" aria-label="Expand all" @click="expandAll" style="width: 20px; height: 20px" /> |
| 31 | + <IconCollapse role="button" aria-label="Collapse all" @click="collapseAll" style="width: 20px; height: 20px" /> |
| 32 | + </div> |
| 33 | + </span> |
| 34 | + <pre |
| 35 | + class="shiki shiki-themes github-light github-dark vp-code" |
| 36 | + ><code class="config-code-block"><ConfigViewerNode |
| 37 | + ref="node" :data="data" :padding="false" parent="" /></code></pre> |
| 38 | + </div> |
| 39 | +</template> |
| 40 | + |
| 41 | +<style> |
| 42 | +.config-code-block { |
| 43 | + display: block; |
| 44 | + padding: 0 24px; |
| 45 | + width: fit-content; |
| 46 | + min-width: 100%; |
| 47 | + line-height: var(--vp-code-line-height); |
| 48 | + font-size: var(--vp-code-font-size); |
| 49 | + color: var(--vp-code-block-color); |
| 50 | + transition: color 0.5s; |
| 51 | +
|
| 52 | + font-weight: 400; |
| 53 | + background-color: transparent; |
| 54 | +
|
| 55 | + /*rtl:ignore*/ |
| 56 | + direction: ltr; |
| 57 | + /*rtl:ignore*/ |
| 58 | + text-align: left; |
| 59 | + white-space: pre; |
| 60 | + word-spacing: normal; |
| 61 | + word-break: normal; |
| 62 | + word-wrap: normal; |
| 63 | + -moz-tab-size: 4; |
| 64 | + -o-tab-size: 4; |
| 65 | + tab-size: 4; |
| 66 | + -webkit-hyphens: none; |
| 67 | + -moz-hyphens: none; |
| 68 | + -ms-hyphens: none; |
| 69 | + hyphens: none; |
| 70 | +} |
| 71 | +
|
| 72 | +.vp-doc .custom-block div[class*='config-lang-'] { |
| 73 | + margin: 8px 0; |
| 74 | + border-radius: 8px; |
| 75 | +} |
| 76 | +
|
| 77 | +.vp-doc div[class*='config-lang-'] { |
| 78 | + position: relative; |
| 79 | + margin: 16px -24px; |
| 80 | + background-color: var(--vp-code-block-bg); |
| 81 | + overflow-x: auto; |
| 82 | + transition: background-color 0.5s; |
| 83 | +} |
| 84 | +
|
| 85 | +@media (min-width: 640px) { |
| 86 | + .vp-doc div[class*='config-lang-'] { |
| 87 | + border-radius: 8px; |
| 88 | + margin: 16px 0; |
| 89 | + } |
| 90 | +} |
| 91 | +
|
| 92 | +@media (max-width: 639px) { |
| 93 | + .vp-doc li div[class*='config-lang-'] { |
| 94 | + border-radius: 8px 0 0 8px; |
| 95 | + } |
| 96 | +} |
| 97 | +
|
| 98 | +.vp-doc div[class*='config-lang-'] + div[class*='config-lang-'], |
| 99 | +.vp-doc div[class$='-api'] + div[class*='config-lang-'], |
| 100 | +.vp-doc |
| 101 | + div[class*='config-lang-'] |
| 102 | + + div[class$='-api'] |
| 103 | + > div[class*='config-lang-'] { |
| 104 | + margin-top: -8px; |
| 105 | +} |
| 106 | +
|
| 107 | +.vp-doc [class*='config-lang-'] pre { |
| 108 | + /*rtl:ignore*/ |
| 109 | + direction: ltr; |
| 110 | + /*rtl:ignore*/ |
| 111 | + text-align: left; |
| 112 | + white-space: pre; |
| 113 | + word-spacing: normal; |
| 114 | + word-break: normal; |
| 115 | + word-wrap: normal; |
| 116 | + -moz-tab-size: 4; |
| 117 | + -o-tab-size: 4; |
| 118 | + tab-size: 4; |
| 119 | + -webkit-hyphens: none; |
| 120 | + -moz-hyphens: none; |
| 121 | + -ms-hyphens: none; |
| 122 | + hyphens: none; |
| 123 | +} |
| 124 | +
|
| 125 | +.vp-doc [class*='config-lang-'] pre { |
| 126 | + position: relative; |
| 127 | + z-index: 1; |
| 128 | + margin: 0; |
| 129 | + padding: 20px 0; |
| 130 | + background: transparent; |
| 131 | + overflow-x: auto; |
| 132 | +} |
| 133 | +
|
| 134 | +.vp-doc [class*='config-lang-'] .has-focused-lines .line:not(.has-focus) { |
| 135 | + filter: blur(0.095rem); |
| 136 | + opacity: 0.4; |
| 137 | + transition: |
| 138 | + filter 0.35s, |
| 139 | + opacity 0.35s; |
| 140 | +} |
| 141 | +
|
| 142 | +.vp-doc [class*='config-lang-'] .has-focused-lines .line:not(.has-focus) { |
| 143 | + opacity: 0.7; |
| 144 | + transition: |
| 145 | + filter 0.35s, |
| 146 | + opacity 0.35s; |
| 147 | +} |
| 148 | +
|
| 149 | +.vp-doc [class*='config-lang-'] > button.copy { |
| 150 | + /*rtl:ignore*/ |
| 151 | + direction: ltr; |
| 152 | + position: absolute; |
| 153 | + top: 12px; |
| 154 | + /*rtl:ignore*/ |
| 155 | + right: 12px; |
| 156 | + z-index: 3; |
| 157 | + border: 1px solid var(--vp-code-copy-code-border-color); |
| 158 | + border-radius: 4px; |
| 159 | + width: 40px; |
| 160 | + height: 40px; |
| 161 | + background-color: var(--vp-code-copy-code-bg); |
| 162 | + opacity: 0; |
| 163 | + cursor: pointer; |
| 164 | + background-image: var(--vp-icon-copy); |
| 165 | + background-position: 50%; |
| 166 | + background-size: 20px; |
| 167 | + background-repeat: no-repeat; |
| 168 | + transition: |
| 169 | + border-color 0.25s, |
| 170 | + background-color 0.25s, |
| 171 | + opacity 0.25s; |
| 172 | +} |
| 173 | +
|
| 174 | +.vp-doc [class*='config-lang-']:hover > button.copy, |
| 175 | +.vp-doc [class*='config-lang-'] > button.copy:focus { |
| 176 | + opacity: 1; |
| 177 | +} |
| 178 | +
|
| 179 | +.vp-doc [class*='config-lang-'] > button.copy:hover, |
| 180 | +.vp-doc [class*='config-lang-'] > button.copy.copied { |
| 181 | + border-color: var(--vp-code-copy-code-hover-border-color); |
| 182 | + background-color: var(--vp-code-copy-code-hover-bg); |
| 183 | +} |
| 184 | +
|
| 185 | +.vp-doc [class*='config-lang-'] > button.copy.copied, |
| 186 | +.vp-doc [class*='config-lang-'] > button.copy:hover.copied { |
| 187 | + /*rtl:ignore*/ |
| 188 | + border-radius: 0 4px 4px 0; |
| 189 | + background-color: var(--vp-code-copy-code-hover-bg); |
| 190 | + background-image: var(--vp-icon-copied); |
| 191 | +} |
| 192 | +
|
| 193 | +.vp-doc [class*='config-lang-'] > button.copy.copied::before, |
| 194 | +.vp-doc [class*='config-lang-'] > button.copy:hover.copied::before { |
| 195 | + position: relative; |
| 196 | + top: -1px; |
| 197 | + /*rtl:ignore*/ |
| 198 | + transform: translateX(calc(-100% - 1px)); |
| 199 | + display: flex; |
| 200 | + justify-content: center; |
| 201 | + align-items: center; |
| 202 | + border: 1px solid var(--vp-code-copy-code-hover-border-color); |
| 203 | + /*rtl:ignore*/ |
| 204 | + border-right: 0; |
| 205 | + border-radius: 4px 0 0 4px; |
| 206 | + padding: 0 10px; |
| 207 | + width: fit-content; |
| 208 | + height: 40px; |
| 209 | + text-align: center; |
| 210 | + font-size: 12px; |
| 211 | + font-weight: 500; |
| 212 | + color: var(--vp-code-copy-code-active-text); |
| 213 | + background-color: var(--vp-code-copy-code-hover-bg); |
| 214 | + white-space: nowrap; |
| 215 | + content: var(--vp-code-copy-copied-text-content); |
| 216 | +} |
| 217 | +
|
| 218 | +.vp-doc [class*='config-lang-'] > span.lang { |
| 219 | + position: absolute; |
| 220 | + top: 2px; |
| 221 | + /*rtl:ignore*/ |
| 222 | + right: 8px; |
| 223 | + z-index: 2; |
| 224 | + font-size: 12px; |
| 225 | + font-weight: 500; |
| 226 | + color: var(--vp-code-lang-color); |
| 227 | + transition: |
| 228 | + color 0.4s, |
| 229 | + opacity 0.4s; |
| 230 | +} |
| 231 | +
|
| 232 | +.vp-doc [class*='config-lang-']:hover > button.copy + span.lang, |
| 233 | +.vp-doc [class*='config-lang-'] > button.copy:focus + span.lang { |
| 234 | + opacity: 0; |
| 235 | +} |
| 236 | +</style> |
0 commit comments