default.vue 8.5 KB

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