aboutsummaryrefslogtreecommitdiff
path: root/src/App.vue
blob: f1219773eb9a3a32151057ba827813550081b8eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<template>
  <v-app @keyup.shift.tab="toggleDrawer" :style="bg">
    <v-navigation-drawer temporary v-model="drawer" location="right"
      ><v-list density="compact" nav>
        <v-list-item
          prepend-icon="mdi-home"
          title="Home"
          value="home"
          @click="
            atHome = true;
            atEdit = false;
            atSettings = false;
          "
        ></v-list-item>
        <v-list-item
          prepend-icon="mdi-pencil"
          title="Edit"
          value="edit"
          @click="
            atHome = false;
            atEdit = true;
            atSettings = false;
          "
        ></v-list-item>
        <v-list-item
          prepend-icon="mdi-cog-outline"
          title="Settings"
          value="settings"
          @click="
            atHome = false;
            atEdit = false;
            atSettings = true;
          "
        ></v-list-item>
        <v-list-item
          prepend-icon="mdi-theme-light-dark"
          title="Theme"
          value="theme"
          @click="toggleTheme"
        ></v-list-item> </v-list
    ></v-navigation-drawer>
    <v-snackbar color="grey" v-model="snackbar">
      {{ snackbarText }}

      <template v-slot:actions>
        <v-btn variant="snackbarText" @click="snackbar = false"> Close </v-btn>
      </template>
    </v-snackbar>
    <v-main>
      <v-container class="float-end w-50">
        <HomePage v-if="atHome" :contentSize="contentSize" />
        <EditPage v-else-if="atEdit" @snackbar-notification="setSnackbarText" />
        <SettingsPage
          v-else-if="atSettings"
          @update-title-size="updateTitleSize"
          @update-content-size="updateContentSize"
          @update-background-image-url="updateBackgroundImageURL"
          :realTitleSize="parseInt(titleSize)"
          :realContentSize="contentSize"
        />
      </v-container>
    </v-main>
    <!-- This is a dirty workaround to use styles inside the template. Further
    help needed. -->
    <component :is="`style`">
      .v-card-title { font-size: {{ titleSize }}; }
    </component>
  </v-app>
</template>

<script>
import { useTheme } from "vuetify";
import HomePage from "./components/HomePage.vue";
import EditPage from "./components/EditPage.vue";
import SettingsPage from "./components/SettingsPage.vue";

export default {
  name: "App",

  components: {
    HomePage,
    EditPage,
    SettingsPage,
  },

  data: () => ({
    titleSize: "35px",
    contentSize: "text-h5",
    drawer: null,
    atHome: true,
    atEdit: false,
    atSettings: false,
    snackbar: false,
    snackbarText: "Default snackbar text (End-user shouldn't see this)",
    bg: {
      // backgroundColor: "grey",
      backgroundImage: "",
      backgroundPosition: "center",
    },
  }),

  setup() {
    const theme = useTheme();

    return {
      theme,
      toggleTheme: () =>
        (theme.global.name.value = theme.global.current.value.dark
          ? "light"
          : "dark"),
    };
  },

  methods: {
    toggleDrawer() {
      this.drawer = !this.drawer;
    },
    setSnackbarText(text) {
      this.snackbarText = text;
      this.snackbar = true;
    },
    updateTitleSize(s) {
      this.titleSize = `${s}px`;
    },
    updateContentSize(s) {
      this.contentSize = s;
    },
    updateBackgroundImageURL(s) {
      this.bg.backgroundImage = s ? `url(${s})` : "";
    },
  },
};
</script>