0.4.0 • Published 1 month ago

psx-app-switcher v0.4.0

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

psx-app-switcher-menu

The psx-app-switcher-menu is a customizable Angular component that provides a menu with links to other projects or web pages. You can easily integrate it into your Angular project by following the steps below.

Installation

To install the psx-app-switcher, use npm:

npm install psx-app-switcher

Usage

  1. Import the PsxAppSwitcherModule and the required interfaces in your app.module.ts:
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {PsxAppSwitcherModule} from 'psx-app-switcher-menu'; // Import the module
import {PsxAppSwitcherConfig, PsxAppSwitcherMenuItem} from 'psx-app-switcher-menu'; // Import the interfaces

@NgModule({
    imports: [
        BrowserModule,
        PsxAppSwitcherModule // Add the module to imports
    ],
    // ...
})
export class AppModule {
}
  1. Use the psx-app-switcher component in your template:
<psx-app-switcher [psXAppSwitcherConfig]="psXAppSwitcherConfig"></psx-app-switcher>
  1. Provide the psXAppSwitcherConfig object in your component:
import {Component} from '@angular/core';
import {PsxAppSwitcherConfig, PsxAppSwitcherMenuItem} from 'psx-app-switcher-menu';

@Component({
    selector: 'app-your-component',
    templateUrl: './your-component.component.html',
    styleUrls: ['./your-component.component.css']
})
export class YourComponent {
    psXAppSwitcherConfig: PsxAppSwitcherConfig = {
        matIconButton: 'menu', // Replace with the desired Material icon or text
        menuItems: [
            {
                name: 'Project 1',
                url: '/project1',
                icon: 'folder' // Replace with the desired icon name or leave it empty
            },
            {
                name: 'Project 2',
                url: '/project2',
                iconClass: 'custom-icon-class' // Add a custom CSS class for the icon or leave it empty
            },
            // Add more menu items as needed
        ]
    };

    // Add other component logic as needed
}

API

The psx-app-switcher component has the following input properties:

InputTypeDefaultDescription
menuOpenbooleanfalseDetermines whether the menu is open or closed.
psXAppSwitcherConfigPsxAppSwitcherConfignullConfiguration object for the switcher menu. See the PsxAppSwitcherConfig interface for details.

The PsxAppSwitcherConfig interface has the following fields:

FieldTypeDescription
matIconButtonstringThe Material icon or text to be displayed inside the trigger button.
menuItemsArrayAn array of menu items. See the PsxAppSwitcherMenuItem interface for details.

The PsxAppSwitcherMenuItem interface has the following fields:

FieldTypeDescription
namestringThe name of the menu item.
urlstringThe URL to navigate when the menu item is clicked.
iconstring(Optional) The name of the Material icon to be displayed with the menu item.
iconClassstring(Optional) The CSS class to apply for a custom icon style.
target'_blank' | '_self' | '_parent' | '_top'(Optional) The target attribute for the link when the menu item is clicked. Default: '_blank'

The psx-app-switcher component also emits an itemSelected event when a menu item is clicked.

Styling

You can customize the appearance of the psx-app-switcher-menu component using the provided CSS classes:

CSS ClassDescription
.menu-buttonStyles the trigger button for the menu.
.menu-button-iconStyles the icon inside the trigger button.
.menuStyles the menu itself.
.menu-itemStyles a menu item.
.menu-item-iconStyles the icon inside a menu item.

HTML Structure:

<div class="psx-app-switcher">
	<button class="menu-button">
		<mat-icon class="menu-button-icon"></mat-icon>
	</button>
	<mat-menu class="menu">
		<button>
			<span class="menu-item">
				<mat-icon class="menu-item-icon"></mat-icon>
			</span>
		</button>
	</mat-menu>
</div>

Example:

/* styles.scss (global) or component-specific styles */

.psx-app-switcher{
    .menu-button {
        background-color: #2196F3;
        color: white;
        /* Add more styles as needed */
    }

    .menu-button-icon {
        font-size: 24px;
        /* Add more styles as needed */
    }

    .menu {
        border: 1px solid #ccc;
        background-color: #f9f9f9;
        /* Add more styles as needed */
    }

    .menu-item {
        padding: 8px 16px;
        /* Add more styles as needed */
    }

    .item-icon {
        margin-right: 8px;
        /* Add more styles as needed */
    }
}
0.4.0

1 month ago

0.3.2

3 months ago

0.3.4

3 months ago

0.3.3

3 months ago

0.3.0

3 months ago

0.2.0

3 months ago

0.3.1

3 months ago

0.1.1

8 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

10 months ago

0.0.0-watch

10 months ago