Skip to content

Commit d39c32f

Browse files
author
Mehdy Dara
committed
Merge pull request #137 from Swiip/uibootstrap-and-material
Add UI-Bootstrap and ngMaterials
2 parents 7453bfd + a996929 commit d39c32f

22 files changed

+551
-73
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,18 @@ The root directory generated for a app with name `gulpAngular` :
107107
* *Unit test (karma)* : out of the box unit test configuration with karma
108108
* *e2e test (protractor)* : out of the box e2e test configuration with protractor
109109
* *browser sync* : full-featured development web server with livereload and devices sync
110-
* *ngHtml2js* : all HTML partials will be converted to JS to be bundled in the application
110+
* *angular-templatecache* : all HTML partials will be converted to JS to be bundled in the application
111111
* **TODO** lazy : don't process files which haven't changed when possible
112112

113113
## Questions the generator will ask
114114
* *jQuery*: jQuery 1.x, 2.x, Zepto, none
115115
* *Angular modules*: animate, cookies, touch, sanitize
116116
* *Resource handler*: ngResource, Restangular, none
117117
* *Router*: ngRoute, UI Router, none
118-
* *UI Framework*: Bootstrap, Foundation, none (depends on the chosen CSS preprocessor)
118+
* *UI Framework*: Bootstrap, Foundation, Angular Material, none (depends on the chosen CSS preprocessor)
119119
* *CSS pre-processor*: Less, Sass with Ruby and Node, Stylus, none
120-
* **TODO** Bootstrap directives : UI Bootstrap, Angular Strap, none (only if you chose Bootstrap)
121-
* **TODO** JS preprocessor: CoffeeScript, TypeScript, ECMAScript6 (Traceur)
120+
* *Bootstrap directives* : UI Bootstrap, Angular Strap, official Bootstrap JavaScript, none (only if you chose Bootstrap)
121+
* **TODO** JS preprocessor: CoffeeScript, TypeScript, ECMAScript6 (Traceur and 6to5)
122122
* **TODO** HTML preprocessor: Jade ?
123123
* **TODO** Script loader: Require, Browserify, ES6 with Require?, none
124124
* **TODO** Test framework: Jasmine, Mocha, Qunit

