|
| 1 | +<template> |
| 2 | + <div class="demo-preview"> |
| 3 | + <component :is="component" /> |
| 4 | + </div> |
| 5 | +</template> |
| 6 | + |
| 7 | +<script setup lang="ts"> |
| 8 | +import { shallowRef } from 'vue'; |
| 9 | +
|
| 10 | +const props = defineProps<{ |
| 11 | + sourceFile: string |
| 12 | +}>() |
| 13 | +
|
| 14 | +const component = shallowRef(null) |
| 15 | +import(`../../examples/${props.sourceFile}.vue`).then(result => { |
| 16 | + component.value = result.default |
| 17 | +}) |
| 18 | +</script> |
| 19 | + |
| 20 | +<style lang="scss"> |
| 21 | +@use 'src/styles/colors'; |
| 22 | +
|
| 23 | +html.dark .demo-preview > *:first-child { |
| 24 | + --line-color: #37445C; |
| 25 | +} |
| 26 | +
|
| 27 | +.demo-preview { |
| 28 | + display: flex; |
| 29 | + flex-direction: column; |
| 30 | + align-items: center; |
| 31 | +
|
| 32 | + > * { |
| 33 | + width: 100%; |
| 34 | + } |
| 35 | +} |
| 36 | +
|
| 37 | +.demo-preview > *:first-child { |
| 38 | + $grid-size: 8px; |
| 39 | + $grid-width: 1px; |
| 40 | + --line-color: #E5E9F0; |
| 41 | +
|
| 42 | + background-size: $grid-size $grid-size; |
| 43 | + background-position: $grid-size $grid-size; |
| 44 | + background-color: var(--vp-c-bg); |
| 45 | + background-image: |
| 46 | + linear-gradient(to right, var(--line-color) $grid-width, transparent $grid-width), |
| 47 | + linear-gradient(to bottom, var(--line-color) $grid-width, transparent $grid-width); |
| 48 | +
|
| 49 | + font-family: 'Roboto', sans-serif; |
| 50 | + font-weight: 400; |
| 51 | + padding: 24px; |
| 52 | +
|
| 53 | + &.resizable { |
| 54 | + resize: horizontal; |
| 55 | + overflow: hidden; |
| 56 | + max-width: 100%; |
| 57 | + min-width: 150px; |
| 58 | + } |
| 59 | +} |
| 60 | +
|
| 61 | +.demo-preview > *.alt-background:first-child { |
| 62 | + background-color: var(--vp-c-bg-alt); |
| 63 | +} |
| 64 | +
|
| 65 | +.demo-preview > *.gray-background:first-child { |
| 66 | + background-color: #bbb; |
| 67 | + --line-color: #999 !important; |
| 68 | +} |
| 69 | +
|
| 70 | +.width-capped-content > * { |
| 71 | + max-width: 400px; |
| 72 | + margin: 0 auto; |
| 73 | +} |
| 74 | +
|
| 75 | +.demo-preview > *:not(:first-child, .ipl-expansion-panel__content) { |
| 76 | + background-color: var(--vp-c-bg); |
| 77 | + border-radius: 8px; |
| 78 | + padding: 8px; |
| 79 | +} |
| 80 | +
|
| 81 | +.demo-preview > *:not(:first-child) { |
| 82 | + margin-top: 8px; |
| 83 | +} |
| 84 | +</style> |
0 commit comments