Skip to content

Commit 01a5aa5

Browse files
committed
Working on vue
1 parent 20561e7 commit 01a5aa5

19 files changed

Lines changed: 58 additions & 329 deletions

libraries/vueJS/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ coverage
2929

3030
*.tsbuildinfo
3131

32-
# Hide secret files
33-
*secrets*
32+
# Hide environment data
33+
*.env
34+
*.env.local

libraries/vueJS/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This library uses the standard Vue template as a foundation. See the details below for running the project.
44

5-
You will also need to create a `secrets.json` file to store your API credentials. See the section below for more details.
5+
You will also need to create a `.env` file to store your API credentials. See the section below for more details.
66

77
## Recommended IDE Setup
88

@@ -41,16 +41,16 @@ npm run build
4141

4242
## Client Credentials
4343

44-
You will need to create a file for storing your client credentials. Typically these secrets would be handled through your server environment, but for basic testing you can create this secrets file to immediately test the library.
44+
You will need to create a file for storing your client credentials. Typically these secrets would be handled through your server environment, but for basic testing you can create this environment file locally to immediately test the library.
4545

4646
Reminder: DON'T COMMIT SECRETS TO VERSION CONTROL!
4747

4848
### Twitch Account for Authentication
4949

5050
IGDB is owned and operated by Twitch.tv. In order to authenticate with the api, you will need an active Twitch account and register a developer application with it to acquire a Client ID and Client Secret. See IGDB's documentation here for details: [IGDB Account Creation](https://api-docs.igdb.com/#account-creation)
5151

52-
### Create Secrets File
52+
### Create Environment File
5353

54-
1. Create a `secrets.json` file at the project root.
55-
2. Add two fields called `clientId` and `clientSecret`.
56-
3. Set those values to their respective values from your Twitch Developer App.
54+
1. Create a `.env` file at the project root.
55+
2. Add two fields called `CLIENT_ID` and `CLIENT_SECRET`.
56+
3. Set those values to their respective values from your Twitch Developer App.

libraries/vueJS/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/vueJS/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"apicalypse": "^1.0.5",
16+
"axios": "^1.12.2",
1617
"vue": "^3.5.22"
1718
},
1819
"devDependencies": {

libraries/vueJS/src/App.vue

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup>
2+
import { onMounted, ref } from 'vue';
23
import DataPreview from './components/DataPreview.vue';
34
import { getCredentials, getAPIToken, getGenreData, getGameData, getCharacterData } from './api';
45
@@ -20,29 +21,28 @@ let sectionThree = ref({
2021
data: null
2122
});
2223
23-
const credentials = getCredentials();
24-
25-
const clientId = credentials.clientId;
26-
const clientSecret = credentials.clientSecret;
27-
28-
const apiToken = getAPIToken(clientId, clientSecret);
24+
let credentials = ref({
25+
clientId: null,
26+
clientSecret: null,
27+
});
28+
let apiToken = ref("");
2929
30-
sectionOne.data = getGenreData(clientId, apiToken);
31-
sectionTwo.data = getGameData(clientId, apiToken);
32-
sectionThree.data = getCharacterData(clientId, apiToken);
30+
onMounted(() => {
31+
credentials.value = getCredentials();
32+
console.log("credentials: " + JSON.stringify(credentials.value));
33+
apiToken.value = getAPIToken(credentials.value.clientId, credentials.value.clientSecret);
34+
sectionOne.value.data = getGenreData(credentials.clientId, apiToken);
35+
sectionTwo.value.data = getGameData(credentials.clientId, apiToken);
36+
sectionThree.value.data = getCharacterData(credentials.clientId, apiToken);
37+
})
3338
3439
3540
function refreshData() {
36-
41+
sectionThree.value.data = getCharacterData(credentials.credentials.clientId);
3742
}
38-
3943
</script>
4044

4145
<template>
42-
<header>
43-
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
44-
</header>
45-
4646
<main>
4747
<div class="pageContent">
4848
<h1>Welcome to the VGD Multi Library!</h1>
@@ -54,7 +54,7 @@ function refreshData() {
5454
</div>
5555

5656
<span class="buttonContainer">
57-
<button id="refreshData">Reload Data</button>
57+
<button id="refreshData" @click="refreshData">Reload Data</button>
5858
</span>
5959

6060
<div id="sectionContainer" class="sectionContainer">
@@ -101,8 +101,8 @@ body {
101101
}
102102
103103
.pageContent {
104-
max-width: 1080px;
105-
min-height: 100%;
104+
min-width: 100%;
105+
min-height: 100vh;
106106
margin: 0 auto;
107107
background-color: #d3d3d3;
108108
}
@@ -121,7 +121,8 @@ body {
121121
122122
.pageContent p {
123123
flex: 1 1 auto;
124-
text-align: justify;
124+
color: black;
125+
text-align: center;
125126
}
126127
127128
.pageContent .buttonContainer {

libraries/vueJS/src/api.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import IGDB_Helper from "./igdb_api/IGDB_Helper.js";
33

44
export function getCredentials() {
55
console.log("Retrieving client ID and client secret");
6-
const secrets = fs.readFileSync("./secrets.json");
7-
const secretsJSON = JSON.parse(secrets);
8-
return secretsJSON;
6+
console.log(`process: ${JSON.stringify(process)}`);
7+
const credentials = {
8+
clientId: process.env.VITE_CLIENT_ID,
9+
clientSecret: process.env.VITE_CLIENT_SECRET
10+
};
11+
return credentials;
912
}
1013

1114
export async function getAPIToken(clientId, clientSecret) {
@@ -15,7 +18,6 @@ export async function getAPIToken(clientId, clientSecret) {
1518
return apiTokenResult.access_token;
1619
}
1720

18-
1921
export async function getGenreData(clientId, apiToken) {
2022
console.log("Pulling game data from IGDB");
2123
const igdb = new IGDB_Helper();

libraries/vueJS/src/assets/base.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060

6161
body {
6262
min-height: 100vh;
63-
color: var(--color-text);
6463
background: var(--color-background);
6564
transition:
6665
color 0.5s,
@@ -83,4 +82,4 @@ body {
8382
text-rendering: optimizeLegibility;
8483
-webkit-font-smoothing: antialiased;
8584
-moz-osx-font-smoothing: grayscale;
86-
}
85+
}
Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
@import './base.css';
22

33
#app {
4-
max-width: 1280px;
5-
margin: 0 auto;
6-
padding: 2rem;
74
font-weight: normal;
5+
min-height: 100vh;
6+
}
7+
8+
#app>main {
9+
min-height: 100vh;
810
}
911

1012
a,
@@ -19,17 +21,4 @@ a,
1921
a:hover {
2022
background-color: hsla(160, 100%, 37%, 0.2);
2123
}
22-
}
23-
24-
@media (min-width: 1024px) {
25-
body {
26-
display: flex;
27-
place-items: center;
28-
}
29-
30-
#app {
31-
display: grid;
32-
grid-template-columns: 1fr 1fr;
33-
padding: 0 2rem;
34-
}
35-
}
24+
}

libraries/vueJS/src/components/HelloWorld.vue

Lines changed: 0 additions & 44 deletions
This file was deleted.

libraries/vueJS/src/components/TheWelcome.vue

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)