New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ngx-ghosts

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-ghosts

Library to create skeleton loading experiences with angular

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

NgxGhosts

Table of Contents:

  • NgxGhosts

Live Demo

Installation

First you need to install the npm module:

npm install ngx-ghosts or yarn install ngx-ghosts

Import the NgxGhostsModule in your AppModule like this:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxGhostsModule } from 'ngx-ghosts';


@NgModule({
    imports: [
        BrowserModule,
        NgxGhostsModule.forRoot()
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

Import the NgxGhostsModule in your shared, lazy, or other modules like this:

@NgModule({
    exports: [
        CommonModule,
        NgxGhostsModule
    ]
})
export class SharedModule { }

Load the ngx-ghosts theme by adding it to the angular.json like this:

...
"build": {
  "options": {
    "styles": [
        "./node_modules/ngx-ghosts/theme.scss",
        "projects/ngx-ghosts-app/src/styles.scss"
      ]
  }
}

Or by importing the theme into your global styles like this:

@import '../../../node_modules/ngx-ghosts/theme.scss';

Now you are ready to add the first ghosts to your application.

Components

Ghost Text Directive

You can add a ghost to a single line of text, or parts of a text line with the GhostText directive. In the example below the "title" requested from a server and a server is shown while the request is pending.

<div class="title-text">
  <span *ghostText="loading; length: 23">{{title}}</span>
</div>

Parameters:

NameDescriptionTypeDefault
ghostTextToggle between ghost and contentbooleanfalse
lengthLength of the ghostnumber or "fill""fill"
classCustom class which is added to the ghost elementstring

Ghost Text Block Directive

You can add a ghost to a multiline text with the GhostTextBlock directive.

<div class="description-text">
  <span *ghostTextBlock="loading; lines: [34, 50]">{{description}}</span>
</div>

Parameters:

NameDescriptionTypeDefault
ghostTextBlockToggle between ghost and contentbooleanfalse
linesAmount and length of lines. When only amount of lines is specified all lines will expand to fillnumber or array of number or "fill"[]
classCustom class which is added to the ghost elementstring

Ghost

For special use cases where the other directives and components don't work you can us the basic Ghost component.

<ghost>My special content</ghost>

Parameters:

NameDescriptionTypeDefault
fillHorizontalUse available horizontal spacebooleanfalse
ghostClassCustom class which is added to the ghost elementstring

Customization

Custom Configuration

One way to customize ngx-ghosts is by providing a custom configuration like this:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxGhostsModule } from 'ngx-ghosts';


@NgModule({
    imports: [
        BrowserModule,
        NgxGhostsModule.forRoot({
          animationStrategy: 'EqualStartAndEnd'
        })
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

The configuration supports following properties:

NameDescriptionTypeDefault
animationStrategyDecide how the animation of your ghosts should behave. You can choose from the following variants:
  • EqualStartAndEnd - All animations start and end at the same time, speed depends on the ghosts length
  • EqualStartAndSpeed - All animations start at the same time and have the same speed
  • OneAnimation - This looks like there would be only one ghost moving across the whole page
  • None - No animation is shown at all
GhostAnimationStrategy"OneAnimation"

Custom theme

There are a whole range of variables that are used to style the ghosts, any variable can be overwritten by providing a custom theme. The Following properties are supported for the theme:

NameDescriptionDefault
ghost-base-colorBackground color of ghosts#e3e4e4
ghost-glow-colorColor of the ghost's glow effect#f5f5f5
ghost-glow-intensityIntensity of the glow effect (0 to 1)0.3
ghost-glow-widthWidth of the glow effect50%
ghost-glow-animation-durationDuration of the ghost animation2000ms
ghost-glow-animation-functionAnimation funtion of the ghost animationlinear
ghost-font-top-spacingRepresents the top gap of the font0.15em
ghost-font-bottom-spacingRepresents the bottom gap of the font0.2em

A custom theme can be created like this:

@import '../../../node_modules/ngx-ghosts/theme.scss';

.dark-theme {
  @include ngx-ghosts-theme(
    (
      ghost-base-color: #000,
      ghost-glow-color: #313639
    )
  );
}

FAQs

Package last updated on 15 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc