-
-
Save philcon93/f926930b72335d85b3084d69419a4be5 to your computer and use it in GitHub Desktop.
Toolbar swatches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swatches = { | |
swatchesArray: ['blue', 'pink', 'green', 'yellow', 'purple', 'orange', 'dark'], | |
pageClass: '.netoPage', | |
styles: function(){ | |
return ` | |
/* Blue */ | |
.netoPage.blue #netoToolbar { | |
background-color: #083E52; | |
border-bottom: solid 1px #083E52; | |
} | |
.netoPage.blue .netoToolbar--search { | |
background-color: #0a4c65; | |
} | |
/* Pink */ | |
.netoPage.pink #netoToolbar { | |
background-color: #BC1F56; | |
border-bottom: solid 1px #BC1F56; | |
} | |
.netoPage.pink #netoToolbar .netoToolbar--search { | |
background-color: #EF4A7E; | |
} | |
/* Green */ | |
.netoPage.green #netoToolbar { | |
background-color: #56C1A8; | |
border-bottom: solid 1px #56C1A8; | |
} | |
.netoPage.green #netoToolbar .netoToolbar--search { | |
background-color: #2A9D83; | |
} | |
/* Yellow */ | |
.netoPage.yellow #netoToolbar { | |
background-color: #E1AA25; | |
border-bottom: solid 1px #E1AA25; | |
} | |
.netoPage.yellow #netoToolbar .netoToolbar--search { | |
background-color: #FFC907; | |
} | |
/* Purple */ | |
.netoPage.purple #netoToolbar { | |
background-color: #622B7C; | |
border-bottom: solid 1px #622B7C; | |
} | |
.netoPage.purple #netoToolbar .netoToolbar--search { | |
background-color: #A769AB; | |
} | |
/* Orange */ | |
.netoPage.orange #netoToolbar { | |
background-color: #EC8623; | |
border-bottom: solid 1px #EC8623; | |
} | |
.netoPage.orange #netoToolbar .netoToolbar--search { | |
background-color: #FBB042; | |
} | |
/* Dark */ | |
.netoPage.dark #netoToolbar { | |
background-color: #383D3F; | |
border-bottom: solid 1px #383D3F; | |
} | |
.netoPage.dark #netoToolbar .netoToolbar--search { | |
background-color: #86898A; | |
} | |
`; | |
}, | |
inject: function(){ | |
var styleSheet = swatches.styles(); | |
var content = `<style>${styleSheet}</style>`; | |
$('head').append(content); | |
}, | |
switch: function(colour, time = 3000){ | |
if(colour){ | |
$.each(swatches.swatchesArray, function(i, v){ | |
$(swatches.pageClass).removeClass(v); | |
}); | |
$(swatches.pageClass).addClass(colour); | |
}else{ | |
var i = 0; | |
window.setInterval(function(){ | |
if (i < swatches.swatchesArray.length - 1){ | |
i = i + 1; | |
} else { | |
i = 0; | |
} | |
$.each(swatches.swatchesArray, function(i, v){ | |
$(swatches.pageClass).removeClass(v); | |
}); | |
$(swatches.pageClass).addClass(swatches.swatchesArray[i]); | |
}, time); | |
} | |
}, | |
init: function(){ | |
swatches.inject(); | |
swatches.switch('dark'); | |
} | |
} | |
swatches.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment