This commit is contained in:
SebClem 2022-05-21 01:07:31 +02:00
commit 01830d740b
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
32 changed files with 11228 additions and 0 deletions

2
.env.development Normal file
View File

@ -0,0 +1,2 @@
VITE_OAUTH_REDIRECT_URL="https://discord.com/api/oauth2/authorize?client_id=238351507634913280&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth2%2Fcallback&response_type=code&scope=identify"
VITE_API_BASE_URL="http://localhost:8080/api/v2/"

15
.eslintrc.cjs Normal file
View File

@ -0,0 +1,15 @@
/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution");
module.exports = {
"root": true,
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-typescript/recommended",
"@vue/eslint-config-prettier"
],
"env": {
"vue/setup-compiler-macros": true
}
}

30
.gitignore vendored Normal file
View File

@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.yarn/cache
.yarn/install-state.gz

9
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"recommendations": [
"johnsoncodehk.volar",
"johnsoncodehk.vscode-typescript-vue-plugin",
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}

1
.yarnrc.yml Normal file
View File

@ -0,0 +1 @@
nodeLinker: node-modules

52
README.md Normal file
View File

@ -0,0 +1,52 @@
# claptrap-ui
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
yarn
```
### Compile and Hot-Reload for Development
```sh
yarn dev
```
### Type-Check, Compile and Minify for Production
```sh
yarn build
```
### Run Unit Tests with [Vitest](https://vitest.dev/)
```sh
yarn test:unit
```
### Lint with [ESLint](https://eslint.org/)
```sh
yarn lint
```

10
env.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_OAUTH_REDIRECT_URL: string;
readonly VITE_API_BASE_URL: string;
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

16
index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vuetify 3 Vite Preview</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

49
package.json Normal file
View File

@ -0,0 +1,49 @@
{
"name": "claptrap-ui",
"version": "0.0.0",
"packageManager": "yarn@3.2.1",
"scripts": {
"serve": "vite preview",
"build": "vite build",
"test:unit": "vitest --environment jsdom",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"dev": "vite",
"preview": "vite preview --port 5050",
"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false"
},
"dependencies": {
"@mdi/font": "5.9.55",
"@vue/cli": "^5.0.4",
"axios": "^0.27.2",
"pinia": "^2.0.13",
"roboto-fontface": "*",
"vue": "^3.2.33",
"vue-router": "^4.0.14",
"vuetify": "^3.0.0-beta.2",
"webfontloader": "^1.0.0"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.1.0",
"@types/jsdom": "^16.2.14",
"@types/node": "^16.11.27",
"@types/webfontloader": "^1.0.0",
"@vitejs/plugin-vue": "^2.3.1",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/test-utils": "^2.0.0-rc.20",
"@vue/tsconfig": "^0.1.3",
"@vuetify/vite-plugin": "^1.0.0-alpha.0",
"eslint": "^8.5.0",
"eslint-plugin-vue": "^8.2.0",
"jsdom": "^19.0.0",
"prettier": "^2.5.1",
"sass": "^1.38.0",
"sass-loader": "^10.0.0",
"typescript": "~4.6.3",
"vite": "^2.9.5",
"vitest": "^0.9.3",
"vue-cli-plugin-vuetify": "~2.4.8",
"vue-tsc": "^0.34.7",
"vuetify-loader": "^2.0.0-alpha.0"
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

0
public/index.html Normal file
View File

14
src/App.vue Normal file
View File

@ -0,0 +1,14 @@
<template>
<v-app>
<header-component />
<v-main>
<v-container>
<router-view />
</v-container>
</v-main>
</v-app>
</template>
<script lang="ts" setup>
import HeaderComponent from "./components/HeaderComponent.vue";
</script>

74
src/assets/base.css Normal file
View File

@ -0,0 +1,74 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
position: relative;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

1
src/assets/logo.svg Normal file
View File

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg>

After

Width:  |  Height:  |  Size: 539 B

View File

@ -0,0 +1,11 @@
<template>
<v-app-bar class="bg-brown-darken-4">
<v-app-bar-title class="text-yellow font-weight-black text-h4">
Claptrap Bot
</v-app-bar-title>
</v-app-bar>
</template>
<script setup lang="ts"></script>
<style scoped></style>

11
src/main.ts Normal file
View File

@ -0,0 +1,11 @@
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import vuetify from "./plugins/vuetify";
import { loadFonts } from "./plugins/webfontloader";
import { createPinia } from "pinia";
loadFonts();
const pinia = createPinia();
createApp(App).use(router).use(vuetify).use(pinia).mount("#app");

12
src/plugins/vuetify.ts Normal file
View File

@ -0,0 +1,12 @@
// Styles
import "@mdi/font/css/materialdesignicons.css";
import "vuetify/styles";
// Vuetify
import { createVuetify } from "vuetify";
export default createVuetify({
theme: {
defaultTheme: "dark",
},
});

View File

@ -0,0 +1,15 @@
/**
* plugins/webfontloader.js
*
* webfontloader documentation: https://github.com/typekit/webfontloader
*/
export async function loadFonts () {
const webFontLoader = await import(/* webpackChunkName: "webfontloader" */'webfontloader')
webFontLoader.load({
google: {
families: ['Roboto:100,300,400,500,700,900&display=swap'],
},
})
}

51
src/router/index.ts Normal file
View File

@ -0,0 +1,51 @@
import { useUserStore } from "@/stores/user";
import OauthCallbackViewVue from "@/views/oauth/OauthCallbackView.vue";
import OauthRedirectViewVue from "@/views/oauth/OauthRedirectView.vue";
import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";
declare module "vue-router" {
interface RouteMeta {
requiresAuth: boolean;
}
}
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
name: "home",
component: HomeView,
meta: {
requiresAuth: true,
},
},
{
path: "/oauth2/callback",
name: "oauth-callback",
component: OauthCallbackViewVue,
meta: {
requiresAuth: false,
},
},
{
path: "/oauth2/redirect",
name: "oauth-redirect",
component: OauthRedirectViewVue,
meta: {
requiresAuth: false,
},
}
],
});
router.beforeEach((to, from) => {
const store = useUserStore();
if (to.meta.requiresAuth && !store.isLoggedIn) {
(<any>window).location = import.meta.env.VITE_OAUTH_REDIRECT_URL;
return false;
}
});
export default router;

3
src/shims-vuetify.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
declare module 'vuetify'
declare module 'vuetify/lib/components'
declare module 'vuetify/lib/directives'

16
src/stores/counter.ts Normal file
View File

@ -0,0 +1,16 @@
import { defineStore } from "pinia";
export const useCounterStore = defineStore({
id: "counter",
state: () => ({
counter: 0,
}),
getters: {
doubleCount: (state) => state.counter * 2,
},
actions: {
increment() {
this.counter++;
},
},
});

13
src/stores/user.ts Normal file
View File

@ -0,0 +1,13 @@
import { defineStore } from "pinia";
export const useUserStore = defineStore("user",{
state: () => ({
name: undefined as string | undefined,
discordId: undefined as string | undefined,
token: undefined as string | undefined,
}),
getters: {
isLoggedIn: (state) => !!state.token,
},
actions: {},
});

View File

@ -0,0 +1,2 @@
// Place SASS variable overrides here
// $font-size-root: 18px;

3
src/views/HomeView.vue Normal file
View File

@ -0,0 +1,3 @@
<template>Home</template>
<script lang="ts" setup></script>

View File

@ -0,0 +1,24 @@
<template>
<v-row>
<v-col class="d-flex justify-center align-center mt-16">
<v-progress-circular size="200" width="17" color="yellow" indeterminate></v-progress-circular>
</v-col>
</v-row>
</template>
<script setup lang="ts">
import axios from "axios";
import { useRoute } from "vue-router";
const baseApi = import.meta.env.VITE_API_BASE_URL;
const baseUrl = window.location.origin;
const route = useRoute();
axios.post(baseApi + "login/discord", {
redirectUri: baseUrl + "/oauth2/callback",
code: route.query.code,
});
</script>
<style scoped></style>

View File

@ -0,0 +1,14 @@
<template>
<v-row>
<v-col class="d-flex justify-center align-center mt-16">
<v-progress-circular size="200" width="17" color="yellow" indeterminate></v-progress-circular>
</v-col>
</v-row>
</template>
<script setup lang="ts">
const test = import.meta.env.VITE_OAUTH_REDIRECT_URL;
window.location.href = import.meta.env.VITE_OAUTH_REDIRECT_URL;
</script>
<style scoped></style>

12
tsconfig.app.json Normal file
View File

@ -0,0 +1,12 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.vite-config.json"
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.vitest.json"
}
]
}

View File

@ -0,0 +1,8 @@
{
"extends": "@vue/tsconfig/tsconfig.node.json",
"include": ["vite.config.*"],
"compilerOptions": {
"composite": true,
"types": ["node", "vitest"]
}
}

9
tsconfig.vitest.json Normal file
View File

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.app.json",
"exclude": [],
"compilerOptions": {
"composite": true,
"lib": [],
"types": ["node", "jsdom"]
}
}

35
vite.config.ts Normal file
View File

@ -0,0 +1,35 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vuetify from '@vuetify/vite-plugin'
const path = require('path')
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
vuetify({
autoImport: true,
}),
],
define: { 'process.env': {} },
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
/* remove the need to specify .vue files https://vitejs.dev/config/#resolve-extensions
resolve: {
extensions: [
'.js',
'.json',
'.jsx',
'.mjs',
'.ts',
'.tsx',
'.vue',
]
},
*/
})

10702
yarn.lock Normal file

File diff suppressed because it is too large Load Diff