Skip to content

Commit

Permalink
Allow to change the initial mobile view of swirl-app-layout (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sqrrl authored Dec 16, 2024
1 parent 8ef3f0e commit 4c86457
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/fluffy-donuts-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@getflip/swirl-components": minor
"@getflip/swirl-components-angular": minor
"@getflip/swirl-components-react": minor
---

Add "initial-mobile-view" prop to swirl-app-layout
2 changes: 2 additions & 0 deletions packages/swirl-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export namespace Components {
* Hide the sidebar
*/
"hideSidebar": () => Promise<void>;
"initialMobileView"?: SwirlAppLayoutMobileView;
"navigationBackButtonLabel"?: string;
"navigationExpansionStateStorageKey"?: string;
"navigationLabel"?: string;
Expand Down Expand Up @@ -5875,6 +5876,7 @@ declare namespace LocalJSX {
"ctaLabel"?: string;
"hasNavigation"?: boolean;
"hideAppBar"?: boolean;
"initialMobileView"?: SwirlAppLayoutMobileView;
"navigationBackButtonLabel"?: string;
"navigationExpansionStateStorageKey"?: string;
"navigationLabel"?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class SwirlAppLayout {
@Prop() ctaLabel?: string;
@Prop({ mutable: true }) hasNavigation: boolean;
@Prop() hideAppBar?: boolean;
@Prop() initialMobileView?: SwirlAppLayoutMobileView;
@Prop() navigationBackButtonLabel?: string = "Go back";
@Prop() navigationExpansionStateStorageKey?: string =
SWIRL_APP_LAYOUT_NAV_EXPANSION_STATE_STORAGE_KEY;
Expand Down Expand Up @@ -114,6 +115,10 @@ export class SwirlAppLayout {
private transitionTimeout: NodeJS.Timeout;

componentWillLoad() {
if (this.initialMobileView) {
this.mobileView = this.initialMobileView;
}

this.mutationObserver = new MutationObserver(() => {
this.updateCustomAppBarBackButtonStatus();
this.updateNavigationStatus();
Expand Down
15 changes: 15 additions & 0 deletions packages/swirl-components/vscode-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,21 @@
"name": "hide-app-bar",
"description": ""
},
{
"name": "initial-mobile-view",
"description": "",
"values": [
{
"name": "body"
},
{
"name": "navigation"
},
{
"name": "sidebar"
}
]
},
{
"name": "navigation-back-button-label",
"description": ""
Expand Down

0 comments on commit 4c86457

Please sign in to comment.