Skip to content

Commit 885d7e9

Browse files
authored
refactor: extract app-layout logic into reusable mixin (#8341)
1 parent 702a8a8 commit 885d7e9

File tree

5 files changed

+601
-572
lines changed

5 files changed

+601
-572
lines changed

packages/app-layout/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"polymer"
3636
],
3737
"dependencies": {
38+
"@open-wc/dedupe-mixin": "^1.3.0",
3839
"@polymer/polymer": "^3.0.0",
3940
"@vaadin/a11y-base": "24.7.0-alpha1",
4041
"@vaadin/button": "24.7.0-alpha1",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2018 - 2024 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { Constructor } from '@open-wc/dedupe-mixin';
7+
8+
export interface AppLayoutI18n {
9+
drawer: string;
10+
}
11+
12+
export declare function AppLayoutMixin<T extends Constructor<HTMLElement>>(
13+
base: T,
14+
): Constructor<AppLayoutMixinClass> & T;
15+
16+
export declare class AppLayoutMixinClass {
17+
/**
18+
* The object used to localize this component.
19+
* To change the default localization, replace the entire
20+
* `i18n` object with a custom one.
21+
*
22+
* To update individual properties, extend the existing i18n object as follows:
23+
* ```js
24+
* appLayout.i18n = {
25+
* ...appLayout.i18n,
26+
* drawer: 'Drawer'
27+
* }
28+
* ```
29+
*
30+
* The object has the following structure and default values:
31+
* ```
32+
* {
33+
* drawer: 'Drawer'
34+
* }
35+
* ```
36+
*/
37+
i18n: AppLayoutI18n;
38+
39+
/**
40+
* Defines whether navbar or drawer will come first visually.
41+
* - By default (`primary-section="navbar"`), the navbar takes the full available width and moves the drawer down.
42+
* - If `primary-section="drawer"` is set, then the drawer will move the navbar, taking the full available height.
43+
* @attr {navbar|drawer} primary-section
44+
*/
45+
primarySection: 'drawer' | 'navbar';
46+
47+
/**
48+
* Controls whether the drawer is opened (visible) or not.
49+
* Its default value depends on the viewport:
50+
* - `true`, for desktop size views
51+
* - `false`, for mobile size views
52+
* @attr {boolean} drawer-opened
53+
*/
54+
drawerOpened: boolean;
55+
56+
/**
57+
* Drawer is an overlay on top of the content
58+
* Controlled via CSS using `--vaadin-app-layout-drawer-overlay: true|false`;
59+
*/
60+
readonly overlay: boolean;
61+
62+
/**
63+
* A global event that causes the drawer to close (be hidden) when it is in overlay mode.
64+
* - The default is `vaadin-router-location-changed` dispatched by Vaadin Router
65+
*
66+
* @attr {string} close-drawer-on
67+
*/
68+
closeDrawerOn: string;
69+
}

0 commit comments

Comments
 (0)