npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-windows

v1.0.1

Published

Simple Angular-based floating window containers

Downloads

119

Readme

NgxWindows

Angular version: 18.1.0

Previous versions of Angular aren't supported.

License: ISC

Using Angular Windows

Installation

Run npm install ngx-windows.

Add ngx-windows style to your angular.json config file:

"styles": [
  "./node_modules/ngx-windows/ngx-windows-style.css",
  "src/styles.scss"
]

Usage

  1. You should provide NgwWindowsManagerService in app config or if you need multiple instances - in specific component that will contain windows.

  2. Add NgwWindowsContainerComponent to your template

<ngw-windows-container [style]="{width: '100vw', height: '100vh'}"/>

You must set width and height of this container for windows.

Current version uses only window inner width and height.

  1. Creating window

In any component inject NgwWindowsManagerService and use it commands to control, filter and manage windows globally. You must provide class of component that will be displayed inside window. Component should have overflow:auto, width:100% and height:100% for more fail-safe experience. If you want to change window component while window is already active you need to use NgwWindowsManagerService.findFN.component = AnotherComponent.

export class YourComponent {
  constructor(public nwm: NgwWindowsManagerService,
              private destroyRef: DestroyRef) {
    const win = this.nwm.createWindow({
      name: 'Test Window',
      component: TestWindowComponent
    });
    win.onRegister$
      .pipe(takeUntilDestroyed(this.destroyRef))
      .subscribe(service => {
        // Change window properties after it's registered...
      });
    // Don't change window properties through win.service here - explaination in HowItWorks section
  }
}

Your window component must contain windowController input!

  windowController = input.required<NgwWindowControllerService>();

Also, remember to set window placement after register:

constructor(private nwm: NgwWindowsManagerService) {
  const win = this.nwm.createWindow({
    name: 'My Window',
    component: TestCpmComponent
  });

  win.onRegister$
    .pipe(takeUntilDestroyed())
    .subscribe(service => {
      service.placementSvc.setAll(
        800,
        600,
        30,
        30
      );
    });
}

HowItWorks

When you call NgwWindowsManagerService.createWindow function adds default properties, ID and onRegister$ Subject to window object and pushes it to activeWindows. After pushed, it's rendered inside NgwWindowsContainerComponent as NgwWindowComponent that calls NgwWindowsManagerService.register after initialization of its service and self. onRegister$: Subject<NgwWindowControllerService> was called after registration which means that you can use all properties and services inside NgwWindowComponent.

API

NgwWindowsManagerService

[!WARNING] Functions that update window properties, add window or remove window uses write operations. If you want to use these functions in effect then you need to set effect property {allowWriteSignals: true}.

NgwWindowControllerService

Each window has its own instance of NgwWindowControllerService that can be accessed via NgwWindowsManagerService.createWindow(...).onRegister$ or NgwWindowsManagerService.findFN.service (after initialization). It's also passed to window app component as required input windowController: InputSignal<NgwWindowControllerService>.

[!WARNING] Functions that update window properties, add window or remove window uses write operations. If you want to use these functions in effect then you need to set effect property {allowWriteSignals: true}.

NgwWindowConfigurationService

Provided in and used by NgwWindowComponent.

NgwWindowPlacementService

Provided in and used by NgwWindowComponent.

NgwWindowStateService

Provided in and used by NgwWindowComponent.

Styling

You can create custom scss file with styles and import it in your styles.scss file. Example file can be found in public/custom-window-style.scss file.

Default style:

ngw-window {
  &:not(.transparent) {
    background: #efefef !important;
  }

  &:not(&.borderless) {
    border: solid 1px #373737;
  }

  &:not(&.noshadow) {
    box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.1);
  }

  &.focused:not(&.noshadow) {
    box-shadow: 1px 1px 6px rgba(0, 0, 0, .35),
    1px 1px 4px rgba(0, 0, 0, .2);
  }

  .ngw-window-topbar {
    background: #373737;
    color: #fff;
  }

  ngw-icon:hover {
    background-color: rgba(255, 255, 255, .15);
  }

  .ngw-window-content {
    color: #000;
    padding: 0;
  }
}

ngw-windows-container .ngw-window-placement-prediction.show {
  background-color: rgba(150, 200, 255, .5);
  border: solid 2px rgba(150, 200, 255, .95);
  backdrop-filter: blur(1px);
}

ngw-icon svg path {
  fill: #fff;
  stroke: #fff;
}