techtools
Головна / proto / flow-old / src / components / BlockHelpPanel.vue

BlockHelpPanel.vue

Vue · 57 рядків

1<script setup>
2import { onBeforeUnmount, onMounted } from 'vue'
3import { renderMarkdown } from '../markdown.js'
4
5const props = defineProps({ help: { type: Object, required: true } })
6const emit = defineEmits(['close'])
7const onKeydown = event => {
8  if (event.key === 'Escape') emit('close')
9}
10onMounted(() => window.addEventListener('keydown', onKeydown))
11onBeforeUnmount(() => window.removeEventListener('keydown', onKeydown))
12</script>
13
14<template>
15  <Teleport to="body">
16    <Transition name="block-help">
17      <aside class="block-help-panel" role="dialog" :aria-label="`${help.title} help`">
18        <header>
19          <div>
20            <span class="block-help-label">BLOCK HELP</span>
21            <h2>{{ help.title }}</h2>
22            <p>{{ help.subtitle }}</p>
23          </div>
24          <button class="block-help-close" title="Close help (Esc)" aria-label="Close help" @click="emit('close')">×</button>
25        </header>
26        <article class="block-help-content" v-html="renderMarkdown(props.help.markdown)"></article>
27      </aside>
28    </Transition>
29  </Teleport>
30</template>
31
32<style scoped>
33.block-help-panel{position:fixed;z-index:70;top:64px;bottom:0;right:330px;width:400px;max-width:calc(100vw - 330px);height:auto;background:#111820;border-left:1px solid #31404d;border-right:1px solid #31404d;box-shadow:-18px 0 45px rgba(0,0,0,.35);display:flex;flex-direction:column;color:#dce7ee}
34.block-help-panel header{display:flex;gap:16px;align-items:flex-start;padding:22px 20px 18px;border-bottom:1px solid #2a3742;background:#17212a}
35.block-help-panel header>div{min-width:0;flex:1}
36.block-help-label{font-size:10px;letter-spacing:.16em;color:#72d7c7;font-weight:800}
37.block-help-panel h2{margin:5px 0 4px;font-size:21px;line-height:1.2;color:#fff}
38.block-help-panel header p{margin:0;font-size:12px;line-height:1.45;color:#94a7b4}
39.block-help-close{flex:none;display:grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid #3b4a56;border-radius:6px;background:#202c35;color:#dce7ee;font-size:23px;line-height:1;cursor:pointer}
40.block-help-close:hover{border-color:#72d7c7;color:#72d7c7}
41.block-help-content{overflow:auto;padding:8px 22px 40px;font-size:13px;line-height:1.62}
42.block-help-content :deep(h1){margin:20px 0 8px;font-size:20px;color:#fff}
43.block-help-content :deep(h2){margin:26px 0 8px;padding-top:4px;font-size:15px;color:#8fe4d7}
44.block-help-content :deep(h3){font-size:13px;color:#fff}
45.block-help-content :deep(p){margin:8px 0;color:#becbd3}
46.block-help-content :deep(ul),.block-help-content :deep(ol){margin:8px 0;padding-left:22px;color:#becbd3}
47.block-help-content :deep(li){margin:5px 0}
48.block-help-content :deep(code){padding:2px 5px;border-radius:4px;background:#26333d;color:#ffcb8b;font:12px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace}
49.block-help-content :deep(pre){overflow:auto;margin:12px 0;padding:13px;border:1px solid #30414d;border-radius:7px;background:#0a1015}
50.block-help-content :deep(pre code){padding:0;background:transparent;color:#c7e6ef;white-space:pre}
51.block-help-content :deep(blockquote){margin:12px 0;padding:8px 12px;border-left:3px solid #72d7c7;background:#18252d;color:#b9cbd4}
52.block-help-enter-active,.block-help-leave-active{transition:transform .18s ease,opacity .18s ease}
53.block-help-enter-from,.block-help-leave-to{transform:translateX(18px);opacity:0}
54@media(max-width:800px){.block-help-panel{right:300px;max-width:calc(100vw - 300px)}}
55</style>
56
57