app/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,24 @@ var GulpAngularGenerator = yeoman.generators.Base.extend({
5454

5555
var done = this.async();
5656

57+
this._.findWhere(prompts, {name: 'bootstrapComponents'}).when = function(props) {
58+
return props.ui.key === 'bootstrap';
59+
};
60+
5761
this.prompt(prompts, function (props) {
62+
if(props.ui.key !== 'bootstrap') {
63+
props.bootstrapComponents = {
64+
name: null,
65+
version: null,
66+
key: null,
67+
module: null
68+
};
69+
}
70+
5871
this.props = props;
72+
5973
done();
6074
}.bind(this));
61-
6275
},
6376

6477
saveSettings: function() {

app/prompts.json

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,89 @@
151151
{
152152
"type": "list",
153153
"name": "ui",
154-
"message": "Which UI framework do you want ?",
154+
"message": "Which UI framework do you want?",
155155
"choices": [
156156
{
157157
"value": {
158158
"name": "bootstrap-sass-official",
159159
"version": "3.2.x",
160-
"key": "bootstrap"
160+
"key": "bootstrap",
161+
"module": null
161162
},
162163
"name": "Bootstrap, the most popular HTML, CSS, and JS framework"
163164
},
164165
{
165166
"value": {
166167
"name": "foundation",
167168
"version": "5.4.x",
168-
"key": "foundation"
169+
"key": "foundation",
170+
"module": null
169171
},
170-
"name": "Foundation, \"The most advanced responsive front-end framework in the world\""
172+
"name": "Foundation, \"The most advanced responsive front-end framework in the world\""
171173
},
172174
{
173175
"value": {
176+
"name": "angular-material",
177+
"version": "0.5.x",
178+
"key": "angular-material",
179+
"module": "ngMaterial"
180+
},
181+
"name": "Angular Material, the reference implementation of the Google's Material Design specification"
182+
},
183+
{
184+
"value": {
185+
"key": "none",
174186
"name": null,
175187
"version": null,
176-
"key": "default"
188+
"module": null
177189
},
178190
"name": "None"
179191
}
180192
]
181193
},
194+
{
195+
"type": "list",
196+
"name": "bootstrapComponents",
197+
"message": "How do you want to implements your Bootstrap components?",
198+
"choices": [
199+
{
200+
"value": {
201+
"name": "angular-bootstrap",
202+
"version": "0.12.x",
203+
"key": "ui-bootstrap",
204+
"module": "ui.bootstrap"
205+
},
206+
"name": "Angular UI Bootstrap, Bootstrap components written in pure AngularJS by the AngularUI Team"
207+
},
208+
{
209+
"value": {
210+
"name": "angular-strap",
211+
"version": "2.1.x",
212+
"key": "angular-strap",
213+
"module": "mgcrea.ngStrap"
214+
},
215+
"name": "AngularStrap, AngularJS 1.2+ native directives for Bootstrap 3"
216+
},
217+
{
218+
"value": {
219+
"name": null,
220+
"version": null,
221+
"key": "official",
222+
"module": null
223+
},
224+
"name": "The official jQuery implementation of Bootstrap"
225+
},
226+
{
227+
"value": {
228+
"name": null,
229+
"version": null,
230+
"key": "none",
231+
"module": null
232+
},
233+
"name": "No JavaScript, just CSS"
234+
}
235+
]
236+
},
182237
{
183238
"type": "list",
184239
"name": "cssPreprocessor",

app/src/format.js

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ module.exports = function () {
1616
ngModules = _.flatten([
1717
ngModules,
1818
this.props.resource.module,
19-
this.props.router.module
19+
this.props.router.module,
20+
this.props.ui.module,
21+
this.props.bootstrapComponents.module
2022
]);
2123

2224
this.modulesDependencies = _.chain(ngModules)
@@ -25,8 +27,7 @@ module.exports = function () {
2527
return '\'' + dependency + '\'';
2628
})
2729
.valueOf()
28-
.join(', ')
29-
;
30+
.join(', ');
3031

3132
// Format list techs used to generate app included in main view of sample
3233
var listTechs = require('../techs.json');
@@ -35,30 +36,35 @@ module.exports = function () {
3536
'angular', 'browsersync', 'gulp', 'jasmine', 'karma', 'protractor',
3637
this.props.jQuery.name,
3738
this.props.ui.key,
39+
this.props.bootstrapComponents.key,
3840
this.props.cssPreprocessor.key
3941
]
4042
.filter(_.isString)
4143
.filter(function(tech) {
42-
return tech !== 'default' && tech !== 'css';
43-
})
44-
;
44+
return tech !== 'default' && tech !== 'css' && tech !== 'official' && tech !== 'none';
45+
});
4546

4647
var techsContent = _.map(usedTechs, function(value) {
4748
return listTechs[value];
4849
});
4950

50-
this.technologies = JSON.stringify(techsContent, null, 2).replace(/"/g, '\'').replace(/\n/g, '\n ');
51+
this.technologies = JSON.stringify(techsContent, null, 2)
52+
.replace(/'/g, '\\\'')
53+
.replace(/"/g, '\'')
54+
.replace(/\n/g, '\n ');
5155
this.technologiesLogoCopies = _.map(usedTechs, function(value) {
5256
return 'src/assets/images/' + listTechs[value].logo;
5357
});
5458

5559
// Select partials relative to props.ui
60+
var uiFileKey = this.props.ui.key === 'ui-bootstrap' ? 'bootstrap' : this.props.ui.key;
61+
5662
this.partialCopies = {};
5763

58-
var navbarPartialSrc = 'src/components/navbar/__' + this.props.ui.key + '-navbar.html';
64+
var navbarPartialSrc = 'src/components/navbar/__' + uiFileKey + '-navbar.html';
5965
this.partialCopies[navbarPartialSrc] = 'src/components/navbar/navbar.html';
6066

61-
var routerPartialSrc = 'src/app/main/__' + this.props.ui.key + '.html';
67+
var routerPartialSrc = 'src/app/main/__' + uiFileKey + '.html';
6268
if(this.props.router.module !== null) {
6369
this.partialCopies[routerPartialSrc] = 'src/app/main/main.html';
6470
}
@@ -81,25 +87,50 @@ module.exports = function () {
8187
this.routerJs = '';
8288
}
8389

90+
// Wiredep exclusions
91+
this.wiredepExclusions = [];
92+
if(this.props.bootstrapComponents.key !== 'official') {
93+
if(this.props.cssPreprocessor.extension === 'scss') {
94+
this.wiredepExclusions.push('/bootstrap-sass-official/');
95+
} else {
96+
this.wiredepExclusions.push('/bootstrap.js/');
97+
}
98+
}
99+
if(this.props.cssPreprocessor.key !== 'css') {
100+
this.wiredepExclusions.push('/bootstrap.css/');
101+
}
102+
84103
// Format choice UI Framework
85-
if(this.props.ui.key === 'bootstrap' && this.props.cssPreprocessor.extension !== 'scss') {
104+
if(this.props.ui.key.indexOf('bootstrap') !== -1 && this.props.cssPreprocessor.extension !== 'scss') {
86105
this.props.ui.name = 'bootstrap';
87106
}
88107

89108
this.styleCopies = {};
90109

91-
var styleAppSrc = 'src/app/__' + this.props.ui.key + '-index.' + this.props.cssPreprocessor.extension;
110+
var styleAppSrc = 'src/app/__' + uiFileKey + '-index.' + this.props.cssPreprocessor.extension;
92111
this.styleCopies[styleAppSrc] = 'src/app/index.' + this.props.cssPreprocessor.extension;
93112

94-
// ## Special case for Foundation and LESS: Foundation dont have a LESS version so we include css
95-
if ((this.props.cssPreprocessor.extension === 'less' && this.props.ui.key === 'foundation') || this.props.cssPreprocessor.extension === 'css' || this.props.cssPreprocessor.extension === 'styl') {
96-
this.isVendorStylesPreprocessed = false;
97-
} else {
98-
this.isVendorStylesPreprocessed = true;
113+
// There is 2 ways of dealing with vendor styles
114+
// - If the vendor styles exist in the css preprocessor chosen,
115+
// the best is to include directly the source files
116+
// - If not, the vendor styles are simply added as standard css links
117+
//
118+
// isVendorStylesPreprocessed defines which solution has to be used
119+
// regarding the ui framework and the css preprocessor chosen.
120+
this.isVendorStylesPreprocessed = false;
121+
122+
if(this.props.cssPreprocessor.extension === 'scss') {
123+
if(this.props.ui.key === 'bootstrap' || this.props.ui.key === 'foundation') {
124+
this.isVendorStylesPreprocessed = true;
125+
}
126+
} else if(this.props.cssPreprocessor.extension === 'less') {
127+
if(this.props.ui.key === 'bootstrap') {
128+
this.isVendorStylesPreprocessed = true;
129+
}
99130
}
100131

101132
if(this.isVendorStylesPreprocessed && this.props.ui.name !== null) {
102-
var styleVendorSource = 'src/app/__' + this.props.ui.key + '-vendor.' + this.props.cssPreprocessor.extension;
133+
var styleVendorSource = 'src/app/__' + uiFileKey + '-vendor.' + this.props.cssPreprocessor.extension;
103134
this.styleCopies[styleVendorSource] = 'src/app/vendor.' + this.props.cssPreprocessor.extension;
104135
}
105136
};

app/techs.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
"description": "Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.",
1212
"logo": "bootstrap.png"
1313
},
14+
"ui-bootstrap": {
15+
"title": "Angular UI Bootstrap",
16+
"url": "http://angular-ui.github.io/bootstrap/",
17+
"description": "Bootstrap components written in pure AngularJS by the AngularUI Team.",
18+
"logo": "ui-bootstrap.png"
19+
},
20+
"angular-strap": {
21+
"title": "Angular Strap",
22+
"url": "http://mgcrea.github.io/angular-strap/",
23+
"description": "AngularJS 1.2+ native directives for Bootstrap 3.",
24+
"logo": "angular-strap.png"
25+
},
26+
"angular-material": {
27+
"title": "Angular Material Design",
28+
"url": "https://material.angularjs.org/#/",
29+
"description": "The Angular reference implementation of the Google's Material Design specification.",
30+
"logo": "angular-material.png"
31+
},
1432
"browsersync": {
1533
"title": "BrowserSync",
1634
"url": "http://browsersync.io/",

app/templates/_bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
"angular-resource": "<%= props.angularVersion %>",<% } else if (props.resource.name === 'restangular') { %>
99
"restangular": "1.4.x",<% } if (props.router.name === 'angular-route') { %>
1010
"angular-route": "<%= props.angularVersion %>",<% } else if (props.router.name === 'angular-ui-router') { %>
11-
"angular-ui-router": "0.2.x",<% } if (props.ui.name !== null) { %>
12-
"<%= props.ui.name %>": "<%= props.ui.version %>",<% } %>
11+
"angular-ui-router": "0.2.x",<% } if(props.ui.name !== null) { %>
12+
"<%= props.ui.name %>": "<%= props.ui.version %>",<% } if(props.bootstrapComponents && props.bootstrapComponents.name !== null) { %>
13+
"<%= props.bootstrapComponents.name %>": "<%= props.bootstrapComponents.version %>",<% } %>
1314
"angular": "<%= props.angularVersion %>"
1415
},
1516
"devDependencies": {

app/templates/gulp/_wiredep.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ gulp.task('wiredep', function () {
88

99
return gulp.src('src/index.html')
1010
.pipe(wiredep({
11-
directory: 'bower_components',
12-
exclude: [/bootstrap-sass-official/, /bootstrap.js/<% if(props.cssPreprocessor.key !== 'css') { %>, /bootstrap.css/<% } %>],
11+
directory: 'bower_components'<% if(wiredepExclusions.length > 0) { %>,
12+
exclude: [<%= wiredepExclusions.join(', ') %>]<% } %>
1313
}))
1414
.pipe(gulp.dest('src'));
1515
});

app/templates/src/_index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
<% if (props.ui.name !== null) { %>
1010
<!-- build:css({.tmp,src}) styles/vendor.css --><% if (isVendorStylesPreprocessed) { %>
1111
<link rel="stylesheet" href="app/vendor.css"><% } else if (props.ui.key === 'bootstrap') { %>
12-
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css"><% } else if (props.ui.key === 'foundation') { %>
13-
<link rel="stylesheet" href="../bower_components/foundation/css/foundation.css"><% } %>
12+
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css"><% } %>
1413
<!-- bower:css -->
1514
<!-- run `gulp wiredep` to automaticaly populate bower styles dependencies -->
1615
<!-- endbower -->
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@import url(http://fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,700,700italic,400italic);
2+
3+
html {
4+
font-family: 'Roboto Slab', serif;
5+
}
6+
7+
[layout=row] {
8+
flex-direction: row;
9+
}
10+
11+
.browsehappy {
12+
margin: 0.2em 0;
13+
background: #ccc;
14+
color: #000;
15+
padding: 0.2em 0;
16+
}
17+
18+
.thumbnail {
19+
height: 200px;
20+
}
21+
22+
.thumbnail img.pull-right {
23+
width: 50px;
24+
}
25+
26+
md-toolbar.md-default-theme {
27+
background-color: black;
28+
}
29+
30+
section.jumbotron {
31+
margin-bottom: 30px;
32+
padding: 1px 30px;
33+
background-color: #5aadbb;
34+
text-align: center;
35+
36+
color: white;
37+
}
38+
39+
section.jumbotron h1 {
40+
font-size: 3em;
41+
}
42+
43+
.techs {
44+
display: flex;
45+
flex-flow: row wrap;
46+
}
47+
48+
.techs md-card {
49+
width: 30%;
50+
}
51+
52+
.techs md-card img.pull-right {
53+
float: right;
54+
width: 50px;
55+
}

0 commit comments

Comments
 (0)