Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(theme): add NavScreen component
- Loading branch information
1 parent
e93d3e5
commit b5cf33c
Showing
15 changed files
with
324 additions
and
72 deletions.
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
43 changes: 43 additions & 0 deletions
43
packages/theme/src/client/module/navbar/components/NavScreen.ts
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,43 @@ | ||
import { disableBodyScroll, clearAllBodyScrollLocks } from "body-scroll-lock"; | ||
import { Transition, defineComponent, h, ref } from "vue"; | ||
|
||
import NavScreenLinks from "@theme-hope/module/navbar/components/NavScreenLinks"; | ||
|
||
import type { VNode } from "vue"; | ||
|
||
import "../styles/nav-screen.scss"; | ||
|
||
export default defineComponent({ | ||
name: "NavScreen", | ||
|
||
props: { | ||
active: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
|
||
setup(props) { | ||
const screen = ref<HTMLElement>(); | ||
|
||
return (): VNode => | ||
h( | ||
Transition, | ||
{ | ||
name: "fade", | ||
onEnter: () => | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
disableBodyScroll(screen.value!, { reserveScrollBarGap: true }), | ||
onAfterLeave: () => clearAllBodyScrollLocks(), | ||
}, | ||
() => | ||
props.active | ||
? h( | ||
"div", | ||
{ class: "nav-screen", ref: screen }, | ||
h("div", { class: "container" }, [h(NavScreenLinks)]) | ||
) | ||
: null | ||
); | ||
}, | ||
}); |
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
37 changes: 37 additions & 0 deletions
37
packages/theme/src/client/module/navbar/components/ToggleNavbarButton.ts
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,37 @@ | ||
import { defineComponent, h } from "vue"; | ||
|
||
import type { VNode } from "vue"; | ||
|
||
import "../styles/toggle-navbar-button.scss"; | ||
|
||
export default defineComponent({ | ||
name: "ToggleNavbarButton", | ||
|
||
props: { | ||
active: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
|
||
emits: ["toggle"], | ||
|
||
setup(props, { emit }) { | ||
return (): VNode => | ||
h( | ||
"button", | ||
{ | ||
class: ["toggle-navbar-button", { "is-active": props.active }], | ||
"aria-label": "Toggle Navbar", | ||
"aria-expanded": props.active, | ||
"aria-controls": "VPNavScreen", | ||
onClick: () => emit("toggle"), | ||
}, | ||
h("span", { class: "button-container" }, [ | ||
h("span", { class: "button-top" }), | ||
h("span", { class: "button-middle" }), | ||
h("span", { class: "button-bottom" }), | ||
]) | ||
); | ||
}, | ||
}); |
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
29 changes: 29 additions & 0 deletions
29
packages/theme/src/client/module/navbar/styles/nav-screen-links.scss
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,29 @@ | ||
.nav-screen-links { | ||
display: none; | ||
padding-bottom: 0.75rem; | ||
|
||
@media (max-width: hope-config.$mobile) { | ||
display: block; | ||
} | ||
|
||
.navbar-links-item { | ||
position: relative; | ||
display: block; | ||
padding: 12px 4px 11px 0; | ||
font-size: 16px; | ||
line-height: 1.5rem; | ||
border-bottom: 1px solid var(--border-color); | ||
|
||
transition: border-bottom-color var(--color-transition); | ||
} | ||
|
||
.nav-link { | ||
color: var(--text-color); | ||
font-weight: normal; | ||
|
||
&:hover, | ||
&.active { | ||
color: var(--theme-color); | ||
} | ||
} | ||
} |
Oops, something went wrong.