2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<div class="text-zoomer">
|
2022-04-24 08:29:14 +00:00
|
|
|
<button title="Zoom out" @click.prevent="zoom(-1)">
|
|
|
|
<i class="fa fa-search-minus"></i>
|
|
|
|
</button>
|
|
|
|
<button title="Zoom in" @click.prevent="zoom(1)">
|
|
|
|
<i class="fa fa-search-plus"></i>
|
|
|
|
</button>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { toRefs } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const props = defineProps<{ target: HTMLElement | null }>()
|
|
|
|
const { target } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const zoom = (level: number) => {
|
|
|
|
if (!target.value) {
|
|
|
|
return
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const style = target.value.style
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
if (style.fontSize === '') {
|
|
|
|
style.fontSize = '1em'
|
|
|
|
style.lineHeight = '1.6'
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
style.fontSize = parseFloat(style.fontSize) + level * 0.2 + 'em'
|
|
|
|
style.lineHeight = String(parseFloat(style.lineHeight) + level * 0.15)
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.text-zoomer {
|
|
|
|
display: flex;
|
|
|
|
transition: .2s;
|
|
|
|
|
|
|
|
button {
|
|
|
|
@include inset-when-pressed();
|
|
|
|
|
|
|
|
background: var(--color-bg-primary);
|
|
|
|
border: 1px solid rgba(255, 255, 255, .2);
|
|
|
|
opacity: .8;
|
|
|
|
color: var(--color-text-primary);
|
|
|
|
transition: background .2s;
|
|
|
|
padding: .5rem .75rem;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
opacity: 1;
|
|
|
|
background: var(--color-bg-primary);
|
|
|
|
color: var(--color-text-primary);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:first-of-type {
|
|
|
|
border-radius: 4px 0 0 4px;
|
|
|
|
border-right: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-of-type {
|
|
|
|
border-radius: 0 4px 4px 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|