Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for theme switching #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions public/css/lanes.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,6 @@ body > svg:last-child {
.pushes.bucket-color-10 {
background-color: #bf6060;
}
.push-info {
position: absolute;
color: white;
display: inline-block;
font: 14px/1 octicons;
text-align: center;
font-weight: normal;
padding: 3px 0;
line-height: 1;
font-size: 11px;
bottom: 0;
}
.branch {
background: orangered;
right: 0;
Expand Down
14 changes: 4 additions & 10 deletions public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ a {
width: 240px;
}

.current-view-type > span.input {
.theme-switcher {
cursor: pointer;
}
.current-view-type > .input {
cursor: pointer;
}
.current-user-name {
Expand All @@ -83,15 +86,6 @@ a {
}
.fixed-bg {
position: fixed;
/*background-image: url(https://ununsplash.imgix.net/photo-1416431168657-a6c4184348ab?q=75&fm=jpg&s=20ba248730c200af0d30c9ba81854867);*/
background: -moz-linear-gradient(top, rgba(238,238,238,1) 0%, rgba(250,250,250,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(238,238,238,1)), color-stop(100%,rgba(250,250,250,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(250,250,250,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(250,250,250,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(250,250,250,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(238,238,238,1) 0%,rgba(250,250,250,1) 100%); /* W3C */
background: #f0f8ff;
background: #f6f6f6;
z-index: -100;
top: -1px;
left: 0;
Expand Down
12 changes: 12 additions & 0 deletions public/css/themes/clouds.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* TODO: logo */

.push-info {
position: absolute;
color: white;
text-shadow: 0 0 5px black, 0 0 2px black, 0 0 1px black;
font: 14px/1 octicons;
}

.fixed-bg {
background-image: url(https://ununsplash.imgix.net/photo-1416431168657-a6c4184348ab?q=75&fm=jpg&s=20ba248730c200af0d30c9ba81854867);
}
17 changes: 17 additions & 0 deletions public/css/themes/light.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* TODO: logo */

.push-info {
position: absolute;
color: white;
display: inline-block;
font: 14px/1 octicons;
text-align: center;
font-weight: normal;
padding: 3px 0;
font-size: 11px;
bottom: 0;
}

.fixed-bg {
background: #f6f6f6;
}
13 changes: 13 additions & 0 deletions public/js/panorama.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ var Panorama = (function () {
});
}

var availableThemes = ['light', 'clouds'];
var cacheThemeKey = 'panorama-theme';

function Panorama(organizations) {
this.organizations = ko.observableArray(organizations);
this.organization = ko.observable(_.first(organizations));
Expand All @@ -193,6 +196,7 @@ var Panorama = (function () {
this.pushes = ko.observableArray();
this.filter = ko.observable();
this.laneLabelVisible = ko.observable(false);
this.theme = localStorage.getItem(cacheThemeKey) || availableThemes[0];

this.organizationInput = ko.computed({
read: function () {
Expand Down Expand Up @@ -346,6 +350,15 @@ var Panorama = (function () {
var next = { list: 'lanes', lanes: 'list' };
this.view(next[this.view()]);
};

Panorama.prototype.switchTheme = function () {
var index = availableThemes.indexOf(this.theme);
var nextTheme = availableThemes[++index % availableThemes.length];

this.theme = nextTheme;
document.querySelectorAll('meta[http-equiv=Default-Style]')[0].content = nextTheme;
localStorage.setItem(cacheThemeKey, nextTheme);
};
Panorama.prototype.getRepository = function (repoName) {
var repo = _.findWhere(this.repos(), {name: repoName});
return repo || {name: '', simpleName: '', color: 'black'};
Expand Down
1 change: 1 addition & 0 deletions views/include/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</aside>
<% } %>
<aside class="current-view">
<div class="theme-switcher"><span data-bind="click: switchTheme" class="octicon octicon-gear"></span></div>
<div class="current-view-type">
Showing
<input class="input input-repo-name" data-bind="value: organizationInput" placeholder="Enter repository name"/> as <span class="input" data-bind="click: switchView, text: view">lanes</span>
Expand Down
3 changes: 3 additions & 0 deletions views/include/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
<head>
<meta charset="utf-8"/>
<title>panorama</title>
<meta http-equiv="Default-Style" content="">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="css/reset-fonts.css"/>
<link rel="stylesheet" href="css/hint.css">
<link rel="stylesheet" href="css/octicons.css"/>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/lanes.css">
<link rel="stylesheet" href="css/list.css">
<link rel="stylesheet" href="css/themes/light.css" title="light">
<link rel="stylesheet" href="css/themes/clouds.css" title="clouds">

<script src="js/reqwest.min.js" type="text/javascript"></script>
<script src="js/knockout.min.js" type="text/javascript"></script>
Expand Down