Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add quick links to docs pages for small screens and add section table of contents indexes #4145

Merged
merged 130 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
e2122a8
docs: add quick links to docs pages for small screens
tmorehouse Sep 23, 2019
2e7a95d
Create quick-links.vue
tmorehouse Sep 23, 2019
f3f4019
Update docs.js
tmorehouse Sep 23, 2019
aeb4eec
Update docs.js
tmorehouse Sep 23, 2019
f62233f
Update quick-links.vue
tmorehouse Sep 23, 2019
45a2c63
Merge branch 'dev' into tmorehouse/docs-links
tmorehouse Sep 23, 2019
d52eb74
Update docs.js
tmorehouse Sep 23, 2019
ca7d350
Update quick-links.vue
tmorehouse Sep 23, 2019
519ddfe
Update quick-links.vue
tmorehouse Sep 25, 2019
4c0246c
Merge branch 'dev' into tmorehouse/docs-links
tmorehouse Sep 25, 2019
2a0004f
Update quick-links.vue
tmorehouse Sep 25, 2019
7a63b78
Update quick-links.vue
tmorehouse Sep 25, 2019
fc0d2ec
Update quick-links.vue
tmorehouse Sep 25, 2019
971704b
Update quick-links.vue
tmorehouse Sep 25, 2019
d4f4503
Update quick-links.vue
jacobmllr95 Sep 25, 2019
7a1e436
Update quick-links.vue
tmorehouse Sep 25, 2019
e1aea06
lint
tmorehouse Sep 25, 2019
7232c2f
Update quick-links.vue
tmorehouse Sep 25, 2019
4aa9763
Update quick-links.vue
tmorehouse Sep 25, 2019
9bd741e
Merge branch 'dev' into tmorehouse/docs-links
jacobmllr95 Sep 25, 2019
6c4ffcc
Update quick-links.vue
jacobmllr95 Sep 25, 2019
9e91211
Update quick-links.vue
jacobmllr95 Sep 25, 2019
f9c573b
add sub sections to quick-links
tmorehouse Sep 25, 2019
311e449
Update docs-mixin.js
tmorehouse Sep 25, 2019
34dbf15
Update quick-links.vue
tmorehouse Sep 25, 2019
81d32eb
Update docs-mixin.js
tmorehouse Sep 25, 2019
8643afe
Update toc.vue
tmorehouse Sep 25, 2019
b37945a
Update quick-links.vue
tmorehouse Sep 25, 2019
d9e2864
Update quick-links.vue
tmorehouse Sep 25, 2019
999fac2
Update toc.vue
tmorehouse Sep 25, 2019
800cc08
Update quick-links.vue
tmorehouse Sep 25, 2019
c59ec47
Update docs-mixin.js
tmorehouse Sep 25, 2019
4bcd893
Update quick-links.vue
tmorehouse Sep 25, 2019
08495ee
Update quick-links.vue
tmorehouse Sep 25, 2019
8cb1633
Update quick-links.vue
tmorehouse Sep 25, 2019
ca3fde5
Update quick-links.vue
tmorehouse Sep 25, 2019
089fa83
Update quick-links.vue
tmorehouse Sep 25, 2019
516923c
Update quick-links.vue
jacobmllr95 Sep 25, 2019
b989df8
Update quick-links.vue
tmorehouse Sep 25, 2019
18133bf
Create section-toc.vue
tmorehouse Sep 25, 2019
7f16dcd
Update section-toc.vue
tmorehouse Sep 25, 2019
7be9d59
Update index.js
tmorehouse Sep 25, 2019
2a8b80b
Update index.js
tmorehouse Sep 25, 2019
a23666d
Update index.js
tmorehouse Sep 25, 2019
9ccf5a9
Update section-toc.vue
tmorehouse Sep 25, 2019
aac532f
Update section-toc.vue
tmorehouse Sep 25, 2019
615759b
Update section-toc.vue
tmorehouse Sep 25, 2019
5ace30a
Update section-toc.vue
tmorehouse Sep 26, 2019
489116b
Update feedback.js
tmorehouse Sep 26, 2019
5c61459
Update index.js
tmorehouse Sep 26, 2019
6b15557
Update index.js
tmorehouse Sep 26, 2019
5ea0e0d
Update index.js
tmorehouse Sep 26, 2019
d39b450
Update docs-mixin.js
tmorehouse Sep 26, 2019
d2cf725
Update index.js
tmorehouse Sep 26, 2019
367ae5e
Update index.js
tmorehouse Sep 26, 2019
62b35a4
Update index.js
tmorehouse Sep 26, 2019
6bf3e6f
Update index.js
tmorehouse Sep 26, 2019
c915a0d
Update index.js
tmorehouse Sep 26, 2019
653a836
Update index.js
tmorehouse Sep 26, 2019
b651f34
Update quick-links.vue
tmorehouse Sep 26, 2019
8e4a95a
Update quick-links.vue
tmorehouse Sep 26, 2019
88a44e7
Update docs-mixin.js
tmorehouse Sep 26, 2019
cc5c7e3
Update quick-links.vue
tmorehouse Sep 26, 2019
473bd44
Update index.js
tmorehouse Sep 26, 2019
bd081f9
Update docs-mixin.js
tmorehouse Sep 26, 2019
c0929fd
Update index.js
tmorehouse Sep 26, 2019
9c14b77
Update section-toc.vue
tmorehouse Sep 26, 2019
5336df2
Update section-toc.vue
tmorehouse Sep 26, 2019
3daab70
Update section-toc.vue
tmorehouse Sep 26, 2019
771a88e
Update quick-links.vue
tmorehouse Sep 26, 2019
f18858b
Update package.json
tmorehouse Sep 26, 2019
d398acc
Update package.json
tmorehouse Sep 26, 2019
66eeaad
Update meta.json
tmorehouse Sep 26, 2019
dc5cc8d
Update section-toc.vue
tmorehouse Sep 26, 2019
5449d4e
Update quick-links.vue
tmorehouse Sep 26, 2019
f62f3d1
Update toc.vue
tmorehouse Sep 26, 2019
c337a0c
Update section-toc.vue
tmorehouse Sep 26, 2019
626fc38
Update quick-links.vue
tmorehouse Sep 26, 2019
a6c621c
Update toc.vue
tmorehouse Sep 26, 2019
17beb91
Update toc.vue
tmorehouse Sep 26, 2019
5d418b1
Update docs.js
tmorehouse Sep 26, 2019
50df289
Update docs.js
tmorehouse Sep 26, 2019
85e1cb7
Update toc.vue
tmorehouse Sep 26, 2019
3597c5a
Update docs.js
tmorehouse Sep 26, 2019
2d7a5be
Update docs.js
tmorehouse Sep 26, 2019
e042e2e
Update docs.js
tmorehouse Sep 26, 2019
fc6cccf
Update docs-mixin.js
tmorehouse Sep 26, 2019
c98e507
Update docs-mixin.js
tmorehouse Sep 26, 2019
ddd11f9
Update docs-mixin.js
tmorehouse Sep 26, 2019
2c8eadd
Update section-toc.vue
tmorehouse Sep 26, 2019
751087b
Update section-toc.vue
tmorehouse Sep 26, 2019
6ca7dd8
Update section-toc.vue
tmorehouse Sep 26, 2019
3b2fe70
Update section-toc.vue
tmorehouse Sep 26, 2019
0704e6e
Update section-toc.vue
tmorehouse Sep 26, 2019
af96f3c
Update section-toc.vue
tmorehouse Sep 26, 2019
046ac82
Update index.js
tmorehouse Sep 26, 2019
d6c61a8
Update section-toc.vue
tmorehouse Sep 26, 2019
d31c813
Update docs-mixin.js
tmorehouse Sep 26, 2019
1f35049
Update section-toc.vue
tmorehouse Sep 26, 2019
387fc33
Update section-toc.vue
tmorehouse Sep 26, 2019
6878276
Prettify
jacobmllr95 Sep 26, 2019
0ff3b0a
Update section-toc.vue
tmorehouse Sep 26, 2019
7e16acf
Update section-toc.vue
tmorehouse Sep 26, 2019
bcfeb61
Update section-toc.vue
tmorehouse Sep 26, 2019
4c48d5c
Create doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
5d09c23
Update section-toc.vue
tmorehouse Sep 26, 2019
b34c218
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
d7ae5b8
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
b1019c5
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
9f5ee34
Update docs.js
tmorehouse Sep 26, 2019
2300216
Update docs.js
tmorehouse Sep 26, 2019
675f97b
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
8bafa10
Update section-toc.vue
tmorehouse Sep 26, 2019
f7d6e25
Update section-toc.vue
tmorehouse Sep 26, 2019
04d7c39
Update docs.js
tmorehouse Sep 26, 2019
45a5a72
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
3f6a4ad
Update docs.js
tmorehouse Sep 26, 2019
74081d2
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
9a61f2f
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
ad1e6de
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
888b1e1
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
b07e4ec
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
647145c
Update sidebar.vue
tmorehouse Sep 26, 2019
68389bc
Update search.vue
tmorehouse Sep 26, 2019
3eb1189
Update sidebar.vue
tmorehouse Sep 26, 2019
e5384a6
Update README.md
tmorehouse Sep 26, 2019
0087e7e
Merge branch 'dev' into tmorehouse/docs-links
tmorehouse Sep 26, 2019
ab30d68
Update doc-breadcrumbs.vue
tmorehouse Sep 26, 2019
b6929fd
Update README.md
tmorehouse Sep 26, 2019
728e6a3
Update README.md
tmorehouse Sep 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions docs/components/quick-links.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<template>
<nav :class="['bd-quick-links', 'mb-3', { 'd-none': quickLinksMoved }]">
<header>
<b-button
v-b-toggle.bd-quick-links-collapse
class="font-weight-bold"
variant="outline-secondary"
size="sm"
block
>
<span v-if="quickLinksVisible">Hide</span>
<span v-else>Show</span>
Page table of contents
</b-button>
</header>
<b-collapse id="bd-quick-links-collapse" v-model="quickLinksVisible" tag="ul">
<li v-for="h2 in toc.toc" :key="h2.href">
<b-link :href="h2.href" @click="scrollIntoView($event, h2.href)">
<span v-html="h2.label"></span>
</b-link>
</li>
</b-collapse>
</nav>
</template>

