Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 1016233 - [Collections App] Collection UI styling #20056

Merged
merged 1 commit into from
Jun 8, 2014
Merged
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
31 changes: 27 additions & 4 deletions apps/collection/js/view_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* global Bookmark */
/* global BaseCollection */
/* global Contextmenu */
/* global Promise */

(function(exports) {

Expand All @@ -10,7 +11,8 @@
var grid = document.getElementById('grid');

var elements = {
bgimage: document.getElementById('bgimage'),
content: document.getElementById('content'),
header: document.getElementById('header'),
close: document.getElementById('close'),
name: document.getElementById('name')
};
Expand All @@ -37,9 +39,7 @@

var categoryId = collection.categoryId;
var query = collection.query;
var name = collection.name;

elements.name.textContent = name;
elements.close.addEventListener('click', function close() {
activity.postResult('close');
});
Expand Down Expand Up @@ -74,7 +74,7 @@
src = 'data:' + image.MIMEType + ';base64,' + image.data;
}

elements.bgimage.style.backgroundImage = 'url(' + src + ')';
elements.content.style.backgroundImage = 'url(' + src + ')';
} else {
// TODO show default image?
}
Expand All @@ -84,12 +84,35 @@

navigator.mozSetMessageHandler('activity', function onActivity(activity) {
if (activity.source.name === 'view-collection') {
// set collection name to header
elements.name.textContent = activity.source.data.name;

// set wallpaper behind header
getWallpaperImage().then(function(src) {
elements.header.style.backgroundImage = 'url(' + src + ')';
});

eme.init().then(function ready() {
HandleView(activity);
});
}
});

function getWallpaperImage() {
return new Promise(function convert(resolve, reject) {
var req = navigator.mozSettings.createLock().get('wallpaper.image');
req.onsuccess = function image_onsuccess() {
var image = req.result['wallpaper.image'];
if (image instanceof Blob) {
image = URL.createObjectURL(image);
}

resolve(image);
};
req.onerror = reject;
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just an idea - does the homescreen already have a reference to the bg image? if it does, we can pass it in activity.data and save time getting the wallpaper from settings

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea. Especially seeing how it takes time to load the image.
Still, I'd defer this for now.

}

// exporting handler so we can trigger it from testpage.js
// without mozActivities since we can't debug activities in app manager
exports.HandleView = HandleView;
Expand Down
1 change: 0 additions & 1 deletion apps/collection/locales/collection.en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ prompt-create-custom=Create your own Smart Collection
network-error-message=Connect to the internet to add more Smart Collections

# view-collection
close=Close
add-to-top-of-collection=Add to top of collection
save-to-homescreen=Save to Homescreen

Expand Down
75 changes: 51 additions & 24 deletions apps/collection/style/css/view.css
Original file line number Diff line number Diff line change
@@ -1,43 +1,70 @@
body {
background: #000000;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranbena will be useful to move this to base.css

gaia-grid {
display: block;
height: 100%;
width: 100%;
}

#bgimage {
position: fixed;
#header {
height: 5.4rem;
line-height: 5.4rem;
color: #ffffff;
font-size: 2.25rem;
overflow: hidden;
background-position: center -2.4rem; /* to continue wallpaper position from status bar */
position: relative;
}
#header:after {
position: absolute;
content: ' ';
z-index: 0;
background-color: rgba(0,0,0,0.8);
top: 0;
left: 0;
right: 0;
bottom: 0;
}
#name {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i would prefer line breaks between rules.

margin-right: 1rem;
padding-left: 3rem;
display: block;
position: relative;
z-index: 1;
overflow: hidden;
white-space: nowrap;
mask: url('../images/app_name_mask.svg#fade_right_mask');
text-overflow: '';
-moz-box-sizing: border-box;
}
#close {
position: absolute;
background: transparent url('../images/close.png') no-repeat 50% 50%/1.7rem;
left: 0;
top: 0;
width: 3rem;
height: 5.4rem;
z-index: 1;
}
#content {
border-top: 0.1rem solid #555;
position: fixed;
top: 5.4rem;
left: 0;
z-index: -1;
right: 0;
bottom: 0;
overflow: scroll;
padding-top: 2.4rem;
background-color: #000000;
background-size: cover;
}

#bgimage:after {
#content:after {
position: fixed;
top: 0;
top: 5.4rem;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
content: " ";
background-color: rgba(0,0,0,0.4);
}

#header {
height: 5rem;
background: #ccc;
font-size: 2rem;
}
#name {
font-weight: bold;
}
#close {
float: right;
color: white;
}

#content {
position: relative;
}
9 changes: 9 additions & 0 deletions apps/collection/style/images/app_name_mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/collection/style/images/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/collection/style/images/close@1.5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/collection/style/images/close@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions apps/collection/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@

</head>
<body>
<div id="bgimage"></div>

<div id="header">
<span id="name"></span>
<span id="close" data-l10n-id="close"></span>
<span id="close"></span>
</div>

<div id="content">
Expand Down
3 changes: 3 additions & 0 deletions shared/js/everythingme/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
return Request(this.service, 'suggestions', options);
},
bgimage: function bgimage(options) {
options.width = eme.device.screen.width;
options.height = eme.device.screen.height;

return Request('Search', 'bgimage', options);
}
};
Expand Down
4 changes: 4 additions & 0 deletions shared/js/everythingme/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
this.deviceId = null;
this.deviceType = null;
this.carrierName = null;
this.screen = {
width: window.screen.width * window.devicePixelRatio,
height: window.screen.height * window.devicePixelRatio
};

// observe info that may change
mozSettings.addObserver('language.current', function setLocale(e) {
Expand Down