mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
update layout stuff
This commit is contained in:
@@ -29,6 +29,14 @@ Reasons why you may want to disable sticky:
|
||||
1. For `aside` / `menu` or blog sites sometimes this space is used for ads based on how far down a user scrolls.
|
||||
1. For `banner`, `header`, `sub-header` it can cause a lot of clutter on the screen and you may only want to show certain elements are the user scrolls.
|
||||
|
||||
## Toggle navigation
|
||||
|
||||
Toggling navigation can be done in a number of ways.
|
||||
|
||||
1. `<wa-layout><button data-navigation-toggle></button></wa-layout>` - The button with `data-navigation-toggle` must be inside the `<wa-layout>` component.
|
||||
1. `<wa-layout nav-state="open"></wa-layout>` -
|
||||
1. `document.querySelector("button").addEventListener("click", () => document.querySelector("wa-layout").toggleNavigation())`
|
||||
|
||||
```html:preview
|
||||
<style>
|
||||
wa-layout::part(header) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import WaDrawer from '../drawer/drawer.component.js';
|
||||
import WaVisuallyHidden from '../visually-hidden/visually-hidden.component.js';
|
||||
import WebAwesomeElement from '../../internal/webawesome-element.js';
|
||||
import type { CSSResultGroup, PropertyValueMap } from 'lit';
|
||||
import { live } from 'lit/directives/live.js';
|
||||
|
||||
/**
|
||||
* @summary
|
||||
@@ -71,6 +72,11 @@ export default class WaLayout extends WebAwesomeElement {
|
||||
*/
|
||||
@property({ attribute: 'view', reflect: true }) view: 'mobile' | 'desktop' = 'mobile';
|
||||
|
||||
/**
|
||||
* Whether or not the navigation drawer is open. Note, the navigation drawer is only "open" on mobile views.
|
||||
*/
|
||||
@property({ attribute: 'nav-open', reflect: true, type: Boolean }) navOpen = false;
|
||||
|
||||
/**
|
||||
* At what "px" to hide the "menu" slot and collapse into a hamburger button
|
||||
*/
|
||||
@@ -172,23 +178,21 @@ export default class WaLayout extends WebAwesomeElement {
|
||||
* Shows the mobile navigation drawer
|
||||
*/
|
||||
showNavigation() {
|
||||
this.navigationDrawer?.show();
|
||||
this.navOpen = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the mobile navigation drawer
|
||||
*/
|
||||
hideNavigation() {
|
||||
this.navigationDrawer?.hide();
|
||||
this.navOpen = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the mobile navigation drawer
|
||||
*/
|
||||
toggleNavigation() {
|
||||
if (this.navigationDrawer) {
|
||||
this.navigationDrawer.open = !this.navigationDrawer.open;
|
||||
}
|
||||
this.navOpen = !this.navOpen
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -259,6 +263,9 @@ export default class WaLayout extends WebAwesomeElement {
|
||||
<wa-drawer
|
||||
placement=${this.navigationPlacement}
|
||||
part="drawer"
|
||||
?open=${live(this.navOpen)}
|
||||
@wa-after-show=${() => this.navOpen = this.navigationDrawer.open}
|
||||
@wa-after-hide=${() => this.navOpen = this.navigationDrawer.open}
|
||||
exportparts="
|
||||
panel:drawer__panel
|
||||
base:drawer__base
|
||||
|
||||
Reference in New Issue
Block a user