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

color-grabber

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-grabber

This Angular Directive changes the background color of its container to the average color of the provided image - also adjusts the color to white or black based on that color

  • 1.1.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Color Grabber

This Angular Directive when applied to a div will get the average color of the provided url of an image and then change the background color to that color. Any test inside the div will be colored white or black based on the average color of the image that best suites it.

Installation

npm install color-grabber

Scaffolding

Import the module into your project under imports

imports: [
    BrowserModule,
    AppRoutingModule,
    ColorGrabberModule
  ],

Use

In the following example, the mat-card contaner has the colorGrab directive applied.

The [imageUrl]="image" is the image to grab the color from.

The [light]="'#FFFFFF'" is the light color to use if the average color is dark. The [dark]="'#000000'" is the dark color to use if the average color is light.

The mat-card contaner background color will change to this color

The Text inside this container will also change ether to black or white depending what suites best based on that colors image.

To use in the directive, use the following

image = "https://picsum.photos/id/1/5616/3744"
<mat-card style="margin: 8px;"
  colorGrab [imageUrl]="image" [light]="'rgb(220, 220, 220)'" [dark]="'rgb(47, 79, 79)'"
  class="box"
  >
    <h3>{{ item.author }}</h3>
    <img [src]="image" width="160" height="120" style="object-fit: cover;">
</mat-card>

Paramiter

imageUrl - provide the full URL of the image (png, jpg)

colorGrab [imageUrl]="item.download_url"

Keywords

FAQs

Package last updated on 23 Jan 2022

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