@lakea/gravity-popover-adapter-floating-ui
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

@lakea/gravity-popover-adapter-floating-ui

An adapter for GrPopover using Floating UI as implementation.

Installation

Install the library using NPM:

npm install @lakea/gravity-popover-adapter-floating-ui @floating-ui/dom --save

Next, create a new file, cookie-adapter-root.module.ts which exposes an Angular's module with a default configuration.

import {NgModule} from '@angular/core';
import {GrPopover} from '@lakea/gravity/ui';
import {GrPopoverAdapterFloatingUi} from '@lakea/gravity-popover-adapter-floating-ui';

@NgModule({
  providers: [
    {
      provide: GrPopover,
      useClass: GrPopoverAdapterFloatingUi,
    },
  ],
})
export class PopoverAdapterRootModule {}

Import PopoverAdapterRootModule to application root module like app.module.ts.

You should import the PopoverAdapterRootModule once in your root module.

The PopoverAdapterRootModule provide the adapter implementation for GrPopover.


Creating your own adapter

Create your adapter implementation class extending GrPopover abstraction:

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

import {GrPopover, GrPopoverInstance, GrPopoverPlacements} from '@lakea/gravity/ui';

@Injectable()
export class GrPopoverAdapter extends GrPopover {
  constructor() {
    super();
  }

  public create(trigger: HTMLElement, element: HTMLElement, placement: GrPopoverPlacements): GrPopoverInstance {
    // YOUR IMPLEMENTATION
  }
}

class GrPopoverAdapterInstance implements GrPopoverInstance {
  constructor(trigger: HTMLElement, element: HTMLElement, placement: GrPopoverPlacements) {
  }

  public show(): void {
    // YOUR IMPLEMENTATION
  }

  public hide(): void {
    // YOUR IMPLEMENTATION
  }

  public destroy(): void {
    // YOUR IMPLEMENTATION
  }
}

So, provide it on your application root module (maybe app.module.ts), like this:

  providers: [
    {
      provide: GrPopover,
      useClass: GrPopoverAdapter,
    }
  ]

Readme

Keywords

none

Package Sidebar

Install

Weekly Downloads

155

Version

3.0.2

License

none

Unpacked Size

35.2 kB

Total Files

12

Last publish

Collaborators

  • ltp.lakea
  • gesielr
  • lakea-gesiel