| 1 | <!-- |
| 2 | Apply scaling or transforming to elements. |
| 3 | |
| 4 | Usage: |
| 5 | |
| 6 | <Transform :scale="0.5"> |
| 7 | <YourElements /> |
| 8 | </Transform> |
| 9 | --> |
| 10 | |
| 11 | <script setup lang="ts"> |
| 12 | import { computed } from 'vue' |
| 13 | |
| 14 | const props = defineProps<{ |
| 15 | scale?: number | string |
| 16 | origin?: string |
| 17 | }>() |
| 18 | |
| 19 | const style = computed(() => { |
| 20 | const transforms = [] |
| 21 | if (props.scale != null) |
| 22 | transforms.push(`scale(${props.scale || 1})`) |
| 23 | |
| 24 | return { |
| 25 | 'transform': transforms.join(' '), |
| 26 | 'transform-origin': props.origin || 'top left', |
| 27 | } |
| 28 | }) |
| 29 | </script> |
| 30 | |
| 31 | <template> |
| 32 | <div :style="style"> |
| 33 | <slot /> |
| 34 | </div> |
| 35 | </template> |
| 36 |