
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
angular-adaptive-backgrounds
Advanced tools
Frame an image with its dominant color using a simple directive
Surround a picture with its dominant color using a simple directive
$ npm install --save angular-adaptive-backgrounds
This directive is essentially extracting the dominant color from an image and applying that color to its parent's background. Here's the most simple example:
<!-- Load the script after AngularJS -->
<script src="angular.js"></script>
<script src="angular-adaptive-backgrounds.js"></script>
// Make sure your app depends on this module
var myApp = angular.module('myApp', ['mb-adaptive-backgrounds']);
<!-- This guy will get receive a background color... -->
<div adaptive-background>
<!-- from this image -->
<img src="cool.jpg">
</div>
Since your markup could get far more complicated in a real example, adaptive-background will dig through its descendents for the first img it can find.
<div adaptive-background>
<div>
<div>
<img src="cool.jpg">
</div>
</div>
</div>
But if you have multiple images descending from your adaptive-background, it might find the wrong one! Fortunately, you can specify a class name.
<div adaptive-background ab-image-class="the-chosen-one">
<div>
<div>
<!-- It will skip right past this image -->
<img src="not-cool.jpg">
</div>
<div>
<!-- and grab a color from this image -->
<img src="cool.jpg" class="the-chosen-one">
</div>
</div>
</div>
In certain cases, you might want to specify a class name for your entire app, instead of repeatedly setting ab-image-class.
myApp.config(function (adaptiveBackgroundsOptionsProvider) {
adaptiveBackgroundsOptionsProvider.set({
imageClass: 'the-chosen-one'
});
});
<!-- Even without setting ab-image-class... -->
<div adaptive-background>
<div>
<div>
<img src="not-cool.jpg">
</div>
<div>
<!-- it will still find this image -->
<img src="cool.jpg" class="the-chosen-one">
</div>
</div>
</div>
Instead of an img element, you might have a background-image on some other element. Have no fear. Simply ensure you've set a parent class, either by ab-image-class or a global config.
<div adaptive-background ab-image-class="the-chosen-one">
<div style="background-image: url('cool.jpg');" class="the-chosen-one"></div>
</div>
If you have text overlaying the background color, that text might no longer be readable. You have a couple classes to work with though.
ab-light-background will be applied to a lighter background and, as you might expect, ab-dark-background on a darker background. You could do something like this to make sure your text contrasts with the background.
.ab-light-background {
color: #333;
}
.ab-dark-background {
color: #fff;
}
If you're displeased with those class names, feel free to change them.
myApp.config(function (adaptiveBackgroundsOptionsProvider) {
adaptiveBackgroundsOptionsProvider.set({
lightClass: 'wow-so-bright',
darkClass: 'pretty-dark-in-here'
});
});
$ npm install
$ npm start
FAQs
Frame an image with its dominant color using a simple directive
The npm package angular-adaptive-backgrounds receives a total of 11 weekly downloads. As such, angular-adaptive-backgrounds popularity was classified as not popular.
We found that angular-adaptive-backgrounds demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.