-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from HE-Arc/sp-14-page-categories
Sp 14 page categories
- Loading branch information
Showing
16 changed files
with
199 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
.idea | ||
db.sqlite3 | ||
__pycache__ | ||
|
||
# Capistrano | ||
/config/ | ||
Capfile | ||
Gemfile | ||
Gemfile.lock | ||
capistrano.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^5.0.3", | ||
"dotenv": "^16.4.5", | ||
"vite": "^5.0.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<script setup> | ||
import axios from 'axios'; | ||
import { onMounted, ref } from 'vue'; | ||
const API_SERVER = import.meta.env.VITE_API_SERVER; | ||
const imageUrl = ref(''); | ||
const fetchImage = async () => { | ||
const response = await axios.get(`${API_SERVER}/api/category/${props.id}/image/`, { responseType: 'arraybuffer' }); | ||
imageUrl.value = 'data:image/jpeg;base64,' + arrayBufferToBase64(response.data); | ||
} | ||
const arrayBufferToBase64 = (buffer) => { | ||
let binary = ''; | ||
const bytes = new Uint8Array(buffer); | ||
const len = bytes.byteLength; | ||
for (let i = 0; i < len; i++) { | ||
binary += String.fromCharCode(bytes[i]); | ||
} | ||
return btoa(binary); | ||
} | ||
const props = defineProps({ | ||
id: Number, | ||
category: Object | ||
}) | ||
onMounted(() => { | ||
fetchImage(); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<RouterLink class="link" :to="{ name: 'Quiz', params: { id_category: id } }"> | ||
<div class="category-item" :style="{ backgroundImage: 'url(' + imageUrl + ')' }"> | ||
<div class="opacity-filter"> | ||
<h2 class="name">{{ category.category_name }}</h2> | ||
<p class="iq">{{ category.user_iq }}</p> | ||
</div> | ||
</div> | ||
</RouterLink> | ||
</template> | ||
|
||
<style scoped style="scss"> | ||
.link | ||
{ | ||
text-decoration: none; | ||
color: inherit; | ||
transition: all 0.3s ease-in-out; | ||
&:hover | ||
{ | ||
transform: scale(1.05); | ||
} | ||
} | ||
.category-item { | ||
border-radius: 1.5rem; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
height: 100%; | ||
.opacity-filter { | ||
background-color: rgba(0, 0, 0, 0.5); | ||
padding: 2rem 1rem; | ||
border-radius: 1.5rem; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
} | ||
.name { | ||
color: white; | ||
font-size: 1.5rem; | ||
font-weight: 800; | ||
font-style: italic; | ||
} | ||
.iq { | ||
color: white; | ||
font-size: 1.2rem; | ||
font-weight: 600; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,52 @@ | ||
<script setup> | ||
import axios from 'axios'; | ||
import { ref, onMounted } from 'vue'; | ||
import CategoryItem from '@/components/CategoryItem.vue'; | ||
const API_SERVER = import.meta.env.VITE_API_SERVER; | ||
const categories = ref([]); | ||
const fetchCategories = async (query) => { | ||
const response = await axios.get(`${API_SERVER}/api/category/iq/`, { | ||
params: query | ||
}); | ||
categories.value = response.data; | ||
} | ||
onMounted(() => { | ||
fetchCategories(); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<main class="container"> | ||
<h1>This is home page with categories</h1> | ||
<button class="btn">Random question</button> | ||
<p class="info">Maximise your IQs in each question category and climb the overall rankings.</p> | ||
<h1 class="title">Categories</h1> | ||
<div class="all-categories"> | ||
<CategoryItem v-for="category, key in categories" :id="parseInt(key)" :category></CategoryItem> | ||
</div> | ||
<div class="btn-container"> | ||
<button class="btn">Random question</button> | ||
|
||
</div> | ||
</main> | ||
</template> | ||
|
||
<style scoped> | ||
.all-categories { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); | ||
row-gap: 1rem; | ||
column-gap: 1.5rem; | ||
} | ||
.info { | ||
margin: 1.5rem 0 1rem 0; | ||
} | ||
.btn-container { | ||
display: flex; | ||
justify-content: center; | ||
padding: 2rem 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<template> | ||
<section class="quiz container"> | ||
<h1>This is quiz page</h1> | ||
Id category {{ $route.params.id_category }} | ||
</section> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import { fileURLToPath, URL } from 'node:url' | ||
|
||
import { defineConfig } from 'vite' | ||
import dotenv from 'dotenv'; | ||
import vue from '@vitejs/plugin-vue' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
vue(), | ||
], | ||
resolve: { | ||
alias: { | ||
'@': fileURLToPath(new URL('./src', import.meta.url)) | ||
export default defineConfig(({ mode }) => { | ||
dotenv.config({ path: `./.env.${mode}` }); | ||
return { | ||
plugins: [ | ||
vue(), | ||
], | ||
resolve: { | ||
alias: { | ||
'@': fileURLToPath(new URL('./src', import.meta.url)) | ||
} | ||
} | ||
} | ||
}) |