Skip to content

Commit

Permalink
feat(core/map-navigation): overlay can be configured via slot attribu…
Browse files Browse the repository at this point in the history
…te (#133)
  • Loading branch information
nuke-ellington committed Nov 15, 2022
1 parent 0cafe03 commit be58975
Show file tree
Hide file tree
Showing 22 changed files with 289 additions and 35 deletions.
6 changes: 4 additions & 2 deletions packages/angular-test-app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import { Toast } from 'src/preview-examples/toast';
import { ToastCustom } from 'src/preview-examples/toast-custom';
import { Toggle } from 'src/preview-examples/toggle';
import { ToggleColor } from 'src/preview-examples/toggle-color';
import { ToggleCustomDisabled } from 'src/preview-examples/toggle-custom-disable';
import { ToggleCustomDisabled } from 'src/preview-examples/toggle-disabled';
import { ToggleCustomLabel } from 'src/preview-examples/toggle-custom-label';
import { Tree } from 'src/preview-examples/tree';
import { TreeCustom } from 'src/preview-examples/tree-custom';
Expand All @@ -84,6 +84,7 @@ import { VerticalTabsWithAvatar } from 'src/preview-examples/vertical-tabs-with-
import { Workflow } from 'src/preview-examples/workflow';
import { WorkflowVertical } from 'src/preview-examples/workflow-vertical';
import { NavigationTestComponent } from './components/navigation-test.component';
import { MapNavigationOverlay } from 'src/preview-examples/map-navigation-overlay';

const routes: Routes = [
{
Expand Down Expand Up @@ -252,7 +253,7 @@ const routes: Routes = [
{ path: 'tile', component: Tile },
{ path: 'timepicker', component: Timepicker },
{ path: 'toggle-color', component: ToggleColor },
{ path: 'toggle-custom-disabled', component: ToggleCustomDisabled },
{ path: 'toggle-disabled', component: ToggleCustomDisabled },
{ path: 'toggle-custom-label', component: ToggleCustomLabel },
{ path: 'toggle', component: Toggle },
{ path: 'upload', component: Upload },
Expand All @@ -262,6 +263,7 @@ const routes: Routes = [
{ path: 'workflow', component: Workflow },
{ path: 'workflow-vertical', component: WorkflowVertical },
{ path: 'map-navigation', component: MapNavigation },
{ path: 'map-navigation-overlay', component: MapNavigationOverlay },
],
},
];
Expand Down
4 changes: 3 additions & 1 deletion packages/angular-test-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { InputReadonly } from 'src/preview-examples/input-readonly';
import { InputWithIcon } from 'src/preview-examples/input-with-icon';
import { Kpi } from 'src/preview-examples/kpi';
import { MapNavigation } from 'src/preview-examples/map-navigation';
import { MapNavigationOverlay } from 'src/preview-examples/map-navigation-overlay';
import { MessageBar } from 'src/preview-examples/message-bar';
import { Modal } from 'src/preview-examples/modal';
import { Pill } from 'src/preview-examples/pill';
Expand All @@ -81,7 +82,7 @@ import { Toast } from 'src/preview-examples/toast';
import { ToastCustom } from 'src/preview-examples/toast-custom';
import { Toggle } from 'src/preview-examples/toggle';
import { ToggleColor } from 'src/preview-examples/toggle-color';
import { ToggleCustomDisabled } from 'src/preview-examples/toggle-custom-disable';
import { ToggleCustomDisabled } from 'src/preview-examples/toggle-disabled';
import { ToggleCustomLabel } from 'src/preview-examples/toggle-custom-label';
import { Tree } from 'src/preview-examples/tree';
import { TreeCustom } from 'src/preview-examples/tree-custom';
Expand Down Expand Up @@ -169,6 +170,7 @@ import { NavigationTestComponent } from './components/navigation-test.component'
Workflow,
WorkflowVertical,
MapNavigation,
MapNavigationOverlay,
TabsRounded,
DatepickerRange,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2022 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { Component } from '@angular/core';

@Component({
selector: 'app-map-navigation-overlay',
template: `
<ix-map-navigation
application-name="Test Application"
navigation-title="Some other content"
>
<ix-icon name="rocket" slot="logo"></ix-icon>
<ix-menu>
<ix-menu-item>Item 1</ix-menu-item>
<ix-menu-item>Item 2</ix-menu-item>
<ix-menu-item>Item 3</ix-menu-item>
</ix-menu>
<div slot="sidebar-content">Sidebar content</div>
<ix-button (click)="showOverlay = true">Show overlay</ix-button>
<ix-map-navigation-overlay
*ngIf="showOverlay"
name="Custom overlay title"
icon="bulb"
slot="overlay"
(closeClick)="showOverlay = false"
></ix-map-navigation-overlay>
</ix-map-navigation>
`,
})
export class MapNavigationOverlay {
showOverlay = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-toggle-custom-disabled',
selector: 'app-toggle-disabled',
template: ` <ix-toggle disabled></ix-toggle> `,
})
export class ToggleCustomDisabled {}
15 changes: 13 additions & 2 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4376,7 +4376,13 @@
"signature": "closeOverlay() => Promise<void>",
"parameters": [],
"docs": "Close current shown overlay",
"docsTags": []
"docsTags": [
{
"name": "deprecated",
"text": "will get removed with next major release in favor of slot based approach"
}
],
"deprecation": "will get removed with next major release in favor of slot based approach"
},
{
"name": "openOverlay",
Expand All @@ -4388,6 +4394,10 @@
"parameters": [],
"docs": "Open a overlay inside content area",
"docsTags": [
{
"name": "deprecated",
"text": "will get removed with next major release in favor of slot based approach"
},
{
"name": "param",
"text": "name"
Expand All @@ -4404,7 +4414,8 @@
"name": "param",
"text": "color"
}
]
],
"deprecation": "will get removed with next major release in favor of slot based approach"
}
],
"events": [
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ export namespace Components {
"applicationName": string;
/**
* Close current shown overlay
* @deprecated will get removed with next major release in favor of slot based approach
*/
"closeOverlay": () => Promise<void>;
/**
Expand All @@ -716,6 +717,7 @@ export namespace Components {
"navigationTitle": string;
/**
* Open a overlay inside content area
* @deprecated will get removed with next major release in favor of slot based approach
* @param name
* @param component
* @param icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
width: 100%;
height: 100%;
z-index: 2;
top: 0;

background-color: var(--theme-overlay--background);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,27 @@
* LICENSE file in the root directory of this source tree.
*/

import { Component, Event, EventEmitter, h, Host, Prop } from '@stencil/core';
import {
Component,
Element,
Event,
EventEmitter,
h,
Host,
Prop,
} from '@stencil/core';
import anime from 'animejs';

@Component({
tag: 'ix-map-navigation-overlay',
styleUrl: 'map-navigation-overlay.scss',
scoped: true,
})
export class MapNavigationOverlay {
private static readonly slowTime = 500;

@Element() hostElement: HTMLIxMapNavigationOverlayElement;

/**
* Title of overlay
*/
Expand All @@ -35,6 +48,31 @@ export class MapNavigationOverlay {
*/
@Event() closeClick: EventEmitter;

componentWillLoad() {
anime({
targets: this.hostElement,
duration: MapNavigationOverlay.slowTime,
backdropFilter: [0, 'blur(1rem)'],
translateX: ['-4rem', 0],
opacity: [0, 1],
easing: 'easeOutSine',
});
}

private closeOverlay() {
anime({
targets: this.hostElement,
duration: MapNavigationOverlay.slowTime,
backdropFilter: ['blur(1rem)', 0],
translateX: [0, '-4rem'],
opacity: [1, 0],
easing: 'easeInSine',
complete: () => {
this.closeClick.emit();
},
});
}

render() {
return (
<Host>
Expand All @@ -61,7 +99,7 @@ export class MapNavigationOverlay {
invisible
icon="close"
size="24"
onClick={() => this.closeClick.emit()}
onClick={() => this.closeOverlay()}
></ix-icon-button>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
SPDX-FileCopyrightText: 2022 Siemens AG
SPDX-License-Identifier: MIT
-->

<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>
</head>
<body>
<ix-map-navigation>
<ix-map-navigation-overlay name="Title" icon="bulb" color="color-info">
Lorem ipsum
</ix-map-navigation-overlay>
</ix-map-navigation>
<script src="http://127.0.0.1:8080/scripts/e2e/load-e2e-runtime.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* SPDX-FileCopyrightText: 2022 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { expect } from '@playwright/test';
import { regressionTest } from '@utils/test';

regressionTest.describe('map-navigation-overlay', () => {
regressionTest('basic', async ({ page }) => {
await page.goto(`map-navigation-overlay/test/basic`);
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,4 @@
overflow: hidden;
z-index: calc(var(--theme-z-index-sticky) - 1);
}

#overlay {
width: 100%;
height: 100%;
position: absolute;
top: 0;
z-index: calc(#{var(--theme-z-index-sticky)} + 1);
}
}
26 changes: 14 additions & 12 deletions packages/core/src/components/map-navigation/map-navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
*/

import {
Component,
Element,
Event,
EventEmitter,
h,
Host,
Method,
Prop,
State
Component,
Element,
Event,
EventEmitter,
h,
Host,
Method,
Prop,
State,
} from '@stencil/core';
import anime from 'animejs';

Expand Down Expand Up @@ -48,7 +48,6 @@ export class MapNavigation {

@State() isSidebarOpen = true;


/**
* Navigation toggled
*/
Expand Down Expand Up @@ -81,7 +80,6 @@ export class MapNavigation {

componentDidRender() {
this.appendMenu();
// this.openOverlay('Test', document.createElement('ix-breadcrumb'), 'info', 'color-warning');
this.closeOverlay();
}

Expand Down Expand Up @@ -142,6 +140,7 @@ export class MapNavigation {

/**
* Open a overlay inside content area
* @deprecated will get removed with next major release in favor of slot based approach
*
* @param name
* @param component
Expand Down Expand Up @@ -178,6 +177,7 @@ export class MapNavigation {

/**
* Close current shown overlay
* @deprecated will get removed with next major release in favor of slot based approach
*/
@Method()
async closeOverlay() {
Expand All @@ -189,6 +189,9 @@ export class MapNavigation {
opacity: [1, 0],
easing: 'easeInSine',
complete: () => {
if (!this.overlay) {
return;
}
this.overlay.firstChild?.remove();
this.overlay.classList.add('d-none');
},
Expand Down Expand Up @@ -236,7 +239,6 @@ export class MapNavigation {
<main>
<slot></slot>
</main>
<div id="overlay"></div>
</div>
</div>
</Host>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/map-navigation/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SPDX-License-Identifier: MIT

### `closeOverlay() => Promise<void>`

Close current shown overlay
<span style="color:red">**[DEPRECATED]**</span> will get removed with next major release in favor of slot based approach<br/><br/>Close current shown overlay

#### Returns

Expand All @@ -40,7 +40,7 @@ Type: `Promise<void>`

### `openOverlay(name: string, component: HTMLElement, icon?: string, color?: string) => Promise<void>`

Open a overlay inside content area
<span style="color:red">**[DEPRECATED]**</span> will get removed with next major release in favor of slot based approach<br/><br/>Open a overlay inside content area

#### Returns

Expand Down
Loading

0 comments on commit be58975

Please sign in to comment.