Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 664d4b0

Browse files
committed
feat: implement feedback
1 parent d5d53fd commit 664d4b0

File tree

2 files changed

+44
-17
lines changed

2 files changed

+44
-17
lines changed

packages/chakra-ui-docs/components/BottomLink.vue

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,54 @@
22
<div>
33
<CFlex justify="space-between">
44
<div>
5-
<CLink as="router-link" :to="prev">
6-
{{ prev == '' ? "" : "Prev" }}
5+
<CLink as="router-link" :to="prevPath">
6+
<CIcon v-show="prevName" name="chevron-left" />
7+
{{ prevName == '' ? "" : prevName }}
78
</CLink>
89
</div>
910

10-
<CLink as="router-link" :to="next">
11-
{{ next == '' ? "": "Next" }}
11+
<CLink as="router-link" :to="nextPath">
12+
{{ nextName == '' ? "" : nextName }}
13+
<CIcon v-show="nextName" name="chevron-right" />
1214
</CLink>
1315
</CFlex>
1416
</div>
1517
</template>
1618

1719
<script>
18-
import { CLink, CFlex } from '@chakra-ui/vue'
20+
import { CLink, CFlex, CIcon } from '@chakra-ui/vue'
1921
import { findNextAndPrevRoute } from '../utils'
2022
2123
export default {
2224
components: {
2325
CLink,
24-
CFlex
26+
CFlex,
27+
CIcon
2528
},
2629
data: () => ({
27-
prev: '',
28-
next: ''
30+
prevPath: '',
31+
prevName: '',
32+
nextPath: '',
33+
nextName: ''
2934
}),
3035
watch: {
31-
$route (to, from) {
32-
const { prev, next } = findNextAndPrevRoute(to.path, this.$router.options.routes)
36+
'$route.path' (nextPath) {
37+
const { prev, next } = findNextAndPrevRoute(nextPath, this.$router.options.routes)
3338
34-
this.prev = prev
35-
this.next = next
39+
this.prevPath = prev.path
40+
this.prevName = prev.name
41+
this.nextPath = next.path
42+
this.nextName = next.name
43+
console.log(this.nextName)
3644
}
3745
},
3846
created () {
3947
const { prev, next } = findNextAndPrevRoute(this.$route.path, this.$router.options.routes)
4048
41-
this.prev = prev
42-
this.next = next
49+
this.prevPath = prev.path
50+
this.prevName = prev.name
51+
this.nextPath = next.path
52+
this.nextName = next.name
4353
}
4454
}
4555
</script>

packages/chakra-ui-docs/utils/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,25 @@ export const removeHyphenFromString = (hyphenatedString) => {
2121
export const findNextAndPrevRoute = (path, routes) => {
2222
const currentRouteIndex = routes.map(route => route.path).indexOf(path)
2323

24-
const nextPageLink = routes[currentRouteIndex + 1]
25-
const prevPageLink = routes[currentRouteIndex - 1]
24+
const nextPage = routes[currentRouteIndex + 1]
25+
const prevPage = routes[currentRouteIndex - 1]
2626

27-
return { prev: prevPageLink ? prevPageLink.path : '', next: nextPageLink ? nextPageLink.path : '' }
27+
const prevPageLink = prevPage
28+
? {
29+
...prevPage,
30+
name: (prevPage.name =
31+
prevPage.name.charAt(0).toUpperCase() + prevPage.name.slice(1))
32+
}
33+
: ''
34+
const nextPageLink = nextPage
35+
? {
36+
...nextPage,
37+
name: (nextPage.name =
38+
nextPage.name.charAt(0).toUpperCase() + nextPage.name.slice(1))
39+
}
40+
: ''
41+
42+
console.log(prevPageLink)
43+
console.log(nextPageLink)
44+
return { prev: prevPageLink, next: nextPageLink }
2845
}

0 commit comments

Comments
 (0)