gctGenerator/site/.vuepress/components/Preview.vue

50 lines
1,011 B
Vue
Raw Normal View History

2022-10-07 23:02:40 +09:00
<template>
<div class="preview-root">
<div class="preview-ctn">
<PreviewString v-for="c in previews"
:key="c.key" :config="c" :version="_version" />
2022-10-07 23:02:40 +09:00
</div>
</div>
</template>
<script>
import {previewIds} from './codes/preview.js';
2022-10-07 23:02:40 +09:00
export default {
props: {
config: {type: Object},
},
computed: {
_version() {
const {_version} = this.config;
return _version;
},
previews() {
return previewIds.flatMap(id => {
const config = /**@type{any}*/(this.config)[id];
if (config == null) return [];
if (config instanceof Array) {
return config.map((c, i) => ({...c, key: `${id}-${i}`}));
} else {
return {...config, key: id};
}
});
},
2022-10-07 23:02:40 +09:00
},
}
</script>
<style scoped>
.preview-root {
2022-10-07 23:02:40 +09:00
position: relative;
width: 600px;
height: 448px;
background: url(/img/preview/background.png);
padding: 0;
overflow: hidden;
}
.preview-ctn {
2022-10-07 23:02:40 +09:00
position: absolute;
top: -16px;
}
</style>