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

fix($theme-default): overlap navbar dropdown menus (fix #2227) #2365

Merged
merged 2 commits into from
Aug 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DropdownLink renders dropdown link. 1`] = `
<div class="dropdown-wrapper"><button type="button" aria-label="Learn More Select" class="dropdown-title"><span class="title">Learn More</span> <span class="arrow right"></span></button>
<div class="dropdown-wrapper"><button type="button" aria-label="Learn More Select" class="dropdown-title"><span class="title">Learn More</span> <span class="arrow down"></span></button> <button type="button" aria-label="Learn More Select" class="mobile-dropdown-title"><span class="title">Learn More</span> <span class="arrow right"></span></button>
<ul class="nav-dropdown" style="display: none;" name="dropdown">
<li class="dropdown-item">
<!----> <a class="nav-link">
Expand Down
36 changes: 26 additions & 10 deletions packages/@vuepress/theme-default/components/DropdownLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
class="dropdown-title"
type="button"
:aria-label="dropdownAriaLabel"
@click="handleDropdown"
billyyyyy3320 marked this conversation as resolved.
Show resolved Hide resolved
>
<span class="title">{{ item.text }}</span>
<span
class="arrow down"
/>
</button>
<button
billyyyyy3320 marked this conversation as resolved.
Show resolved Hide resolved
class="mobile-dropdown-title"
type="button"
:aria-label="dropdownAriaLabel"
@click="setOpen(!open)"
>
<span class="title">{{ item.text }}</span>
Expand Down Expand Up @@ -105,6 +116,11 @@ export default {

isLastItemOfArray (item, array) {
return last(array) === item
},

handleDropdown () {
const isTriggerByTab = event.detail === 0
billyyyyy3320 marked this conversation as resolved.
Show resolved Hide resolved
if (isTriggerByTab) this.setOpen(!this.open)
}
}
}
Expand All @@ -130,6 +146,13 @@ export default {
vertical-align middle
margin-top -1px
margin-left 0.4rem
.mobile-dropdown-title
@extends .dropdown-title
display none
font-weight 600
font-size inherit
&:hover
color $accentColor
.nav-dropdown
.dropdown-item
color inherit
Expand Down Expand Up @@ -175,10 +198,9 @@ export default {
&.open .dropdown-title
margin-bottom 0.5rem
.dropdown-title
font-weight 600
font-size inherit
&:hover
color $accentColor
display: none
.mobile-dropdown-title
display: block
.nav-dropdown
transition height .1s ease-out
overflow hidden
Expand All @@ -203,12 +225,6 @@ export default {
display block !important
&.open:blur
display none
.dropdown-title .arrow
// make the arrow always down at desktop
border-left 4px solid transparent
border-right 4px solid transparent
border-top 6px solid $arrowBgColor
border-bottom 0
.nav-dropdown
display none
// Avoid height shaked by clicking
Expand Down