default.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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. // ...
  105. ],
  106. alert: {
  107. show: false,
  108. html: "",
  109. },
  110. }),
  111. created() {
  112. // fetch locale preference or browser default
  113. if (process.client && navigator.language) {
  114. if (!("locale" in localStorage))
  115. this.$vuetify.lang.current = navigator.language.slice(0, 2);
  116. else this.$vuetify.lang.current = localStorage.locale;
  117. }
  118. },
  119. mounted() {
  120. setTimeout(() => {
  121. // Chrome < 70 or FF < 60 unsupported warning popup
  122. if (
  123. (this.$ua._parsed.name == "Chrome" &&
  124. parseInt(this.$ua._parsed.version.split(".")[0]) < 70) ||
  125. (this.$ua._parsed.name == "Firefox" &&
  126. parseInt(this.$ua._parsed.version.split(".")[0]) < 60)
  127. ) {
  128. this.alert.html = `<b style="background: #222; border-radius: .5rem; padding: .25rem .25rem .25rem .5rem; margin: 0 .25rem;">
  129. ${this.$ua._parsed.name} ${this.$ua._parsed.version.split(".")[0]}
  130. </b> is not supported. Consider upgrading to the latest version.`;
  131. this.alert.show = true;
  132. }
  133. }, 1000);
  134. },
  135. methods: {
  136. changeLocale(locale) {
  137. // reset to browser default if selection matches browser default
  138. if (locale == navigator.language.slice(0, 2)) localStorage.clear();
  139. // else save preference
  140. else localStorage.locale = locale;
  141. this.$vuetify.lang.current = locale;
  142. },
  143. },
  144. };
  145. </script>
  146. <style>
  147. html,
  148. body {
  149. height: 100%;
  150. background: #111;
  151. height: -webkit-fill-available; /* for MacOS/iOS overscroll */
  152. scrollbar-color: #424242 #111;
  153. }
  154. ::selection {
  155. background: #f44;
  156. color: #111;
  157. }
  158. ::-webkit-scrollbar {
  159. width: 1rem;
  160. }
  161. ::-webkit-scrollbar-track {
  162. background: #111; /* color of the tracking area */
  163. }
  164. ::-webkit-scrollbar-thumb {
  165. background-color: #333; /* color of the scroll thumb */
  166. border-radius: 1rem 0 0 1rem; /* roundness of the scroll thumb */
  167. border-bottom: 0.25rem solid #111; /* creates padding around scroll thumb */
  168. border-left: 0.25rem solid #111; /* creates padding around scroll thumb */
  169. border-top: 0.25rem solid #111; /* creates padding around scroll thumb */
  170. }
  171. ::-webkit-scrollbar-thumb:hover {
  172. background-color: #f22; /* color of the scroll thumb */
  173. border-radius: 1rem 0 0 1rem; /* roundness of the scroll thumb */
  174. border-bottom: 0.25rem solid #111; /* creates padding around scroll thumb */
  175. border-left: 0.25rem solid #111; /* creates padding around scroll thumb */
  176. border-top: 0.25rem solid #111; /* creates padding around scroll thumb */
  177. }
  178. .debug {
  179. /* usage: add class="debug" to the element */
  180. outline: 2px solid red;
  181. }
  182. .v-sheet.v-snack__wrapper {
  183. border-radius: 0.75rem !important;
  184. }
  185. .mainAltButton {
  186. margin: 0.25em;
  187. }
  188. .title-text {
  189. font-size: 3rem;
  190. }
  191. .topBar {
  192. padding: 0 3rem;
  193. width: fit-content !important;
  194. border-radius: 1rem !important;
  195. /* overflow: hidden; */
  196. }
  197. .glass {
  198. backdrop-filter: blur(16px) saturate(200%);
  199. -webkit-backdrop-filter: blur(16px) saturate(200%);
  200. background: rgba(42, 42, 42, 0.75) !important;
  201. }
  202. /* used in docs.vue */
  203. .flex-wrapper {
  204. display: flex;
  205. flex-wrap: nowrap;
  206. }
  207. #translator {
  208. border-radius: 1rem !important;
  209. position: fixed;
  210. bottom: 2rem;
  211. right: 1rem;
  212. }
  213. @media (max-width: 768px) {
  214. /* mobile */
  215. .title-text {
  216. font-size: 2rem;
  217. }
  218. .topBar {
  219. width: calc(
  220. 100vw - 2rem
  221. ) !important; /* (2rem = mx-4) 1rem on left, 1rem on right */
  222. padding: 0;
  223. }
  224. .flex-wrapper {
  225. display: flex;
  226. flex-wrap: wrap;
  227. }
  228. #translator {
  229. bottom: 1rem;
  230. }
  231. }
  232. /* used in docs.vue, help.vue and faq.vue */
  233. .width-constraint {
  234. max-width: auto;
  235. margin: 0 auto;
  236. }
  237. @media (min-width: 960px) {
  238. /* tablet */
  239. .width-constraint {
  240. width: 75vw;
  241. }
  242. }
  243. @media (min-width: 1264px) {
  244. /* desktop */
  245. .width-constraint {
  246. width: 60vw;
  247. }
  248. }
  249. @media (min-width: 1904) {
  250. /* 4k/ultrawide */
  251. .width-constraint {
  252. width: 42vw;
  253. }
  254. }
  255. /* animations and all that */
  256. .swoop-in-enter-active,
  257. .swoop-in-leave-active,
  258. .swoop-out-enter-active,
  259. .swoop-out-leave-active,
  260. .swoop-left-enter-active,
  261. .swoop-left-leave-active,
  262. .swoop-right-enter-active,
  263. .swoop-right-leave-active {
  264. transition-duration: 0.1s;
  265. transition-property: opacity, transform;
  266. }
  267. .swoop-left-enter,
  268. .swoop-right-leave-active {
  269. opacity: 0;
  270. transform: translate(1rem, 0);
  271. }
  272. .swoop-left-leave-active,
  273. .swoop-right-enter {
  274. opacity: 0;
  275. transform: translate(-1rem, 0);
  276. }
  277. .swoop-in-enter,
  278. .swoop-out-leave-active {
  279. opacity: 0;
  280. transform: scale(0.9);
  281. }
  282. .swoop-in-leave-active,
  283. .swoop-out-enter {
  284. opacity: 0;
  285. transform: scale(1.1);
  286. }
  287. .fly-in-from-top {
  288. opacity: 0;
  289. transform: scale(0.8) translateY(-12rem);
  290. animation: fly-in-from-top 0.5s 0.3s ease forwards;
  291. }
  292. @keyframes fly-in-from-top {
  293. 0% {
  294. opacity: 0;
  295. transform: scale(0.8) translateY(-12rem);
  296. }
  297. 100% {
  298. opacity: 1;
  299. transform: scale(1) translateY(0);
  300. }
  301. }
  302. /* reduced-motion animations */
  303. @media (prefers-reduced-motion) {
  304. .fly-in-from-top {
  305. opacity: 1;
  306. transform: none;
  307. animation: none;
  308. }
  309. .swoop-in-enter-active,
  310. .swoop-in-leave-active,
  311. .swoop-out-enter-active,
  312. .swoop-out-leave-active,
  313. .swoop-left-enter-active,
  314. .swoop-left-leave-active,
  315. .swoop-right-enter-active,
  316. .swoop-right-leave-active {
  317. transition-duration: 0.05s;
  318. transition-property: opacity;
  319. }
  320. .swoop-left-enter,
  321. .swoop-right-leave-active {
  322. opacity: 0;
  323. transform: none;
  324. }
  325. .swoop-left-leave-active,
  326. .swoop-right-enter {
  327. opacity: 0;
  328. transform: none;
  329. }
  330. .swoop-in-enter,
  331. .swoop-out-leave-active {
  332. opacity: 0;
  333. transform: none;
  334. }
  335. .swoop-in-leave-active,
  336. .swoop-out-enter {
  337. opacity: 0;
  338. transform: none;
  339. }
  340. }
  341. </style>