forked from pulumi/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scroll to top button (pulumi#3152)
- Loading branch information
Showing
8 changed files
with
64 additions
and
4 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
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,3 @@ | ||
pulumi-top-button { | ||
|
||
} |
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,7 @@ | ||
import { TopButton } from './top-button'; | ||
|
||
describe('pulumi-top-button', () => { | ||
it('builds', () => { | ||
expect(new TopButton()).toBeTruthy(); | ||
}); | ||
}); |
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 @@ | ||
import { Component, Listen, State, h } from "@stencil/core"; | ||
|
||
// Scroll to top button. | ||
@Component({ | ||
tag: "pulumi-top-button", | ||
styleUrl: "top-button.scss", | ||
shadow: false | ||
}) | ||
export class TopButton { | ||
|
||
@State() | ||
visible: string; | ||
|
||
@Listen("scroll", { target: "window" }) | ||
handleScroll() { | ||
this.setVisibility(); | ||
} | ||
|
||
componentWillRender() { | ||
this.setVisibility(); | ||
} | ||
|
||
render() { | ||
let buttonClass = `btn-scroll-top fas fa-chevron-up ${this.visible}` | ||
return ( | ||
<a class={buttonClass} title="Scroll to top" href="#"></a> | ||
); | ||
} | ||
|
||
setVisibility() { | ||
this.visible = window.scrollY > 2500 ? "visible" : "hidden"; | ||
} | ||
} |
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