Including dependencies with ember-cli - ember.js

I am trying out ember-cli to get an ember project going, however I have previously relied on rails and the asset pipeline to compile all my js and (s)css for previous projects.
I admit a weak understanding of js build tools, so apologies if the question is basic: How can I see what dependencies are being compiled/included in the build? Specifically, I want to include both zurb-foundation and ember-leaflet in my project. I am not sure if they are there (at least the leaflet map is not showing up in the project --- using a basic example that worked with both rails and rail-eak).
The files (ember-leaflet, etc) are in the vendor directory of the project and were placed there thru bower install (I assume?); do I have to manually include them in the root bower.json file (currently they are not); is the order in bower.json important?
Thanks in advance.
DJ

After some digging and a lot of reading I found the solution here and got ember-leaflet to work.
1.) Download the libs
bower install --save leaflet
bower install --save ember-leaflet
Note: It's probably not neccessary to download leaflet, since ember-leaflet seems to have it included (leaflet-dist).This is the part I did manually a few times, so you may or may not have vendor/leaflet-dist. Just change accordingly.
2.) Configure building the assets
Add the import lines in your Brocfile.js before the module.exports line
app.import('vendor/leaflet-dist/leaflet-src.js')
app.import('vendor/leaflet-dist/leaflet.css')
app.import('vendor/ember-leaflet/dist/ember-leaflet.js')
module.exports = app.toTree();
3) make Leaflet and EmberLeaflet known to Ember (.jshintrc)
{
"predef": {
...
"L": true,
"EmberLeaflet": true
}
...
}
4) create a view
export default EmberLeaflet.MapView.extend({
classNames : ['ember-leaflet-map']
});
5) create a template using the view (where view name corresponds to the file name, here views/mapview.js)
<div id="map">
{{view 'mapview'}}
</div>
6) check / add vendor style sheet to app/index.html (should be present with recent versions of ember-cli)
<head>
...
<link rel="stylesheet" href="assets/vendor.css">
</head>
7) run Ember
ember server
8) Bonus: In case you are using Twitter Bootstrap 3 here's the css I had to add to app/styles/app.css (could probably be simplified)
html,
body {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
padding-top: 20px;
height: 100%;
}
.page-content {
padding: 40px 15px;
height: 100%;
}
.row {
margin-bottom: 1.5em;
}
#map {
height: 100%;
}
.ember-leaflet-map {
height: 100%;
}
body > .ember-view {
height: 100%;
}

It seems like somebody just created an ember-cli addon: https://www.npmjs.org/package/ember-cli-ember-leaflet
I'm going to try it :)

Related

Why is GoLand issuing a warning on SCSS code?

I have the following (correct) code in a Vue component, edited from GoLand
<style lang="scss">
.q-dark div,
.body--dark div {
&.calendars {
color: #fefefe;
background-color: black;
}
&.forecast {
background-color: black;
}
}
</style>
GoLand complains about this code:
The same code edited in WebStorm does not show any warnings.
Is there something I should configure or add?
Please make sure you have SASS plugin installed, it doesn't come bundled with Goland: in Preferences | Plugins, Marketplace search for SASS, choose to install it

Foundation interchange image swap does not work correctly