<style scoped lang="scss">
#bd-quick-links-collapse {
border-left: 5px solid #ccc;
padding-left: 2.5rem;
margin-top: 1rem;
}
</style>

<script>
import { makeTOC, offsetTop, scrollTo } from '~/utils'

export default {
name: 'BDVToc',
data() {
return {
readme: '',
meta: null,
offset: 0,
quickLinksVisible: false
quickLinksMoved: false
}
},
computed: {
toc() {
return makeTOC(this.readme, this.meta)
}
},
created() {
this.$root.$on('setTOC', (readme, meta) => {
this.readme = readme
this.meta = meta || null
})
},
mounted() {
const $body = document.body
// Set the correct offset based on the header height
const $header = $body.querySelector('header.navbar')
if ($header) {
this.offset = $header.offsetHeight + 6
}
// Move the quick links to the correct position, if possible
const $referenceNode = $body.querySelector('.bd-lead') || $body.querySelector('h1')
if ($referenceNode) {
// IE 11 doesn't support the .after() method, and appears
// that the polyfill doesn't polyfill this method
// $referenceNode.after(this.$el)
$referenceNode.insertAdjacentElement('afterend', this.$el)
jacobmllr95 marked this conversation as resolved.
Show resolved Hide resolved
}
// Make the quick links visible
// We hide them initially to make the position change not that distracting
this.quickLinksMoved = true
},
methods: {
isArray(value) {
return Array.isArray(value)
},
scrollIntoView(evt, href) {
evt.preventDefault()
evt.stopPropagation()
// We use an attribute `querySelector()` rather than `getElementByID()`,
// as some auto-generated ID's are invalid or not unique
const id = (href || '').replace(/#/g, '')
const $el = document.body.querySelector(`[id="${id}"]`)
if ($el) {
// Get the document scrolling element
const scroller = document.scrollingElement || document.documentElement || document.body
// Scroll heading into view (minus offset to account for nav top height
scrollTo(scroller, offsetTop($el) - 70, 100, () => {
// Set a tab index so we can focus header for a11y support
$el.tabIndex = -1
// Focus the heading
$el.focus()
})
}
}
}
}
</script>
10 changes: 6 additions & 4 deletions docs/components/toc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ export default {
return makeTOC(this.readme, this.meta)
}
},
created() {
this.$root.$on('setTOC', (readme, meta) => {
this.readme = readme
this.meta = meta || null
})
},
mounted() {
const $header = document.body.querySelector('header.navbar')
if ($header) {
this.offset = $header.offsetHeight + 6
}
this.$root.$on('setTOC', (readme, meta) => {
this.readme = readme
this.meta = meta || null
})
},
methods: {
isArray(value) {
Expand Down
4 changes: 3 additions & 1 deletion docs/layouts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Feedback from '~/components/feedback'
import Header from '~/components/header'
import Footer from '~/components/footer'
import Search from '~/components/search'
import QuickLinks from '~/components/quick-links.vue'
import Sidebar from '~/components/sidebar.vue'
import Toc from '~/components/toc.vue'

Expand All @@ -26,7 +27,8 @@ export default {
},
[
h(Feedback, { class: ['float-right', 'mt-2', 'mb-0', 'mb-lg-2'] }),
h('div', { class: ['clearfix', 'd-bock', 'd-lg-none'] }),
h('div', { class: ['clearfix', 'd-bock', 'd-xl-none'] }),
h(QuickLinks, { class: 'd-xl-none' }),
h('nuxt')
]
)
Expand Down