Skip to content

Theme previews#1692

Merged
canstudios-louisem merged 7 commits intoadaptlearning:developfrom
CanStudios:theme-previews
Aug 29, 2017
Merged

Theme previews#1692
canstudios-louisem merged 7 commits intoadaptlearning:developfrom
CanStudios:theme-previews

Conversation

@canstudios-louisem
Copy link
Copy Markdown
Contributor

This will search for a file called preview.jpg in the root of your theme and display it on the theme selection screen if there is one.

I will also make a PR to the vanilla theme with a pr for the preview.jpg one of our designers made.

@canstudios-louisem canstudios-louisem added this to the 0.4.0 Refactor milestone Aug 2, 2017
float: left;
position: relative;
background: url(/css/assets/theme_bg.png) top left no-repeat;
background: url(/images/theme_bg.png) top left no-repeat;
Copy link
Copy Markdown
Member

@taylortom taylortom Aug 3, 2017

Choose a reason for hiding this comment

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

Is this correct? Getting a 403 error.


postRender: function() {
var previewUrl = '/api/theme/preview/' + this.model.attributes.name + '/' + this.model.attributes.version;
var $previewLoc = this.$el.find('.theme-preview');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this.$el.find('.theme-preview') can just be written as this.$('.theme-preview')

statusCode: {
// if a preview image is found
200: function() {
$previewLoc.prepend('<img src="' + previewUrl + '"alt="Preview image"' + '/>');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can the alt text be localised please?

Could also switch to the jQuery object syntax if you fancied it:

$previewLoc.prepend($('<img/>', { src: previewUrl, alt: '...' }));

@taylortom
Copy link
Copy Markdown
Member

taylortom commented Aug 9, 2017

@canstudios-louisem when accessing the theme picker page with old themes (i.e. those without preview images), I get the following console errors:

11:17:58.042 jquery.js:9659 GET http://localhost:5000/api/theme/preview/adapt-theme-community/0.0.2 404 (Not Found)
11:17:58.047 jquery.js:9659 GET http://localhost:5000/api/theme/preview/adapt-contrib-vanilla/2.0.4 404 (Not Found)

Would it be possible to handle this scenario on the server-side, without returning an error?

@canstudios-louisem
Copy link
Copy Markdown
Contributor Author

I will change the 404 response to a 204 would be fine and that won't give a console error and is a standard reponse for this kind of thing.

},

postRender: function() {
var previewUrl = '/api/theme/preview/' + this.model.attributes.name + '/' + this.model.attributes.version;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very minor but could we use model.get() to access attributes here please, for consistency.

@canstudios-louisem
Copy link
Copy Markdown
Contributor Author

@taylortom @tomgreenfield I have made those changes.

Copy link
Copy Markdown
Member

@taylortom taylortom left a comment

Choose a reason for hiding this comment

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

Works for me

@canstudios-louisem
Copy link
Copy Markdown
Contributor Author

Before release we also need to update https://github.com/adaptlearning/adapt_framework/wiki/Developers-Guide:-Theme

Copy link
Copy Markdown
Contributor

@tomgreenfield tomgreenfield left a comment

Choose a reason for hiding this comment

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

Looking good – theme previews are now pulling in fine and the absent ones aren't 404'ing.

I've noticed that the sample image doesn't fit entirely with the current styling. Can we take this opportunity to standardise the image and styling to fit a 16:9 ratio? This would give an optimal resolution of 275 x 155.

It would also be great to fall back to a default icon, like we do in the asset manager.

@canstudios-louisem
Copy link
Copy Markdown
Contributor Author

@tomgreenfield I've just tested 16:9 and it's quite short which means you can't really see any components and the header I think we should stay at 275x205. I will add the same default icon as in assets though.

@canstudios-louisem
Copy link
Copy Markdown
Contributor Author

@tomgreenfield and @taylortom do you want to re approve as I've pushed a few things since you did?

$previewLoc.prepend($('<img/>', { src: previewUrl, alt: Origin.l10n.t('app.themepreviewalt') }));
},
204: function() {
$previewLoc.prepend($('<i/>', { class: 'fa fa-file-image-o' }));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very minor suggestion: I wonder if we can use something more theme-related for the icon here, as we use the image file one in various other places in the app's asset management. Best font awesome icon I can find is the paintbrush (there may be something better):

screen shot 2017-08-21 at 11 39 39

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image icon looks more like it is related to assets

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's fine by me ive asked one of our creatives to see if they know anything better than the paintbrush as im not sure its quite right.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cool, thanks Louise!


.theme-list-item {
height: 175px;
height: 280px;
Copy link
Copy Markdown
Contributor

@tomgreenfield tomgreenfield Aug 21, 2017

Choose a reason for hiding this comment

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

The sample image still doesn't display fully with the styling provided. We'll need an extra 15px added to the height to fit with the padding suggested in the comment below.

theme

color:rgb(214, 242, 249);
font-size: 50px;
padding-top: 70px;
padding-left: 116px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of using padding, please can we centre the icon dynamically using a CSS transform?

position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

With a set height on the container (205px if we're matching the sample image).

<div class="theme-header">
<div class="display-name"><h4 style="color: {{foreground_color.default}}">{{displayName}}</h4></div>
<div class="description">{{description}}</div>
<div class="theme-preview"></div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please can the preview <div> be moved to sit after the header <div>?

This will allow us to have consistent padding – none on the inner, 20px on the header and none on its children.

$previewLoc.prepend($('<img/>', { src: previewUrl, alt: Origin.l10n.t('app.themepreviewalt') }));
},
204: function() {
$previewLoc.prepend($('<i/>', { class: 'fa fa-file-image-o' }));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need quotes around class since it's a reserved word in JavaScript.

@canstudios-louisem
Copy link
Copy Markdown
Contributor Author

@taylortom @tomgreenfield I've pushed an update with those changes. I added the paintbrush but our designer also made this thoughts? I'm not set on either the paintbrush is one less image file tho.

@taylortom
Copy link
Copy Markdown
Member

Great thanks @canstudios-louisem, looks good.

I have to admit that the linked image icon doesn't mean anything to me, I'd never guess it was related to appearance/theming. Happy to go with the general consensus though.

Copy link
Copy Markdown
Contributor

@tomgreenfield tomgreenfield left a comment

Choose a reason for hiding this comment

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

Sorry, minor comment again!


&-inner {
.theme-header {
padding: 20px 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can the padding be made equal so we avoid text hitting the side of the container? We then won't need it declared for .display-name or .description.

padding

$previewLoc.prepend($('<img/>', { src: previewUrl, alt: Origin.l10n.t('app.themepreviewalt') }));
},
204: function() {
$previewLoc.prepend($('<i/>', { 'class': 'fa fa-paint-brush' }));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Happy with the paintbrush icon, @taylortom.

@canstudios-louisem
Copy link
Copy Markdown
Contributor Author

sorted @tomgreenfield

@canstudios-louisem canstudios-louisem merged commit 7fbab8d into adaptlearning:develop Aug 29, 2017
@canstudios-louisem canstudios-louisem deleted the theme-previews branch August 29, 2017 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants