forked from jariz/vibrant.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsite.coffee
34 lines (28 loc) · 1.39 KB
/
website.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
document.addEventListener 'DOMContentLoaded', ->
examples = document.querySelectorAll '.examples > div'
for example in examples
img = example.querySelector('img')
img.setAttribute('src', img.getAttribute('data-src'))
img.addEventListener 'load', (e) ->
vibrant = new Vibrant this
panel = e.target.parentElement
panel = panel.parentElement while not panel.classList.contains('panel')
panel.style.backgroundColor = vibrant.VibrantSwatch.getHex()
panel.style.color = vibrant.VibrantSwatch.getTitleTextColor()
colors = document.createElement 'div'
colors.classList.add 'colors'
panel.querySelector('.panel-body').appendChild colors
profiles = ['VibrantSwatch', 'MutedSwatch', 'DarkVibrantSwatch', 'DarkMutedSwatch', 'LightVibrantSwatch', 'LightMutedSwatch']
for profileName in profiles
profile = vibrant[profileName]
if not profile then continue
colorHolder = document.createElement 'div'
color = document.createElement 'div'
color.classList.add 'color'
color.classList.add 'shadow-z-1'
color.style.backgroundColor = profile.getHex()
colorName = document.createElement 'span'
colorName.innerHTML = profileName.substring(0, profileName.length - 6)
colorHolder.appendChild color
colorHolder.appendChild colorName
colors.appendChild colorHolder