-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import {SplitView} from '@spectrum-web-components/split-view'; | ||
import '@spectrum-web-components/split-view/sp-split-view.js'; | ||
|
||
export default function setup(): void { | ||
/** | ||
* Make split views responsive and stack vertically on narrow screens. | ||
*/ | ||
export default function setupSplitView(): void { | ||
// 60em = --sl-breakpoint--large | ||
const mql = window.matchMedia('(max-width: 60em'); | ||
mql.addEventListener('change', event => { | ||
const topSplit = document.querySelector('.sl-c-playground') as SplitView; | ||
const topSplit = document.querySelector('.sl-c-playground') as SplitView; | ||
|
||
function updateLayout(event: MediaQueryListEvent | MediaQueryList): void { | ||
if (topSplit) topSplit.vertical = event.matches; | ||
}); | ||
} | ||
updateLayout(mql); | ||
mql.addEventListener('change', updateLayout); | ||
} |