Skip to content

Commit

Permalink
feat(component): refactor component
Browse files Browse the repository at this point in the history
  • Loading branch information
zack9433 committed Jul 21, 2016
1 parent b153b91 commit bbb0960
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": ["es2015-webpack"],
"plugins": ["lodash", "transform-runtime"],
"presets": ["es2015"],
"plugins": ["lodash"],
"env": {
"test": {
"plugins": [
Expand Down
19 changes: 19 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
bower_components
node_modules
*.log
.DS_Store
bundle.js
test
test.js
demo/
.babelrc
.eslintrc
.gitignore
.gitattributes
.travis.yml
.yo-rc.json
*.deb
coverage
*.tar
*.tar.gz
*.zip
4 changes: 2 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import 'angular-sanji-window.css';
import 'toastr.css';
import './app.scss';
import angular from 'angular';
import component from './component';
import {sjCellular} from './component';

const app = angular.module('webapp', [component]);
const app = angular.module('webapp', [sjCellular]);
class AppController {
constructor($translate, LANG_KEYS) {
this.$translate = $translate;
Expand Down
8 changes: 5 additions & 3 deletions app/component/component.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const $inject = ['$q', 'rest', 'exception', '_', 'pathToRegexp', '$filter', 'logger'];
import _ from 'lodash';

const $inject = ['$q', 'rest', 'exception', 'pathToRegexp', '$filter', 'logger'];
const config = require('./component.resource.json');
class CellularService {
constructor(...injects) {
Expand All @@ -18,7 +20,7 @@ class CellularService {
_transform(data) {
switch(config.get.type) {
case 'collection':
return this._.map(data, (item, index) => {
return _.map(data, (item, index) => {
return {
title: (config.get.titlePrefix || 'tab') + index,
content: item,
Expand All @@ -33,7 +35,7 @@ class CellularService {
fields: config.fields
};
default:
return this._.map(data, (item, index) => {
return _.map(data, (item, index) => {
return {
title: (config.get.titlePrefix || 'tab') + index,
content: item,
Expand Down
11 changes: 6 additions & 5 deletions app/component/form/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import angular from 'angular';
import sjCore from 'sanji-core-ui';
import {sjCore} from 'sanji-core-ui';

import './form.tpl.html';
import CellularFormContainerComponent from './container.component';
import CellularFormComponent from './form.component';

let app = angular.module('sanji.cellular.form', [sjCore]);
app.component('sanjiCellularFormContainer', CellularFormContainerComponent);
app.component('sanjiCellularForm', CellularFormComponent);
export default app = app.name;
const sjCellularForm = angular.module('sanji.cellular.form', [sjCore])
.component('sanjiCellularFormContainer', CellularFormContainerComponent)
.component('sanjiCellularForm', CellularFormComponent)
.name;
export {sjCellularForm};
19 changes: 10 additions & 9 deletions app/component/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import angular from 'angular';
import sjCore from 'sanji-core-ui';
import sjCellularInfo from './info';
import sjCellularForm from './form';
import {sjCore} from 'sanji-core-ui';
import {sjCellularInfo} from './info';
import {sjCellularForm} from './form';

import i18nConfig from './component.i18n';
import CellularService from './component.service';
import CellularWindowComponent from './window.component';

let app = angular.module('sanji.cellular', [
const sjCellular = angular.module('sanji.cellular', [
sjCore,
sjCellularInfo,
sjCellularForm
]);
app.config(i18nConfig);
app.service('cellularService', CellularService);
app.component('sanjiCellularWindow', CellularWindowComponent);
export default app = app.name;
])
.config(i18nConfig)
.service('cellularService', CellularService)
.component('sanjiCellularWindow', CellularWindowComponent)
.name;
export {sjCellular};
13 changes: 7 additions & 6 deletions app/component/info/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import angular from 'angular';
import sjCore from 'sanji-core-ui';
import {sjCore} from 'sanji-core-ui';

import './cellular-signal.tpl.html';
import './cellular-signal.style.scss';
Expand All @@ -9,8 +9,9 @@ import './info.tpl.html';
import CellularInfoContainerComponent from './container.component';
import CellularInfoComponent from './info.component';

let app = angular.module('sanji.cellular.info', [sjCore]);
app.component('sanjiCellularInfoContainer', CellularInfoContainerComponent);
app.component('sanjiCellularInfo', CellularInfoComponent);
app.component('cellularSignal', CellularSignalComponent);
export default app = app.name;
const sjCellularInfo = angular.module('sanji.cellular.info', [sjCore])
.component('sanjiCellularInfoContainer', CellularInfoContainerComponent)
.component('sanjiCellularInfo', CellularInfoComponent)
.component('cellularSignal', CellularSignalComponent)
.name;
export {sjCellularInfo};
4 changes: 0 additions & 4 deletions app/component/info/info.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ class CellularInfoController {
constructor(...injects) {
CellularInfoController.$inject.forEach((item, index) => this[item] = injects[index]);
}

save(data) {
this.submitCallback({data: data});
}
}
CellularInfoController.$inject = $inject;
export default CellularInfoController;
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@
},
"devDependencies": {
"angular-mocks": "~1.5.0",
"autoprefixer-loader": "~3.2.0",
"autoprefixer": "~6.3.7",
"babel-core": "^6.0.0",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.0.0",
"babel-plugin-__coverage__": "^11.0.0",
"babel-plugin-lodash": "^3.2.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.10.3",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015-webpack": "^6.4.1",
"babel-runtime": "^6.6.1",
"babel-preset-es2015": "^6.9.0",
"chai": "~3.5.0",
"commitizen": "^2.8.0",
"css-loader": "~0.23.1",
Expand All @@ -49,7 +46,7 @@
"eslint": "^2.0.0",
"eslint-loader": "^1.3.0",
"expose-loader": "~0.7.1",
"extract-text-webpack-plugin": "2.0.0-beta.1",
"extract-text-webpack-plugin": "^2.0.0-beta.3",
"file-loader": "~0.9.0",
"ghooks": "^1.2.0",
"html-webpack-plugin": "~2.22.0",
Expand Down Expand Up @@ -78,8 +75,8 @@
"semantic-release": "^4.3.5",
"style-loader": "~0.13.0",
"url-loader": "~0.5.7",
"webpack": "2.1.0-beta.17",
"webpack-dev-server": "2.1.0-beta.0",
"webpack": "^2.1.0-beta.20",
"webpack-dev-server": "^2.1.0-beta.0",
"webpack-notifier": "~1.3.0"
},
"repository": {
Expand All @@ -95,6 +92,6 @@
"license": "MIT",
"homepage": "https://github.com/Sanji-IO/sanji-cellular-ui",
"dependencies": {
"sanji-core-ui": "~1.15.3"
"sanji-core-ui": "~1.16.0"
}
}
2 changes: 1 addition & 1 deletion protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports.config = {
],

cucumberOpts: {
require: 'features/token.step.js',
require: 'features/cellular.step.js',
format: 'pretty' // or summary
}
};
11 changes: 9 additions & 2 deletions webpack.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ config.externals = [
config.module.loaders = [
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css!postcss!sass?includePaths[]=' + bourbon)
loader: ExtractTextPlugin.extract({
notExtractLoader: 'style-loader',
loader: 'css!postcss!sass?includePaths[]=' + bourbon
})
}
].concat(config.module.loaders);

config.module.postLoaders = [
{test: /\.js$/, loader: 'ng-annotate', exclude: /(node_modules)/}
];
config.postcss = [ autoprefixer({ browsers: ['last 2 versions'] }) ];

config.plugins.push(
Expand All @@ -38,7 +44,8 @@ config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
warnings: false,
dead_code: true
}
})
);
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var config = {
{test: /\.js$/, loader: 'eslint', exclude: /(node_modules)/}
],
loaders: [
{ test: /\.js$/, loader: 'ng-annotate!babel?cacheDirectory', exclude: /node_modules/ },
{ test: /\.js$/, loader: 'babel?cacheDirectory', exclude: /node_modules/ },
{ test: /\.json$/, loader: 'json', exclude: /node_modules/ },
{ test: /\.html$/, loader: 'ng-cache?prefix=[dir]/[dir]', exclude: [/node_modules/, path.join(__dirname, '/app/index.html')] }
],
Expand Down
5 changes: 4 additions & 1 deletion webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ config.entry = {
};
config.module.loaders = [
{test: /\.scss/, loader: 'style!css!postcss!sass?includePaths[]=' + bourbon},
{test: /\.css$/, loader: 'style!css!autoprefixer?browsers=last 2 versions'},
{test: /\.css$/, loader: 'style!css!postcss?browsers=last 2 versions'},
{test: /\.(png|jpg|gif|jpeg)$/, loader: 'url-loader?limit=8192', exclude: /node_modules/},
{test: /\.(woff|woff2)$/, loader: 'url?limit=10000&minetype=application/font-woff', exclude: /node_modules/},
{test: /\.(ttf|eot|svg)$/, loader: 'file', exclude: /node_modules/}
].concat(config.module.loaders);

config.module.postLoaders = [
{test: /\.js$/, loader: 'ng-annotate', exclude: /(node_modules)/}
];
config.postcss = [ autoprefixer({ browsers: ['last 2 versions'] }) ];

config.plugins.push(
Expand Down

0 comments on commit bbb0960

Please sign in to comment.