-
Notifications
You must be signed in to change notification settings - Fork 60
Add on this page navigation #416
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
Merged
dobromir-hristov
merged 31 commits into
swiftlang:main
from
dobromir-hristov:dhristov/r97715869-add-on-this-page-navigation
Sep 20, 2022
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
60eeb6c
feat: add OnThisPageTracker component
fe4200f
feat: add a sticky right sidenav to docs
80f64c9
refactor: add styling to the OnThisPageTracker and fix issues with bu…
8945cdc
refactor: make sure sections without a title are not tracked for OnTh…
50ac4cc
refactor: add a smart OnThisPageStickyContainer.vue component
058aa23
fix: spacing issue
30b3226
chore: add tests and cleanup old code
4917162
fix: optionally enable OnThisPageNav
d0e300a
fix: import path
2909e7c
fix: extra spacing
d6dc8a1
refactor: make sure OnThisPageStickyContainer is visible for more vie…
e79c79e
refactor: remove extra nested logic as it will not be used
04f58b0
refactor: use pre-defined font-weights
78f05b9
fix: prevent jump on scroll, when at the bottom of the page
24173b5
fix: remove bolding
8074389
Apply suggestions from code review
dobromir-hristov caebb3c
refactor: set the section's anchor as current
3dc8979
Merge branch 'dhristov/r97715869-add-on-this-page-navigation' of http…
7a05c87
refactor: remove `on-this-page` font style for `body-reduced-tight`
79555cb
refactor: OnThisPageNav scoped slot
b06756a
Merge branch 'main' into dhristov/r97715869-add-on-this-page-navigation
3e15a92
refactor: use mixin focusAndScroll method
5760958
Apply suggestions from code review
dobromir-hristov 1d2929b
refactor: copy date
20fd172
Merge branch 'dhristov/r97715869-add-on-this-page-navigation' of http…
177efa5
refactor: exit early the `onScroll` function
63aa095
refactor: register OnThisPage Sections inside the `LinkableHeading` c…
415dac2
Merge branch 'main' into dhristov/r97715869-add-on-this-page-navigation
0b576c7
refactor: cleanup unused state
85effce
chore: remove unused components
05fc0f9
Merge branch 'main' into dhristov/r97715869-add-on-this-page-navigation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
60 changes: 60 additions & 0 deletions
60
src/components/DocumentationTopic/OnThisPageStickyContainer.vue
This file contains hidden or 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,60 @@ | ||
<!-- | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
--> | ||
<template> | ||
<div class="OnThisPageStickyContainer" :class="{ hidden: isHidden }"> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
// 660px content + (170px aside + 22px padding-right)*2 + 28px*2 gutter | ||
export const ON_THIS_PAGE_CONTENT_BREAKPOINT = 1110; | ||
// 1080 content + (170px aside + 22px padding-right) | ||
export const ON_THIS_PAGE_CONTENT_BREAKPOINT_BIG = 1272; | ||
|
||
export default { | ||
name: 'OnThisPageStickyContainer', | ||
inject: ['store'], | ||
computed: { | ||
isHidden: ({ store }) => { | ||
dobromir-hristov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let compareTo = ON_THIS_PAGE_CONTENT_BREAKPOINT; | ||
// when the window is above 1500, the content max-width grows | ||
if (window.outerWidth >= 1500) { | ||
compareTo = ON_THIS_PAGE_CONTENT_BREAKPOINT_BIG; | ||
} | ||
return store.state.contentWidth < compareTo; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang='scss'> | ||
@import 'docc-render/styles/_core.scss'; | ||
|
||
.OnThisPageStickyContainer { | ||
$aside-width: rem(170px); | ||
margin-top: $contenttable-spacing-single-side; | ||
position: sticky; | ||
top: $nav-height + rem(10px); | ||
align-self: flex-start; | ||
flex: 0 0 auto; | ||
width: $aside-width; | ||
margin-left: -($aside-width + $nav-padding); | ||
padding-right: $nav-padding; | ||
|
||
@include breakpoint(small) { | ||
display: none; | ||
} | ||
|
||
&.hidden { | ||
display: none; | ||
} | ||
} | ||
</style> |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.