• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🌄 Surround a picture with its dominant color using a simple directive

Angular Adaptive Backgrounds

Surround a picture with its dominant color using a simple directive

$ npm install --save angular-adaptive-backgrounds

the lowdown

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>

getting fancy

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>

choose an image

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>

css background-image

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>

classes

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'
  });
});

dev

$ npm install
$ npm start

More Repositories

1

angular-youtube-embed

📺 Embed a YouTube player with a simple directive
HTML
509
star
2

Lax

IRC client built with Electron & React
JavaScript
139
star
3

react-tetris

🎮 by popular demand
TypeScript
137
star
4

wren-json

Handling JSON for Wren
51
star
5

butter.js

🍴 pixel sorting with canvas
JavaScript
42
star
6

lox.js

JavaScript
20
star
7

angular-drag-to-reorder

✊ Drag items in an ng-repeat to reorder them
CoffeeScript
19
star
8

wren-pure

Utility library for Wren
11
star
9

wrenpm

A package manager for Wren
JavaScript
11
star
10

elm-dr-mario

👨‍⚕️💊🦠
Elm
10
star
11

elm-to-dot

Crawl an Elm project and produce a dependency graph in DOT
Elm
10
star
12

elm-minesweeper

💣
Elm
10
star
13

thelist

📃 play sounds with soundcloud
JavaScript
10
star
14

lisp.js

a lisp interpreter in javascript
JavaScript
9
star
15

presidential-election-data

U.S. presidential election data in JSON
JavaScript
9
star
16

bf.go

😵 brainfuck in golang
Go
9
star
17

elm-slime-volleyball

🔵🔴 try to beat the blue slime
Elm
9
star
18

scales

🎹 play musical scales ON THE INTERNET
JavaScript
8
star
19

elm-rocket-league

⚽️🚙💨
Elm
7
star
20

boof

it's really really good
TypeScript
7
star
21

Snapchat.js

🎨 drop file in, draw like in snapchat
JavaScript
7
star
22

twitter2snapchat-server

API for converting Twitter handles to Snapchat handles
JavaScript
6
star
23

jim

it's a bot that likes basketball
CoffeeScript
6
star
24

launchpad-marquee

Use your Novation Launchpad as a scrolling marquee
JavaScript
6
star
25

elm-dot-lang

DOT Language
Elm
5
star
26

pablo

💿 make ur own album cover
JavaScript
5
star
27

advent-of-code

some solutions
JavaScript
5
star
28

first-listen-dl

cop that 🔥🔥🔥
JavaScript
5
star
29

redditelly

watch vids
CoffeeScript
4
star
30

jupiter

an album cover
CoffeeScript
4
star
31

overturn-presidential-election

JavaScript
4
star
32

weave.js

commonjs module bundler that's v fast
JavaScript
4
star
33

life

JavaScript
3
star
34

say-time

JavaScript
3
star
35

dots

a game about connecting
JavaScript
3
star
36

all-the-free-drum-kits

download lots of noises
JavaScript
3
star
37

mit-press-open-access

catalog of direct links to Open Access books
JavaScript
3
star
38

5hundo

🐴 @gilesvangruisen owned it so
JavaScript
3
star
39

voronoi

JavaScript
3
star
40

allelm

download elm.json file for every published Elm package and generate a force-directed graph layout
JavaScript
2
star
41

viz

audio visualization with canvas
CSS
2
star
42

launchpad-s-reader

read input from Launchpad S MIDI controller
JavaScript
2
star
43

tunes

super broken music player built on node-webkit
CSS
2
star
44

rosalind

some solutions
Haskell
2
star
45

rl-easy21

TypeScript
2
star
46

node-quine

neat
JavaScript
2
star
47

elm-reddit

https://brandly.github.io/elm-reddit/#r/javascript
Elm
2
star
48

first-listen-api

Query data from NPR First Listen
JavaScript
2
star
49

lisp-repl

in your browser since 2015
JavaScript
2
star
50

jstro-synesthesia

turn letters into blocks of color, according to jstro's own colors
JavaScript
2
star
51

harvard-food-trucks-cli

check on Chicken & Rice Guys
JavaScript
2
star
52

hubot-nba

A hubot script for NBA stats
CoffeeScript
2
star
53

als2xml

Convert .als files into .xml files
JavaScript
2
star
54

Sandwich

a terrible app for browsing reddit
Swift
2
star
55

allcrates

Generate a dependency graph for every Rust crate to be viewed in pm
JavaScript
2
star
56

Sudoku

2
star
57

schiff

simple, real time chat with Angular, Node, and Socket.io
JavaScript
2
star
58

grill

peer-to-peer video chat
JavaScript
2
star
59

drunk-tweet

JavaScript
1
star
60

blackboard-course-cleaner

JavaScript
1
star
61

hello-github-actions

Dockerfile
1
star
62

js1k-2013

JavaScript
1
star
63

sample_app

rails tutorial
Ruby
1
star
64

elm-arch

matt learns elm
Elm
1
star
65

slack-noteshrink

A slackbot that shrinks your notes
Python
1
star
66

flickr-lightbox

JavaScript
1
star
67

rust-raytracer

Rust
1
star
68

go-wiki

Go
1
star
69

charley-proj

Jupyter Notebook
1
star
70

lcd

looks kind of cool
JavaScript
1
star
71

2048

JavaScript
1
star
72

lisp-cli

JavaScript
1
star
73

moire

cool lines
CoffeeScript
1
star
74

blackboard-download-video

HTML
1
star
75

learn-server-rendering

JavaScript
1
star
76

sublime-indent-depth

change how many spaces are used to indent a file
Python
1
star
77

react-flame-graph

TypeScript
1
star
78

xor-nn

a small, feedforward neural network that quickly learns how to XOR
JavaScript
1
star
79

Curriculum

Create online courses
JavaScript
1
star
80

js-sudoku

solve sudoku real fast
JavaScript
1
star
81

egghead-react

just some code from a tutorial
JavaScript
1
star
82

bash-hunnid

Shell
1
star
83

rust-lox

Rust
1
star
84

elm-fill-in-the-blanks

an elm project that doesn't do anything
Elm
1
star
85

learn-three

JavaScript
1
star
86

ss15-queso

The official competition repo for team queso
JavaScript
1
star
87

yahtzee-textract

🗒 read a yahtzee score card and do the math
JavaScript
1
star
88

shootings

List of school shootings in the United States
Jupyter Notebook
1
star
89

uniballer

schools that produced a single NBA player
HTML
1
star
90

flock

JavaScript
1
star
91

elm-flame-graph

🔥 render a flame graph in your Elm app
Elm
1
star