The problem:
When I resize the window the images will only sometimes change. It's almost like they get stuck / the resize event is not being captured properly by foundation. If I start resizing the window like a rabid monkey it will occasionally swap the image. If I resize the window according to the media queries and then refresh the page the correct image renders. This appears to be a resize only issue.
Other details:
I have just a regular .html file (new site hosted from IIS on a separate machine) with a simple demo of Interchange image swapping.
If I manually call: $(document).foundation("interchange", "resize"); the image will swap correctly.
Foundation version 5.3.1
Testing in Chrome 36 and Firefox 31.
So far the only built in media query that works is (default). (medium), (large) etc. do nothing, I have to write out the actually query to get it to work (or manually create them using named_queries. This may be an unrelated problem but does seem strange to me.
<html>
<head>
<title>Interchange</title>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<script type='text/javascript' src='/foundation.js'></script>
<script type='text/javascript' src='/foundation.interchange.js'></script>
<link rel='stylesheet' href='/foundation.css' />
<link rel='stylesheet' href='/normalize.css' />
<script type='text/javascript'>
$(function () {
$(document).foundation();
$(document).on('replace', function (e, newVal) {
console.log(newVal);
});
// Adding this horrible hack will make it work 100% of the time.
// BUT THIS SHOULD NOT BE NECESSARY!
//$(window).resize(function(){
// $(document).foundation("interchange", "resize");
//})
});
</script>
</head>
<body>
<img data-interchange="[/images/space-small.jpg, (default)], [/images/space-medium.jpg, (only screen and (min-width: 641px))], [/images/space-large.jpg, (only screen and (min-width: 1000px))]">
</body>
</html>
I found the answer to my own question and it was indeed that odd media queries issue I described in the OP that lead me to the problem.
Foundation's javascript is dependent on the Foundation CSS existing before it initializes.
All I had to do was make sure the CSS link was above the script include and everything started working as expected.
Not sure this will help anyone, but I was getting the same issue but ONLY on Chrome. I added the foundation.min.css to my page like b1j suggested and voila! unfortunately though as I used the SASS version I couldn't just leave this included into the page as I would have double the amount of css included into my page. So I pasted the foundation.css contents into a style tag in the head of my document and deleted its contents bit by bit until I found the piece of css that fixed it. Here it is:
meta.foundation-mq-small {
font-family: "/only screen/";
width: 0em; }
meta.foundation-mq-medium {
font-family: "/only screen and (min-width:40.063em)/";
width: 40.063em; }
meta.foundation-mq-large {
font-family: "/only screen and (min-width:64.063em)/";
width: 64.063em; }
meta.foundation-mq-xlarge {
font-family: "/only screen and (min-width:90.063em)/";
width: 90.063em; }
meta.foundation-mq-xxlarge {
font-family: "/only screen and (min-width:120.063em)/";
width: 120.063em; }
Not sure why this wasn't compiled into my CSS but I will look, but incase anyone needs a quick fix, this should do it!

Error with bootstrap-sass. Migrating to rails4

I trying to migrate from rails 3.2 to rails 4.0.1 and when I do all by this guide http://railscasts.com/episodes/415-upgrading-to-rails-4
I have error with bootstrapp css
File to import not found or unreadable: bootstrap-responsive.
Load paths:
/home/arseniy/Work/requests/app/assets/images
/home/arseniy/Work/requests/app/assets/javascripts
/home/arseniy/Work/requests/app/assets/stylesheets
/home/arseniy/Work/requests/vendor/assets/images
/home/arseniy/Work/requests/vendor/assets/javascripts
/home/arseniy/Work/requests/vendor/assets/stylesheets
/home/arseniy/.rvm/gems/ruby-2.0.0-p247#requests/gems/bootstrap-sass-3.0.2.1/vendor/assets/fonts
/home/arseniy/.rvm/gems/ruby-2.0.0-p247#requests/gems/bootstrap-sass-3.0.2.1/vendor/assets/javascripts
/home/arseniy/.rvm/gems/ruby-2.0.0-p247#requests/gems/bootstrap-sass-3.0.2.1/vendor/assets/stylesheets
/home/arseniy/.rvm/gems/ruby-2.0.0-p247#requests/gems/jquery-rails-3.0.4/vendor/assets/javascripts
/home/arseniy/.rvm/gems/ruby-2.0.0-p247#requests/gems/coffee-rails-4.0.1/lib/assets/javascripts
/home/arseniy/.rvm/gems/ruby-2.0.0-p247#requests/gems/bootstrap-sass-3.0.2.1/vendor/assets/stylesheets
(in /home/arseniy/Work/requests/app/assets/stylesheets/bootstrap_and_overrides.css.scss:3)
This my bootstrap_and_overrides.css.scss
#import "bootstrap";
body { padding-top: 60px; }
#import "bootstrap-responsive";
.footer {
text-align: right;
color: #aaa;
}
as explained in this migration Guide Bootstrap now applies the "Mobile First" Practice.
Therefore you don't need responsive css anymore, and all necessary code is included in the "bootstrap.css" file.
Just remove your
#import "bootstrap-responsive";
Line and it should be fine!

Sass Mixins Not Available in bootstrap-sass Project

I have a Rails 4 project with bootstrap-sass and mixins like border-radius(3px) are unrecognized. I'm not certain what I'm doing wrong, but here are what I think are the relevant file parts:
// myfile.css.scss
#import "bootstrap";
#hotel-form {
display: none;
border: 1px gray solid;
padding: 1em;
margin-top: 2em;
#include border-radius(3px);
}
I shouldn't need to import bootstrap in the above but I did it anyhow to try to get the border-radius mixin to be recognized.
# Gemfile
... lots of other stuff
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass'
... and more other stuff
// application.css
*= require_self
*= require_tree .
I don't know if application.css is the problem. I get bootstrap from a CDN as follows:
-# application.html.haml
= stylesheet_link_tag "//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"
= javascript_include_tag "//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"
I've tried every different combination other than installing bootstrap on my dev machine with no joy. Any pointers appreciated.
Thanks

Ember project with themes and skins

Any ideas on how to create an Ember / Handlebars project with suport for multiple themes / skins that can be changed through a dropbox in the UI?
Current version of Ember is 1.0.0-rc.2
Thanks
Nothing too unique to Ember here. Use CSS for themes/skins, and change the current theme stylesheet when the dropbox changes.
FYI, there is a switch stylesheet ember-cli that you can use:
https://www.npmjs.com/package/ember-theme-changer
Install Theme Changer
ember install ember-theme-changer
Modify the code below in ember-cli-build.js:
// ember-cli-build.js
outputPaths: {
app: {
css: {
'light': '/assets/light.css', // FOR LIGHT THEME => app.scss
'dark': '/assets/dark.css' // FOR DAR THEME => dark.scss
}
}
},
Create your own SCSS with difference configuration.
Go to app/styles folder
Create dark.css and app.scss
dark.scss
body{
background-color: black;
}
app.scss
body{
background-color: light;
}
All you need just to make two button to switch the css file that you apply to
Think of it this easy way:
In Html template application.hbs
<link href="light.css" rel="stylesheet" type="text/css" >
<button class='light'>LIGHT MODE</button>
<button class='dark'>DARK MODE</button>
In Javascript File
$('.light').click(function (){
$('link[href="light.css"]').attr('href','black.css');
});
$('.black').click(function (){
$('link[href="black.css"]').attr('href','light.css');
});
comments: You can use other addon (more complicated) which it can be found on:
https://www.emberaddons.com/
https://www.npmjs.com/package/ember-themed-syntax