generated from bot-base/telegram-bot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
68 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
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,17 @@ | ||
[ | ||
{ | ||
"question": "What is Vue 3?", | ||
"answer": "Vue 3 is the latest version of the Vue framework.", | ||
"open": false | ||
}, | ||
{ | ||
"question": "How to create a component in Vue 3?", | ||
"answer": "You can create a component in Vue 3 using the <script setup> syntax or the standard component definition.", | ||
"open": false | ||
}, | ||
{ | ||
"question": "What is a prop in Vue 3?", | ||
"answer": "A prop is a custom attribute for passing information from parent to child components.", | ||
"open": false | ||
} | ||
] |
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,17 @@ | ||
[ | ||
{ | ||
"question": "What is Vue 3?", | ||
"answer": "Vue 3 is the latest version of the Vue framework.", | ||
"open": false | ||
}, | ||
{ | ||
"question": "How to create a component in Vue 3?", | ||
"answer": "You can create a component in Vue 3 using the <script setup> syntax or the standard component definition.", | ||
"open": false | ||
}, | ||
{ | ||
"question": "What is a prop in Vue 3?", | ||
"answer": "A prop is a custom attribute for passing information from parent to child components.", | ||
"open": false | ||
} | ||
] |
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,59 @@ | ||
<template> | ||
<div class="accordion"> | ||
<div v-for="(item, index) in items" :key="index" class="accordion-item"> | ||
<div class="accordion-header" @click="toggle(index)"> | ||
<h2>{{ item.question }}</h2> | ||
</div> | ||
<div v-show="item.open" class="accordion-content"> | ||
<p>{{ item.answer }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "Accordion", | ||
props: { | ||
items: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
methods: { | ||
toggle(index) { | ||
this.items[index].open = !this.items[index].open; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.accordion { | ||
border: 1px solid #333; | ||
border-radius: 4px; | ||
background-color: #222; | ||
} | ||
.accordion-item { | ||
border-bottom: 1px solid #333; | ||
} | ||
.accordion-header { | ||
padding: 1rem; | ||
cursor: pointer; | ||
background-color: #333; | ||
color: #fff; | ||
font-family: Psychic-Force, sans-serif; | ||
} | ||
.accordion-header:hover { | ||
background-color: #444; | ||
} | ||
.accordion-content { | ||
padding: 1rem; | ||
background-color: #222; | ||
color: #ddd; | ||
} | ||
</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,68 +1,22 @@ | ||
<template> | ||
<BackButton @click="handleBackButton" /> | ||
<h1>FAQ</h1> | ||
<el-input v-model="filterText" placeholder="Filter keyword" /> | ||
|
||
<el-tree | ||
ref="treeRef" | ||
style="width: 100%" | ||
class="filter-tree" | ||
:data="data" | ||
:props="defaultProps" | ||
:filter-node-method="filterNode" | ||
/> | ||
<div id="app"> | ||
<Accordion :items="faqItems" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref, watch } from "vue"; | ||
import { ElTree } from "element-plus"; | ||
import { BackButton, useWebAppBackButton } from "vue-tg"; | ||
import { useRouter } from "vue-router"; | ||
const router = useRouter(); | ||
function handleBackButton() { | ||
useWebAppBackButton().hideBackButton(); | ||
router.back(); | ||
} | ||
interface Tree { | ||
[key: string]: any; | ||
} | ||
const filterText = ref(""); | ||
const treeRef = ref<InstanceType<typeof ElTree>>(); | ||
const defaultProps = { | ||
children: "children", | ||
label: "label", | ||
<script> | ||
import Accordion from "./Accordion.vue"; | ||
import faq from "../assets/ru/faq.json"; | ||
export default { | ||
name: "FAQ", | ||
components: { | ||
Accordion, | ||
}, | ||
data() { | ||
return { | ||
faqItems: faq, | ||
}; | ||
}, | ||
}; | ||
watch(filterText, (val) => { | ||
treeRef.value!.filter(val); | ||
}); | ||
const filterNode = (value: string, data: Tree) => { | ||
if (!value) return true; | ||
return data.label.includes(value); | ||
}; | ||
const data: Tree[] = [ | ||
{ | ||
label: "Когда минт?!", | ||
children: [ | ||
{ | ||
label: "Когда-нибудь.", | ||
}, | ||
], | ||
}, | ||
{ | ||
label: "Игра будет?", | ||
children: [ | ||
{ | ||
label: "Обязательно будет!", | ||
}, | ||
], | ||
}, | ||
]; | ||
</script> |
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