Skip to content

Commit

Permalink
feat(babel): compile down to ES5
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickocoffeyo committed Jul 20, 2018
1 parent c580d06 commit 8418343
Show file tree
Hide file tree
Showing 6 changed files with 749 additions and 36 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": ["last 3 versions"]
}
}]
]
}
89 changes: 58 additions & 31 deletions dist/aframe-simple-link-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,57 @@
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/* global AFRAME */

/* global AFRAME */
if (typeof AFRAME === 'undefined') {
throw new Error(
'Component attempted to register before AFRAME was available.'
);
throw new Error('Component attempted to register before AFRAME was available.');
}

/**
* Simple Link component for A-Frame.
*/


AFRAME.registerComponent('simple-link', {
schema: {
lookAtCamera: { default: true, type: 'boolean' },
href: { default: '', type: 'string' },
title: { default: '', type: 'string' },
radius: { default: 1, type: 'number' },
font: {default: 'kelsonsans', type: 'string' },
color: { default: '#fff', type: 'color' },
titleColor: { default: '#fff', type: 'color' },
image: { default: '', type: 'asset' },
on: { default: 'click' }
lookAtCamera: {
default: true,
type: 'boolean'
},
href: {
default: '',
type: 'string'
},
title: {
default: '',
type: 'string'
},
radius: {
default: 1,
type: 'number'
},
font: {
default: 'kelsonsans',
type: 'string'
},
color: {
default: '#fff',
type: 'color'
},
titleColor: {
default: '#fff',
type: 'color'
},
image: {
default: '',
type: 'asset'
},
on: {
default: 'click'
}
},

/**
Expand All @@ -102,23 +129,22 @@ AFRAME.registerComponent('simple-link', {
/**
* Called once when component is attached. Generally for initial setup.
*/
init() {
init: function init() {
this.navigate = this.navigate.bind(this);
const { el } = this;

var el = this.el;
el.setAttribute('geometry', {
primitive: 'circle',
radius: this.data.radius
});

if (this.data.image) {
el.setAttribute('material', {
src: this.data.image,
color: this.data.color
});
}

const textEl = document.createElement('a-entity');

var textEl = document.createElement('a-entity');
textEl.setAttribute('text', {
color: this.data.textColor,
align: 'center',
Expand All @@ -134,8 +160,9 @@ AFRAME.registerComponent('simple-link', {
* Called when component is attached and when component data changes.
* Generally modifies the entity based on the data.
*/
update(oldData) {
const { data } = this;
update: function update(oldData) {
var data = this.data;

if (data.on !== oldData.on) {
this.updateEventListener();
}
Expand All @@ -145,7 +172,7 @@ AFRAME.registerComponent('simple-link', {
* Called when a component is removed (e.g., via removeAttribute).
* Generally undoes all modifications to the entity.
*/
remove() {
remove: function remove() {
this.removeEventListener();
},

Expand All @@ -158,27 +185,28 @@ AFRAME.registerComponent('simple-link', {
* Called when entity pauses.
* Use to stop or remove any dynamic or background behavior such as events.
*/
pause() {},
pause: function pause() {},

/**
* Called when entity resumes.
* Use to continue or add any dynamic or background behavior such as events.
*/
play() {
play: function play() {
this.updateEventListener();
},
updateEventListener: function updateEventListener() {
var el = this.el;

updateEventListener() {
const { el } = this;
if (!el.isPlaying) {
return;
}

this.removeEventListener();
el.addEventListener(this.data.on, this.navigate);
},
removeEventListener: function removeEventListener() {
var on = this.data.on;

removeEventListener() {
const { data: { on } } = this;
if (on) {
this.el.removeEventListener(on, this.navigate);
}
Expand All @@ -188,11 +216,10 @@ AFRAME.registerComponent('simple-link', {
* Called when the link is clicked.
*
*/
navigate() {
navigate: function navigate() {
window.location = this.data.href;
}
});


/***/ })
/******/ ]);
2 changes: 1 addition & 1 deletion dist/aframe-simple-link-component.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,10 @@
"examples/build.js",
"dist/**"
]
},
"dependencies": {
"@babel/core": "^7.0.0-beta.54",
"@babel/preset-env": "^7.0.0-beta.54",
"babel-loader": "^8.0.0-beta"
}
}
17 changes: 17 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @file webpack.config.js
* Exports configuration for Webpack.
*/

const rules = [];
rules.push({
test: /\.js|jsx$/,
exclude: /node_modules/,
use: 'babel-loader'
});

module.exports = {
module: {
rules
}
};
Loading

0 comments on commit 8418343

Please sign in to comment.