default.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <v-app dark>
  3. <!-- height = 4rem, margin-y = 1rem -->
  4. <v-app-bar
  5. app
  6. class="topBar glass elevation-0 fly-in-from-top my-4 mx-auto"
  7. >
  8. <!-- Translator desktop -->
  9. <v-tabs centered center-active color="primary" router show-arrows>
  10. <v-tab v-for="link in links" :key="link.path" :to="link.path">
  11. {{ $vuetify.lang.t(`$vuetify.${link.name}.name`) }}
  12. </v-tab>
  13. </v-tabs>
  14. </v-app-bar>
  15. <!-- abstract background -->
  16. <v-img
  17. src="/ui/abstract.svg"
  18. style="position: fixed; left: 0; right: 0; width: 100vw; height: 100vh"
  19. />
  20. <v-main style="padding-top: 4rem !important">
  21. <!-- min-height helps keep content centered, use .debug to to see it -->
  22. <center
  23. class="py-8 mx-auto d-flex flex-column justify-center items-center"
  24. style="width: 90vw; min-height: calc(100vh - 8rem)"
  25. >
  26. <nuxt />
  27. </center>
  28. </v-main>
  29. <!-- Translator mobile -->
  30. <v-menu
  31. top
  32. left
  33. offset-y
  34. rounded="lg"
  35. nudge-top="16"
  36. class="d-flex flex-column"
  37. transition="slide-y-reverse-transition"
  38. >
  39. <template v-slot:activator="{ on, attrs }">
  40. <v-btn text fab class="glass" id="translator" v-bind="attrs" v-on="on">
  41. <v-icon>mdi-translate</v-icon>
  42. </v-btn>
  43. </template>
  44. <v-list class="py-0">
  45. <v-list-item
  46. v-for="(lang, index) in langs"
  47. :key="index"
  48. link
  49. :class="$vuetify.lang.current === lang.locale ? 'primary--text' : ''"
  50. @click="changeLocale(lang.locale)"
  51. >
  52. <v-list-item-title v-text="lang.name"></v-list-item-title>
  53. </v-list-item>
  54. </v-list>
  55. </v-menu>
  56. <!-- Debugger Notification -->
  57. <v-snackbar
  58. v-model="alert.show"
  59. :timeout="-1"
  60. class="ma-4 desktop-only"
  61. transition="slide-y-reverse-transition"
  62. color="primary"
  63. bottom
  64. left
  65. text
  66. >
  67. <v-icon color="primary" class="mr-4">mdi-alert-circle-outline</v-icon>
  68. <span class="my-auto" v-html="alert.html"></span>
  69. <template #action="{ attrs }">
  70. <v-btn
  71. v-bind="attrs"
  72. color="primary"
  73. text
  74. icon
  75. @click="alert.show = false"
  76. >
  77. <v-icon>mdi-close-circle-outline</v-icon>
  78. </v-btn>
  79. </template>
  80. </v-snackbar>
  81. </v-app>
  82. </template>
  83. <script>
  84. export default {
  85. data: () => ({
  86. links: [
  87. { name: "home", path: "/" },
  88. { name: "install", path: "/install" },
  89. { name: "api", path: "/docs" },
  90. { name: "help", path: "/help" },
  91. { name: "faq", path: "/faq" },
  92. { name: "donate", path: "/donate" },
  93. { name: "links", path: "/links" },
  94. ],
  95. langs: [
  96. { name: "English", locale: "en" },
  97. { name: "Español", locale: "es" },
  98. { name: "Türkçe", locale: "tr" },
  99. { name: "Русский", locale: "ru" },
  100. { name: "Čeština", locale: "cs" },
  101. { name: "日本語", locale: "ja" },
  102. { name: "Français", locale: "fr" },
  103. // { name: "Deutsch", locale: "de" },
  104. { name: "Українська", locale: "uk" },
  105. { name: "한국어", locale: "ko" },
  106. ],
  107. alert: {
  108. show: false,
  109. html: "",
  110. },
  111. }),
  112. created() {
  113. // fetch locale preference or browser default
  114. if (process.client && navigator.language) {
  115. if (!("locale" in localStorage))
  116. this.$vuetify.lang.current = navigator.language.slice(0, 2);
  117. else this.$vuetify.lang.current = localStorage.locale;
  118. }
  119. },
  120. mounted() {
  121. setTimeout(() => {
  122. // Chrome < 70 or FF < 60 unsupported warning popup
  123. if (
  124. (this.$ua._parsed.name == "Chrome" &&
  125. parseInt(this.$ua._parsed.version.split(".")[0]) < 70) ||
  126. (this.$ua._parsed.name == "Firefox" &&
  127. parseInt(this.$ua._parsed.version.split(".")[0]) < 60)
  128. ) {
  129. this.alert.html = `<b style="background: #222; border-radius: .5rem; padding: .25rem .25rem .25rem .5rem; margin: 0 .25rem;">
  130. ${this.$ua._parsed.name} ${this.$ua._parsed.version.split(".")[0]}
  131. </b> is not supported. Consider upgrading to the latest version.`;
  132. this.alert.show = true;
  133. }
  134. }, 1000);
  135. },
  136. methods: {
  137. changeLocale(locale) {
  138. // reset to browser default if selection matches browser default
  139. if (locale == navigator.language.slice(0, 2)) localStorage.clear();
  140. // else save preference
  141. else localStorage.locale = locale;
  142. this.$vuetify.lang.current = locale;
  143. },
  144. },
  145. };
  146. </script>
  147. <style>
  148. html,
  149. body {
  150. height: 100%;
  151. background: #111;
  152. height: -webkit-fill-available; /* for MacOS/iOS overscroll */
  153. scrollbar-color: #424242 #111;
  154. }
  155. ::selection {
  156. background: #f44;
  157. color: #111;
  158. }
  159. ::-webkit-scrollbar {
  160. width: 1rem;
  161. }
  162. ::-webkit-scrollbar-track {
  163. background: #111; /* color of the tracking area */
  164. }
  165. ::-webkit-scrollbar-thumb {
  166. background-color: #333; /* color of the scroll thumb */
  167. border-radius: 1rem 0 0 1rem; /* roundness of the scroll thumb */
  168. border-bottom: 0.25rem solid #111; /* creates padding around scroll thumb */
  169. border-left: 0.25rem solid #111; /* creates padding around scroll thumb */
  170. border-top: 0.25rem solid #111; /* creates padding around scroll thumb */
  171. }
  172. ::-webkit-scrollbar-thumb:hover {
  173. background-color: #f22; /* color of the scroll thumb */
  174. border-radius: 1rem 0 0 1rem; /* roundness of the scroll thumb */
  175. border-bottom: 0.25rem solid #111; /* creates padding around scroll thumb */
  176. border-left: 0.25rem solid #111; /* creates padding around scroll thumb */
  177. border-top: 0.25rem solid #111; /* creates padding around scroll thumb */
  178. }
  179. .debug {
  180. /* usage: add class="debug" to the element */
  181. outline: 2px solid red;
  182. }
  183. .v-sheet.v-snack__wrapper {
  184. border-radius: 0.75rem !important;
  185. }
  186. .mainAltButton {
  187. margin: 0.25em;
  188. }
  189. .title-text {
  190. font-size: 3rem;
  191. }
  192. .topBar {
  193. padding: 0 3rem;
  194. width: fit-content !important;
  195. border-radius: 1rem !important;
  196. /* overflow: hidden; */
  197. }
  198. .glass {
  199. backdrop-filter: blur(16px) saturate(200%);
  200. -webkit-backdrop-filter: blur(16px) saturate(200%);
  201. background: rgba(42, 42, 42, 0.75) !important;
  202. }
  203. /* used in docs.vue */
  204. .flex-wrapper {
  205. display: flex;
  206. flex-wrap: nowrap;
  207. }
  208. #translator {
  209. border-radius: 1rem !important;
  210. position: fixed;
  211. bottom: 2rem;
  212. right: 1rem;
  213. }
  214. @media (max-width: 768px) {
  215. /* mobile */
  216. .title-text {
  217. font-size: 2rem;
  218. }
  219. .topBar {
  220. width: calc(
  221. 100vw - 2rem
  222. ) !important; /* (2rem = mx-4) 1rem on left, 1rem on right */
  223. padding: 0;
  224. }
  225. .flex-wrapper {
  226. display: flex;
  227. flex-wrap: wrap;
  228. }
  229. #translator {
  230. bottom: 1rem;
  231. }
  232. }
  233. /* used in docs.vue, help.vue and faq.vue */
  234. .width-constraint {
  235. max-width: auto;
  236. margin: 0 auto;
  237. }
  238. @media (min-width: 960px) {
  239. /* tablet */
  240. .width-constraint {
  241. width: 75vw;
  242. }
  243. }
  244. @media (min-width: 1264px) {
  245. /* desktop */
  246. .width-constraint {
  247. width: 60vw;
  248. }
  249. }
  250. @media (min-width: 1904) {
  251. /* 4k/ultrawide */
  252. .width-constraint {
  253. width: 42vw;
  254. }
  255. }
  256. /* animations and all that */
  257. .swoop-in-enter-active,
  258. .swoop-in-leave-active,
  259. .swoop-out-enter-active,
  260. .swoop-out-leave-active,
  261. .swoop-left-enter-active,
  262. .swoop-left-leave-active,
  263. .swoop-right-enter-active,
  264. .swoop-right-leave-active {
  265. transition-duration: 0.1s;
  266. transition-property: opacity, transform;
  267. }
  268. .swoop-left-enter,
  269. .swoop-right-leave-active {
  270. opacity: 0;
  271. transform: translate(1rem, 0);
  272. }
  273. .swoop-left-leave-active,
  274. .swoop-right-enter {
  275. opacity: 0;
  276. transform: translate(-1rem, 0);
  277. }
  278. .swoop-in-enter,
  279. .swoop-out-leave-active {
  280. opacity: 0;
  281. transform: scale(0.9);
  282. }
  283. .swoop-in-leave-active,
  284. .swoop-out-enter {
  285. opacity: 0;
  286. transform: scale(1.1);
  287. }
  288. .fly-in-from-top {
  289. opacity: 0;
  290. transform: scale(0.8) translateY(-12rem);
  291. animation: fly-in-from-top 0.5s 0.3s ease forwards;
  292. }
  293. @keyframes fly-in-from-top {
  294. 0% {
  295. opacity: 0;
  296. transform: scale(0.8) translateY(-12rem);
  297. }
  298. 100% {
  299. opacity: 1;
  300. transform: scale(1) translateY(0);
  301. }
  302. }
  303. /* reduced-motion animations */
  304. @media (prefers-reduced-motion) {
  305. .fly-in-from-top {
  306. opacity: 1;
  307. transform: none;
  308. animation: none;
  309. }
  310. .swoop-in-enter-active,
  311. .swoop-in-leave-active,
  312. .swoop-out-enter-active,
  313. .swoop-out-leave-active,
  314. .swoop-left-enter-active,
  315. .swoop-left-leave-active,
  316. .swoop-right-enter-active,
  317. .swoop-right-leave-active {
  318. transition-duration: 0.05s;
  319. transition-property: opacity;
  320. }
  321. .swoop-left-enter,
  322. .swoop-right-leave-active {
  323. opacity: 0;
  324. transform: none;
  325. }
  326. .swoop-left-leave-active,
  327. .swoop-right-enter {
  328. opacity: 0;
  329. transform: none;
  330. }
  331. .swoop-in-enter,
  332. .swoop-out-leave-active {
  333. opacity: 0;
  334. transform: none;
  335. }
  336. .swoop-in-leave-active,
  337. .swoop-out-enter {
  338. opacity: 0;
  339. transform: none;
  340. }
  341. }
  342. </style>