FontSizePicker.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <span class="inline-flex">
  3. <tippy ref="fontSize" interactive trigger="click" theme="popover" arrow>
  4. <template #trigger>
  5. <span class="select-wrapper">
  6. <ButtonSecondary
  7. v-tippy="{ theme: 'tooltip' }"
  8. :title="$t('settings.change_font_size')"
  9. class="pr-8"
  10. svg="type"
  11. outline
  12. :label="`${getFontSizeName(
  13. fontSizes.find((size) => size == active)
  14. )}`"
  15. />
  16. </span>
  17. </template>
  18. <SmartItem
  19. v-for="(size, index) in fontSizes"
  20. :key="`size-${index}`"
  21. :label="`${getFontSizeName(size)}`"
  22. :info-icon="size === active ? 'done' : ''"
  23. :active-info-icon="size === active"
  24. @click.native="
  25. () => {
  26. setActiveFont(size)
  27. $refs.fontSize.tippy().hide()
  28. }
  29. "
  30. />
  31. </tippy>
  32. </span>
  33. </template>
  34. <script lang="ts">
  35. import { defineComponent } from "@nuxtjs/composition-api"
  36. import {
  37. HoppFontSizes,
  38. HoppFontSize,
  39. applySetting,
  40. useSetting,
  41. } from "~/newstore/settings"
  42. export default defineComponent({
  43. setup() {
  44. return {
  45. fontSizes: HoppFontSizes,
  46. active: useSetting("FONT_SIZE"),
  47. }
  48. },
  49. methods: {
  50. getFontSizeName(size: HoppFontSize) {
  51. return this.$t(`settings.font_size_${size}`)
  52. },
  53. setActiveFont(size: HoppFontSize) {
  54. document.documentElement.setAttribute("data-font-size", size)
  55. applySetting("FONT_SIZE", size)
  56. },
  57. },
  58. })
  59. </script>