Skip to content

Commit ca2c78b

Browse files
committed
feat(ui): basic sidebar page
1 parent 833cbe1 commit ca2c78b

File tree

5 files changed

+71
-4
lines changed

5 files changed

+71
-4
lines changed

app.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<script setup>
2+
import { useRoute } from 'vue-router'
23
import Roadmap from './components/Roadmap.vue'
34
import HeroSection from './layouts/hero.vue'
5+
6+
const route = useRoute()
7+
const nodeId = route.params.slug
8+
49
const title = 'Hoja de Ruta Definitiva para Aprender Rust: Desde Principiante hasta Experto'
510
const description = `
611
¿Estás listo para dominar uno de los lenguajes de programación más potentes y eficientes? Nuestra hoja de ruta te guiará paso a paso en tu viaje de aprendizaje de Rust, desde los conceptos básicos hasta las técnicas avanzadas. Diseñada para principiantes y desarrolladores experimentados, esta guía exhaustiva te ayudará a construir una sólida base en Rust y a aprovechar al máximo su rendimiento, seguridad y concurrencia.
@@ -9,7 +14,7 @@ Ya sea que desees desarrollar aplicaciones de sistemas, videojuegos, criptomoned
914
`
1015
useHead({
1116
bodyAttrs: {
12-
class: 'bg-orange-200 dark:bg-[#131313]/90 w-screen min-h-screen bg-center bg-fixed dark:bg-kaku dark:bg-cover dark:bg-blend-darken dark:backdrop-blur-xl overflow-x-hidden dark:text-[#e2cea9]'
17+
class: 'bg-orange-200 dark:bg-[#131313]/90 w-screen min-h-screen bg-center bg-fixed dark:bg-kaku dark:bg-cover dark:bg-blend-darken dark:backdrop-blur-xl overflow-x-hidden dark:text-[#e2cea9]' + ((nodeId && !route.query.fromClick) ? ' overflow-hidden' : '')
1318
}
1419
})
1520
@@ -31,7 +36,5 @@ Ya sea que desees desarrollar aplicaciones de sistemas, videojuegos, criptomoned
3136
</script>
3237

3338
<template>
34-
<Header />
35-
<HeroSection />
36-
<Roadmap />
39+
<NuxtPage />
3740
</template>

components/FullView.vue

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<div class="right-0 top-0 z-40 flex min-h-screen w-full flex-col overflow-y-auto bg-white p-4 focus:outline-0 sm:p-6">
3+
<h2>{{ node.title }}</h2>
4+
<p>{{ node.content }}</p>
5+
</div>
6+
</template>
7+
8+
<script setup>
9+
defineProps({
10+
node: Object
11+
})
12+
</script>

components/NodeCard.vue

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
22
import Card from './Card.vue'
3+
import { useRouter } from 'vue-router'
34
import { useVueFlow } from '@vue-flow/core'
45
import { Handle, Position } from '@vue-flow/core'
56
@@ -11,6 +12,7 @@
1112
bottom: Position.Bottom,
1213
}
1314
15+
const router = useRouter()
1416
const props = defineProps({
1517
data: Object,
1618
withoutIcon: {
@@ -30,6 +32,7 @@
3032
// TODO: open side content
3133
onNodeClick(({ node }) => {
3234
if (ignoreTypes.includes(node.type)) return
35+
router.push({ path: `/${node.id}`, query: { fromClick: true } })
3336
console.log(node)
3437
})
3538
// TODO: animate all path if have event.node.data.topicLevel.eq()

components/Sidebar.vue

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<div class="flex h-full w-full flex-col overflow-y-auto bg-white p-4 focus:outline-0 sm:max-w-[600px] sm:p-6">
3+
</div>
4+
</template>
5+
6+
<script setup>
7+
defineProps({
8+
node: Object
9+
})
10+
</script>

pages/[slug].vue

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<template>
2+
<div class="sticky right-0 top-0 z-40 w-screen min-h-screen">
3+
<Sidebar v-if="showSidebar" :node="nodeData" />
4+
<FullView v-else :node="nodeData" />
5+
</div>
6+
<Header />
7+
<HeroSection />
8+
<Roadmap />
9+
</template>
10+
11+
<script setup>
12+
import { useRoute } from 'vue-router'
13+
import { ref, onMounted } from 'vue'
14+
import Sidebar from '@/components/Sidebar.vue'
15+
import FullView from '@/components/FullView.vue'
16+
import Roadmap from '@/components/Roadmap.vue'
17+
import HeroSection from '@/layouts/hero.vue'
18+
19+
const route = useRoute()
20+
const nodeId = route.params.slug
21+
const nodeData = ref(null)
22+
const showSidebar = ref(true)
23+
24+
onMounted(async () => {
25+
// Fetch the node data based on the nodeId
26+
const response = await fetchNodeData(nodeId)
27+
nodeData.value = response
28+
29+
showSidebar.value = response && (route.query.fromClick || false)
30+
})
31+
32+
async function fetchNodeData(id) {
33+
return {
34+
id,
35+
title: 'Nodo ' + id,
36+
content: 'Contenido del nodo ' + id
37+
}
38+
}
39+
</script>

0 commit comments

Comments
 (0)