-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Dropdown Items in Navbar #13
Merged
Merged
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0494566
dropdown - init
ulivz 121e6ca
add nav link component to distinguish internal and external link
ulivz 3ddca36
enhance the active state of dropdown link
ulivz 72be30c
beautify font weight for dropdown link and clean code
ulivz 4bccf3a
clean code
ulivz 5ac3c2a
update doc
ulivz dbb7a08
update README
ulivz 50689ea
address comments
ulivz 6de2efa
fix jumpy link
ulivz 7eb2563
address comments
ulivz 94c2236
use exact match mode for route link
ulivz 6c9e1a4
implement nested links in dropdown
ulivz 5ca1d02
clean dropdown type
ulivz 7c6d462
fix cursor status
ulivz 96c30c5
chore: tweaks
ulivz 3397dc2
Merge branch 'master' into dropdown
ulivz 5030421
Merge branch 'master' into dropdown
ulivz 96a6cc6
refactor: address comments and clean duplicate code due to merging.
ulivz 7f440d0
style: use more exact class selector, and clean old element selector …
ulivz 4bf15cb
add cursor: pointer to nav item.
ulivz 650089d
feat: togglable dropdown on mobile
ulivz b3e0583
chore: dropdown - remove test links, and make it collapsed by default…
ulivz bf13baa
Update README.md
yyx990803 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 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
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
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,33 @@ | ||
<template> | ||
<router-link | ||
class="router-link" | ||
:to="link" | ||
v-if="!isExternal(link)" | ||
exact | ||
>{{ item.text }}</router-link> | ||
<a | ||
v-else | ||
:href="link" | ||
target="_blank" | ||
class="router-link" | ||
>{{ item.text }}</a> | ||
</template> | ||
|
||
<script> | ||
import { isExternal, ensureExt } from './util' | ||
export default { | ||
props: { | ||
item: { | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
link() { | ||
return ensureExt(this.item.link) | ||
} | ||
}, | ||
methods: { | ||
isExternal | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
<template> | ||
<nav class="nav-links" v-if="userLinks.length || githubLink"> | ||
<!-- user links --> | ||
<router-link v-for="item in userLinks" | ||
:to="item.link" | ||
<div | ||
class="nav-item" | ||
v-for="item in userLinks" | ||
:key="item.link"> | ||
{{ item.text }} | ||
</router-link> | ||
<div | ||
v-if="item.type === 'links'" | ||
class="dropdown-wrapper"> | ||
<span class="dropdown-title">{{ item.text }}</span> | ||
<span class="arrow"></span> | ||
<ul class="nav-dropdown"> | ||
<li | ||
v-for="subItem in item.items" | ||
:key="subItem.link"> | ||
<h4 v-if="subItem.type === 'links'">{{ subItem.text }}</h4> | ||
<ul v-if="subItem.type === 'links'"> | ||
<li | ||
v-for="childSubItem in subItem.items" | ||
:key="childSubItem.link"> | ||
<nav-link :item="childSubItem"></nav-link> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some conflicts due to fixes which are also addressed in this PR. Should be easy to resolve. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All conflict has been resolved. |
||
</li> | ||
</ul> | ||
<nav-link v-else :item="subItem"></nav-link> | ||
</li> | ||
</ul> | ||
</div> | ||
<nav-link v-else :item="item"></nav-link> | ||
</div> | ||
<!-- github link --> | ||
<a v-if="githubLink" | ||
:href="githubLink" | ||
|
@@ -20,15 +42,17 @@ | |
|
||
<script> | ||
import OutboundLink from './OutboundLink.vue' | ||
import { isActive, ensureExt } from './util' | ||
import NavLink from './NavLink.vue' | ||
import { isActive, resolveNavLinkItem } from './util' | ||
|
||
export default { | ||
components: { OutboundLink }, | ||
components: { OutboundLink, NavLink }, | ||
computed: { | ||
userLinks () { | ||
return (this.$site.themeConfig.nav || []).map(item => ({ | ||
text: item.text, | ||
link: ensureExt(item.link) | ||
return (this.$site.themeConfig.nav || []).map((link => { | ||
return Object.assign(resolveNavLinkItem(link), { | ||
items: (link.items || []).map(resolveNavLinkItem) | ||
}) | ||
})) | ||
}, | ||
githubLink () { | ||
|
@@ -52,21 +76,96 @@ export default { | |
.nav-links | ||
display inline-block | ||
a | ||
color inherit | ||
font-weight 500 | ||
line-height 1.25rem | ||
margin-left 1.5rem | ||
color inherit | ||
&:hover, &.router-link-active | ||
color $accentColor | ||
.nav-item | ||
position relative | ||
display inline-block | ||
margin-left 1.5rem | ||
font-weight 500 | ||
line-height 2rem | ||
.dropdown-wrapper | ||
&:hover .nav-dropdown | ||
display block | ||
.arrow | ||
display inline-block | ||
vertical-align middle | ||
margin-top -1px | ||
margin-left 6px | ||
width 0 | ||
height 0 | ||
border-left 4px solid transparent | ||
border-right 4px solid transparent | ||
border-top 5px solid #ccc | ||
.nav-dropdown | ||
li | ||
color inherit | ||
line-height 1.7rem | ||
a | ||
display block | ||
height 1.7rem | ||
line-height 1.7rem | ||
position relative | ||
border-bottom none | ||
font-weight 400 | ||
margin-bottom 0 | ||
padding 0 1.5rem 0 1.25rem | ||
&:hover | ||
color $accentColor | ||
&.router-link-active | ||
color $accentColor | ||
&::after | ||
content "" | ||
width 0 | ||
height 0 | ||
border-left 5px solid $accentColor | ||
border-top 4px solid transparent | ||
border-bottom 4px solid transparent | ||
position absolute | ||
top calc(50% - 3px) | ||
left 10px | ||
&:first-child h4 | ||
margin-top 0 | ||
padding-top 0 | ||
border-top 0 | ||
& > h4 | ||
margin 0.45rem 0 0 | ||
border-top 1px solid #eee | ||
padding 0.45rem 1.5rem 0 1.25rem | ||
& > ul | ||
padding 0 | ||
list-style none | ||
.github-link | ||
margin-left 1.5rem | ||
|
||
@media (max-width: $MQMobile) | ||
.nav-links a | ||
margin-left 0 | ||
.nav-links | ||
.nav-item, .github-link | ||
margin-left 0 | ||
|
||
@media (min-width: $MQMobile) | ||
.nav-links a | ||
&:hover, &.router-link-active | ||
color $textColor | ||
margin-bottom -2px | ||
border-bottom 2px solid lighten($accentColor, 5%) | ||
.nav-links | ||
a | ||
&:hover, &.router-link-active | ||
color $textColor | ||
margin-bottom -2px | ||
border-bottom 2px solid lighten($accentColor, 5%) | ||
.nav-dropdown | ||
display none | ||
box-sizing border-box; | ||
max-height calc(100vh - 2.7rem) | ||
overflow-y auto | ||
position absolute | ||
top 100% | ||
right 0 | ||
background-color #fff | ||
padding 10px 0 | ||
border 1px solid #ddd | ||
border-bottom-color #ccc | ||
text-align left | ||
border-radius 0.25rem | ||
white-space nowrap | ||
margin 0 | ||
</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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 67c758e, should only be
exact
for the homepage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed at 96a6cc6.