Last active
July 26, 2017 01:11
-
-
Save krivaten/115d2f3eaf0d6c4304c0a3cbba9dfb14 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { | |
get, | |
computed | |
} = Ember; | |
export default Ember.Component.extend({ | |
tagName: 'svg', | |
attributeBindings: [ | |
'viewbox' | |
], | |
bubbleCount: 1, | |
bubbleSize: 40, | |
barSize: 100, | |
viewbox: computed('bubbleIndex', 'bubbleCount', function() { | |
const count = get(this, 'bubbleCount'); | |
const bubbleSize = get(this, 'bubbleSize'); | |
const barSize = get(this, 'barSize'); | |
const totalSize = bubbleSize + barSize; | |
return `0 0 ${count * totalSize} ${bubbleSize}`; | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { | |
get, | |
computed | |
} = Ember; | |
export default Ember.Component.extend({ | |
tagName: 'g', | |
attributeBindings: [ | |
'viewbox', | |
'transform' | |
], | |
viewbox: '0 0 40 40', | |
activeBubbleIndex: 0, | |
bubbleCount: 1, | |
bubbleIndex: 0, | |
bubbleSize: 40, | |
barSize: 40, | |
isLast: computed('bubbleIndex', 'bubbleCount', function() { | |
const index = get(this, 'bubbleIndex'); | |
const count = get(this, 'bubbleCount'); | |
return count === (index + 1); | |
}), | |
bubbleNumber: computed('bubbleIndex', function() { | |
return get(this, 'bubbleIndex') + 1; | |
}), | |
barPos1: computed('bubbleSize', function() { | |
const bubbleSize = get(this, 'bubbleSize'); | |
return bubbleSize - 3; | |
}), | |
barPos2: computed('barSize', 'bubbleSize', function() { | |
const barSize = get(this, 'barSize'); | |
const bubbleSize = get(this, 'bubbleSize'); | |
return bubbleSize + barSize; | |
}), | |
isComplete: computed('bubbleIndex', 'bubbleCount', function() { | |
const index = get(this, 'bubbleIndex'); | |
const activeBubbleIndex = get(this, 'activeBubbleIndex'); | |
return (index + 1) <= activeBubbleIndex; | |
}), | |
isActive: computed('bubbleIndex', 'bubbleCount', function() { | |
const index = get(this, 'bubbleIndex'); | |
const activeBubbleIndex = get(this, 'activeBubbleIndex'); | |
return (index + 1) === activeBubbleIndex; | |
}), | |
isSuccess: computed.or('isComplete', 'isActive'), | |
strokeColor: computed('isSuccess', function() { | |
return get(this, 'isSuccess') ? '#81c13b' : '#979797'; | |
}), | |
fillColor: computed('isSuccess', function() { | |
return get(this, 'isSuccess') ? '#81c13b' : '#e0e0e0'; | |
}), | |
transform: computed('bubbleIndex', 'bubbleCount', function() { | |
const index = get(this, 'bubbleIndex'); | |
const count = get(this, 'bubbleCount'); | |
return `translate(${index * 120})`; | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
activeBubbleIndex: 3, | |
bubbles: [ | |
'Panda', | |
'Monkey', | |
'Thylacine', | |
'Honey Badger', | |
'Tiger', | |
'Pony' | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { helper } from 'ember-helper'; | |
import { typeOf } from 'ember-utils'; | |
export function repeat([length, value]) { | |
if (typeOf(length) !== 'number') { | |
return [value]; | |
} | |
return Array.apply(null, { length }).map(() => value); // eslint-disable-line | |
} | |
export default helper(repeat); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
svg { | |
width: 100%; | |
height: auto; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment